mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
f905ef40fad1c775faa7e3549045670cb9077637
Architect P1 review (2026-04-29 of commit 0d3e379) found 4 items.
This commit fixes #1, #2, #3 + adds #4 doc note. All required before
P2's recovery.Sender wiring trusts the same EmitFunc for backlog
emit.
#1 (P2 SHOWSTOPPER): encoding seam moved INTO EmitFunc.
Before: Ship() pre-encoded payload via EncodeShipEntry, passed
encoded bytes as `data` to NotifyAppend. EmitFunc just did
`WriteMsg(conn, MsgShipEntry, data)`.
Hidden bug for P2: when DrainBacklog calls `s.emit(e.LBA, e.LSN,
e.Data)` with e.Data = raw substrate bytes from ScanLBAs, NOT
pre-encoded ShipEntry, EmitFunc would WriteMsg garbage. Replica's
MsgShipEntry handler would fail decode. Architect: "wiring
recovery to this same EmitFunc without encoding in or before emit
will ship garbage on rebuild/catch-up".
After: EmitFunc owns EncodeShipEntry. WalShipper hands raw
`(lba, lsn, data)` tuples; EmitFunc encodes per-call using
walShipperEntry.emitLineage. Both steady (Ship) and backlog
(P2 DrainBacklog) feed the SAME EmitFunc shape — one encoding
seam, one wire frame type.
Implementation:
- walShipperEntry adds emitLineage RecoveryLineage field.
- WalShipperFor's EmitFunc reads lineage from entry under
emitCtxMu, calls EncodeShipEntry inside.
- updateWalShipperConn renamed to updateWalShipperEmitContext;
now sets BOTH conn AND lineage atomically.
- Ship() passes RAW data (block bytes), NOT pre-encoded payload.
Future P2: recovery.Sender's session-installer calls
updateWalShipperEmitContext with session lineage before
walShipper.StartSession. After session ends, restores steady
lineage. SAME EmitFunc handles both flows.
#2: TestBlockExecutor_StableUnderConcurrent_Ship test scope
clarified.
Architect: "cursor == maxLSN does not prove no lost emits — if
goroutines finish out of LSN order, Realtime's idempotent-skip
drops lowers while cursor still ends at maxLSN".
Renamed: TestBlockExecutor_WalShipperRegistry_StableUnderConcurrent_Ship
Test now explicitly pins:
- INV-SINGLE registry stability under concurrent Ship load.
- cursor advanced from 0 (some Ship landed).
- cursor ≤ maxLSN (sanity bound).
And explicitly does NOT pin:
- "all 200 LSNs reach the wire" — that's lossless-emit
semantics, requires production-mirror serialized Ship pattern
(held under volume.mu in production via OnLocalWrite).
Belongs to P2 e2e where serialized Ship matches production.
Comment block at top of test calls out architect P1 review #2
as the rationale.
#3: ordering invariant for updateWalShipperEmitContext documented.
Architect: "every code path that can emit must refresh conn
context the same way Ship does (or centralize 'resolve conn
then notify')".
Added explicit invariant doc on updateWalShipperEmitContext:
"every code path that ends in an emit (steady Ship, future
recovery-session backlog DrainBacklog, future Activate) MUST
refresh this context BEFORE the call that may emit. Otherwise
EmitFunc emits with stale lineage / nil conn".
#4: registry lifecycle TODO documented.
Architect: "walShippers is never torn down when a peer goes
away with new session/conn semantics. Probably fine for MVP;
watch replica churn / InvalidateSession".
Added doc note: walShippers entries are never torn down today;
P3+ may add Forget(replicaID) hook for replica churn / lineage
invalidation / executor reuse. Out of scope for MVP since
current call sites construct one BlockExecutor per
(volume, replica) lifecycle.
Test sweep:
go test ./core/transport/ -count=1 → all PASS (including the
renamed test with weaker but honest assertions).
Wider sweep (transport + recovery + storage + replication +
replication/component): all PASS.
Net effect: P2 (recovery.Sender thin) can now plug DrainBacklog
into the SAME walShipper that Ship() uses, with EmitFunc handling
encoding for both. The "5th time wrong pump" risk is materially
lower.
Languages
Go
84.7%
Rust
7.7%
Shell
2.7%
templ
1.5%
Java
1%
Other
2.1%