Skip to content

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
CBG-5255
Open

CBG-5255 [4.0.5 backports] allow metadata id to be nil while syncinfo exists#8229
gregns1 wants to merge 1 commit intorelease/4.0.5from
CBG-5255

Conversation

@gregns1
Copy link
Copy Markdown
Contributor

@gregns1 gregns1 commented May 5, 2026

CBG-5255

Backports #8059

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • 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

Dependencies (if applicable)

  • Link upstream PRs
  • Update Go module dependencies when merged

Integration Tests

… exists

Co-authored-by: Gregory Newman-Smith <109068393+gregns1@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 5, 2026 16:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.MetadataID optional (*string) and updates metadata ID computation to tolerate a missing metadataID in _sync:syncInfo.
  • Updates base.InitSyncInfo to return both requiresResync and requiresAttachmentMigration, and introduces logic that treats metadataID=nil as “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{}
@gregns1 gregns1 requested a review from torcolvin May 5, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants