mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
d8b30f59569a69e6701d202eb85540400f4bc269
* docs: wiring plan for core/recovery → core/transport + cmd Strategy doc for the next PR (g7-redo/wiring): how to land the dual-lane recovery package alongside (NOT replacing) the existing single-lane core/transport path per architect ruling. Sections: - Strategy: --recovery-mode flag (legacy / dual-lane); default legacy until one milestone of dual-lane GREEN observed. - Surface inventory: 6 files in core/transport, 1-2 in cmd, 0 in core/recovery (it stays untouched). - Lifecycle alignment: PeerShipCoordinator is the single source of truth for "is replica P in a rebuild session" when dual-lane active; legacy's BlockExecutor.activeSession is internal to the legacy path. Mode is exclusive. - Wire-format collision (frameSessionStart=0x01 vs MsgShipEntry= 0x01): three options analyzed; recommend separate ports per mode. - Coordinator scope: per-volume, NOT per-replica (so MinPin sees all replicas for a meaningful min). - Priority 2.5 (WAL recycle consumes MinPin): new RecycleFloorSource interface in core/storage; coordinator already implements it exactly; recommend split into g7-redo/recycle-pin-hookup PR after this one. - Test plan: dual-lane integration tests + recycle-pin unit test. Existing legacy tests unchanged. - Rollback: default flip is one-line; legacy removal is a separate later PR. 4 open questions for architect (wire collision option, 2.5 split, default flip timing, legacy removal timing). Out of scope: §3.2 #3 interleave, retry budget (parallel PR), liveShipTargetLSNSentinel removal (waits for legacy removal). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * transport: dual-lane wiring (BlockExecutor + StartRebuild branch) First wiring step per docs/recovery-wiring-plan.md §1-§3. Adds the parallel-flag plumbing for routing StartRebuild through the core/recovery package's PrimaryBridge while leaving the legacy single-lane path completely untouched on the default constructor. Architect ACK on §11 Resolution 1 (separate ports, Option A) drives the design: dual-lane uses a separate listen address from the legacy port; this commit only does the primary-side dial; replica's listen loop is illustrated in dual_lane_test.go and will be hoisted into cmd/blockvolume in a follow-up. What lands: core/transport/executor.go + DualLaneConfig struct (Bridge / DialAddr / ReplicaID). + dualLane *DualLaneConfig field on BlockExecutor. + NewBlockExecutorWithDualLane(primaryStore, replicaAddr, dualLaneAddr, coord, replicaID) constructor. + Bridge captures executor's onStart/onClose via closures so SetOnSession*Callback continues to work post-construction. core/transport/rebuild_sender.go + StartRebuild branches on e.dualLane != nil. + startRebuildDualLane: dial dual-lane port, call bridge.StartRebuildSession, immediately FinishLiveWrites (legacy semantic — no live writes during rebuild). Logs the same "executor: rebuild start" marker QA helpers scrape, with "(dual-lane)" suffix for trace clarity. core/transport/dual_lane_test.go + runDualLaneListener test helper (illustrates what cmd will do in production: net.Listen + accept loop spawning recovery.ReplicaBridge.Serve per conn). + TestDualLane_BlockExecutor_StartRebuild — full path: OnSessionStart fires, OnSessionClose fires with achievedLSN == primaryH, replica's substrate matches primary byte-for-byte, coordinator returns to PhaseIdle. + TestDualLane_LegacyConstructorIsNotDualLane — guard that the existing NewBlockExecutor stays legacy (dualLane == nil). Validation: 2 new tests pass; all existing core/transport tests unchanged; full repo `go test ./...` green. OUT OF SCOPE for this PR (per wiring plan §10): - cmd/blockvolume flag wiring (next commit). - WAL recycle path consuming MinPinAcrossActiveSessions (architect priority 2.5 — separate g7-redo/recycle-pin-hookup PR per §11 Resolution 2). - Removing core/transport/replica.go::liveShipTargetLSNSentinel lane shim (waits for legacy removal milestone). - §3.2 #3 single-queue real-time interleave (architect priority #2). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * wiring: cmd flag + replication factory + listener (dual-lane reachable from binary) Second wiring step per docs/recovery-wiring-plan.md. After this commit, the daemon binary actually exposes the dual-lane recovery path: a flag selects mode, the replication volume injects the right BlockExecutor factory per peer, and a separate listener binds at port+1 for inbound recover-session conns. cmd/blockvolume/main.go + --recovery-mode=legacy|dual-lane flag (default legacy). + Validation: rejects unknown values at parse time. + In dual-lane mode, after constructing replVolume: - new per-volume recovery.PeerShipCoordinator, - SetDualLaneExecutorFactory wires per-peer NewBlockExecutorWithDualLane closures, - separate listener at deriveDualLaneAddr(data-addr) running recovery.ReplicaBridge.AcceptDualLaneLoop in its own goroutine, - graceful close via deferred cancel + ln.Close at daemon shutdown. + deriveDualLaneAddr helper: host:port → host:port+1 (deployment convention, wiring plan §4 Option A). cmd/blockvolume/dual_lane_addr_test.go + Pins the port+1 convention: IPv4, IPv6, port=0 boundary, overflow at 65535, malformed inputs. core/replication/volume.go + dualLaneExecutorFactory type (factory takes replicaID alongside addr — the legacy 2-arg signature does not). + newDualExec field, nil-default = use legacy newExec. + UpdateReplicaSet branches on which factory is set per peer. + SetDualLaneExecutorFactory exported setter for cmd to inject the per-volume coordinator-capturing closure. MUST be called before UpdateReplicaSet (existing peers do not retroactively re-construct). core/recovery/integration_stub.go + Hoist AcceptDualLaneLoop helper from the test file to a public method on ReplicaBridge. Production cmd uses this directly; test wrapper now just calls it. core/transport/dual_lane_test.go + Refactor runDualLaneListener to use the new public helper instead of an inline accept loop. Lifecycle simplified (ctx cancel + ln close → loop returns). Validation: cmd/blockvolume tests + full repo go test ./... PASS. Default --recovery-mode=legacy keeps existing G5-* / G6 behavior identical. Out of scope (still): WAL recycle path consuming MinPin (g7-redo/ recycle-pin-hookup, separate PR per architect §11 Resolution 2), removing legacy lane shim, §3.2 #3 interleave. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * component: dual-lane engine-driven happy path (wiring step 3) Closes the wiring milestone per docs/recovery-wiring-plan.md §7 + architect "P0 = component layer dual-lane full chain" (2026-04-29). Full chain pinned: master fact → adapter.OnAssignment → engine ingest Identity → emits ProbeReplica → executor.Probe → adapter ingests RecoveryFacts → engine.decide() picks rebuild (R<S) → emits StartRebuild → adapter dispatches to dual-lane-mode BlockExecutor → recovery.PrimaryBridge.StartRebuildSession → sender goroutine over the replica's separate dual-lane port → recovery.Receiver applies base lane + barrier → SessionClosedCompleted flows back through executor.OnSessionClose → adapter → engine.Trace records the event. Cluster builder additions: + WithDualLaneRecovery() — composable with WithEngineDrivenRecovery. + Coord() — exposes the per-volume PeerShipCoordinator for assertion. + DualLaneReplicaAddr(i) — diagnostic. + ReplicaNode.DualLaneAddr — populated when dual-lane mode set. + Start() branches: per-replica dual-lane listener bound on 127.0.0.1:0 alongside the legacy listener; per-volume coord instantiated before executors so each NewBlockExecutorWithDualLane captures the same instance. Substrate: MemoryWAL (new factory in cluster.go) — NOT BlockStore or walstore. Architect-bound rationale for using memorywal rather than walstore here: - V2-faithful per-LSN replay (RecoveryModeWALReplay, write-time LSN through ScanLBAs) — matches the dual-lane recovery contract the test asserts. - In-memory; no /tmp churn between tests; no flusher/checkpoint timing surprises in scenario assertions. - Already part of the contract test table (BlockStore / WALStore / MemoryWAL all pass the same 12 tests), so substrate parity is covered separately. Tests pinned (both PASS, runs in ~30ms each on memorywal): TestDualLane_EngineDrivenRebuild_HappyPath: - Engine emits StartRebuild after probe-result ingest. - Trace records SessionClosedCompleted within 5s deadline. - coord.Phase("r-0") == PhaseIdle post-session. - Replica's substrate matches primary byte-for-byte across the rebuilt range (12 LBAs). TestDualLane_CoordReleasesPinFloorAfterSession: - Pin floor released; MinPinAcrossActiveSessions reports anyActive=false post-session. - PinFloor("r-0") == 0 after coord.EndSession. - INV-SESSION-TEARDOWN-IS-EXPLICIT. Out of scope (still): - Hardware integration (separate phase). - WAL recycle path consuming MinPin (g7-redo/recycle-pin-hookup, architect §11 Resolution 2). - §3.2 #3 single-queue real-time interleave (architect priority #2). - Multi-replica fanout under dual-lane (single replica here for focus). Full repo `go test ./...` PASS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- 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%