Repository navigation
Retry MongoDB replica-set configuration during member recovery - #20796
Ankit Jain (radical) with Copilot wants to merge 4 commits into
Conversation
Co-authored-by: radical <1472+radical@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 20796Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 20796" |
This comment has been minimized.
This comment has been minimized.
|
Copilot the PR description should have the issue# that it is fixing. And consider if we need specific tests for the new behavior including negative ones. |
Co-authored-by: radical <1472+radical@users.noreply.github.com>
The PR description already links the change to #19980 in its “Fixes #19980” suffix. I added focused coverage for the transient recovery code and negative cases for other codes; all 38 replica-set builder tests pass. The follow-up is commit |
This comment has been minimized.
This comment has been minimized.
MongoDB can interrupt the reconfiguration immediately after replica-set initiation with InterruptedDueToReplStateChange (code 11602). This escaped retry handling and marked the replica set FailedToStart. Retry recovery interruptions during configuration reads, initiation, and reconfiguration through the existing bounded loop. Re-probe after partial initialization to preserve the persisted configuration, and retain the last recovery error for retry-exhaustion diagnostics. Add server-failpoint scenarios for recovery, permanent errors, and retry exhaustion, checking membership and replica-set operations after recovery. Validation: 38 replica-set unit tests pass. Container-backed scenarios compile but could not run because the local Docker daemon is unavailable. Fixes #21133 Fixes #20478 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tests selector4 / 100 PR test projects · 2 PR jobs, from 3 changed files. Selected PR test projects (4 / 100)
Selected PR jobs (2)
How these were chosen — grouped by what changed🔧 📦 affected project 🧪 🧪 Job reasons
Selection computed for commit |
Sébastien Ros (sebastienros)
left a comment
There was a problem hiding this comment.
No blocking problems found. There is one low-severity test gap, posted inline.
PR description: it still says "Blocked: container-backed validation remains required", but all seven new VerifyReplicaSetConfigurationHandlesCommandErrors scenarios passed on Ubuntu in CI run 39988871153, against MongoDB 9.0.4. Please update it before merge.
Could not verify:
- Recovery was only shown with injected fail points. All the logged failures predate this fix, and the 11 other replica-set tests in that CI run showed no retry from this race, so closing the linked issues assumes the flake stays gone on later runs.
- Nothing was run locally. Only the Ubuntu test results were inspected, so it is unknown whether the container scenarios ran in the passing Windows job.
| { | ||
| // A member can interrupt config reads while transitioning during initialization. Its persisted | ||
| // configuration is unknown, so retry before deciding whether the set needs to be initialized. | ||
| allMembersUninitialized = false; |
There was a problem hiding this comment.
This line has no test protecting it. The replSetGetConfig / 11602 scenario in VerifyReplicaSetConfigurationHandlesCommandErrors only runs against a fresh set. If this assignment were removed, the failure would be swallowed and replSetInitiate would still succeed on mongo1, with the same failure count and member IDs, so the test would still pass. (Worked out from the code, not run.)
The case it guards: a persisted member returns 11602 while a newly prepended empty member returns NotYetInitialized. Without this line, Aspire runs replSetInitiate on the empty member, creating a new set instead of extending the persisted one. The current code handles this correctly; nothing stops it regressing.
Suggested fix: add a case based on VerifyMongoDBMultiNodeReplicaWithDataShouldWorkAcrossUsages(MemberPrepended) that sets the fail point on the persisted member, then asserts that its data and member IDs survive.
|
[automated] Closing as superseded for the reported replica-set startup race by #21594, which waits for the initial member to become writable primary before reconfiguration. This PR’s broader recovery retries and failpoint tests were not incorporated; closing this PR does not mark its linked issues resolved. |
Description
MongoDB replica sets can fail to start when a member changes replication state during setup:
Recovery interruptions were not retried during initiation or reconfiguration, including the reconfiguration immediately after successful initiation.
Retry this response throughout configuration probing, initiation, and reconfiguration using the existing bounded loop. Re-probing after partial initialization preserves the persisted configuration.
Add server-failpoint scenarios for transient recovery, permanent errors, and retry exhaustion, checking membership IDs, transactions, and change streams after recovery.
Validation
Passed: 38 replica-set unit tests. This also compiled the new functional scenarios.
Blocked: container-backed validation remains required. The focused functional run failed at the DCP prerequisite because the local Docker daemon socket was missing, before reaching the scenarios. The remaining run was stopped; this is not a passing recovery test.
Fixes #19980
Fixes #21133
Fixes #20478
Checklist
<remarks />and<code />elements on your triple slash comments?