test: the barrier wake is jittered; a final refusal names the exit over superseded; docs

The lifecycle page says how the start waits (no bound while blockmaster
gives no reply, 30 s from the first answer or the barrier), what the new
log lines mean, and what to do on exit 78 reason=moved or reason=deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-23 23:46:16 -08:00
1 parent ec8f1ee0f7
commit fc990eef8a
3 files changed
+48 -22

No files matched your search

@@ -510,14 +510,16 @@ func TestChunkStartupExitFinalGives78(t *testing.T) {
return st.Err()
}
for _, tc := range []struct {
name string
refuse error
code int
reason string
name string
refuse error
foreign bool // the stream also delivered a newer line naming another replica
code int
reason string
}{
{"moved", refusal(control.WorkspaceLeaseRefusal_MOVED), exitWorkspaceSuperseded, "moved"},
{"deleted", refusal(control.WorkspaceLeaseRefusal_DELETED), exitWorkspaceSuperseded, "deleted"},
{"no detail", status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder"), exitWorkspaceRetry, "assignment_timeout"},
{"moved", refusal(control.WorkspaceLeaseRefusal_MOVED), false, exitWorkspaceSuperseded, "moved"},
{"moved, newer foreign line also seen", refusal(control.WorkspaceLeaseRefusal_MOVED), true, exitWorkspaceSuperseded, "moved"},
{"deleted", refusal(control.WorkspaceLeaseRefusal_DELETED), false, exitWorkspaceSuperseded, "deleted"},
{"no detail", status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder"), false, exitWorkspaceRetry, "assignment_timeout"},
} {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
@@ -538,6 +540,12 @@ func TestChunkStartupExitFinalGives78(t *testing.T) {
}
for tc.reason != "assignment_timeout" {
if _, final := h.MasterWaitState(); final != "" {
if tc.foreign {
assign("r2", 2)
if !h.IsCurrentReplicaSuperseded() {
t.Fatal("fixture: the newer foreign line does not supersede")
}
}
break
}
select {
@@ -142,8 +142,14 @@ func TestLeaseGuardSleepsUntilTheBarrier(t *testing.T) {
}
reply = refusalWith(t, "barrier", control.WorkspaceLeaseRefusal_BARRIER, 40*time.Second)
_ = g.Refresh(context.Background())
for i := 0; i < 20; i++ {
in("after BARRIER: until just past T", g.renewDelay(), 40*time.Second+100*time.Millisecond, 40*time.Second+600*time.Millisecond)
wakes := map[time.Duration]bool{}
for i := 0; i < 50; i++ {
d := g.renewDelay()
in("after BARRIER: until just past T", d, 40*time.Second+100*time.Millisecond, 40*time.Second+600*time.Millisecond)
wakes[d] = true
}
if len(wakes) < 10 {
t.Fatalf("%d distinct wake delays in 50; the wake past T must be jittered", len(wakes))
}
now = now.Add(39 * time.Second)
in("1 s before T", g.renewDelay(), 1100*time.Millisecond, 1600*time.Millisecond)
+25 -13
View File
@@ -314,19 +314,27 @@ blockmaster grants the lease again only after a barrier: the stored lease horizo
(up to 45 s after the last renewal) and the last grant, each plus
`--workspace-max-clock-skew` (default `20s`). With the defaults that is at most
**65 seconds after the process stopped**; if blockmaster restarted meanwhile, also at
least 50 seconds (30 s plus the skew) after that restart, whichever is later. Until
then the process logs, every second, `workspace lease: renewal failed after ...: ...
workspace forced move lease expiry plus clock-skew margin has not elapsed`, and does
not serve. After the grant it reclaims HEAD and serves its local WAL: nothing
acknowledged is lost.
least 50 seconds (30 s plus the skew) after that restart, whichever is later. The
refusal says when: `workspace lease: renewal failed after ...: workspace forced move
lease expiry plus clock-skew margin has not elapsed (re-grant refused until <time>, in
<duration>)`. The process sleeps until just after that time (then polls every 200 ms
for 5 s), does not serve meanwhile, and `/status` shows `MasterWait` with reason
`barrier` and that time. After the grant it reclaims HEAD and serves its local WAL:
nothing acknowledged is lost.
**A start waits 30 seconds for its lease** (fixed, no flag). If the barrier passes
inside that wait, the process is granted and serves. If it does not, the process logs
**A start waits for its lease.** While blockmaster gives no reply, or refuses the
node's credentials, the wait has no bound: the process serves nothing, holds no lease,
and logs `blockvolume: waiting for the master: <reason> since <time> (no bound)` when
the reason changes and every 10 minutes (`/status` shows the same as `MasterWait`).
Once blockmaster answers, the wait ends 30 seconds after the first answer, or 30
seconds after the master's barrier time when that is later (fixed, no flag). If the
grant comes inside the wait, the process serves. If it does not, the process logs
`durable: chunk authority wait for volume=v1 ended after ...: assignment unavailable,
not serving (...)`, and exits with `blockvolume: exiting status=75
reason=assignment_timeout`; the unit starts it again, and a start whose wait reaches
past the barrier serves. With the default flags the second start is enough. The unit
stops trying after 10 starts in 10 minutes.
not serving (...)` and exits with `blockvolume: exiting status=75
reason=assignment_timeout`; the unit starts it again. A master outage therefore costs
at most one restart (the holder's lease fence), not the unit's start limit (10 starts
in 10 minutes). A master that answers and drops in turn postpones the 30 seconds for
as long as it flaps.
No re-grant happens after a revoke, a recorded ACK or a move of the volume.
@@ -448,8 +456,12 @@ follow from that order:
| old holder logs `blockvolume: workspace lease closeout: workspace lease expired before clean ACK` | Revoked, but no ACK | Only a forced move to another node remains (HEAD is sealed: if step 3 succeeded, nothing is lost) |
| renewal fails with `workspace lease: revocation or move pending` | The volume was revoked or moved | The process cannot serve again; continue the hand-over |
| renewal fails with `workspace lease: stale authority` | A move gave the volume a newer epoch | This process is the old holder: stop it, do not restart it |
| renewal fails with `... clock-skew margin has not elapsed` | Waiting for the re-grant barrier | Wait (at most 65 s after the stop, with defaults) |
| `durable: chunk authority wait for volume=v1 ended after ...: assignment unavailable, not serving` | Started before its lease was granted; the process then exits 75 (`reason=assignment_timeout`) | Nothing under the example unit: it is started again and a later start serves. Without a supervisor, start it again after the barrier |
| renewal fails with `... clock-skew margin has not elapsed (re-grant refused until <time>, ...)` | Waiting for the re-grant barrier | Wait: the process sleeps until that time (at most 65 s after the stop, with defaults) |
| `blockvolume: waiting for the master: unreachable since <time> (no bound)` | blockmaster gives no reply; the process waits without exiting | Bring blockmaster back; the process continues by itself |
| `blockvolume: waiting for the master: credentials since <time> (no bound)` | blockmaster refuses this node's credentials; the process waits without exiting | Fix the node's certificate or role; the next call passes without a restart |
| `durable: chunk authority wait for volume=v1 ended after ...: assignment unavailable, not serving` | blockmaster answered for 30 s (past its barrier) and granted no lease; the process then exits 75 (`reason=assignment_timeout`) | Nothing under the example unit: it is started again. A unit for a volume this host no longer serves stops at its start limit: disable it |
| `blockvolume: exiting status=78 reason=moved` | blockmaster refused the lease: the volume moved to another host at a newer epoch. Not restarted | The volume serves elsewhere. If it is later moved back to this host, start the unit again (`systemctl start`); otherwise disable it |
| `blockvolume: exiting status=78 reason=deleted` | blockmaster refused the lease: the volume's delete is committed. Not restarted | Disable the unit and remove its settings |
| `durable: refusing to attach volume=v1 root=...: HEAD holder=... is not this holder ... (remove or quarantine the local root)` | This host's local copy is older than a HEAD another holder published | When the process is gone (see the rule above), move `<durable-root>/v1.bin` and the files `v1.bin.chunk*` beside it into another directory, then start again: it starts fresh from HEAD |
| `force-move: ... admissible at <time>, master clock` | The barrier has not passed | Wait until that time, rerun the same command |