-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tablemetadatacache: add cluster settings to automate job execution
This commit adds the ability to automate running the `UPDATE TABLE METADATA` job. Two new cluster settings are introduced to control the interval the job is run at: - `obs.tablemetadatacache.data_valid_duration` non-negative duration setting, which specifies the duration for which the data in system.table_metadata is considered valid. This duration will be used as a threshold to inform the system on when we should run the job to refresh data. Default 20m. - `obs.tablemetadatacache.automatic_updates.enabled` boolean setting, which defaults to false. If true, the system will execute the update job on according to the interval setting above. Fixes: #130098 Epic: CRDB-37558 Release note (ops change): New cluster settings have been added which control the refresh behaviour for the cached data shown in the db pages in db console. - `obs.tablemetadatacache.data_valid_duration` non-negative duration setting, which specifies the duration for which the data in system.table_metadata is considered valid. If the cache's last update time exceeds this threshold, users visiting the db pages will trigger a cache refresh. Default 20m. - `obs.tablemetadatacache.automatic_updates.enabled` enables the cache to be automatically updated according the validity interval. Default false.
- Loading branch information
Showing
7 changed files
with
201 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2024 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package tablemetadatacache | ||
|
||
import ( | ||
"errors" | ||
"time" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/settings" | ||
) | ||
|
||
const defaultDataValidDuration = time.Minute * 20 | ||
|
||
var tableMetadataCacheAutoUpdatesEnabled = settings.RegisterBoolSetting( | ||
settings.ApplicationLevel, | ||
"obs.tablemetadata.automatic_updates.enabled", | ||
"enables automatic updates of the table metadata cache system.table_metadata", | ||
false, | ||
settings.WithPublic) | ||
|
||
var tableMetadataCacheValidDuration = settings.RegisterDurationSetting( | ||
settings.ApplicationLevel, | ||
"obs.tablemetadata.data_valid_duration", | ||
"the duration for which the data in system.table_metadata is considered valid", | ||
defaultDataValidDuration, | ||
settings.WithValidateDuration(func(t time.Duration) error { | ||
// This prevents the update loop from running too frequently. | ||
if t < time.Minute { | ||
return errors.New("validity period can't be less than 1 minute") | ||
} | ||
return nil | ||
}), | ||
settings.WithPublic) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters