mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
ad7bc74d3abaacb65120d0b61b3f4394852ccca4
Architect ratification (2026-04-30 §10): dual-lane port emits recovery
frameWALEntry; legacy port keeps MsgShipEntry. Single resident
WalShipper per (volume, replicaID); per-connection format selected by
emit profile on walShipperEntry, switched by recovery session brackets.
Changes:
recovery: export WriteWALEntryFrame(w, kind, lba, lsn, data) — public
helper for transport-side EmitFunc to write the dual-lane WAL frame
format. Wraps internal writeFrame + encodeWALEntry.
transport.WalShipper: EmitFunc signature gains EmitKind parameter.
NotifyAppend Realtime path passes EmitKindLive; DrainBacklog scan
passes EmitKindBacklog. Allows EmitFunc to choose WALKindBacklog
vs WALKindSessionLive on the dual-lane wire.
transport.BlockExecutor:
+ EmitProfile { SteadyMsgShip, DualLaneWALFrame }
+ walShipperEntry.emitProfile field (atomic with conn + lineage)
+ EmitFunc dispatches on profile + kind:
SteadyMsgShip + any kind → MsgShipEntry (SWRP envelope +
EncodeShipEntry)
DualLaneWALFrame + Live → frameWALEntry(WALKindSessionLive)
DualLaneWALFrame + Backlog → frameWALEntry(WALKindBacklog)
+ EmitFunc treats nil conn as silent drop (matches Idle-mode
semantics; avoids racing against session-bracket installation
when callers inject live writes via PushLiveWrite during the
WalShipperFor → sink.StartSession window)
- updateWalShipperEmitContext takes profile param
- SnapshotEmitContext returns profile too
- Ship() passes EmitProfileSteadyMsgShip to preserve legacy wire
transport.RecoverySink:
+ NewRecoverySinkWithProfiles for explicit profile control
+ sessionProfile / steadyProfile fields
+ StartSession installs session profile (default: DualLaneWALFrame)
+ EndSession seals the sink (sealed=true under sealMu) FIRST, then
restores steady context. Matches senderBacklogSink.flushAndSeal
contract — post-EndSession NotifyAppend returns ErrSinkSealed
(clean "session is closing" signal during the window between
session-end and bridge-map-removal).
transport.startRebuildDualLane (production hot path):
- Snapshots steady (conn, lineage, profile) before constructing sink
- Builds RecoverySink with session profile=DualLaneWALFrame
- Calls bridge.StartRebuildSessionWithSink (replaces
StartRebuildSession with bridging sink)
Result: WalShipper handles both backlog drain (DrainBacklog) and
live writes (NotifyAppend) during the session, on the dual-lane
port, in recovery wire format. EndSession restores steady context
(legacy port + MsgShipEntry).
Tests:
+ TestP2d_EmitDispatch_SteadyMsgShipProfile — wire bytes start with
SWRP magic + msgType=MsgShipEntry.
+ TestP2d_EmitDispatch_DualLaneWALFrameProfile_LiveKind — wire
bytes are recovery frame format with WALKindSessionLive tag.
+ TestP2d_EmitDispatch_DualLaneWALFrameProfile_BacklogKind —
DrainBacklog scan emits with WALKindBacklog tag.
+ TestRecoverySink_NotifyAppendAfterEndSession_Sealed — post-
EndSession NotifyAppend returns ErrSinkSealed.
Existing E2E coverage (now routed through WalShipper):
- TestDualLane_BlockExecutor_StartRebuild — byte-equal post-rebuild
(profile dispatch correct → receiver decodes → bytes land).
- TestDualLane_LiveWritesDuringSession_AtomicSeal — 40 concurrent
pushes, all byte-equal on replica.
- TestDualLane_EngineDrivenRebuild_HappyPath +
TestDualLane_EngineDrivenRebuild_WithPushLiveDuringSession
(component-level engine→adapter→executor→bridge full chain).
Cluster gains BlockExecutor(replicaIdx) accessor for component tests
that exercise dual-lane bridge surfaces.
go test ./core/recovery/ ./core/transport/ ./core/replication/{,component} —
all PASS, no regressions.
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%