CBG-5255 [4.0.5 backports] allow metadata id to be nil while syncinfo exists#8229
Open
gregns1 wants to merge 1 commit intorelease/4.0.5from
Open
CBG-5255 [4.0.5 backports] allow metadata id to be nil while syncinfo exists#8229gregns1 wants to merge 1 commit intorelease/4.0.5from
gregns1 wants to merge 1 commit intorelease/4.0.5from
Conversation
… exists Co-authored-by: Gregory Newman-Smith <109068393+gregns1@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR backports upstream work to handle a legacy/upgrade edge case where a _sync:syncInfo document can exist with a metadata_version but without a metadataID (e.g., after attachment migration with non-persistent config). The goal is to avoid incorrectly forcing resync/metadata-ID changes in that scenario.
Changes:
- Makes
base.SyncInfo.MetadataIDoptional (*string) and updates metadata ID computation to tolerate a missingmetadataIDin_sync:syncInfo. - Updates
base.InitSyncInfoto return bothrequiresResyncandrequiresAttachmentMigration, and introduces logic that treatsmetadataID=nilas “no resync required”. - Expands test coverage, including new error-path testing via a new
LeakyDataStore.AddCallback, and stabilizes upgrade tests by waiting for attachment migration completion.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| rest/upgradetest/upgrade_registry_test.go | Waits for attachment migration completion before upgrading, and improves failure diagnostics when DB doesn’t come online. |
| rest/config_manager.go | Handles syncInfo.MetadataID == nil safely when computing metadata IDs. |
| rest/config_manager_test.go | Updates test syncInfo payload to explicitly set metadataID for the “associated with a different DB” case. |
| db/database_test.go | Updates SyncInfo assertions for pointer metadataID and validates the new requiresResync return from InitSyncInfo. |
| base/leaky_datastore.go | Adds AddCallback hook to simulate Add failures/CAS races in tests. |
| base/leaky_bucket.go | Extends LeakyBucketConfig with the new AddCallback. |
| base/constants_syncdocs.go | Makes SyncInfo.MetadataID optional, adds requiresResync helper, and centralizes the minimum attachment-migration metadata version constant. |
| base/constants_syncdocs_test.go | Adds coverage for InitSyncInfo error paths and CAS-mismatch scenarios using AddCallback. |
Comment on lines
+168
to
+174
| addCallback: func(docID string) (bool, error) { | ||
| if shouldFailAdd.CompareAndSwap(false, true) { | ||
| newSyncInfo := &SyncInfo{MetadataID: Ptr(expectedMetadataID)} | ||
| added, err := ds.Add(docID, 0, newSyncInfo) | ||
| require.True(t, added) | ||
| require.NoError(t, err) | ||
| return false, sgbucket.CasMismatchErr{} |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-5255
Backports #8059
Pre-review checklist
fmt.Print,log.Print, ...)base.UD(docID),base.MD(dbName))docs/apiDependencies (if applicable)
Integration Tests