You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CBG-5980: Set the default client partition window to the server purge interval - #8942
If client_partition_window_secs is not set, Sync Gateway now uses the metadata purge interval of the bucket as the client partition window. If the bucket has no purge interval of its own, it uses the cluster-wide value. Before this change, the default was a fixed 30 days.
DatabaseContextOptions.ClientPartitionWindow is now a pointer, so nil means that the setting is not set. The new DatabaseContext.ClientPartitionWindow returns the configured value or the cached purge interval, and Authenticator() uses it.
With include_runtime=true, GET /{db}/_config and GET /_config report the window that the database uses. Without include_runtime, the config leaves the field out when the user did not set it, in both persistent and non-persistent mode.
NewDatabaseContext fills the purge interval cache, and the default is also cached for buckets that are not Couchbase buckets. This stops a data race between Authenticator() and Close() on DatabaseContext.Bucket.
Removed the 30-day default from DefaultDbConfig and from the OpenAPI spec, and added the field to the allowlist in TestDefaultDbConfigFieldCoverage.
Added TestDefaultClientPartitionWindow. It covers explicit and default values, with and without include_runtime, in persistent and non-persistent mode. It runs only on Couchbase Server, because on Rosmar the purge interval always equals the old 30-day default.
Behavior change: without the setting, the window drops from 30 days to the server purge interval, which is 3 days by default. Clients that stay offline longer than that no longer get revocations for grants removed while they were offline. This needs a release note.
Pre-review checklist
Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api
The defaulting logic and runtime config behavior look coherent, and the added test coverage matches the stated intent. One documentation source of truth is still inconsistent (the Go struct comment still mentions a 30-day default).
Pass 2 (validation): No additional high-confidence, actionable review comments to add beyond existing discussions. The defaulting change and runtime config reporting are consistent, and the prior doc-comment inconsistency is addressed in this diff.
Use reloaded database context for runtime purge interval
rest/admin_api.go:623
With refresh_config=true, applyConfigs replaces the database context, but h.db still points to the previous one. If the persisted config removes an explicit seven-day window, GET /db/_config?refresh_config=true&include_runtime=true reports 604800 seconds even though the reloaded database uses its purge interval (259200 seconds for a three-day interval). Look up the current database context before filling this runtime field, and add a regression test for removing an explicit value during refresh.
If client_partition_window_secs is not set, the client partition window
is now the metadata purge interval of the bucket, or the cluster-wide
value if the bucket has none. Before this change, the default was a
fixed 30 days.
- force a reload of metadata purge interval on database creation
- replace DefaultPurgeInterval with DefaultClientPartitionWindow
- read the purge interval from cache for ClientPartitionWindow
The reason will be displayed to describe this comment to others. Learn more.
Looks good - just one follow-up ticket to file to make sure we support a changing metadata purge interval on server side.
This only affects the existing Authenticator code right now, which was always a hardcoded 30d const before this PR anyway so I'm not bothered about supporting it in this PR yet.
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CBG-5980
If
client_partition_window_secsis not set, Sync Gateway now uses the metadata purge interval of the bucket as the client partition window. If the bucket has no purge interval of its own, it uses the cluster-wide value. Before this change, the default was a fixed 30 days.DatabaseContextOptions.ClientPartitionWindowis now a pointer, sonilmeans that the setting is not set. The newDatabaseContext.ClientPartitionWindowreturns the configured value or the cached purge interval, andAuthenticator()uses it.include_runtime=true,GET /{db}/_configandGET /_configreport the window that the database uses. Withoutinclude_runtime, the config leaves the field out when the user did not set it, in both persistent and non-persistent mode.NewDatabaseContextfills the purge interval cache, and the default is also cached for buckets that are not Couchbase buckets. This stops a data race betweenAuthenticator()andClose()onDatabaseContext.Bucket.DefaultDbConfigand from the OpenAPI spec, and added the field to the allowlist inTestDefaultDbConfigFieldCoverage.TestDefaultClientPartitionWindow. It covers explicit and default values, with and withoutinclude_runtime, in persistent and non-persistent mode. It runs only on Couchbase Server, because on Rosmar the purge interval always equals the old 30-day default.Behavior change: without the setting, the window drops from 30 days to the server purge interval, which is 3 days by default. Clients that stay offline longer than that no longer get revocations for grants removed while they were offline. This needs a release note.
Pre-review checklist
base.UD(docID),base.MD(dbName))docs/apiDependencies (if applicable)
Integration Tests