Repository navigation
fix(shard): judge a partition transfer peer by the view this log adopted - #4439
almostintuitive wants to merge 1 commit into
Conversation
|
Thanks for the PR. It is labeled Slash commands (own line, regular comment) move it around the queue:
See CONTRIBUTING.md for details. |
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (0.00%) is below the target coverage (50.00%). You can increase the patch coverage or adjust the target coverage.
Additional details and impacted files@@ Coverage Diff @@
## master #4439 +/- ##
=============================================
- Coverage 90.75% 74.52% -16.24%
Complexity 2611 2611
=============================================
Files 1406 1400 -6
Lines 331886 228943 -102943
Branches 283658 180717 -102941
=============================================
- Hits 301216 170612 -130604
- Misses 24367 52461 +28094
+ Partials 6303 5870 -433
🚀 New features to boost your workflow:
|
A replica that needs partition state transfer cannot finish a view change: its WAL cannot certify a holed log, so every view-scoped send is withheld. Its elections time out alone and ratchet its view far past the group's (58 against the primary's 20 in a reproduction). Two places trusted that view (apache#4438): - The descriptor gate compared the serving primary's view with it, so it refused every offer from the group's real primary as "from a replica behind this one", though the offer held more committed state. - A transient refusal (an offer still flushing or hashing, routine under load) was judged against the primary of that view. The real primary did not match, so the retry rotated to a backup, which then matched and was asked forever. Either way the replica stayed behind for good and kept serving reads from its stale prefix. Compare the serving view with the local log_view, the last view whose log this replica adopted, and judge a refusal by the refuser's own view when it is at least that log_view. A phantom view-0 primary is still refused, and so is an offer from before the adopted view or below the commit point this replica knows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
19e3519 to
931f5e5
Compare
|
Closing as superseded by #4483, which closes #4438 with the same |
Which issue does this PR address?
Closes #4438
This PR first held three failing tests, one per livelock. Now that #4311 merged, it holds the fix, as asked on the issue. Master already resolved two of the three livelocks in its own way, so this PR now covers only the remaining one:
install_state_transfernow refuses only when the journal holds an op in(commit_op, held_max].RepairSession::requested_frompulls the next chunk while a fenced commit point cannot move.I dropped those two tests. Their setup no longer matches the code, and the behavior they pinned is gone.
Rationale
A replica that needs partition state transfer cannot finish a view change. Its WAL cannot certify a log with holes, so the persist gate withholds every view-scoped send. Its elections time out with nobody to hear them, and each timeout raises its
viewby one. In the reproduction from #4438, its log was last adopted in view 11, its own view reached 58, and the group's primary was at view 20.Two places trusted that raised view:
on_partition_state_transfer_targetrefused an offer whenheader.view < view(). Every offer from the real primary (view 20 < 58) was refused as "from a replica behind this one", though it held more committed state.primary_index(view()), which is replica 1 at view 58. The real primary (replica 2) did not match, so the retry rotated to replica 1. Replica 1 is a backup and can only refuse, but it matched the raised view's primary, so the replica asked it forever.Either way the replica stayed behind and kept serving reads from its stale prefix.
What changed?
transfer_offer_is_behindcompares the serving view with the locallog_view, the last view whose log this replica adopted, instead ofview. It still refuses a phantom view-0 primary, an offer from before the adopted view, and an offer below the localcommit_max.log_view. Otherwise it falls back to the localview, as before. Refusal descriptors already carry the sender's view. If a backup refuses, the existing ring rotation still moves on, and it now reaches the real primary.Nothing else decides what may be installed. The install keeps its own guards:
commit_opat or abovecommit_min, no journaled op erased throughmax(WAL head, commit_max), and the incarnation and history fences.Tests
Both handler tests call the real
on_partition_state_transfer_targetwith the reproduction's numbers (log view 11, view 58, primary at view 20):given_the_primary_offer_when_this_replica_ratcheted_its_view_alone_should_accept_it: fails on master (the offer is refused), passes with the fix.given_a_transient_refusal_from_the_primary_when_this_replica_ratcheted_its_view_alone_should_ask_it_again: fails on master (left: Some(1),right: Some(2): the re-arm targets backup 1), passes with the fix.transfer_descriptor_gate_tests: three unit tests for the refusals the gate must keep (an offer from before the adopted view, one below the known commit point, a phantom view-0 primary).Local Execution
rust-toolchain.toml, in a Linux container, on masterb15c8e1e9.cargo test -p shard --lib: 274 passed.cargo test -p simulator: 16 passed.cargo test -p partitions --lib: 642 passed.partition_storage::tests::a_removal_cut_short_leaves_the_marker_in_placefails on unmodified master too when run as root, because root ignores the directory mode.cargo fmt --all --checkandcargo clippy -p shard --all-targets --all-features -- -D warningsare clean.cargo clippypre-push hook, only clippy on the touched crate.apache/iggy:edge(44c7dc834, no fix) once: 1 partition, 30k msg/s,persisted, each node SIGKILLed in turn 80 s apart and down for 40 s. The wedge did not occur in that run (5,994,900 acked, 0 lost, all three replicas converged after one state transfer), and in October it occurred in 1 of 2 upstream runs. Our fork evidence:f6dfbdbb3, with all three original fixes: 4 of 4 runs passed, one of them with dedup on. Each had 0 lost, and all replicas ended byte-identical. The same build without the fixes lost 2,130,700 of 4,407,400 acked events, and one replica stayed wedged at view 58.AI Usage
masterat its assertion and passes with the fix. A review pass using theteam-reviewcharter ran on the diff, with one combined distributed-systems and storage reviewer instead of four, because the change is small. It found no safety problem in the gate change. It found the transient-refusal rotation that the first version of this fix missed. It also proposed the plain-number signature fortransfer_offer_is_behind. Both are in this PR.🤖 Generated with Claude Code