mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
ee60eb0ced0c1b2a42d4aac7467db90edf358a89
Sender's WAL pump now flows through a sink in P2b too — but via a
backlog-relay adapter that keeps the same frameWALEntry wire
behavior as legacy streamBacklog. This keeps the receiver path
(decoder + RebuildSession.ApplyWALEntry on dual-lane port) untouched.
Real rewind / transport.WalShipper integration is P2d (which also
wires the dual-lane / receiver decoding alignment).
Why a relay-not-real-WalShipper for P2b:
Recovery's receiver consumes frameWALEntry on the dual-lane port.
transport.WalShipper writes MsgShipEntry on the executor's legacy
port. Plugging transport.WalShipper directly into recovery.Sender
in P2b would mean wire-format mismatch + receiver dispatch break.
The intentional shim is `senderBacklogSink` (DrainBacklog →
streamBacklog) — sink-shape API, same wire bytes.
Changes:
sender.go:
+ senderBacklogSink — adapts streamBacklog() to WalShipperSink:
StartSession / EndSession are no-ops (real rewind stays in
transport.WalShipper for P2d); DrainBacklog calls the existing
streamBacklog() in-place.
+ NewSenderWithBacklogRelay(primary, coord, conn, replicaID) —
constructs sender with senderBacklogSink{s: s}. Used by all
existing e2e + integration callers in P2b.
Sink-mode Run() flow: after sink.DrainBacklog returns nil, the
legacy `<-closeCh` wait + drainAndSeal still run so
PushLiveWrite session-lane entries (the existing test
scenario that injects post-target writes) keep converging.
P2c can move session-live into NotifyAppend once transport
WalShipper is wired.
NewSenderWithSink doc updated to reflect the closeCh + drainAndSeal
retention until P2c.
e2e_test.go:
All NewSender(...) → NewSenderWithBacklogRelay(...). No assertion
changes; same e2e shape, sink-mode path now exercised end-to-end.
integration_stub.go:
PrimaryBridge uses NewSenderWithBacklogRelay so the
bridge-shaped lifecycle (StartRebuildSession + PushLiveWrite +
FinishLiveWrites) still works through the sink branch.
sender_walshipper_sink_test.go:
+ TestSender_WithSink_DelegationOrder: spawns a goroutine that
`sender.Close()` after `<-sink.drainCalledCh` so sink-mode
Run unblocks past the closeCh wait and reaches sink.EndSession +
barrier path (otherwise drainCalledCh never fires).
+ TestNewSenderWithBacklogRelay_installsRelaySink: smoke test
that the new constructor installs senderBacklogSink and the
type satisfies WalShipperSink (compile-time check).
Lint fix: remove sync/atomic copy from earlier scaffolding.
Header comments clarified for P2 stage progression.
Test sweep:
go test ./core/recovery/... → all PASS (legacy path + sink path
both exercised; e2e tests now run via the relay sink).
go test ./core/transport/... → all PASS (no transport changes
in P2b).
go test ./core/replication/... ./core/replication/component/...
→ all PASS.
Roadmap note (architect-aware):
P2c — make sink required; delete legacy NewSender pump (streamBacklog
+ closeCh + drainAndSeal + PushLiveWrite + liveQueue + sealed
+ queueMu + walItem + Close). Sink-mode Run is already the
future shape; legacy path is deletable when no caller relies
on Close + drainAndSeal.
P2d — wire transport.WalShipper into recovery.Sender by aligning
wire format (dual-lane vs legacy port) at receiver decoding.
Then NewSenderWithBacklogRelay can be retired in favor of
NewSenderWithSink(real walShipperAdapter). Transport-layer
integration tests for architect rules 1+2 (updateContext
before StartSession; restore after EndSession) land here.
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%