mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
volume, master: watchdog disarm and incarnation re-arm controls
claude05 accepted the disarm rule (21:24Z): after a fresh ready fact clears it, the watchdog stays disarmed until the next primary epoch or a new process incarnation. Tests: - ready, then not ready an hour later on the same incarnation (and the same assignment replayed): no recovery_timeout; - a restarted process (new incarnation, same primary epoch) is re-armed and reports recovery_timeout past the timeout, while the old process stays disarmed; - master: a running primary that degrades on the same incarnation (no unhealthy reason) follows the normal failover rules to the qualified peer, and nothing is listed as unhealthy. Doc only otherwise: the watchdog comment names the incarnation re-arm. Refs #128 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
81575168cc
commit
845bdc0a63
3 files changed
+71
-2
No files matched your search
@@ -142,3 +142,24 @@ func TestRecoveryWatchdog_MasterUnhealthyFailsOverToQualifiedPeer(t *testing.T)
|
||||
t.Fatalf("unhealthy primary with a qualified peer: line=%+v want r2@2", line)
|
||||
}
|
||||
}
|
||||
|
||||
// A running primary that was ready and later reports not ready on the
|
||||
// same incarnation (no unhealthy reason) follows the normal failover
|
||||
// rules: no boot grace for that incarnation, so it fails over to the
|
||||
// qualified peer, and nothing is listed as unhealthy (claude05, 21:24Z).
|
||||
func TestRecoveryWatchdog_MasterLaterDegradationFollowsNormalRules(t *testing.T) {
|
||||
h, svc := watchdogMaster(t)
|
||||
defer closeTestMaster(t, h)
|
||||
h.SetPromotionEvidenceProvider(&switchProbe{}) // r1 not ready, r2 ready with evidence
|
||||
|
||||
reportRF3(t, svc, wireSlot{"r1-a", false, ""}, wireSlot{"r2-a", true, ""}, wireSlot{"r3-a", false, ""})
|
||||
if _, err := h.RunLifecycleProductTick(); err != nil {
|
||||
t.Fatalf("product tick: %v", err)
|
||||
}
|
||||
if line := waitAuthorityReplica(t, h.Publisher(), "vol-rf3", "r2"); line.Epoch != 2 {
|
||||
t.Fatalf("degraded running primary with a qualified peer: line=%+v want r2@2", line)
|
||||
}
|
||||
if got := unhealthyReplicas(t, svc); len(got) != 0 {
|
||||
t.Fatalf("unhealthy replicas=%v; want none (no explicit unhealthy fact)", got)
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,10 @@ import (
|
||||
// stays moved: the master decides that, not the volume.
|
||||
// - It watches recovery after a primary assignment only: once the
|
||||
// replica has been promotion-ready in that assignment, the watchdog
|
||||
// is disarmed until the next primary epoch (a running primary that
|
||||
// later degrades is not a boot-recovery stall).
|
||||
// is disarmed until the next primary epoch or a new process
|
||||
// incarnation (its state is per process). A running primary that
|
||||
// later degrades is not a boot-recovery stall: it goes through the
|
||||
// normal controller/gate failover.
|
||||
// - role_admission_failed reports the G1 role-admission latch of a
|
||||
// primary-assigned replica, for as long as the latch holds.
|
||||
//
|
||||
|
||||
@@ -140,3 +140,49 @@ func TestRecoveryWatchdog_StatusShowsReasonAndCatchUp(t *testing.T) {
|
||||
t.Fatalf("supporting replica /status: reason=%q catchUp=%+v; want no reason and catch-up elapsed >= 20ms", st.UnhealthyReason, st.CatchUp)
|
||||
}
|
||||
}
|
||||
|
||||
// Once ready in this assignment, a later not-ready on the same
|
||||
// incarnation is a running primary degrading, not a boot-recovery stall:
|
||||
// no recovery_timeout, however long it lasts (claude05, 21:24Z).
|
||||
func TestRecoveryWatchdog_ReadyThenLaterNotReadyReportsNoTimeout(t *testing.T) {
|
||||
h, clk := watchdogHost(t, 10*time.Second)
|
||||
h.applyFact(selfPrimaryFact(1))
|
||||
clk.advance(time.Second)
|
||||
if r := h.unhealthyReason(true); r != "" {
|
||||
t.Fatalf("ready: %q", r)
|
||||
}
|
||||
clk.advance(time.Hour)
|
||||
if r := h.unhealthyReason(false); r != "" {
|
||||
t.Fatalf("not ready an hour after being ready, same incarnation: %q; want no recovery_timeout", r)
|
||||
}
|
||||
h.applyFact(selfPrimaryFact(1)) // the same assignment replayed: still disarmed
|
||||
clk.advance(time.Hour)
|
||||
if r := h.unhealthyReason(false); r != "" {
|
||||
t.Fatalf("same assignment replayed: %q; want still disarmed", r)
|
||||
}
|
||||
}
|
||||
|
||||
// A new process incarnation re-arms the watchdog: its state is per
|
||||
// process, so a restarted primary that stays not-ready past the timeout
|
||||
// reports recovery_timeout even for the same primary epoch.
|
||||
func TestRecoveryWatchdog_NewIncarnationRearms(t *testing.T) {
|
||||
old, clk := watchdogHost(t, 10*time.Second)
|
||||
old.applyFact(selfPrimaryFact(1))
|
||||
if r := old.unhealthyReason(true); r != "" {
|
||||
t.Fatalf("old process ready: %q", r)
|
||||
}
|
||||
|
||||
restarted, clk2 := watchdogHost(t, 10*time.Second) // new process, same replica
|
||||
if restarted.incarnation == old.incarnation {
|
||||
t.Fatalf("restarted process kept incarnation %q", old.incarnation)
|
||||
}
|
||||
restarted.applyFact(selfPrimaryFact(1)) // same primary epoch
|
||||
clk2.advance(11 * time.Second)
|
||||
if s := reportSlot(t, restarted); s.Eligible || s.UnhealthyReason != UnhealthyRecoveryTimeout {
|
||||
t.Fatalf("restarted process past timeout: eligible=%t reason=%q; want ineligible, %s", s.Eligible, s.UnhealthyReason, UnhealthyRecoveryTimeout)
|
||||
}
|
||||
clk.advance(time.Hour)
|
||||
if r := old.unhealthyReason(false); r != "" {
|
||||
t.Fatalf("old process stays disarmed: %q", r)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user