mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
4b16a2e7599fb681bac8a3cf289b0119b22e8749
Architect round-22 bundle: new BlockExecutor.Barrier public method +
upgrade of existing executor.doFence to respect round-21 uniform
rule (INV-REPL-LINEAGE-BORNE-ON-BARRIER-ACK). Two coupled changes,
same file, same executor-level ownership, one commit — shipping
Barrier with validation while leaving doFence silent-accept would
violate the uniform rule at the first ack-consuming surface.
Changes:
core/transport/barrier.go
New BarrierAck type: {Lineage, AchievedLSN, Success, Reason} —
validated per-peer barrier outcome surfaced to
DurabilityCoordinator (T4b-3).
New ErrBarrierLineageMismatch sentinel: returned by Barrier
when the response lineage does not match the request. Callers
treat it as a failed barrier for quorum arithmetic.
core/transport/executor.go (doFence upgrade)
After recvBarrierResp succeeds, validate that resp.Lineage
matches the lineage we sent. Mismatch → FenceResult with
Success=false + FailReason containing expected=<lineage>
actual=<lineage> tuple. Short/zeroed/malformed decode failures
already surface as recvBarrierResp errors (T4b-1 decode layer);
they now cleanly propagate to OnFenceComplete instead of
silent-accept ("_ = resp" removed).
core/transport/executor.go (new Barrier method)
func (e *BlockExecutor) Barrier(replicaID, lineage, targetLSN)
(BarrierAck, error)
Implementation mirrors Ship (architect round-11 Option B
composite):
1. Session lookup by lineage.SessionID
2. Epoch-== fence (silent drop on stale epoch via error return)
3. Lazy-dial if session.conn == nil, with "first-winner keeps"
race resolution under e.mu
4. sendBarrierReq + recvBarrierResp (existing helpers; both
set conn deadlines, so timeout is bounded by
recoveryConnTimeout=5s)
5. Full-lineage validation — resp.Lineage != lineage returns
ErrBarrierLineageMismatch with diagnostic log format
matching architect round-21 text (peer ID + expected +
actual tuple)
Tests (5 required per mini-plan §2 T4b-2):
- TestExecutor_Barrier_Happy — real ReplicaListener round-trip;
lineage echo byte-exact; Success=true
- TestExecutor_Barrier_TimeoutFires — replica accepts but never
responds; Barrier's recv deadline fires in ~5s (elapsed
between 4s and 15s, must wedge for most of the deadline to
count as deadline-driven rather than fast-error)
- TestExecutor_Barrier_LineageMismatch_Rejected — custom replica
sends a valid-decode BarrierResponse with different lineage;
Barrier returns ErrBarrierLineageMismatch
- TestExecutor_Fence_LineageMismatch_MarksFailure — the round-22
pin; custom replica sends wrong-lineage ack; doFence propagates
Success=false through OnFenceComplete with FailReason carrying
expected= + actual= tuples. This catches "first existing ack
consumer silently accepts" regression class.
- TestExecutor_Fence_ShortOrZeroedLineage_MarksFailure — two
sub-cases (8-byte short payload, 40-byte all-zero lineage);
both propagate through OnFenceComplete as Success=false (the
T4b-1 decode-layer error is faithfully relayed to the callback).
Preserve:
- sendBarrierReq / recvBarrierResp helper signatures unchanged
- Existing catch-up (catchup_sender.go:102-108) and rebuild
(rebuild_sender.go:103) paths continue to decode successfully
with the extended wire; they ignore the lineage field for T4b
scope — their lineage-validation lands at T4c (catch-up) and
T5 (rebuild) respectively
- adapter.OnFenceComplete callback shape unchanged (FenceResult
gains fuller FailReason content but fields untouched)
Verification: full 21-package repo suite green. G-2 tri-line godoc
on Barrier + BarrierAck + ErrBarrierLineageMismatch. G-3 cumulative.
Timeout test elapsed = 5.00s exactly, confirming deadline is the
unblocking mechanism.
Second task in T4b batch. Next: T4b-3 DurabilityCoordinator (muscle
path; G-1 pre-code V2 diff-footprint required before coding).
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%