diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index 7c9f841c27..e157ae311e 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -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 { diff --git a/seaweed-block/core/host/volume/master_wait_test.go b/seaweed-block/core/host/volume/master_wait_test.go index da5e1c8914..fb89ffd2d3 100644 --- a/seaweed-block/core/host/volume/master_wait_test.go +++ b/seaweed-block/core/host/volume/master_wait_test.go @@ -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) diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index 0f9ed3ba79..96e2eca624 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -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