Skip to content

[4.0.9 Backport] CBG-5873: prevent async index init panic with concurrent GET - #8916

Merged
bbrks merged 1 commit into
release/4.0.9from
CBG-5873
Oct 19, 2026
Merged

bbrks merged 1 commit into
release/4.0.9from
CBG-5873

Conversation

@vipbhardwaj

@vipbhardwaj vipbhardwaj commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

CBG-5873 (backport of CBG-5869)

A GET of _index_init while 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 an IndexStatusTracker that 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 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 initialises metadata indexes (CBG-5224); 4.0.9 does not, so the tracker covers the named scopes plus _default, as 4.0.9 tracks today
  • db/background_mgr_async_index_init_test.go — imports renamed back to testify; Init and GetProcessStatus calls match 4.0.9's signatures; base.WaitWithTimeout (CBG-5261, not on 4.0.9) replaced by wg.Wait()

🤖 Opened with the sync-gateway-backport skill in Claude Code

…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
bbrks merged commit e45c91e into release/4.0.9 Oct 19, 2026
36 checks passed
@bbrks
bbrks deleted the CBG-5873 branch October 19, 2026 19:57
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