mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
59bf6f06b52061ba7e76b4fbec25c8e0f80521c7
24
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7fab4770c2 |
replication: drop the per-write INFO line from the local write path (#204)
At RF=1 every local write logged 'replication: OnLocalWrite volume=... lba=... lsn=... peers=0'; under sustained writes one volume's log grew to 162 MB in 13 minutes and the useful lines were buried. The counters (Stats: WriteOps, WriteFanoutNanos) keep the per-write evidence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
273ca809d8 |
durable: a refused observer rebase never leaves I/O open; seed and install serialized
SetWriteObserver published the observer first and only logged a refused ship-LSN rebase, so the volume kept serving writes its observer would mis-order. Now: - SetWriteObserver rebases an LSN-ordering observer to the store's next LSN before installing it. If the rebase is refused, the observer is not installed and the error is returned. The backend also records the fault and refuses every I/O until an install succeeds, so a later attach that marks the volume operational cannot reopen it. blockvolume reports the error. - The frontier seed and its observer rebase run in one critical section with observer installs (observerMu). Whichever runs second sees the other's result; a seed landing between an install's rebase and its publication can no longer leave the observer on the old LSN. A refused rebase after the seed records the same fault. - RebaseShipLSN documents that it moves only the ordering cursor: entries already dispatched to peer queues carry lower LSNs and are untouched. The composition test checks the install error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d7d1718358 |
replication, durable: rebase the ship order after a restored host's frontier seed
A ReplicationVolume orders writes from the store's next LSN, captured when it is built. On a restored walstore-chunk host the frontier seed moves that LSN to HEAD.remote_lsn+1 later, during the deferred attach. The resequencer then waited forever for the LSNs below it, and writes and flushes hung. Whoever moves the next LSN now tells every component that cached it: - ReplicationVolume.RebaseShipLSN(lsn) moves the ship order forward. It is refused while any write is pending or in flight, never dropping one, and never moves backwards; an equal LSN is a no-op. - The provider calls it through the backend's observer right after SeedChunkFrontier, before the layer attaches and the volume serves I/O. - StorageBackend.SetWriteObserver rebases a newly installed observer to the store's next LSN, covering a seed that landed before the observer was installed (blockvolume installs it after SetReplicationVolume, while the attach is still deferred). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
87617aedad | fix: require recovery before peer queue reset | ||
|
|
45b21313b4 | replication: close executor lifecycle before store teardown | ||
|
|
99bcd363a0 | phase167: add ordered asynchronous replication | ||
|
|
8303e7235a | phase167: harden ordered write durability | ||
|
|
d84ca10bdd | phase167: establish concurrent write baseline | ||
|
|
1dde8647af | phase65: add runtime terminal evidence | ||
|
|
869e64f858 | phase64: add blockvolume runtime rebuild endpoint | ||
|
|
5c4f995c55 |
v0.2 alpha: Day-1 activation and first-volume loop (#48)
Package the Kubernetes alpha into a script-based Day-1 activation loop: activate the stack, create the first PVC-backed volume, verify writer/reader data, collect product-owned observation evidence, render a local read-only report, and clean up. Includes multi-node-safe activation defaults, first-volume example automation, read-only ops report output, README/quickstart/release note updates, and review-driven hardening for fail-fast configuration, promotion evidence, inventory fail-closed behavior, and test guards. Validated by Day-1 activation run 20260517-205252-04e9 and read-only report run 20260517-212358-bfba. Local targeted tests passed. |
||
|
|
dfa31007a1 |
testops: add beta hardening gates and storage readiness evidence
Adds the beta-hardening test and operations foundation for Seaweed Block, including runner-native protocol/beta gates, CSI lifecycle and durable restart coverage, iSCSI/NVMe protocol release gates, returned-replica evidence, read-only operations status reports, OS initiator compatibility gates, and fast iSCSI L2 durable restart/reconnect coverage. |
||
|
|
4a15e6271c |
docs(replication): drop internal phase/gate prefixes from peer + volume comments
Pass scope: package docs, exported func godocs, struct field docs, inline comments. Removes T4a/T4b/T4c/T4d / G5-5/G5-5C / G6 / 'architect' date-stamped historical pedigree from peer.go (50 hits) and volume.go (28 hits) while preserving: - state-machine transition tables - stable invariant IDs (INV-REPL-*, INV-G5-5C-PER-PEER-ADAPTER-*) - lock-ordering discipline - 'Called by / Owns / Borrows' lifecycle blocks No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
5c454d1716 | G9A: fail strict write ACK when peer is recovering | ||
|
|
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> |
||
|
|
ca04592639 |
G5-5C #7: per-peer adapter wiring (production fix for hardware-revealed gap)
Per architect ruling 2026-04-27 (Option B: absorb fix in G5-5C as Batch #7), this batch fixes the host wiring gap revealed by hardware run 3: ROOT CAUSE: cmd/blockvolume constructs ONE *VolumeReplicaAdapter for the host's own slot (Identity.ReplicaID = primary's-own-slot). G5-5C ProductionProbeFn forwarded peer probe results into that adapter. Engine apply.go:117-128 checkReplicaID correctly drops events targeted at peer (replicaID != Identity.ReplicaID) as wrong_replica. Result: probe success on wire, but no StartCatchUp ever dispatched. FIX: per-peer adapter, each tracking its peer's identity, each wired to dispatch engine commands to that peer's transport executor. NEW FILES: - core/host/volume/peer_command_executor.go (~140 LOC) PeerCommandExecutor adapts peer's transport.BlockExecutor to satisfy adapter.CommandExecutor. Most methods delegate verbatim (Probe, StartCatchUp, StartRebuild, StartRecoverySession, InvalidateSession, Fence). Two value-adds: 1. SetOnSessionStart/Close intercept inner callbacks to drive peer.SetState (Degraded → CatchingUp on start; CatchingUp → Healthy on Success). Without this, peer state stays Degraded after successful catch-up and probe loop keeps polling. 2. PublishHealthy/Degraded translate engine verdicts to peer.SetState/peer.Invalidate. Inner executor's Publish* are log-only; runtime peer state machine is what gates Ship + ProbeIfDegraded. - core/host/volume/peer_adapter_registry.go (~140 LOC) PeerAdapterRegistry maps ReplicaID → *VolumeReplicaAdapter. OnPeerAdded constructs PeerCommandExecutor + adapter, primes with AssignmentObserved for the peer's identity. OnPeerRemoved drops the adapter. AdapterFor lookups for the router probeFn. Self-replicaID guard refuses host-own-slot registration. Idempotent double-add. Lineage-bump produces fresh adapter. Close drops everything. UPDATED FILES: - core/replication/volume.go: ConfigurePeerLifecycleHook (onAdded, onRemoved). Hook fired from UpdateReplicaSet add/remove/lineage- bump teardown paths under v.mu. Configure-once contract; replays current peer set on configure (so registry catches up to peers added before hook). - core/host/volume/probe_loop_wiring.go: AdapterRouter signature type added. ProductionProbeFn now takes router instead of single adapter; routes per-peer; nil-router and missing-peer paths fail-closed. - cmd/blockvolume/main.go: construct PeerAdapterRegistry; wire ConfigurePeerLifecycleHook; pass registry.AdapterFor to ProductionProbeFn. Failure paths cleaned up the same way as prior wire steps. - core/host/volume/boundary_guard_test.go: PCDD-STUFFING-001 fence now allows TWO sites for adapter.AssignmentInfo composite literals: decodeAssignmentFact (master decode boundary) AND OnPeerAdded (per-peer engine identity priming, G5-5C Batch #7). Other sites still fail. - core/replication/component/g5_5c_restart_catchup_test.go: configureProbeLoopOnCluster now uses AdapterRouter signature (closure over c.primary.adapters[0]). NEW TESTS (15 total, all PASS): - peer_adapter_registry_test.go (7): RegisterAndPrimes, DropsAdapter, SelfReplicaIDRefused, DoubleAddIdempotent, LineageBumpTeardown, CloseDropsAll, NilSafe. - peer_command_executor_test.go (5): PublishHealthy → SetState, PublishDegraded → Invalidate, SessionStart → CatchingUp, SessionClose → Healthy, DelegatesProbe. - probe_loop_wiring_test.go (3 updated + 2 new): NilRouter_ReturnsErrAndDoesNotPanic, RouterReturnsNil_ReturnsErr, RouterPicksByReplicaID (new — pins per-peer routing contract). Test results: full ./... regression PASS at 17:58. No behavioral regression on G5-4 / earlier T4 paths. Component test #6 (restart-catch-up convergence) still PASSES via new router signature. NEW INV (replaces previously-deferred G5-5D INV): - INV-G5-5C-PER-PEER-ADAPTER-PER-PEER-ENGINE — production binary constructs *VolumeReplicaAdapter per (volume × admitted peer). Engine.checkReplicaID correctness preserved. Next: m01 hardware re-run #4. Expected GREEN within 30s deadline. |
||
|
|
602fc0d8ca |
G5-5C #4: engine boundary tests — dispatch / Case 1 reconnect / lineage stale-event drop / stale-ack guard
Architect Batch #4 review 2026-04-27 ruled the four §2 invariants (#4 / #11 / #12 / #13) belong at the engine layer, not core/replication/ — "single owner per invariant, don't double-assert in adapter and engine". Batch 3 already covered the runtime concerns (lifecycle, cooldown, lock ordering, peer-instance teardown); Batch #4 covers the truth-layer translations engine performs from probe results into recovery commands. Tests (5 tests, 9 subcases, 9/9 PASS): §2 #4 dispatch (catch-up vs rebuild) — TableDriven: - caught_up: R≥H → DecisionNone, no recovery cmd - gap_within_wal: R<H, R≥S → DecisionCatchUp + StartCatchUp - gap_exceeds_wal: R<S → DecisionRebuild + StartRebuild - rebuild_pinned: pin overrides catch-up → StartRebuild Mutual exclusion checked on each row (the OTHER cmd must NOT emit). No real retention/WAL logic dragged in; pure (R,S,H) input → cmd output table. §2 #11 reconnect Case 1 (identity unchanged): Admit at (epoch=1, EV=1) → catch-up running → session fails → fresh ProbeSucceeded at SAME (epoch=1, EV=1) → engine still in CatchUp at the same lineage. Identity.{Epoch,EndpointVersion} pinned unchanged. No StartRebuild emitted (no master re-emit needed for Case 1 — pinned by §1.F). §2 #12 lineage-bump during in-flight recovery: In-flight session 42 at epoch=1 → AssignmentObserved at epoch=2 resets Session/Recovery/Reachability via identityChanged path → late SessionClosedCompleted carrying old SessionID=42 must be DROPPED. Asserts: Recovery.R does NOT advance, Session.Phase does NOT promote to Completed, no PublishHealthy emit. Distinct from batch 3's volume-layer Case 2 test (peer-instance replacement); this asserts the engine truth layer drops stale-SessionID events. §2 #13 stale-ack guard (single owner = engine): StaleSessionAck_DoesNotPromoteHealth — SessionCompleted with AchievedLSN=50 < TargetLSN=100; Recovery.R advances to 50 but decide() leaves Decision in CatchUp (R<H), so Healthy gate refuses to flip. PublishHealthy NOT emitted. StaleSessionAck_FullAchievedDoesPromote — counterpart confirming AchievedLSN=H DOES promote (so prior test isn't trivially passing via "Healthy never promotes"). PublishHealthy emit confirmed. Also addresses architect's lock-order reminder #1 from Batch 3 review: volume.go ConfigureProbeLoop's peersFn comment now states explicitly "HARD RULE: code on the probe path MUST NOT re-enter v.mu while holding peer.mu" so any future "peer callback into volume" code is blocked at review. Full ./core/engine/ + ./core/replication/ regression: PASS. Per architect ruling, §2 #14 backoff progression is mathematically pinned at the peer layer (batch 2); no further integration-layer re-assertion needed. Next batch (G5-5C #5): cmd/blockvolume flag wiring + production probeFn that calls executor.Probe + adapter.OnProbeResult. |
||
|
|
40d6eff03b |
G5-5C #3: ReplicationVolume probe loop integration + 12 tests
Per architect ratification of mini-plan v0.5 §1.A binding (probe loop owned by ReplicationVolume lifecycle) + 4 guidance items 2026-04-27, this batch wires probe loop ownership into the volume and pins startup/teardown ordering, lineage-bump abandonment, and cooldown config push-down via tests. Architect guidance #1 (startup ordering): ConfigureProbeLoop sets the loop up; StartProbeLoop is a separate explicit step. Loop will not run before primary admit unless StartProbeLoop is called. Empty peer set is no-op (no probes fire), no panic. Architect guidance #2 (Stop ordering): Close() stops the probe loop FIRST (snapshot pointer under v.mu, release lock, Stop() with lock released) BEFORE re-acquiring v.mu for peer teardown. This avoids in-flight probeFn callbacks landing on closed peers and prevents deadlock between loop's peersFn (which needs v.mu) and Close's peer iteration (which holds v.mu). Pinned by TestVolume_Close_StopsLoopBeforePeerTeardown using a probeFn that blocks on ctx.Done(). Architect guidance #3 (cooldown propagation): UpdateReplicaSet calls peer.SetProbeCooldownConfig on every newly-created peer (whether first add or lineage-bump recreate) using the volume's saved ProbeLoopConfig.CooldownBase/Cap. ConfigureProbeLoop also pushes the config to peers that exist at configure-time. Pinned by TestVolume_UpdateReplicaSet_AppliesProbeCooldownToNewPeers and TestVolume_Configure_PushesCooldownToExistingPeers. Architect guidance #4 (lineage-bump abandonment, Case 2 §1.F): the new *ReplicaPeer instance has fresh cooldown state — failureCount=0, probeNextEligible zero, cooldownCfg from current volume config. Old peer's accumulated backoff cannot leak because old peer is a distinct (now-Closed) instance. A late OnProbeAttempt arriving on the old peer clears its in-flight flag idempotently and does NOT mutate the new peer (already pinned by batch 2's TestPeer_OnProbeAttempt_ClosedDoesNotUpdateCooldown; this batch adds the volume-integration counterpart). Pinned by TestVolume_LineageBump_NewPeerHasFreshCooldown and TestVolume_LineageBump_OldPeerProbeAbandoned. Volume.go additions: - 3 new fields: probeLoop *ProbeLoop, probeCfg ProbeLoopConfig, probeCfgSet bool (all under v.mu) - ConfigureProbeLoop(cfg, probeFn, now) — Configure-once contract, rejects double-configure, builds peersFn over v.peers under v.mu, wires DefaultProbeCooldownFn / DefaultProbeResultFn, pushes config to existing peers - StartProbeLoop() — rejects pre-Configure, rejects post-Close, delegates to ProbeLoop.Start (sync.Once) - probeLoopForTest() — package-private accessor - Close() rewritten to stop loop FIRST under careful lock release - UpdateReplicaSet pushes cooldown config onto each newly-created peer Tests (12/12 PASS): - ConfigureProbeLoop happy path (no peers, no probes, clean Close) - ConfigureProbeLoop rejects double-configure - StartProbeLoop without Configure is rejected - StartProbeLoop on closed volume is rejected - StopBeforeStart idempotent at volume layer - Close stops loop BEFORE peer teardown (with blocking probeFn) - UpdateReplicaSet pushes cooldown to new peers (post-Configure add) - ConfigureProbeLoop pushes cooldown to pre-existing peers - LineageBump_NewPeerHasFreshCooldown — old failureCount=3 + non-zero deadline; new peer has failureCount=0 + zero deadline + fresh cfg - LineageBump_OldPeerProbeAbandoned — claim on old peer; lineage bump tears down; new peer NOT in-flight; late OnProbeAttempt on old peer is idempotent and does not touch new peer - ProbeLoop_OnlyDegradedPeersDispatched — Healthy r1, Degraded r2; loop probes only r2 (volume-integration counterpart of batch 2's peer-level OnlyDegradedPasses) - ProbeFnError_AdvancesBackoff — end-to-end: probeFn err → DefaultProbeResultFn → peer.OnProbeAttempt(false) → failureCount monotonic ≥ 3 within deadline Full ./core/replication/ regression: PASS. Next batch (G5-5C #4): lineage-change / stale-ack / reconnect dual-axis tests + probe-driven dispatch branch verification. |
||
|
|
c6bace4e79 |
G5-5 upstream instrumentation: observer + OnLocalWrite + ship gates
QA round 8: ALL 6 ship/dial/barrier lines from |
||
|
|
e8aec8b954 |
T4d-4 part A: RecoveryMode interface method + Stop lifecycle (BUG-005 non-repeat) + framework wrap fix
Per T4d mini-plan v0.4 §2.4 expanded scope. Part A of three: smaller
substrate cleanups + lifecycle hardening land first; Path B fold
(ReplicationVolume↔adapter wiring + WithEngineDrivenRecovery real)
follows as part B; Windows cleanup + L2 matrix as part C.
T4c §I row 6 closure (RecoveryMode interface method):
- core/storage/logical_storage.go — add RecoveryMode() to
LogicalStorage interface (returns substrate's tier-1 sub-mode
per memo §5.1 / §13.0a)
- core/storage/store.go BlockStore.RecoveryMode() →
RecoveryModeStateConvergence (in-memory; ScanLBAs synthesizes)
- core/storage/walstore.go WALStore.RecoveryMode() →
RecoveryModeWALReplay (V2-faithful per-LSN)
- core/storage/smartwal/store.go Store.RecoveryMode() →
RecoveryModeStateConvergence (per-LBA dedup)
- core/transport/catchup_sender.go — replace duck-typed
CheckpointLSN probe with e.primaryStore.RecoveryMode() interface
call. Forwards cleanly through component framework wraps via
embedded LogicalStorage.
- core/replication/component/faults.go godoc — replace stale
"MASKED by wrap" limitation note with T4d-4 closure note;
AssertSawRecoveryMode now works correctly under wraps
T4d-4 lifecycle (BUG-005 non-repeat):
- core/replication/volume.go — Stop() canonical entry point added
(delegates to existing Close); semantic clarity over Close().
Both methods are equivalent in T4d-4; Stop() is the named entry
for "stop volume lifecycle activity" while Close() retained for
backward compatibility. Future expansions (drain pending I/O,
stop background goroutines) land in Stop().
- INV-REPL-LIFECYCLE-HANDLE-BORROWED-001 pinned by
TestReplicationVolume_Stop_DoesNotCloseBorrowedStore: store is
STILL usable after volume.Stop (substrate handle is borrowed,
never closed by us — BUG-005 discipline)
- TestReplicationVolume_Stop_Idempotent: second + later Stop calls
are no-ops returning nil
- TestReplicationVolume_Stop_TearsDownPeers: empty-set lifecycle pin
Tests added (5 new):
- TestReplicationVolume_Stop_Idempotent
- TestReplicationVolume_Stop_DoesNotCloseBorrowedStore
- TestReplicationVolume_Stop_TearsDownPeers
- TestStorageRecoveryMode_BlockStore_StateConvergence
- TestStorageRecoveryMode_Walstore_WALReplay
- TestStorageRecoveryMode_LogicalStorageInterface_HasMethod
(compile-time fence pinning RecoveryMode is on the interface,
not just on substrate impls)
NOT in part A (deferred to part B / C):
- ReplicationVolume↔adapter wiring (Path B fold, part B)
- WithEngineDrivenRecovery real binding (Path B fold, part B)
- Full L2 integration matrix (part C)
- Windows TempDir cleanup race (part C)
- Test rename per kickoff §5 (part C)
- sessionID coordination (T4c §I row 5; part C — minor)
22 packages green; 0 failures. Forward-carries: T4c-2 + T4d-1 +
T4d-2 + T4d-3 invariants all green; new RecoveryMode plumbing
preserves T4c-2 INV-REPL-RECOVERY-MODE-OBSERVABLE.
Refs: T4d mini-plan v0.4 §2.4 (architect-ratified expanded scope);
T4c §I row 6 (substrate RecoveryMode method); kickoff §2.1 (BUG-005
non-repeat lifecycle); G-1 sign
|
||
|
|
44f87603fd |
T4b-5: ReplicationVolume.Sync + WriteObserver.Sync seam
Wires DurabilityCoordinator (T4b-4) into the per-volume Sync path.
Host-side FLUSH / SYNCHRONIZE_CACHE now drives the full local fsync
+ per-peer barrier closure in parallel with mode-dependent arithmetic.
Changes:
core/frontend/durable/storage_adapter.go
WriteObserver interface extended: Sync(ctx, targetLSN) joins the
existing Observe(ctx, lba, lsn, data) method. Contract documented
inline — observer.Sync OWNS the full sync job (both local
fsync and peer barriers) when installed; StorageBackend delegates
rather than calling storage.Sync locally.
StorageBackend.Sync branches: observer==nil preserves the
pre-T4b behavior (local storage.Sync only); observer!=nil reads
walHead from LogicalStorage.Boundaries() and calls observer.Sync
with that as targetLSN. The observer (ReplicationVolume) then
invokes DurabilityCoordinator.SyncLocalAndReplicas which runs
local + barriers in parallel inside its own goroutines.
core/replication/volume.go
ReplicationVolume gains:
- coord field set to NewDurabilityCoordinator at construction
- durabilityMode field, SetDurabilityMode setter +
DurabilityMode accessor. Default BestEffort (zero value).
Per mini-plan §5, T4b does not support per-Sync-call mode
override — mode is a per-volume setting.
- Sync(ctx, targetLSN) method — snapshots peers under v.mu,
builds a localSync closure around v.store.Sync, delegates
to coord.SyncLocalAndReplicas, returns error verbatim.
Lock scope: v.mu held across the FULL Sync call. Matches the
T4a-4 round-15 Condition A discipline — concurrent Sync +
OnLocalWrite calls are serialized on v.mu, preserving the V2
shipMu semantics extended from ship-only into ship+barrier.
Accepted correctness-first trade-off: a slow peer barrier stalls
other writers on the same volume; async-queue optimization
(Option Z) is deferred post-T4.
Tests (2 required per mini-plan §2 T4b-5):
- TestReplicationVolume_Sync_BestEffort_E2E — full end-to-end
smoke: StorageBackend.Write 10 LBAs → Observe → ship → replica
applies. StorageBackend.Sync → observer.Sync →
DurabilityCoordinator → local fsync + peer barrier in parallel.
Replica's R-boundary (durable frontier) must reach primary's
H (walHead) after Sync returns. Peer stays Healthy throughout.
- TestReplicationVolume_Sync_PreservesLSNOrderUnderConcurrency —
forward-carry fence for INV-REPL-LSN-ORDER-FANOUT-001 under
the new Sync code path. 40 goroutines, caller-side serialized
LSN allocation + OnLocalWrite, periodic Sync calls interleaved
every 4th iteration. LBA ordering is inverted from LSN order so
any reorder is byte-detectable. All 40 LBAs must settle to the
correct LSN marker at the replica.
Forward-carry verification: T4a-4's
TestReplicationVolume_OnLocalWrite_ConcurrentLSNs_OrderedAtReplica
continues to pass — the existing ordering invariant is not regressed
by the new Sync code path that shares v.mu.
Verification: full 21-package repo suite green including the
extended WriteObserver interface not breaking core/frontend/durable
tests. G-2 tri-line godoc on SetDurabilityMode, DurabilityMode
accessor, Sync method, extended WriteObserver.Sync contract. G-3
cumulative.
Fifth task in T4b batch. Next: T4b-6 L2 subprocess integration
matrix closes the batch.
|
||
|
|
420a5a1c4a |
T4a-6: L2 subprocess integration test — T4a batch close gate
Ships the end-to-end integration test that proves all five T4a
production commits (T4a-1..T4a-5) compose correctly through the
full frontend→storage→replication→transport→replica wire. This
is the T4a batch close gate per mini-plan §4.
In-scope addition flagged by QA round-20 review and confirmed by
sw (not a discovery-bridge trigger — mini-plan always implied this
wire): StorageBackend.Write did NOT invoke
ReplicationVolume.OnLocalWrite. The hook is added here via a
narrow WriteObserver interface seam so core/frontend/durable does
not import core/replication directly.
Changes:
core/frontend/durable/storage_adapter.go
New WriteObserver interface with Observe(ctx, lba, lsn, data)
method. Named Observe (not OnLocalWrite) to avoid a method-
name collision on ReplicationVolume which already has a
differently-typed OnLocalWrite(ctx, LocalWrite). New
SetWriteObserver(obs) installation seam; called only at setup
(not hot-swappable). writeBytes now takes ctx through and
invokes obs.Observe after each successful LogicalStorage.Write,
best-effort (error logged, does NOT fail the Write — matches
V2 fire-and-forget ShipAll).
Ordering: LSN-order fan-out is preserved because the observer
(ReplicationVolume) serializes its own fan-out under v.mu
(Option X, architect-signed at T4a-4 round-15).
core/replication/volume.go
New Observe(ctx, lba, lsn, data) method that wraps into
LocalWrite and delegates to OnLocalWrite. This lets
*ReplicationVolume satisfy durable.WriteObserver without
either package importing the other's public struct type.
core/replication/l2_integration_test.go (NEW, ~450 LOC)
Internal-package test (access to ReplicationVolume.peers +
ReplicaPeer internals needed for transport-kill simulation).
Matrix harness:
- smartwal_gating — sign-bearing row; t.Fatal on failure
- walstore_nongating — reported row; failures logged with
non-gating note per BUG-007 / T3 matrix discipline
Scenarios:
1. BasicEndToEnd_PrimaryWriteReachesReplicaByteExact —
100 LBAs written through StorageBackend.Write,
verified byte-exact on replica's LogicalStorage. Peer
stays Healthy throughout. Both matrix rows pass.
2. BestEffort_DisconnectThenReassign (QA-requested G5
pass-gate shape) — 30 LBAs shipped Healthy; transport
kill via peer.executor.InvalidateSession +
peer.Invalidate (simulates mid-stream conn severed);
30 more LBAs written best-effort (primary persists
locally, peer Degraded, OnLocalWrite returns nil);
fresh replica spun up on new addr; fake-master
UpdateReplicaSet with gen=2 rebuilds peer (INV-REPL-
PEER-REBUILD-ON-AUTHORITY-CHANGE); 10 LBAs shipped
against fresh replica byte-exact.
Pass-gate fence: asserts the second-batch LBAs do
NOT appear on the fresh replica — catch-up is T4c
territory. Catches scope leak if a future refactor
quietly pulls catch-up into T4a.
Cleanup discipline (learned from T4a-4 test hang):
- replica cleanups registered BEFORE primary so LIFO
ordering closes primary's peer sessions first (no
listener.Stop() wedged on open client conns).
- DisconnectThenReassign creates a second replica after
primary, so it explicitly calls primary.repVol.Close()
at scenario end to unblock the non-LIFO cleanup chain.
Verification: full 20-package repo suite green (all pre-existing
tests pass after WriteObserver addition — backward compat
preserved via optional observer pointer). T4a-6 matrix: 4 test
rows all pass (2 scenarios × 2 backends). No -race on Windows
(CGO_ENABLED=1 requirement documented in MEMORY.md).
T4a batch close now mechanically satisfied; awaiting QA sign +
T-end three-sign per §8C.2 cadence.
|
||
|
|
db3be2e58c |
T4a-5: wire Host authority-callback to ReplicationVolume (P-refined)
Completes the T4a-5.0 §8C.3 Discovery Bridge resolution (Option
P-refined, landed per architect + QA round-19). Extends the
AssignmentFact wire with master-minted peer set + monotonic
generation, adds a separate host-only decode path that does NOT
touch AssignmentInfo (preserves the TestNoOtherAssignment
InfoConstruction AST fence), and wires Host.streamOnce to drive
ReplicationVolume.UpdateReplicaSet after every self-replica
AssignmentFact.
Guardrails (all four from round-19) honored:
1. decodeAssignmentFact unchanged; AST fence stays green.
2. decodeReplicaTargets is SEPARATE and produces replication.
ReplicaTarget + generation, never AssignmentInfo. Adapter +
engine packages: zero changes.
3. Peer set is master-minted only. Host does NOT accumulate or
derive from other-replica facts (option R rejected).
4. peer_set_generation mandatory on the wire; monotonic guard in
ReplicationVolume.UpdateReplicaSet.
Changes:
core/rpc/proto/control.proto
NEW message ReplicaDescriptor{replica_id, epoch, endpoint_
version, data_addr, ctrl_addr}. AssignmentFact gains
`repeated ReplicaDescriptor peers = 7` (excludes self) and
`uint64 peer_set_generation = 8` (monotonic, master-minted).
core/rpc/control/control.pb.go + control_grpc.pb.go
Regenerated via scripts/genproto.sh.
core/host/master/services.go
SubscribeAssignments fills fact.Peers via new collectPeers
helper (reads Publisher.LastPublished for each non-self slot
in the volume's accepted topology). Generation derived as
`(info.Epoch << 32) | info.EndpointVersion` — monotonic
because publisher's lex-dedupe upstream guarantees strictly-
increasing (Epoch, EV) pairs and Epoch/EV are durable authority
facts (survives master restart).
core/host/volume/subscribe.go
NEW decodeReplicaTargets(fact) ([]replication.ReplicaTarget,
uint64) — strict field-copy, same discipline as decode
AssignmentFact. Produces a different output type so the
AST fence TestNoOtherAssignmentInfoConstruction continues to
pass.
core/host/volume/host.go
Config gains `ReplicationVolume *replication.ReplicationVolume`
(nil = T0/observer-only; non-nil = T4a-5 production wire).
streamOnce self-replica branch calls UpdateReplicaSet(gen,
targets) AFTER adapter.OnAssignment. Non-blocking log on
error (best-effort; failure does not stop the assignment
stream).
core/replication/volume.go
UpdateReplicaSet signature break (QA option (a), no shim):
Before: UpdateReplicaSet(targets []ReplicaTarget) error
After: UpdateReplicaSet(generation uint64, targets []ReplicaTarget) error
Three-way generation rule (T4a-5.0 §9.4, QA corrected sw's
original MaxUint64 sentinel which would have one-way-poisoned
the monotonic guard):
- gen == 0: unversioned apply; peer map mutated;
lastAppliedGeneration NOT advanced. Test/fake-master only.
- gen > 0 && gen > lastApplied: apply + advance.
- gen > 0 && gen <= lastApplied: stale; peer map NOT mutated;
replayedGens counter increments; debug log emits peer-ID-
set delta (Q2 binding — IDs only, not full target structs).
Returns nil (idempotent replay is success).
Empty peer set (N → 0) flows through the same teardown path as
any N → M-1 removal. No special branch (Q3 binding).
New state: lastAppliedGeneration uint64 (mu-guarded);
replayedGens atomic.Uint64 (stats counter, private; public
Stats() deferred to T4-end observability pass).
New helpers (internal): peerIDSet, targetIDSet,
stringSetEqual, formatIDSet (deterministic brace-form
rendering of peer-ID sets for log diffs).
core/replication/volume_test.go
All 8 existing tests migrated to new signature with gen=0
(unversioned apply preserves previous functional semantics).
3 new tests (Q1/Q2/Q3 pins):
9. UpdateReplicaSet_Generation_MonotonicGuard — advance
through gens 1, 2, 3; stale replays at gen=2 and gen=3
(equal is stale); verify replayedGens counter; forward
progress at gen=4 works. Exercises Q2 differing-peers
path via the gen=2 replay with original r1+r2 set.
10. UpdateReplicaSet_GenerationZero_DoesNotAdvanceGuard —
gen=5 applied, gen=0 applied (peers mutated, last
Applied stays at 5), gen=3 rejected as stale. Pins the
correctness of the gen=0 rule vs. the original
MaxUint64 sentinel which would have failed this test.
11. UpdateReplicaSet_EmptyPeerSet_AppliesWithTeardown — Q3
binding three assertions: PeerCount=0 after empty
apply, all former peers' executor sessions invalidated,
next OnLocalWrite succeeds as zero-fanout no-op.
Verification: full 20-package repo suite green (core/host: 124s
including supersede_integration_test; core/host/volume: 31ms
confirming AST fence TestNoOtherAssignmentInfoConstruction still
passes; core/replication: all 17 tests green). G-2 tri-line godoc
on every new public surface.
Closes T4a-5.0 §8C.3 Discovery Bridge. Next: T4a-6 L2 subprocess
integration test.
|
||
|
|
3597bc40ca |
T4a-4: ReplicationVolume MVP (Option X LSN-order fan-out)
Introduces ReplicationVolume — the per-volume fan-out owner that
tracks the authoritative replica set and serializes Ship fan-out so
the V2 BlockVol.shipMu LSN-order invariant survives the V3 layer
split.
Architect-approved Option X (G-1 pre-code review,
v3-phase-15-t4a-4-g1-v2-read.md): v.mu.Lock() held across the
entire per-peer fan-out loop (Condition A), not just map snapshot
or "prepare then unlock then ship." The mutex is plain sync.Mutex
(no reader-only API worth preserving RWMutex for).
Contract wording (architect-revised, explicit):
ReplicationVolume.OnLocalWrite serializes fan-out in LSN order
for a given volume. Caller order is NOT trusted as the
correctness mechanism.
System invariant: INV-REPL-LSN-ORDER-FANOUT-001. V2 BlockVol.shipMu
atomically composed "allocate LSN + append WAL + Ship" under one
mutex. V3 splits the three concerns across engine / LogicalStorage /
ReplicationVolume; the LSN-order property is preserved end-to-end
when (a) Backend.Write invokes LogicalStorage.Write + OnLocalWrite
under the caller's own atomicity (natural shape — same goroutine)
and (b) OnLocalWrite's mutex serializes fan-out. Test
TestReplicationVolume_OnLocalWrite_ConcurrentLSNs_OrderedAtReplica
is the adversarial pin: N concurrent callers, caller-side lock
mimics Backend.Write, LBAs interleaved with LSN ordering so any
reorder is byte-detectable at the replica.
Accepted T4a trade-off (mini-plan change log): correctness-first
serialized design. Per-volume fan-out holds v.mu during each
peer's ShipEntry, so a slow peer (lazy dial, 3s write deadline,
degraded state) stalls the writer path. Async queue (Option Z) is
deferred optimization, not forgotten design debt — revisit only
after INV-REPL-LSN-ORDER-FANOUT-001 is proven in production.
Surface (~200 LOC production + 430 LOC tests):
- LocalWrite: {LBA, Data, LSN} — the layer-cross carrier
- ReplicationVolume: peers map + borrowed store + serialization mu
- NewReplicationVolume(volumeID, store): borrow store, never close
- UpdateReplicaSet(targets): add/remove/recreate-on-lineage-bump
under v.mu. Lineage bump = tear-down + recreate (T4a MVP; T4c
may add in-place lineage update)
- OnLocalWrite(ctx, w): LSN-order-serialized fan-out; per-peer
error is best-effort (logged + peer already marked Degraded by
ReplicaPeer.ShipEntry's forward-carry CARRY-1); does NOT fail
the OnLocalWrite call
- Close(): idempotent; releases all peers' sessions; does NOT
close the borrowed store (BUG-005 discipline)
- PeerCount() / newExec field: test seam for executor observation
BlockExecutor gains one test-grade accessor:
- HasSession(id): diagnostic for Opt-3 executor-teardown fence.
Used by TestReplicationVolume_UpdateReplicaSet_RemovePeer_
ExecutorTornDown to assert session removal after peer.Close.
Tri-line godoc contract; not intended for production flow.
Tests (8, all green):
1. UpdateReplicaSet_AddPeer — empty → 1 peer
2. UpdateReplicaSet_RemovePeer_ExecutorTornDown — Opt-3 three-
assertion fence (Close-called, session-removed, re-add-works-
and-ships-byte-exact)
3. UpdateReplicaSet_LineageBump_RecreatesPeer — same ReplicaID
new Epoch → new sessionID, new lineage
4. OnLocalWrite_SinglePeer_BestEffort — 20 LBAs byte-exact,
peer stays Healthy
5. OnLocalWrite_PeerErrorDoesNotFailCaller — dead-addr peer,
OnLocalWrite returns nil, peer Degraded
6. OnLocalWrite_ConcurrentLSNs_OrderedAtReplica — INV-REPL-LSN-
ORDER-FANOUT-001 adversarial pin (40 concurrent goroutines,
LBA/LSN interleaved, replica state byte-detectable)
7. Constructor_DoesNotOwnStore — BUG-005 regression fence; store
usable post-ReplicationVolume.Close
8. OnLocalWrite_Closed_Errors — post-Close call returns error,
no panic
Full core/transport + core/replication + core/adapter suites green.
G-2 three-line godoc contracts on every public symbol (New, Update,
OnLocalWrite, Close, PeerCount) + HasSession on executor. G-3
preserved.
|