mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
1c6dc56107d8ed54e079aeadbf2cd170b9e87a15
New leaf task introduced by QA round-23 §0-B review. T4b-3 originally
planned for ReplicaPeer.Fence-only; QA's peer-state-mutation locality
check surfaced that DurabilityCoordinator must consume peer.Barrier
(not peer.executor.Barrier) so the error → Invalidate translation
lives at the per-peer execution layer — matching V2's WALShipper-
internal markDegraded locality. T4b-3 now ships both Barrier + Fence
wrappers as a leaf before the T4b-4 DurabilityCoordinator muscle port.
Invariant pinned: INV-REPL-BARRIER-FAILURE-DEGRADES-PEER at the V3
per-peer layer, mirroring T4a-3's Ship → Invalidate translation.
Changes:
core/transport/executor.go
Extract FenceSync(replicaID, lineage) error — synchronous fence
exchange returning a descriptive error on any dial / send /
recv / lineage-mismatch failure. Refactored existing async
doFence to wrap FenceSync + adapt the error to the callback-
based FenceResult. Behavior unchanged for existing async
callers (engine recovery path); T4b-3 peer wrapper gets a
clean sync surface.
core/replication/peer.go
New ReplicaPeer.Barrier(ctx, targetLSN):
- Passes peer.lineage UNCHANGED to executor.Barrier — does
NOT override lineage.TargetLSN with the caller's targetLSN.
Replica's acceptMutationLineage rejects same-authority
messages that change TargetLSN, so override would self-
reject. Caller's targetLSN is coordinator-layer-only
(compared against ack.AchievedLSN for mode arithmetic).
- MUST NOT gate on state == Degraded per V2 "always attempt
BarrierAll" invariant (architect §4.3 note in G-1 doc).
Only post-Close gate applies.
- On transport error: p.Invalidate(reason) + state=Degraded
(INV-REPL-BARRIER-FAILURE-DEGRADES-PEER pin).
New ReplicaPeer.Fence(ctx, lineage):
- Takes caller-supplied lineage (not peer-owned) because
fence semantic is "confirm this specific authority tuple"
— coordinator or recovery path chooses which lineage.
- Delegates to executor.FenceSync.
- Same error → Invalidate translation.
Tests (5 required per QA spec):
- TestReplicaPeer_Barrier_Happy — round-trip against real
ReplicaListener; ack.Lineage == peer.lineage byte-exact;
state remains Healthy
- TestReplicaPeer_Barrier_ErrorPropagates_MarksDegraded —
unreachable replica; Barrier returns error; peer transitions
Healthy → Degraded. INV-REPL-BARRIER-FAILURE-DEGRADES-PEER
pin at peer layer.
- TestReplicaPeer_Fence_Happy — fence exchange at peer.lineage
against real replica; state stays Healthy
- TestReplicaPeer_Barrier_AfterClose_Errors — post-Close call
returns 'closed' error; no panic
- TestReplicaPeer_Fence_AfterClose_Errors — post-Close call
returns 'closed' error; no panic
Verification: full 21-package repo suite green. G-2 tri-line godoc
on Barrier, Fence (Called by / Owns / Borrows) + FenceSync on
executor. G-3 cumulative. Existing T4b-2 Fence tests pass after the
doFence → FenceSync refactor (behavior preserved).
Third task in T4b batch. Next: T4b-4 DurabilityCoordinator (muscle
port; G-1 pre-signed by QA in revised artifact at sw-block/design/
v3-phase-15-t4b-4-g1-v2-read.md) against the peer.Barrier surface.
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%