mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
c314b608df7a93fbbd963a2bb5b2835518b80e42
Architect review ofad7bc74against §6.8 / consensus v3.8 nine MUSTs: two correctness fixes — concurrency safety (writer race) + accounting (missing RecordShipped on WalShipper-routed path). §6.8 #1 SINGLE-SERIALIZER (mechanical): walShipperEntry adds writeMu sync.Mutex. EmitFunc holds it during conn.Write. recovery.WalShipperSink gains optional duck-typed sub-interface `interface{ WriteMu() *sync.Mutex }`. transport.RecoverySink implements it via e.WalShipperWriteMu(replicaID). recovery.Sender.NewSenderWithSink: duck-types the sink; if WriteMu() present, sender.sharedWriter = sink.WriteMu(). writeFrame uses sharedWriter when set, falling back to its own writerMu otherwise. Result: in dual-lane sessions, Sender.writeFrame (SessionStart / BaseBlock / BaseDone / BarrierReq) AND EmitFunc (frameWALEntry) serialize on the same per-replica entry mutex. No more interleaved header/payload from two concurrent writers on the same conn. Steady (Ship) path uses entry's own writeMu uncontended (only Ship writes the legacy port). Accounting (post-emit RecordShipped): walShipperEntry adds postEmit func(lsn uint64). EmitFunc fires outside writeMu after a successful conn.Write. WalShipperSink gains optional sub-interface `interface{ SetPostEmitHook(func(lsn uint64)) }`. RecoverySink implements via e.SetWalShipperPostEmitHook. recovery.Sender.Run: at session start (after defers), checks if sink supports SetPostEmitHook; if so, installs func(lsn) { coord.RecordShipped(replicaID, lsn) } and clears via defer at session end. Result: each successful WalShipper-routed emit (Backlog scan or Live NotifyAppend) advances coord.shipCursor in lockstep with emit. Pre-C1 the dual-lane path silently left shipCursor at fromLSN; future code that depends on the cursor (BacklogDrained, TryAdvanceToSteadyLive, observability) was latent-broken. Tests: + TestC1_WriteMu_SharedAcrossSenderAndWalShipper — sink.WriteMu() and executor.WalShipperWriteMu return same mutex address. + TestC1_WriteMu_NoInterleave — concurrent NotifyAppend emits parse cleanly as a sequence of well-formed recovery frames (no header/payload interleave detected). + TestC1_PostEmitHook_AdvancesShipCursor — full dual-lane rebuild completes cleanly; replica frontier reaches primaryH; coord returns to Idle. Exercises the post-emit hook on every shipped LSN without panic / hook misuse. go test ./core/recovery/ ./core/transport/ ./core/replication/{,component} — all PASS, no regressions. Companion: sw-block design mini-plan §11.2 / §11.3 (commit058305225on seaweedfs/feature/sw-block).
Languages
Go
84.5%
Rust
7.9%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%