[4.1.2 Backport] CBG-5743: passing invalid collections to /db/_resync?action=start will cause resync to be stuck in running - #8631
Open
torcolvin wants to merge 1 commit into
Open
[4.1.2 Backport] CBG-5743: passing invalid collections to /db/_resync?action=start will cause resync to be stuck in running#8631torcolvin wants to merge 1 commit into
torcolvin wants to merge 1 commit into
Conversation
Redocly previews |
Contributor
There was a problem hiding this comment.
Pull request overview
Backports the fix for a Sync Gateway 4.1.2 issue where starting _resync with invalid collection names could leave the resync/background-manager state stuck as running, blocking subsequent resync attempts until manual cleanup.
Changes:
- Reset database run-state from
DBResyncingback toDBOfflinewhen resync start fails, preventing the DB from being left in a resyncing state. - Treat invalid collection names as a client error (
400 Bad Request) and add an end-to-end REST test to ensure status transitions toerrorrather than remainingrunning. - Persist terminal background-manager status and clear heartbeat docs via a shared
updateTerminalStatus()helper.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
rest/api.go |
Resets h.db.State back to offline when ResyncManager.Start fails. |
rest/adminapitest/resync_test.go |
Adds TestResyncInvalidCollections to cover invalid-collections start behavior and recovery. |
docs/api/paths/admin/db-_resync.yaml |
Documents a 400 response for _resync POST. |
db/background_mgr.go |
Marks synchronous start failures as error and persists terminal status via updateTerminalStatus(). |
db/background_mgr_resync_dcp.go |
Converts invalid collection resolution failures into 400 Bad Request. |
base/leaky_datastore.go |
Adds a pre-update test hook to fail before calling the underlying datastore. |
base/leaky_bucket.go |
Plumbs PreUpdateCallback into LeakyBucketConfig with thread-safe accessors. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Member
again |
bbrks
previously approved these changes
Aug 26, 2026
bbrks
approved these changes
Aug 26, 2026
…?action=start will cause resync to be stuck in running Cherry-picked from 2758dbf (CBG-5496, #8454). Adapted db/background_mgr_test.go: upstream's new TestBackgroundManagerStartReturnsErrorWhileProcessKeepsRunning is typed against MockProcessOptions, introduced by CBG-5653 (#8490, "switch backgroundmanager options to strong types"), which is not on 4.1.2. The test is applied in full with BackgroundManager[map[string]any] and map[string]any{} options, matching how every other test in this file instantiates the manager on 4.1.2. No assertions changed. The test carries upstream's t.Skip for CBG-5660. Prerequisite for CBG-5594 (CBG-5521): introduces updateTerminalStatus() and the SetError() call in BackgroundManager.start() that it builds on. Co-authored-by: Ritesh Sapata <34858159+RIT3shSapata@users.noreply.github.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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-5743
Unclean cherry pick of #8454 (CBG-5496) to 4.1.2
Stacked on #8660 (CBG-5752), which sits on #8635 (CBG-5744).
Changes from main commit:
db/background_mgr_test.go—TestBackgroundManagerStartReturnsErrorWhileProcessKeepsRunningis typed againstMockProcessOptions, added by CBG-5653 (CBG-5653 switch backgroundmanager options to strong types #8490) which is not on 4.1.2. Applied in full againstBackgroundManager[map[string]any], matching the rest of the file on this branch; no assertions changed. The test keeps upstream'st.Skipfor CBG-5660.🤖 Opened with the
sync-gateway-backportskill in Claude Code