mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
cb353bccea7cc0c7a067e6cf9d74b3238c85350b
* test(G2): red - a promoted host applies the deposed primary's ship fencing-gaps-todo.md G2, red test first. A real ReplicaListener and the real Host.applyFact primary path: ship at epoch 1 to listener B, master promotes B to primary at epoch 2 (a self AssignmentFact), the old primary ships at epoch 1 again. Today the ship is applied. Adds the seam the fix uses: Host.SetSelfFence / fenceSelf call the host's own listener on the primary path (after UpdateReplicaSet, before OnAssignment) and on the supporting-replica path, and replay an already adopted role when the listener is installed later (cmd/blockvolume wires it before Serve). The listener's FenceAsPrimary / AdmitAsReplica are no-ops in this commit, so the test is red on behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(G2): a new primary fences its own replica listener fencing-gaps-todo.md G2. The replica listener gets an epoch floor and a primary flag. FenceAsPrimary(e), called by the host on the primary path before OnAssignment, sets the floor to at least e and refuses every replication mutation; AdmitAsReplica(e), on the supporting-replica path, re-admits replication but keeps the floor. acceptMutationLineage, the single gate for ship, recovery lane start and rebuild block/done, applies both. Probes are unchanged. Green: TestG2_PromotedHostRefusesShipFromDeposedPrimary (real Host.applyFact primary path + real listener) passes 3/3; new listener tests: a primary refuses ship / recovery lane start / rebuild but answers probes; the floor stays after AdmitAsReplica and never goes down. Ledger: INV-FENCE-SELF-ON-PROMOTE-001. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style(G2): gofmt replica.go field alignment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(G2): the fence drains replication mutations already past the gate Review of cc884db (claude03 P2-1, codex01 P1): acceptMutationLineage released r.mu before the store write, and FenceAsPrimary only flipped flags, so a deposed-epoch ship or rebuild admitted just before promotion was applied after the fence returned, while the host served as primary. Each mutating frame (ship, recovery lane start, rebuild block, rebuild done, barrier) is now counted under r.mu from before its gate check until its storage effect is done; its ack is written after it is uncounted, so the fence never waits on the network. FenceAsPrimary sets primary and the floor (no new admissions), then waits for the count to reach zero, bounded (10 s); on timeout it returns an error and the host fails closed: no OnAssignment, as for an UpdateReplicaSet failure; master redelivers. Lock order: Host.selfFenceMu -> ReplicaListener.mu, never the reverse; r.mu is held only for gate state and the counter (Cond.Wait releases it), never across storage or network calls. Red (fence without the wait) / green: in-flight controls for ship (direct and ApplyHook paths) and a rebuild base write fail, then pass 3/3; a mutation stuck past the bound makes the fence report an error; the host does not adopt primary when the fence fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%