Skip to content

[4.1.2 Backport] CBG-5591: stop indexes being built on default when not required - #8523

Merged
bbrks merged 1 commit into
release/4.1.2from
CBG-5591
Aug 4, 2026
Merged

[4.1.2 Backport] CBG-5591: stop indexes being built on default when not required#8523
bbrks merged 1 commit into
release/4.1.2from
CBG-5591

Conversation

@bbrks

@bbrks bbrks commented Aug 3, 2026

Copy link
Copy Markdown
Member

CBG-5591

Unclean cherry pick of #8495 to 4.1.2
Changes from main commit:

  • rest/manualbucketpooltest/database_init_manager_test.go — package doesn't exist on 4.1.2; its TestDatabaseInitConcurrentDatabasesSameBucket lives in rest/database_init_manager_test.go, so the InitializeDatabase signature change was applied there instead
  • rest/database_init_manager_test.godbConfig.setup() takes an extra forcePerBucketAuth arg on 4.1.2, so the ported tests use the 6-arg form

Stacked on #8522 (CBG-5414 backport), which this depends on - with that in place, rest/database_init_manager.go and TestBuildCollectionIndexData match main exactly.

@bbrks
bbrks requested a review from gregns1 August 3, 2026 15:33
Base automatically changed from CBG-5414-4.1.2 to release/4.1.2 August 4, 2026 11:40
@gregns1
gregns1 requested a review from a team August 4, 2026 11:40
…ot required

Cherry-picked from c1008bc (CBG-5586, #8495). Stacked on the CBG-5414
backport, which this builds on.

rest/manualbucketpooltest/database_init_manager_test.go doesn't exist on this
branch - its TestDatabaseInitConcurrentDatabasesSameBucket lives in rest/, so
the InitializeDatabase signature change is applied there instead.

Co-authored-by: Gregory Newman-Smith <109068393+gregns1@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 4, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Backports the main-branch fix for CBG-5591 to 4.1.2, refining database index initialization so Sync Gateway doesn’t (re)build metadata indexes on _default._default when they’re no longer required—especially after system-metadata migration has completed—avoiding wasted work and initialization failures when _default has been dropped.

Changes:

  • Plumbs a migrationComplete signal into DatabaseInitManager so index initialization can exclude vestigial _default metadata indexes post-migration.
  • Updates collection-to-index-set planning (buildCollectionIndexData) to treat _default’s “data role” and “metadata role” independently.
  • Reduces test bucket pool usage in ISGR test setup by only acquiring buckets when configs don’t already provide one, and adds/updates tests to cover the new index-init behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rest/utilities_testing_isgr.go Avoids double-reserving bucket-pool buckets by only allocating a test bucket when the caller didn’t supply one.
rest/server_context.go Detects migration completion (via dual metadata store state) and passes it through to index initialization.
rest/indextest/index_test.go Updates async-init tests’ expected collection counts for the new index-init behavior.
rest/database_init_manager.go Extends initialization APIs to accept migrationComplete and updates index planning logic to exclude _default metadata indexes post-migration.
rest/database_init_manager_test.go Adds/updates tests to validate correct collection/index initialization across legacy vs system-metadata modes and migration states.
rest/admin_api.go Ensures manual index-init requests pass migration completion state to the init manager.
Suppressed comments (1)

rest/indextest/index_test.go:505

  • Same as above: without explicitly setting UseSystemMobileMetadataCollection, this test no longer guarantees it is exercising the system-metadata + migration-complete path (and the updated expected collection count can be satisfied by legacy mode too).
	dbConfig := makeDbConfig(t, tb, syncFunc, importFilter)
	dbConfig.StartOffline = base.Ptr(true)
	dbConfigPayload, err := json.Marshal(dbConfig)

Comment on lines 373 to 375
dbConfig := makeDbConfig(t, tb, syncFunc, importFilter)
dbConfig.StartOffline = base.Ptr(true)
dbConfig.UseSystemMobileMetadataCollection = base.Ptr(true)
dbConfigPayload, err := json.Marshal(dbConfig)
@bbrks
bbrks merged commit e145aad into release/4.1.2 Aug 4, 2026
43 checks passed
@bbrks
bbrks deleted the CBG-5591 branch August 4, 2026 12:04
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