mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
8f10be2869dd99230904e38902ab92d3eff8a3af
Hardware-validated fix for the silent rebuild stall on 40da4c8. Three
coordinated changes that close the gap between unit-test-green and
hardware-completing dual-lane rebuild:
1. **`startRebuildDualLane` — sentinel translation**
Caller passed `fromLSN=0` to the bridge, taken literally by
`WalShipper.StartSession(0)`. On a primary that's been running,
the WAL retention floor is at `checkpointLSN` (entries through
the checkpoint are durable in the extent and the WAL ring has
recycled past 0); `ScanLBAs(0)` immediately returns
`ErrWALRecycled`, the wal goroutine errors, sender exits before
barrier emission, hardware silently stalls.
Fix: pass `sessionFromLSN = targetLSN` (the snapshot pin). Base
lane covers the snapshot through the checkpoint, WAL drain has
nothing to ship at the pin (cursor==head), live writes during
the session flow via NotifyAppend on the steady-state path.
2. **`WalShipper.DrainBacklog` — cursor-caught-up shortcut**
At the dual-lane bootstrap with `cursor == fromLSN == targetLSN
== primary head`, the loop entered ScanLBAs and hit the recycle
gate. Add an early shortcut: if `cursor >= head` at iter start,
skip ScanLBAs and try the R1 transition directly.
3. **`RebuildSession.SeedWalApplied` + receiver wiring**
For a base-only rebuild (WAL drain ships nothing), `walApplied`
stayed at 0; `TryComplete`'s `walApplied >= targetLSN` conjunct
could never hold. Seed it with `fromLSN` at SessionStart so the
predicate satisfies after `MarkBaseComplete` + `WitnessBarrier`.
4. **`executor.go` dual-lane onClose — completion marker**
QA harness `wait_until_rebuild_complete` greps for
`executor: rebuild complete, sent N blocks (targetLSN=N)` —
emitted only by the legacy `doRebuild` path. Mirror it on the
dual-lane bridge's onClose callback so the harness recognizes
completion identically across modes.
Hardware result (G7 #2 — empty replica join, 1000 LBAs):
rebuild dispatched in 1s, completed in 1s after dispatch
(total 2s), 1000 LBAs byte-equal verified post-rebuild.
Markers fired: `barrier prepare ... WalLegOk=true` +
`barrier handshake ... match=true` + peer state
`catching_up → healthy`.
Known seam (out of scope, T4-during-live-writes):
When live writes arrive during the session, the receiver's T4
monotonic checker expects `lsn == appliedWalLSN+1` where
`appliedWalLSN` is seeded to `fromLSN`. Live writes get LSNs
starting at `fromLSN`, breaking T4. Resolving this requires
splitting the wire-fromLSN (T4 expectation) from the
shipper-anchor (DrainBacklog cursor) — separate work. The
hardware harness's scenario #5 (concurrent writes during
rebuild) hits an unrelated probe-loop dispatch issue first
and never gets to exercise this seam.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%