mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
93d8e6cce9cfba32148109b6089628effdb9d708
13
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
731f278542 | storage: fail rebuild snapshots on read faults and preserve RMW fencing | ||
|
|
45b21313b4 | replication: close executor lifecycle before store teardown | ||
|
|
6a5d54678c |
docs(core): drop internal phase/gate prefixes from production comments
Strip T4a/T4b/T4c/T4d, G3+/G5-5/G5-5A/G5-5C/G6/G7-redo, P14/P15, and "architect round-NN" prose from godoc and in-body comments across the core/ tree. Preserve stable invariant identifiers (INV-* names) since they're searchable across the codebase. Files: core/engine/apply.go, core/host/master/services.go, core/replication/component/cluster.go, core/replication/probe_loop.go, core/storage/walstore.go, core/storage/walstore_recovery.go, core/transport/executor.go, core/transport/replica.go. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
eb4071ed05 |
fix(test): align component cluster harness to replica-%d (Phase 0 prerequisite)
The component harness (cluster.go) constructed dual-lane executors with rid="r-%d" while the engine driver in dual_lane_engine_test.go sent AssignmentInfo / ProbeResult under "replica-%d". Pre-Phase-0- Fix-#1 this silently diverged: bridge keyed coord.PinFloor under "r-N", sink keyed WalShipper writeMu + post-emit RecordShipped under "replica-N". The rebuild barrier completed despite the keying mismatch (replica-driven BarrierResp), so the bug stayed invisible. Now that startRebuildDualLane fail-closes on a mismatched non-empty construction RID (commit |
||
|
|
ad7bc74d3a |
P2d: WalShipper-routed dual-lane rebuild + per-connection wire format
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>
|
||
|
|
5b64dfd3c5 |
recovery: WAL recycle gate consumes MinPin (priority 2.5) (#14)
Closes architect priority 2.5 per docs/recovery-wiring-plan.md §6.
Pinned by INV-RECYCLE-GATED-BY-MIN-ACTIVE-PIN. Depends on wiring
(stack-on-wiring per architect Option A 2026-04-29).
Substrate gate (`core/storage`):
+ RecycleFloorSource interface — externally-supplied
`MinPinAcrossActiveSessions() (uint64, bool)`. Substrate stays
orthogonal to engine: structural typing means
`core/recovery.PeerShipCoordinator` satisfies it without import.
+ RecycleFloorGate optional interface — substrate impl that
accepts a source via `SetRecycleFloorSource`. Cmd / wiring
type-asserts on it; smartwal can opt in later.
walstore (`core/storage/walstore.go`):
+ recycleFloorSrc field, mu-guarded.
+ persistCheckpoint clamps proposed `highestLSN` to floor when
source reports active session. Existing no-regress guard
(`if highestLSN <= s.checkpointLSN`) handles transient
floor-below-checkpoint races.
+ SetRecycleFloorSource setter.
memorywal (`core/storage/memorywal/store.go`):
+ recycleFloorSrc field, mu-guarded.
+ AdvanceWALTail clamps proposed `newTail` to floor when source
reports active session. Same shape as walstore.
+ SetRecycleFloorSource setter.
Coordinator assertion (`core/recovery/peer_ship_coordinator.go`):
+ `var _ storage.RecycleFloorSource = (*PeerShipCoordinator)(nil)`
— compile-time pin so future signature drift breaks the build,
not the runtime gate.
Daemon wiring (`cmd/blockvolume/main.go`):
+ In dual-lane mode, install gate via `RecycleFloorGate` type
assertion. Skipped silently when substrate doesn't support it
(BlockStore today). Diagnostic stderr line for operators.
Component fixture (`core/replication/component/cluster.go`):
+ Cluster.Start installs the gate when dualLane is set, so
component-level dual-lane tests exercise the recycle path
against the same coordinator they install on executors.
Tests (12 new):
+ walstore_recycle_pin_test.go (6) — nil source / inactive /
active clamp / floor-above-proposed (no clamp) / no-regress
when floor < current checkpoint / disable via Set(nil).
+ memorywal/store_recycle_pin_test.go (6) — nil source / inactive
/ active clamp + scan-gate inequality / floor-above-proposed /
disable / RecycleFloorGate interface satisfaction.
Verified: `go test ./core/... ./cmd/... -count=1` all green
(transport, host, recovery, storage{,/memorywal,/smartwal},
replication{,/component}, blockvolume).
inv-test-map.md updated: row flips from "logic only; recycle
integration is next milestone" to "coord + walstore + memorywal
substrate integration" with the 12 new tests cited.
|
||
|
|
d8b30f5956 |
G7-redo wiring: cmd flag + replication factory + transport + component fixture (dual-lane reachable from binary) (#13)
* 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> |
||
|
|
8d813f6ca1 |
G5-5C #6: end-to-end restart-catch-up component test + StopHard listener
Architect Batch #6 review 2026-04-27 ratified scope: end-to-end wiring + convergence test, mirror G5-5 hardware step #4 without iSCSI/iptables harness. 5 implementation constraints all addressed: #1 determinism: bounded retries, 30 ms loop interval, 20 ms cooldown base, 200 ms cap, hard 8 s deadline on convergence wait. CI flake guard via 1.5 s no-convergence window in negative control test. #2 kill semantic: ReplicaListener.Stop() blocks on wg.Wait waiting for active handler conns to drain, but on localhost the primary side never closes the live-ship conn so handlers block forever on ReadMsg. Added ReplicaListener.StopHard() that closes active conns BEFORE waiting; KillReplicaListener routes through it. The pre-existing Stop() semantics are preserved for the regular teardown path. Same-port rebind via NewReplicaListener retry loop with 2 s deadline (TIME_WAIT tolerance). #3 probe path same as cmd/blockvolume: configureProbeLoopOnCluster uses volume.ProductionProbeFn (NOT a stub) → ConfigureProbeLoop → StartProbeLoop. The exact closure main installs in production. #4 assertion layer: byte-equal convergence only — no engine R/S/H peeks. Architect ruling: "至少一条: ReplicaDegraded → probe → catch-up dispatched → frontier/byte-equal". #5 no rebuild branch verification: test asserts convergence only, not which engine command was emitted. In this scenario the smartwal store's post-rebind boundaries land R<S so engine picks Rebuild; that's incidental, not a property the test pins. Files: - core/transport/replica.go: +StopHard method, +conns map for active-conn tracking; pre-existing Stop semantics unchanged. - core/replication/component/cluster.go: KillReplicaListener now calls StopHard. - core/replication/component/g5_5c_restart_catchup_test.go (new): - TestG5_5C_RestartCatchUp_Convergence: positive end-to-end test. - TestG5_5C_RestartCatchUp_NoConvergence_WithoutProbeLoop: negative control — same scenario without ConfigureProbeLoop must NOT converge in 1.5 s window. Without this control, the positive test could pass via some other accidental reconvergence pathway; this pin proves the probe loop is load-bearing. Helpers (test-local): - rebindReplicaListener: same-port restart with 2 s rebind retry. - configureProbeLoopOnCluster: production wiring on cluster harness. - drivePeerAdmit: AssignmentInfo + initial ProbeResult to reach Healthy. - writeOneBlock: write through StorageBackend so WriteObserver fires (not direct store write). Three-counter SessionID onboarding note (architect Batch #5 follow-up): core/replication/peer.go now documents in code why three counters exist (peerSessionID for live-ship; adapter probe counter for engine-emitted ProbeReplica; probeSessionID for G5-5C runtime- driven probes) and why none cross paths. Test results: - TestG5_5C_RestartCatchUp_Convergence: PASS (0.05 s) - TestG5_5C_RestartCatchUp_NoConvergence_WithoutProbeLoop: PASS (1.54 s) - Full ./... regression: PASS (every package, no behavioral regression on G5-4 / earlier T4 paths). Next: m01 hardware run of iterate-m01-replicated-write.sh verify_restart_catchup expecting #1/#2/#3 regression GREEN + #4 GREEN within deadline. After hardware GREEN, sw drafts §close. |
||
|
|
028ea64fc6 |
T4d-4 part B: engine-driven recovery wiring + rebuild-on-exhaustion + G5-DECISION-001 serializability
Per T4d mini-plan v0.5 §2.4 (architect round-47 expanded scope).
Closes 3 of 4 HARD CLOSE GATE items (#1 #2 #4); #3 full L2 matrix
+ QA #8 LastSentMonotonic full form deferred to part C with
substrate fault injection.
ROUND-47 ENGINE CHANGE — catchup-exhaustion escalates to rebuild:
- core/engine/apply.go applySessionFailed: catch-up budget exhaustion
now DIRECTLY emits StartRebuild (Decision flips to Rebuild,
StartRebuild command emitted with current Recovery.H as TargetLSN).
Pre-round-47: cleared Decision + emitted PublishDegraded; rebuild
only fired if a fresh probe arrived. Round-47: rebuild path becomes
engine-driven end-to-end without probe dependency.
- Rebuild has MaxRetries=0 per DefaultRuntimePolicyFor; rebuild
failure terminates (Decision cleared, PublishDegraded emitted).
Pinned by INV-REPL-CATCHUP-EXHAUSTION-ESCALATES-TO-REBUILD +
INV-REPL-REBUILD-FAILURE-TERMINAL.
- Existing TestSessionFailed_NonRecycled_RetriesUntilBudget updated
for round-47 escalation (asserts StartRebuild emit on attempt #4
+ Decision=Rebuild + DecisionReason="catchup_budget_exhausted").
WITHENGINEDRIVENRECOVERY() REAL — round-47 HARD GATE #1 + #2:
- core/replication/component/cluster.go: WithEngineDrivenRecovery()
now installs ONE VolumeReplicaAdapter per replica at Start.
Adapters are wired to executors via the constructor's
executor-callback registration (existing adapter ctor behavior).
- New PrimaryNode.adapters field + Cluster.Adapter(idx) accessor.
- New Cluster.DriveAssignment / Cluster.DriveProbeResult helpers
for test scenarios driving engine state through real adapter.
- Stub warning text + log message removed; engine-driven recovery
is now the real path when opted in.
G5-DECISION-001 SERIALIZABILITY — round-47 obligation:
- core/engine/g5_decision_001_serializability_test.go pins that
engine.ReplicaState (+ all nested truth structs) round-trips
through encoding/json cleanly. T4d-4 obligation: keep struct
serializable so G5 can choose Path A (persist recovery state
across primary restart) without structural rewrite.
- 2 tests: full-state round-trip + zero-value round-trip
- T4d-4 does NOT implement persistence — just maintains the
serializability property.
NEW TESTS (9):
core/engine/recovery_test.go (2 new + 1 updated):
- TestT4d4_CatchupExhaustionEscalatesToRebuild (round-47 #4 pin)
- TestT4d4_RebuildExhaustionIsTerminal (rebuild MaxRetries=0
termination)
- (existing) TestSessionFailed_NonRecycled_RetriesUntilBudget
updated for round-47 escalation semantic
core/engine/g5_decision_001_serializability_test.go (2):
- TestG5Decision001_ReplicaState_RoundTripJSON
- TestG5Decision001_ReplicaState_ZeroValueStable
core/replication/component/t4d4_engine_driven_test.go (5):
- TestT4d4_WithEngineDrivenRecovery_IsReal (HARD GATE #1)
- TestT4d4_AdapterWithoutWithEngineDrivenRecovery_IsNil (fence)
- TestT4d4_DriveAssignment_EngineEmitsProbeReplica
- TestT4d4_RoundTrip_AssignmentToProbeToCatchUp_EngineDriven
- TestT4d4_CatchupBudgetExhausted_EngineEmitsRebuild
Existing test updated for round-47:
- core/adapter/adapter_test.go
TestPreparedNeverStarted_FailsClosedOnImmediateStartError:
set rebuildErr matching catchUpErr; assert chain ends at
Degraded after retry+escalate+rebuild-terminal (was: assert
PhaseFailed after first attempt — round-47 makes that
intermediate not terminal).
NOT in part B (deferred to part C):
- HARD GATE #3: Full L2 matrix incl QA #8 LastSentMonotonic full form
— needs substrate fault injection wrapping engine-driven flow
- Windows TempDir cleanup race + sessionID coordination + test rename
Forward-carry status:
- Round-47 engine change preserves all prior round-43/44/46
invariants (lane purity, stale-skip, no per-LBA regression)
- T4d-1 typed-kind contract: forward-carries
- T4d-2 lane-pure apply gate: forward-carries
- T4d-3 R+1 threading: forward-carries
- T4d-4 part A (RecoveryMode + Stop lifecycle): forward-carries
- 22 packages green; 0 failures
Refs: T4d mini-plan v0.5 §2.4 (architect-ratified expanded scope);
round-47 architect ruling (catchup-exhaustion escalates to rebuild +
G5-DECISION-001); G-1 sign
|
||
|
|
3351a66ff2 |
T4d-3: R+1 threading + import-discipline fence (G-1 v0.2 PORT items 1-5; CARRY-T4D-LANE-CONTEXT-001 Option B)
Per T4d mini-plan v0.3 §2.3 + G-1 v0.2 (architect+QA-signed
2026-04-25). Refs G-1 sign: pending hash (G-1 doc lives in
seaweedfs sw-block/design/v3-phase-15-t4d-3-g1-v2-read.md v0.2);
QA approval round-46 cleared T4d-3 start.
PORT items landed (G-1 v0.2 §3, items 1-5):
Item 1 — start boundary: engine.StartCatchUp gains FromLSN field;
engine emits Recovery.R + 1 (decide path + retry-loop re-emit).
Pinned by INV-REPL-CATCHUP-FROMLSN-IS-REPLICA-FLUSHED-PLUS-1 +
INV-REPL-CATCHUP-FROMLSN-FROM-ENGINE-STATE-NOT-PROBE.
Item 2 — per-call deadline: preserved unchanged (T4c-2 INV-REPL-
CATCHUP-DEADLINE-PER-CALL-SCOPE forward-carries).
Item 3 — last-sent monotonic + completion: preserved unchanged
(T4c-2 invariants forward-carry; barrier ack remains completion
truth).
Item 4 — retry budget: engine retry-loop reuses ORIGINAL Recovery.R
+ 1 on re-emit per G-1 §6.2 architect Option A (no inter-attempt
re-probe; apply gate handles over-ship). Pinned by
TestT4d3_CatchUp_RetryReusesOriginalRPlus1.
Item 5 — retention-miss escalation: T4d-1 typed-kind contract
already in place; engine branches on FailureKind. Forward-carry.
V3-NATIVE items (no V2 source per G-1 v0.2 §4):
- Engine-owned retry loop (Q1) — already in place at T4c-3
- Unified recovery command model — T4c-pre-B
- Lane-aware apply gate integration — T4d-2
- BarrierResponse.AchievedLSN as completion truth — T4c-2
- Package-boundary discipline — pinned by new
TestT4d3_Catchup_TransportNeverImportsSubstrateInternals
(parses transport .go files via go/parser; fails if any
substrate-internal package import surfaces)
Signature ripple (10 files):
- engine.StartCatchUp{FromLSN uint64} added (no removals)
- adapter.CommandExecutor.StartCatchUp interface +1 param
- transport.BlockExecutor.StartCatchUp + doCatchUp +1 param
- 4 test executor stubs (mockExecutor, closureExecutor,
policyClosureExecutor, restartExecutor) + production
HealthyPathExecutor + noopExecutor + ops nopExecutor
- transport.recovery_session.go bridge passes fromLSN=1 (legacy
StartRecoverySession path; forward-carry to T4e for explicit
fromLSN field on StartRecovery)
- adapter.adapter_test.go bridge passes fromLSN=1
- 5 transport test call sites + 3 component integration test sites
- component framework CatchUpReplica helper passes fromLSN=1
(transitional shim; tests needing explicit R+1 use direct
executor invocation per G-1 §7)
NEW TESTS (G-1 §7 test parity matrix):
- core/engine/t4d3_rplus1_test.go (3 tests):
- TestT4d3_CatchUp_Engine_RPlus1_FromOwnState_NotProbeDirectly
(pins INV-REPL-CATCHUP-FROMLSN-FROM-ENGINE-STATE-NOT-PROBE)
- TestT4d3_CatchUp_RetryReusesOriginalRPlus1 (G-1 §6.2 Option A)
- TestT4d3_StartCatchUpStruct_HasFromLSNField (compile fence)
- core/transport/t4d3_rplus1_test.go (3 tests):
- TestT4d3_CatchUp_ScansFromReplicaR_NotGenesis (substrate
receives caller-supplied fromLSN; sender does NOT add +1)
- TestT4d3_CatchUp_StartCatchUpSignature_FromLSNRequired
- TestT4d3_CatchUp_NonEmptyReplica_BlockStoreOverShipsExpected
(round-46 ADDITION 2 substrate-bound naming — opposing-
assertion regression fence per §9 caveat)
- core/transport/import_discipline_test.go (1 test):
- TestT4d3_Catchup_TransportNeverImportsSubstrateInternals
(Q3 INV-REPL-TRANSPORT-STORAGE-CONTRACT-ONLY; parses transport
sources, fails on substrate-internal imports)
- core/replication/component/t4d3_scenarios_test.go (4 tests):
- TestT4d3_CatchUp_NonEmptyReplica_ShortGap_BandwidthBounded_
Walstore (substrate-bound bandwidth observation)
- TestT4d3_CatchUp_NonEmptyReplica_ShortGap_BandwidthBounded_
Smartwal (mirror)
- TestT4d3_RetryAfterReplicaAdvanced_OverScansHandledByApplyGate
(round-46 ADDITION 1 — pins §6.2 Option A safety claim:
over-scan + apply gate per-LBA stale-skip; assertions cover
byte-exact convergence + no per-LBA regression + coverage
union completeness)
- TestT4d3_RecoveryTargetLSN1_KnownGap (CARRY-T4D-LANE-CONTEXT-
001 Option B close — SKIPPED with explicit forward-binding
for the T4e or beyond fix; gate API itself is already
lane-pure, only caller's signal source needs upgrading)
CARRY-T4D-LANE-CONTEXT-001 close (round-46 architect HARD CLOSE
CONDITION): Option B chosen (NOT Option A) because true handler/
session-context lane signal is a much larger refactor (separate
listener ports OR per-connection lane tag via session-registration
handshake OR new MessageType — all wire/transport-architectural
changes). Architect listed Option B as acceptable. The skip-marked
test documents the H=1 known gap; godoc cites
CARRY-T4D-LANE-CONTEXT-001 explicitly for catalogue cross-reference.
NOT in T4d-3 scope (deferred):
- Engine-driven recovery wiring through ReplicationVolume↔adapter
(G-1 §4 Item A integration scope) — engine retry-loop is
unit-tested; full ReplicationVolume↔adapter binding is a
follow-up task. Rationale: this commit is large enough; landing
the R+1 threading + import discipline as one piece + adding
end-to-end engine-driven recovery wiring as another keeps
reviewability tractable. T4d-4 owns the lifecycle integration;
the engine-driven-recovery wiring fits naturally there OR as a
T4d-3-followup.
Forward-carry status:
- T4d-1 typed-kind contract: forward-carries unchanged
- T4d-2 lane-pure apply gate: forward-carries; round-46 lane
discipline still honored (gate doesn't sniff lineage)
- All round-43/44 stale-skip invariants: forward-carry green
- T4c-2 6 catch-up invariants: forward-carry under R+1 threading
(verified via T4c muscle tests still passing)
- 22 packages green; 0 failures
Tests added: 11 (per G-1 §7 matrix).
Refs: T4d mini-plan v0.3 §2.3 (architect-ratified); G-1 v0.2
QA-signed (CARRY-T4D-LANE-CONTEXT-001 close condition Option B);
round-46 architect ruling (lane-pure gate); kickoff §9 (Q1/Q2/Q3).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|
|
1a6c508226 |
T4d-2: replica recovery apply gate (lane-aware, 2-map split, Option C hybrid)
Per T4d mini-plan v0.3 §2.2 (architect-ratified). Round-43 lock + round-44 refinement: lane-aware per-LBA stale-skip with coverage- advance on skip; live-lane stale fail-loud; 2-map split. The correctness boundary for "no per-LBA data regression." NEW core/replication/apply_gate.go: - ReplicaApplyGate component + per-session state (applyGateSession with appliedLSN + liveTouched + recoveryCovered maps) - Apply(lineage, lba, data, lsn) routes by lane (Q2: lane derived from lineage.TargetLSN signal — > liveShipTargetLSN = recovery; == liveShipTargetLSN = live; no wire byte added) - applyRecovery: if lsn <= appliedLSN[lba] → skip data + advance recoveryCovered (round-44 #1); else apply + update both maps - applyLive: if lsn <= appliedLSN[lba] → return error (round-44 #2 INV-REPL-LIVE-LANE-STALE-FAILS-LOUD); else apply + update appliedLSN + liveTouched ONLY (NOT recoveryCovered) - initSessionLocked: queries store.AppliedLSNs() at session init (Option C hybrid per kickoff §2.5 #1); falls back to empty map on ErrAppliedLSNsNotTracked (BlockStore) with INFO log - SessionState / SessionRecoveryCoverage / SessionAppliedLSN — read-only inspection helpers for tests + ops Pinned invariants (T4d mini-plan §4 #6): - INV-REPL-NO-PER-LBA-DATA-REGRESSION (goal-level) - INV-REPL-RECOVERY-STALE-ENTRY-SKIP-PER-LBA (mechanism) - INV-REPL-RECOVERY-COVERAGE-ADVANCES-ON-SKIP (round-44) - INV-REPL-LIVE-LANE-STALE-FAILS-LOUD (round-44) - INV-REPL-RECOVERY-COVERAGE-RESTART-SAFE (Option C makes pinnable) - INV-REPL-LANE-DERIVED-FROM-HANDLER-CONTEXT (Q2) Transport wiring (core/transport/replica.go): - New transport.ApplyHook interface (Apply method); duck-typed adapter so replication.ReplicaApplyGate satisfies it without an import cycle (replication already imports transport) - New NewReplicaListenerWithApplyHook constructor; existing NewReplicaListener delegates with hook=nil (preserves T4a/T4b/T4c behavior — direct apply when no gate installed) - MsgShipEntry handler: if hook installed, delegate; live-lane fail-loud error → log + drop conn (round-44 #2) Component framework wiring (core/replication/component/cluster.go): - WithApplyGate() builder option installs the gate on every replica's listener - ReplicaNode gains ApplyGate field - Cluster.ApplyGate(idx) accessor for tests asserting per-session gate state Tests (16 new): - core/replication/apply_gate_test.go (13 unit tests on the gate): lane discriminator (5 cases), recovery stale-skip data + coverage advance, fresh apply advances both, live stale fail-loud, live stale doesn't advance recoveryCovered, lane independence across distinct sessions, Option C BlockStore fallback, Option C substrate-seed honored, restart-mid-recovery (BlockStore documented limitation), restart-safe via substrate seed (full Option C path), substrate apply error propagates, CloseSession releases state - core/replication/component/apply_gate_scenarios_test.go (4 integration scenarios): RecoveryStaleSkip_CoverageStillAdvances (round-44 #1), LiveLaneStaleEntry_FailsLoud (round-44 #2), LaneDerivedFromTargetLSN (Q2), OptionCHybrid_WalstoreSeed (substrate-seed integration) - core/replication/component/stale_entry_adversarial_test.go: TestComponent_Adversarial_StaleEntryDoesNotRegress UN-SKIPPED (round-46) — now uses cluster.WithApplyGate(); pin INV-REPL-RECOVERY-STALE-ENTRY-SKIP-PER-LBA at integration scope Forward-carry status (preserved): - All T4a/T4b/T4c invariants forward-carry green - T4d-1 typed-kind contract unaffected (gate orthogonal to failure classification) - T4c apply path unchanged when WithApplyGate not requested NOT in T4d-2 scope (deferred per mini-plan §1.2): - Engine-driven full-flow integration (T4d-3 wires ReplicationVolume↔adapter; T4d-2's WithEngineDrivenRecovery hook remains stub) - Substrate-side stale-skip in walstore/smartwal ApplyEntry (T4d-1 caveat: where practical; gate is the authoritative correctness boundary) 22 packages green; 16 new tests; 1 previously-skipped test now PASSING. Refs: T4d mini-plan v0.3 §2.2 (architect-ratified 2026-04-25); kickoff §9 Q1/Q2/Q3; round-43/44 architect text; round-46 QA approval clearing T4d-2 start. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
370a0e8de9 |
component framework: close 3 of 4 QA-flagged gaps; stub 4th for T4d
QA round-39 Stage 1 flagged 4 framework gaps blocking deferred scenarios. This commit closes 3 of 4 with primitives + demos; 4th (engine-driven recovery) is API-stubbed pending T4d wiring. Closed gaps: (1) WithPrimaryStorageWrap(fn) builder option - Cluster.WithPrimaryStorageWrap installs a substrate transform before BlockExecutors bind; wraps may override any LogicalStorage method. Three pre-built wraps in faults.go: - NewRecycledScanWrap() — always returns ErrWALRecycled - NewSeverDuringScanWrap(N, err) — emits N entries then severs - NewObservedScanWrap(*atomic.Int32) — counts emit observations - Demos: TestComponent_RecycledScanWrap_EscalatesToRebuild, TestComponent_SeverDuringScan_PartialProgress, TestComponent_ObservedScanWrap_CountsEmits (2) Live-ship primitive driving ReplicationVolume.OnLocalWrite - Cluster.WithLiveShip() builder option spins up StorageBackend + ReplicationVolume; configured replicas auto-registered as peers - PrimaryWriteViaBackend(lba, data) writes through the production data-plane entry → WriteObserver hook → fan-out to replicas - PrimaryWriteViaBackendN(n) batch helper - Demo: TestComponent_LiveShip_PrimaryWriteViaBackend_FansOut (4) Mid-stream drop helper SeverDuringScan - Implemented as NewSeverDuringScanWrap above; counts entries via atomic.Int32 inside the substrate wrap and returns the configured sever error after N successful emits - Robust to substrates with fewer than N entries (no-op rather than fail-closed, so scenarios are emit-count-tolerant) API-stubbed for T4d: (3) WithEngineDrivenRecovery() — option records intent, emits a one-shot t.Logf warning at Start, runs as direct-executor mode. Forward-carry: when T4d wires ReplicationVolume↔adapter, this option swaps the adapter-aware constructor in. Demo: TestComponent_EngineDrivenRecovery_StubWarning pins the API shape so scenarios authored today won't need to change when behavior lands. Known limitation documented in faults.go: substrate-extension methods (e.g. walstore.CheckpointLSN) are MASKED by the wrap because Go embedding only exposes interface methods. The catch-up sender's recovery_mode label probe duck-types CheckpointLSN; under a wrap, it always sees state_convergence regardless of underlying substrate. Forward-carry: refactor mode-label detection behind a substrate-reported RecoveryMode() method that wraps can forward. 5 new demos = 9 matrix rows (smartwal+walstore where applicable). go test ./... -count=1 → 22 packages green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
6a3b84cd29 |
component test framework: cluster harness + 7 demo scenarios
QA-requested (round-39): build a component test framework so QA can author T4c-follow-up + T4d scenarios in ~20-30 lines without re-deriving cluster setup boilerplate. Lands `core/replication/component/` package with: - Cluster builder: NewCluster(t, factory).WithReplicas(n).Start() → fully wired primary + N replicas over real localhost TCP using production code paths (BlockStore + ReplicaListener + BlockExecutor) - RunMatrix(t, scenario): runs the scenario across smartwal + walstore; both substrates gate per round-22 sign-bearing discipline - RunSubstrate(t, name, factory, scenario): single-substrate runner for substrate-specific pins - Write/sync primitives: PrimaryWrite, PrimaryWriteN, PrimarySync, ReplicaApply (for setting up pre-existing replica state) - Recovery primitives: CatchUpReplica, ProbeReplica - Fault injection: KillReplicaListener, SeverConnection - Convergence assertions: WaitForConverge, AssertReplicaConverged - Mode-label assertions: AssertSawRecoveryMode with ExpectAnyMode / ExpectWALReplay / ExpectStateConvergence constants - Log capture: tees log.Default writer into per-test buffer so mode- label assertions don't need stderr parsing - Mode-constant init-time pin: panics if ExpectWALReplay / ExpectStateConvergence drift from storage.RecoveryMode* values 7 demo scenarios in cluster_test.go double as smoke for the framework + copy-paste templates for QA: - TestComponent_HappyCatchUp — simplest scenario shape - TestComponent_GapExceedsRetention_Recycled — substrate fault wrap pattern (recycledScanStub demonstrates ScanLBAs override for ErrWALRecycled injection) - TestComponent_ProbeHappy — probe wire smoke across substrates - TestComponent_TwoReplicas_BothConverge — multi-replica fan-out - TestComponent_PartialReplicaThenCatchUp — ReplicaApply for pre-existing partial state setup - TestComponent_RecoveryModeLabel_Walstore — per-substrate label pin (wal_replay) - TestComponent_RecoveryModeLabel_Smartwal — per-substrate label pin (state_convergence) - TestComponent_ModeConstantsStable — drift fence Authoring guide: sw-block/design/v3-phase-15-component-test-guide.md documents the API + common patterns + extension discipline. Aim: ~20-30 lines per new scenario. Forward-carry items (sw will add when needed): - WithPrimaryStorageWrap(wrap) option — substrate fault injection at the executor layer (today the wrap pattern only works at the storage layer; substrate-level executor-test integration needs the option) - WithEngineDrivenRecovery() option — when T4d lands the ReplicationVolume↔adapter wiring, the framework gains the engine- driven recovery flow as an opt-in mode go test ./... -count=1 → all 22 packages green (component is the new package). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |