Repository navigation
fix(#9590): refuse READ_YOUR_WRITES / LINEARIZABLE reads on a node removed from the Raft configuration - #9605
Conversation
…removed from the Raft configuration A removed node's division stays open and receives no appends, so a READ_YOUR_WRITES bookmark it has not applied, or a LINEARIZABLE read index, is never reached there: the read waited the whole quorum timeout and then degraded (READ_YOUR_WRITES) or failed (LINEARIZABLE). Refuse them at once with a retryable NeedRetryException, as #9510 does for writes. EVENTUAL reads and bookmarks already applied are still served. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | Report missing for 8c0ef0e1 |
| Diff coverage | ✅ 100.00% diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (8c0ef0e) Report Missing Report Missing Report Missing Head commit (5eb59aa) 255895 205115 80.16% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#9605) 10 10 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
ReviewThe change is small and targeted, and it follows the intent of #9510. I found nothing blocking. What looks good
Minor points
LGTM overall. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughRemoved Raft members now receive a retryable error for specified consistent reads instead of waiting for indexes they cannot apply. EVENTUAL reads and READ_YOUR_WRITES reads with already-applied bookmarks remain available. Unit and integration tests cover these behaviors. ChangesRemoved-node read handling
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The supplied review evidence identifies no issue that needs to be fixed before merge. Pre-merge checks |
|
…moval in the served-reads IT Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ReviewSmall, well-scoped fix. The gate sits in the one place all read paths share, costs nothing for EVENTUAL and already-satisfied RYW reads, fails open when the configuration is unknown (consistent with #9510), and is tested at both unit level and against real Ratis (the IT uses StallAwareStopwatch and @tag("slow") as CLAUDE.md requires). Points to consider
No security or performance concerns. The fast refusal also stops removed nodes from tying up threads for the quorum timeout. 🤖 Generated with Claude Code |
… during its wait; relax the #7641 order assertion Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review of #9605Overall this looks good. The fix is small and well scoped, and it follows the shape of #9510. What works
Minor points (none blocking)
No security concerns. The change only refuses requests, and the message leaks nothing sensitive. I did not run the tests locally. |
…lter the #7641 call log to the calls under test Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ReviewOverall this is a small, well-scoped fix. The gate sits in the one place all read paths go through, and the cost on the hot paths is nil: EVENTUAL reads and RYW reads that are already satisfied never check membership. What looks good
Minor suggestions (non-blocking)
I found no security or performance problems. Looks good to merge once CI is green. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9605 +/- ##
============================================
- Coverage 77.56% 77.56% -0.01%
- Complexity 4338 4364 +26
============================================
Files 2165 2166 +1
Lines 223158 223278 +120
Branches 47870 47892 +22
============================================
+ Hits 173097 173185 +88
- Misses 31762 31786 +24
- Partials 18299 18307 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #9590
A node removed from the Raft configuration (
leaveCluster(),DELETE /api/v1/cluster/peer/{id}) keeps an open division that receives no more appends. #9510 made it refuse writes; its consistent reads still waited on an index it never reaches.RaftReplicatedDatabase.waitForReadConsistency()now refuses them, retryably (NeedRetryException, HTTP 503 / Bolt TransientError / gRPC ABORTED), and the message names the reason:READ_YOUR_WRITESread on a non-leader whose bookmark is ahead of this node's trusted applied index. Before: it waited the full quorum timeout, then degraded to EVENTUAL and served data missing the write. It is also re-checked after the wait, so a node removed during the wait refuses rather than serving the degraded read. A member that merely timed out keeps the documented degrade-to-EVENTUAL contract;LINEARIZABLEread. Before: it waited for a read index the division never applies and failed only at the timeout.EVENTUALreads, andREAD_YOUR_WRITESreads whose bookmark this node already applied, are still served and never consult membership (the already-applied case now also skips the no-op wait call).isRemovedFromConfiguration()is the #9510 check (a division lookup plus a configuration read, no lock), already run on every commit.Test plan
Issue9590ReadConsistencyGateOnRemovedNodeTest(new, regular lane,FakeRaftHAServer): leader/follower x removed/member x RYW ahead/applied, removed during the wait, removed after the wait caught up, LINEARIZABLE on both roles, fail-open on an unknown configuration, EVENTUALIssue9590RemovedNodeRefusesConsistentReadsIT(new,slow, real Ratis, 3 nodes): 3 of its 4 tests fail onmainwithout the fix (verified), all pass with itIssue9510NodeRemovedFromConfigurationRefusesWritesIT,RaftReadConsistencyBookmarkIT,RaftCommandReadConsistencyITha-raftunit suite withoutslow/benchmark/vector: 3007 tests, 0 failuresCoverage
Invariant: a node that is not a member of the Raft configuration never serves a consistent read it cannot back, and never blocks one it knows it cannot reach.
query(language, query[, args])x3 ->waitForReadConsistency()command(...)->applyReadConsistencyForReadOnlyCommand->waitForReadConsistency()query/command, fixed hereensureLinearizableRead/ensureLinearizableFollowerReadwaitForReadConsistency()(grep), fixed hereKnown gaps: a read whose wait began while the node was still a member still blocks until the quorum timeout before it is refused (latency only, no stale data is served). Filed as #9606: closing it needs a read-only variant of
waitForAppliedIndex, because the same wait backs the post-commit waits, where a retryable exception would invite a duplicate retry.The fake-based test needed
FakeRaftHAServerto recordisRemovedFromConfiguration,ensureLinearizableReadandensureLinearizableFollowerRead.Issue7641DropInReplicasWaitsForLocalApplyTestasserted the exact full call log, so it now filters the log to the two calls it checks.Adversarial pass
This run had no tool for spawning a separate subagent, so no independent agent did the pass. The author's self-check found:
Review cycles
FakeRaftHAServerrecordingcontainsExactlyDeferred / skipped items
waitForAppliedIndexand is out of scope. It is unchanged for members and no longer applies to a removed node.getTrustedAppliedIndexlookup": the second read is deliberate (fresh after the wait) and is now commented.isRemovedFromConfiguration()takes no lock": it does a Ratis division map lookup, a configuration read and a peer-list scan, with no lock. It is the same check HA: a node removed from the Raft configuration may still accept writes and stall each one for the quorum timeout (follow-up to #9411) #9510 already runs on every commit, and here it runs only on LINEARIZABLE reads, which already pay a ReadIndex round trip.isRemovedFromConfiguration": this reverses cycle 2's suggestion. It was skipped so that the drop-ordering test does not break each time a recorded call is added.slowlike the HA: a node removed from the Raft configuration may still accept writes and stall each one for the quorum timeout (follow-up to #9411) #9510 IT, and the leader LINEARIZABLE path is covered byaLeaderThatLeftTheClusterRefusesALinearizableRead.Final state: max-cycles-reached (4/4). The last review had no blocking items.
🤖 Generated with Claude Code
Summary by CodeRabbit