-
Notifications
You must be signed in to change notification settings - Fork 145
CBG-5511: Stop db loading opting out of mobile collection if bootstrap migration is done #8440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e6f119c
CBG-5511: Stop db loading opting out of mobile collection if bootstra…
gregns1 3c84613
use rest tester cluster
gregns1 375a904
copilot review
gregns1 3931a34
remove test assertion - needs its own test once a differnet PR is in
gregns1 a137180
add new test
gregns1 2714a34
address comments
gregns1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,38 +15,40 @@ type DatabaseError struct { | |
| } | ||
|
|
||
| var DatabaseErrorMap = map[databaseErrorCode]string{ | ||
| DatabaseBucketConnectionError: "Error connecting to bucket", | ||
| DatabaseInvalidDatastore: "Collection(s) not available", | ||
| DatabaseInitSyncInfoError: "Error initializing sync info", | ||
| DatabaseInitializationIndexError: "Error initializing database indexes", | ||
| DatabaseCreateDatabaseContextError: "Error creating database context", | ||
| DatabaseSGRClusterError: "Error with fetching SGR cluster definition", | ||
| DatabaseCreateReplicationError: "Error creating replication during database init", | ||
| DatabaseOnlineProcessError: "Error attempting to start online process", | ||
| DatabaseAllowConflictsError: "Allow conflicts is set to true", | ||
| DatabaseEnableStarChannelFalseError: "Enable star channel is set to false", | ||
| DatabaseClusterCompatVersionError: "Bucket has metadata from a newer Sync Gateway cluster compat version", | ||
| DatabaseInvalidResyncPartitions: "resync_partitions exceeds number of vBuckets", | ||
| DatabaseNoMetadataStore: "No metadata store for db metadata to be stored in", | ||
| DatabaseBucketConnectionError: "Error connecting to bucket", | ||
| DatabaseInvalidDatastore: "Collection(s) not available", | ||
| DatabaseInitSyncInfoError: "Error initializing sync info", | ||
| DatabaseInitializationIndexError: "Error initializing database indexes", | ||
| DatabaseCreateDatabaseContextError: "Error creating database context", | ||
| DatabaseSGRClusterError: "Error with fetching SGR cluster definition", | ||
| DatabaseCreateReplicationError: "Error creating replication during database init", | ||
| DatabaseOnlineProcessError: "Error attempting to start online process", | ||
| DatabaseAllowConflictsError: "Allow conflicts is set to true", | ||
| DatabaseEnableStarChannelFalseError: "Enable star channel is set to false", | ||
| DatabaseClusterCompatVersionError: "Bucket has metadata from a newer Sync Gateway cluster compat version", | ||
| DatabaseInvalidResyncPartitions: "resync_partitions exceeds number of vBuckets", | ||
| DatabaseNoMetadataStore: "No metadata store for db metadata to be stored in", | ||
| DatabaseSystemCollectionOptInRequired: "Database must enable use_system_metadata_collection on a bucket whose bootstrap metadata has migrated to the system collection", | ||
|
Comment on lines
+29
to
+31
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are missing from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, i'll add that |
||
| } | ||
|
|
||
| type databaseErrorCode uint8 | ||
|
|
||
| // Error codes exposed for each error a database can encounter on load. These codes are consumed by Capella so must remain stable. | ||
| const ( | ||
| DatabaseBucketConnectionError databaseErrorCode = 1 | ||
| DatabaseInvalidDatastore databaseErrorCode = 2 | ||
| DatabaseInitSyncInfoError databaseErrorCode = 3 | ||
| DatabaseInitializationIndexError databaseErrorCode = 4 | ||
| DatabaseCreateDatabaseContextError databaseErrorCode = 5 | ||
| DatabaseSGRClusterError databaseErrorCode = 6 | ||
| DatabaseCreateReplicationError databaseErrorCode = 7 | ||
| DatabaseOnlineProcessError databaseErrorCode = 8 | ||
| DatabaseAllowConflictsError databaseErrorCode = 9 | ||
| DatabaseEnableStarChannelFalseError databaseErrorCode = 10 | ||
| DatabaseClusterCompatVersionError databaseErrorCode = 11 | ||
| DatabaseInvalidResyncPartitions databaseErrorCode = 12 | ||
| DatabaseNoMetadataStore databaseErrorCode = 13 | ||
| DatabaseBucketConnectionError databaseErrorCode = 1 | ||
| DatabaseInvalidDatastore databaseErrorCode = 2 | ||
| DatabaseInitSyncInfoError databaseErrorCode = 3 | ||
| DatabaseInitializationIndexError databaseErrorCode = 4 | ||
| DatabaseCreateDatabaseContextError databaseErrorCode = 5 | ||
| DatabaseSGRClusterError databaseErrorCode = 6 | ||
| DatabaseCreateReplicationError databaseErrorCode = 7 | ||
| DatabaseOnlineProcessError databaseErrorCode = 8 | ||
| DatabaseAllowConflictsError databaseErrorCode = 9 | ||
| DatabaseEnableStarChannelFalseError databaseErrorCode = 10 | ||
| DatabaseClusterCompatVersionError databaseErrorCode = 11 | ||
| DatabaseInvalidResyncPartitions databaseErrorCode = 12 | ||
| DatabaseNoMetadataStore databaseErrorCode = 13 | ||
| DatabaseSystemCollectionOptInRequired databaseErrorCode = 14 | ||
| ) | ||
|
|
||
| func NewDatabaseError(code databaseErrorCode) *DatabaseError { | ||
|
|
||
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
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
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
72 changes: 72 additions & 0 deletions
72
rest/manualbucketpooltest/metadata_migration_no_default_test.go
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright 2026-Present Couchbase, Inc. | ||
| // | ||
| // Use of this software is governed by the Business Source License included | ||
| // in the file licenses/BSL-Couchbase.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/APL2.txt. | ||
|
|
||
| package manualbucketpooltest | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "testing" | ||
|
|
||
| "github.com/couchbase/sync_gateway/base" | ||
| "github.com/couchbase/sync_gateway/db" | ||
| "github.com/couchbase/sync_gateway/rest" | ||
| "github.com/couchbase/sync_gateway/testing/assert" | ||
| "github.com/couchbase/sync_gateway/testing/require" | ||
| "github.com/couchbase/sync_gateway/testing/sgtest" | ||
| ) | ||
|
|
||
| func TestFreshDeploymentWithNoDefaultAndOptOutMetadataCollection(t *testing.T) { | ||
| base.TestRequiresCollections(t) | ||
| if sgtest.UnitTestUrlIsWalrus() { | ||
| t.Skip("test requires dropping _default collection") | ||
| } | ||
|
|
||
| ctx := base.TestCtx(t) | ||
|
|
||
| tb := base.GTestBucketPool.CreateTestBucket(t) | ||
| t.Cleanup(func() { base.GTestBucketPool.RemoveBucket(tb) }) | ||
|
|
||
| const ( | ||
| scope = "sg_test_0" | ||
| collection1 = "sg_test_0" | ||
| ) | ||
|
|
||
| require.NoError(t, tb.CreateDataStore(ctx, base.ScopeAndCollectionName{Scope: scope, Collection: collection1})) | ||
|
|
||
| require.NoError(t, tb.DropDataStore(ctx, base.ScopeAndCollectionName{ | ||
| Scope: base.DefaultScope, Collection: base.DefaultCollection, | ||
| }), "dropping _default._default should succeed on Couchbase Server") | ||
|
|
||
| rt := rest.NewRestTester(t, &rest.RestTesterConfig{ | ||
| CustomTestBucket: tb.NoCloseClone(), | ||
| PersistentConfig: true, | ||
| }) | ||
| defer rt.Close() | ||
|
|
||
| dbConfig := rt.NewDbConfig() | ||
| dbConfig.UseSystemMobileMetadataCollection = base.Ptr(false) | ||
| dbConfig.Scopes = rest.ScopesConfig{ | ||
| scope: rest.ScopeConfig{ | ||
| Collections: rest.CollectionsConfig{collection1: {}}, | ||
| }, | ||
| } | ||
| resp := rt.CreateDatabase("db1", dbConfig) | ||
| rest.RequireStatus(t, resp, http.StatusBadRequest) | ||
| assert.Contains(t, resp.Body.String(), "must enable use_system_metadata_collection") | ||
|
|
||
| // recover by opting-in | ||
| dbConfig.UseSystemMobileMetadataCollection = base.Ptr(true) | ||
| resp = rt.CreateDatabase("db1", dbConfig) | ||
| rest.RequireStatus(t, resp, http.StatusCreated) | ||
|
|
||
| summaryResp := rt.GetAllDBsVerbose() | ||
| require.Len(t, summaryResp, 1) | ||
| assert.Equal(t, summaryResp[0].DBName, "db1") | ||
| assert.Nil(t, summaryResp[0].DatabaseError) | ||
| assert.Equal(t, db.RunStateString[db.DBOnline], summaryResp[0].State) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.