Repository navigation
[4.0.9 Backport] CBG-5873: prevent async index init panic with concurrent GET - #8916
Merged
Merged
Conversation
…rent GET Cherry-picked from d81f862 (CBG-5869, #8806), adapted to 4.0.9 without CBG-5653 (typed background manager options), per team advice, as for the 4.1.3 backport (CBG-5874). - db/background_mgr_async_index_init.go, rest/admin_api.go: main passes the status tracker in the typed AsyncIndexInitOptions from CBG-5653; 4.0.9 uses map[string]any options, so it is passed as options["statusTracker"].(*IndexStatusTracker). The race fix itself is as upstream. - rest/admin_api.go: main's tracker also covers the _system scope, where 4.1 initializes metadata indexes (CBG-5224); 4.0.9 does not, so the tracker covers the named scopes plus _default, as 4.0.9 does today. - db/background_mgr_async_index_init_test.go: imports renamed from the testing/{require,assert} wrappers to testify; Init and GetProcessStatus calls match 4.0.9's signatures (map options, no extra return value or argument); base.WaitWithTimeout (CBG-5261, not on 4.0.9) replaced by wg.Wait(). Co-authored-by: Tor Colvin <tor.colvin@couchbase.com>
bbrks
approved these changes
Oct 19, 2026
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-5873 (backport of CBG-5869)
A GET of
_index_initwhile index initialisation was running could crash Sync Gateway: the status map was marshalled while the init worker was still writing to it. Status now lives in anIndexStatusTrackerthat is written and copied under its own lock.Unclean cherry pick of #8806 to 4.0.9
Adapted to 4.0.9 without CBG-5653 (typed background manager options), per team advice, as in the 4.1.3 backport (#8894).
Stacked on #8915.
Changes from main commit:
db/background_mgr_async_index_init.go,rest/admin_api.go— main passes the tracker in the typedAsyncIndexInitOptionsfrom CBG-5653; 4.0.9 usesmap[string]anyoptions, so it is passed asoptions["statusTracker"].(*IndexStatusTracker). The race fix itself is as upstreamrest/admin_api.go— main's tracker also covers the_systemscope, where 4.1 initialises metadata indexes (CBG-5224); 4.0.9 does not, so the tracker covers the named scopes plus_default, as 4.0.9 tracks todaydb/background_mgr_async_index_init_test.go— imports renamed back to testify;InitandGetProcessStatuscalls match 4.0.9's signatures;base.WaitWithTimeout(CBG-5261, not on 4.0.9) replaced bywg.Wait()🤖 Opened with the
sync-gateway-backportskill in Claude Code