Repository navigation
[4.1.3 Backport] CBG-5874: prevent async index init panic with concurrent GET - #8894
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The locking, snapshot copying, and backport wiring address the race without identified blocking issues; tests were not executed.
0 open findings
What changed in this PR
Backports the concurrent _index_init status-read fix to Sync Gateway 4.1.3, retaining the release branch’s map-based options.
Changes:
- Protects status updates and snapshot copying with a dedicated tracker lock.
- Wires the tracker into the REST handler and background manager lifecycle.
- Adds a concurrent status-update/read regression test.
| File | Description |
|---|---|
| rest/admin_api.go | Creates and passes the tracker; routes status updates through it. |
| db/background_mgr_async_index_init.go | Adds synchronized status tracking and independent snapshots. |
| db/background_mgr_async_index_init_test.go | Tests concurrent status writes and reads. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This was referenced Oct 16, 2026
…rent GET Cherry-picked from d81f862 (CBG-5869, #8806), adapted to 4.1.3 without CBG-5653 (typed background manager options), per team advice. - db/background_mgr_async_index_init.go, rest/admin_api.go: main passes the status tracker in the typed AsyncIndexInitOptions from CBG-5653; 4.1.3 still uses map[string]any options, so the tracker is passed as options["statusTracker"].(*IndexStatusTracker). The race fix itself (IndexStatusTracker and copying status under its lock) is as upstream. - db/background_mgr_async_index_init_test.go: Init takes map options to match; imports renamed from the testing/{require,assert} wrappers to testify, which 4.1.3 uses. Co-authored-by: Tor Colvin <tor.colvin@couchbase.com>
torcolvin
approved these changes
Oct 23, 2026
torcolvin
enabled auto-merge (squash)
October 23, 2026 14:41
torcolvin
disabled auto-merge
October 23, 2026 14:41
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-5874 (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.1.3
Adapted to 4.1.3 without CBG-5653 (typed background manager options), per team advice.
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.1.3 still usesmap[string]anyoptions, so it is passed asoptions["statusTracker"].(*IndexStatusTracker). The race fix itself is as upstreamdb/background_mgr_async_index_init_test.go—Inittakes map options to match; release branch predates thetesting/{require,assert}wrappers, so imports renamed back to testify🤖 Opened with the
sync-gateway-backportskill in Claude Code