mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
40d6eff03b5d26ccefed9c37c54cbc8d91b14295
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.
Languages
Go
84.6%
Rust
7.8%
Shell
2.7%
templ
1.6%
Java
1%
Other
2%