mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
Merge pull request #654 from seaweedfs/fix/revoke-ack-retry
fix(blockvolume): ask a revocation ACK again until the lease deadline
This commit is contained in:
commit
08a67c4b07
7 files changed
+288
-16
No files matched your search
@@ -18,8 +18,15 @@ const (
|
||||
exitWorkspaceSuperseded = 78
|
||||
// Post-drain ACK wait; M2 Revoking -> Revoked, Part D. It covers the
|
||||
// guard's stop reply (the resource owner has drained by then) and its
|
||||
// ACK call, so it exceeds the ACK's own bound by 1 s.
|
||||
workspaceLeaseCloseoutTimeout = volume.WorkspaceAckTimeout + time.Second
|
||||
// ACK attempts, which the guard repeats until the lease deadline when an
|
||||
// answer is lost. The units kill the process TimeoutStopSec=30s after
|
||||
// the stop (deploy/systemd). Before this wait the drain is bounded by
|
||||
// WorkspaceDrainTimeout (5 s); after it, superviseProcess waits at most
|
||||
// WorkspaceDrainTimeout (5 s) for the exit. 30 s - 5 s - 5 s = 20 s,
|
||||
// less 1 s margin = 19 s. The guard's attempts end at the lease deadline
|
||||
// (about 20 s after the last renewal); attempts still running here end
|
||||
// as an unconfirmed ACK (exit 75), as before.
|
||||
workspaceLeaseCloseoutTimeout = 19 * time.Second
|
||||
)
|
||||
|
||||
type workspaceExit struct {
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/host/volume"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// A revocation ACK whose first answer is lost to a busy master (its call
|
||||
// timed out, or the master was unavailable) is asked again, and the repeat's
|
||||
// answer completes the stop with status 0, not 75. Any other first answer
|
||||
// is final: one ACK, exit 75.
|
||||
func TestWorkspaceRevocationAckIsAskedAgainAfterALostAnswer(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
first error
|
||||
acks int32
|
||||
code int
|
||||
}{
|
||||
{"deadline exceeded once", status.Error(codes.DeadlineExceeded, "context deadline exceeded"), 2, 0},
|
||||
{"unavailable once", status.Error(codes.Unavailable, "workspace ACK: read detached HEAD: busy"), 2, 0},
|
||||
{"refused (final)", status.Error(codes.FailedPrecondition, "workspace revoke ACK: stale or unsolicited"), 1, 75},
|
||||
} {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
var stream *exitAssignmentStream
|
||||
h, send := exitAuthorityHost(t, func(s *exitAssignmentStream) {
|
||||
stream = s
|
||||
s.revoke = true
|
||||
s.ackFirstError = c.first
|
||||
})
|
||||
send("r", 1)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
doneConsumed := false
|
||||
requests, done := startWorkspaceLease(ctx, h)
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
if !doneConsumed {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(3 * time.Second):
|
||||
t.Error("lease worker did not join")
|
||||
}
|
||||
}
|
||||
})
|
||||
e := newProcessExit(ctx)
|
||||
f := flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v", replicaID: "r"}
|
||||
request, leaseDone := waitWorkspaceStop(e, f, h, requests, done)
|
||||
if request == nil || !h.WorkspaceLeaseRevoking() {
|
||||
t.Fatal("real planned drain not acquired")
|
||||
}
|
||||
me := layout.HolderID{Epoch: 1, Holder: "s/r", ClaimID: "k"}
|
||||
st := layoutProofStore{h: layout.Head{Gen: 1, Epoch: 1, Holder: "s/r", ClaimID: "k", State: layout.StateDetached, Activity: layout.Activity{Kind: layout.ActIdle}}, found: true}
|
||||
gen, proofErr := workspaceLayoutDetachedGeneration(request.ctx, st, request.id, me)
|
||||
if proofErr != nil {
|
||||
t.Fatal(proofErr)
|
||||
}
|
||||
request.reply <- workspaceStopResult{gen: gen}
|
||||
finishWorkspaceLease(e, f, h, leaseDone)
|
||||
doneConsumed = true
|
||||
out := <-e.decision
|
||||
if got := stream.acks.Load(); got != c.acks {
|
||||
t.Fatalf("%d ACK calls; want %d", got, c.acks)
|
||||
}
|
||||
if out.code != c.code {
|
||||
t.Fatalf("stop classified %+v; want status %d", out, c.code)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// The closeout (with its repeated ACK attempts) fits the shipped units' stop
|
||||
// budget: the drain before it and superviseProcess's exit wait after it
|
||||
// (each volume.WorkspaceDrainTimeout) plus the closeout stay under every
|
||||
// blockvolume unit's TimeoutStopSec, and the closeout leaves room for at
|
||||
// least two ACK attempts.
|
||||
func TestWorkspaceCloseoutFitsTheUnitsStopBudget(t *testing.T) {
|
||||
if workspaceLeaseCloseoutTimeout < 2*volume.WorkspaceAckTimeout {
|
||||
t.Fatalf("closeout %v leaves no room for a second %v ACK attempt", workspaceLeaseCloseoutTimeout, volume.WorkspaceAckTimeout)
|
||||
}
|
||||
units, err := filepath.Glob(filepath.Join("..", "..", "deploy", "systemd", "sw-blockvolume*.service"))
|
||||
if err != nil || len(units) == 0 {
|
||||
t.Fatalf("no blockvolume units found: %v", err)
|
||||
}
|
||||
for _, unit := range units {
|
||||
raw, err := os.ReadFile(unit)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := regexp.MustCompile(`(?m)^TimeoutStopSec=(\d+)s\s*$`).FindSubmatch(raw)
|
||||
if m == nil {
|
||||
t.Fatalf("%s: no TimeoutStopSec=<n>s", unit)
|
||||
}
|
||||
n, _ := strconv.Atoi(string(m[1]))
|
||||
stop := time.Duration(n) * time.Second
|
||||
if total := volume.WorkspaceDrainTimeout + workspaceLeaseCloseoutTimeout + volume.WorkspaceDrainTimeout; total >= stop {
|
||||
t.Fatalf("%s: drain %v + closeout %v + exit wait %v = %v, not under TimeoutStopSec %v", unit, volume.WorkspaceDrainTimeout, workspaceLeaseCloseoutTimeout, volume.WorkspaceDrainTimeout, total, stop)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,10 @@ type exitAssignmentStream struct {
|
||||
// the typed IDENTITY detail.
|
||||
identityRefusals atomic.Int32
|
||||
ackError error
|
||||
acks atomic.Int32
|
||||
// ackFirstError, when set, answers only the first ACK (counted, not
|
||||
// recorded) with it; later ones get ackError.
|
||||
ackFirstError error
|
||||
acks atomic.Int32
|
||||
facts chan *control.AssignmentFact
|
||||
}
|
||||
|
||||
@@ -45,7 +48,9 @@ func (s *exitAssignmentStream) AckWorkspaceRevoked(_ context.Context, a *control
|
||||
if a.GetHeadGen() != 1 {
|
||||
return nil, errors.New("ACK lacks the stored detached proof")
|
||||
}
|
||||
s.acks.Add(1)
|
||||
if s.acks.Add(1) == 1 && s.ackFirstError != nil {
|
||||
return nil, s.ackFirstError
|
||||
}
|
||||
return &control.WorkspaceEmpty{}, s.ackError
|
||||
}
|
||||
func (s *exitAssignmentStream) ReportHeartbeat(context.Context, *control.HeartbeatReport) (*control.HeartbeatAck, error) {
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"github.com/seaweedfs/seaweed-block/core/host/volume"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// lostFirstAckReply loses only the first ACK's answer, after the real master
|
||||
// committed it; later ACKs pass through.
|
||||
type lostFirstAckReply struct {
|
||||
control.WorkspaceServiceClient
|
||||
calls *atomic.Int32
|
||||
}
|
||||
|
||||
func (c lostFirstAckReply) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck, opts ...grpc.CallOption) (*control.WorkspaceEmpty, error) {
|
||||
reply, err := c.WorkspaceServiceClient.AckWorkspaceRevoked(ctx, q, opts...)
|
||||
if c.calls.Add(1) == 1 && err == nil {
|
||||
return nil, status.Error(codes.DeadlineExceeded, "injected: the first ACK's answer lost after the master committed it")
|
||||
}
|
||||
return reply, err
|
||||
}
|
||||
|
||||
// A real guard against the real master: the first revocation ACK gets no
|
||||
// answer, (a) because its answer is lost after the master committed it, or
|
||||
// (b) because the master's first HEAD read is slower than the guard's 5 s
|
||||
// ACK bound. The guard asks again; the master answers the repeat (a: as
|
||||
// already recorded; b: by recording it), so the guard's drain ends without
|
||||
// error (the process exits 0, not 75) and the master holds exactly one ACK,
|
||||
// with the holder's identity, the stopped generation and the HEAD position.
|
||||
// On the parent commit (one attempt) both cases end with DeadlineExceeded.
|
||||
func TestWorkspaceRevocationAckRetryAgainstTheRealMaster(t *testing.T) {
|
||||
for _, c := range []string{"answer lost after commit", "slow first HEAD read"} {
|
||||
t.Run(c, func(t *testing.T) {
|
||||
head := authority.WorkspaceHead{Gen: 99, Epoch: 1, Holder: "node-a/r1", RemoteLSN: 42, Detached: true}
|
||||
var reads atomic.Int32
|
||||
reader := func(ctx context.Context, _ string) (authority.WorkspaceHead, error) {
|
||||
if reads.Add(1) == 1 && c == "slow first HEAD read" {
|
||||
time.Sleep(volume.WorkspaceAckTimeout + time.Second) // past the guard's bound
|
||||
}
|
||||
return head, nil
|
||||
}
|
||||
h, conn, ctx := reviewBindingHostBeforeStart(t, reader, nil)
|
||||
reviewLegacyBind(t, h, conn, ctx, "v")
|
||||
ws := control.NewWorkspaceServiceClient(conn)
|
||||
var acks atomic.Int32
|
||||
var client interface {
|
||||
RenewWorkspaceLease(context.Context, *control.WorkspaceIdentity, ...grpc.CallOption) (*control.WorkspaceLeaseFact, error)
|
||||
AckWorkspaceRevoked(context.Context, *control.WorkspaceRevocationAck, ...grpc.CallOption) (*control.WorkspaceEmpty, error)
|
||||
} = countingAck{ws, &acks}
|
||||
if c == "answer lost after commit" {
|
||||
client = lostFirstAckReply{ws, &acks}
|
||||
}
|
||||
id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r1", Epoch: 1}
|
||||
g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r1", Epoch: 1, Healthy: true}}, client, id,
|
||||
func(context.Context) (uint64, error) { return 7, nil }, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
runCtx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
if err := g.Refresh(runCtx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := ws.RevokeWorkspace(ctx, id); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := g.Refresh(runCtx); err != nil {
|
||||
t.Fatalf("the revocation's drain ended with %v; want a confirmed ACK after asking again", err)
|
||||
}
|
||||
if n := acks.Load(); n != 2 {
|
||||
t.Fatalf("%d ACK calls; want 2 (the unanswered one and its repeat)", n)
|
||||
}
|
||||
ack := h.Publisher().WorkspaceState("v").Ack
|
||||
if ack == nil || ack.ReplicaID != "r1" || ack.Epoch != 1 || ack.Holder != head.Holder || ack.RemoteLSN != head.RemoteLSN || ack.HeadGen != 7 {
|
||||
t.Fatalf("recorded ACK %+v; want r1@1 by %s at LSN %d, gen 7", ack, head.Holder, head.RemoteLSN)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// countingAck counts the guard's ACK calls to the real master.
|
||||
type countingAck struct {
|
||||
control.WorkspaceServiceClient
|
||||
calls *atomic.Int32
|
||||
}
|
||||
|
||||
func (c countingAck) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck, opts ...grpc.CallOption) (*control.WorkspaceEmpty, error) {
|
||||
c.calls.Add(1)
|
||||
return c.WorkspaceServiceClient.AckWorkspaceRevoked(ctx, q, opts...)
|
||||
}
|
||||
@@ -191,12 +191,27 @@ func (s *services) RevokeWorkspace(ctx context.Context, q *control.WorkspaceIden
|
||||
return leaseFact(s.host.Publisher(), q.GetVolumeId(), lease), nil
|
||||
}
|
||||
|
||||
func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck) (*control.WorkspaceEmpty, error) {
|
||||
func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck) (_ *control.WorkspaceEmpty, err error) {
|
||||
if err := auth.RequireNode(ctx, q.GetIdentity().GetServerId()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Each step's time is logged with the answer: a holder bounds its call
|
||||
// (volume.WorkspaceAckTimeout), and a miss names the step that ate it.
|
||||
arrived := time.Now()
|
||||
var locked, headRead, recorded time.Time
|
||||
defer func() {
|
||||
at := func(t time.Time) string {
|
||||
if t.IsZero() {
|
||||
return "-"
|
||||
}
|
||||
return t.Sub(arrived).String()
|
||||
}
|
||||
s.host.log.Printf("blockmaster: AckWorkspaceRevoked volume=%q replica=%q epoch=%d lock=%s head=%s recorded=%s answered=%s err=%v",
|
||||
q.GetIdentity().GetVolumeId(), q.GetIdentity().GetReplicaId(), q.GetIdentity().GetEpoch(), at(locked), at(headRead), at(recorded), time.Since(arrived), err)
|
||||
}()
|
||||
s.host.workspaceMu.Lock()
|
||||
defer s.host.workspaceMu.Unlock()
|
||||
locked = time.Now()
|
||||
id := q.GetIdentity()
|
||||
if err := s.workspaceVolume(id.GetVolumeId()); err != nil {
|
||||
return nil, err
|
||||
@@ -212,15 +227,17 @@ func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.Workspace
|
||||
return nil, status.Error(codes.Unavailable, "workspace ACK: detached HEAD reader unavailable")
|
||||
}
|
||||
readCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
head, err := s.host.cfg.WorkspaceHeadReader(readCtx, id.GetVolumeId())
|
||||
head, herr := s.host.cfg.WorkspaceHeadReader(readCtx, id.GetVolumeId())
|
||||
cancel()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Unavailable, "workspace ACK: read detached HEAD: %v", err)
|
||||
headRead = time.Now()
|
||||
if herr != nil {
|
||||
return nil, status.Errorf(codes.Unavailable, "workspace ACK: read detached HEAD: %v", herr)
|
||||
}
|
||||
holder := id.GetServerId() + "/" + id.GetReplicaId()
|
||||
if err := s.host.Publisher().AckWorkspaceRevocation(ctx, id.GetVolumeId(), authority.WorkspaceRevokeAck{ReplicaID: id.GetReplicaId(), Epoch: id.GetEpoch(), HeadGen: q.GetHeadGen(), Holder: holder}, head); err != nil {
|
||||
return nil, workspaceError(err)
|
||||
}
|
||||
recorded = time.Now()
|
||||
if err := s.host.reconcileWorkspaceBindings(); err != nil {
|
||||
return nil, workspaceError(err)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package volume
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand/v2"
|
||||
@@ -11,6 +12,8 @@ import (
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type WorkspaceLeaseClient interface {
|
||||
@@ -77,6 +80,22 @@ const stopPendingPoll = 250 * time.Millisecond
|
||||
// here (the holder exits 75 although the master may have recorded it).
|
||||
const WorkspaceAckTimeout = 5 * time.Second
|
||||
|
||||
// ackRetryPause separates the attempts of a revocation ACK that got no answer.
|
||||
const ackRetryPause = 250 * time.Millisecond
|
||||
|
||||
// retryableAckError: the ACK call got no answer (its deadline passed, or the
|
||||
// master was unavailable), so whether the master recorded it is unknown.
|
||||
func retryableAckError(err error) bool {
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return true
|
||||
}
|
||||
switch status.Code(err) {
|
||||
case codes.DeadlineExceeded, codes.Unavailable:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// WorkspaceDrainTimeout is the existing fail-closed lease drain bound.
|
||||
// INV-WS-STARTUP-RETRY-001 also bounds the process cleanup by this duration.
|
||||
const WorkspaceDrainTimeout = 5 * time.Second
|
||||
@@ -407,10 +426,25 @@ func (g *WorkspaceLeaseGuard) drain(parent context.Context, ack bool) error {
|
||||
}
|
||||
leaseCtx, leaseCancel := context.WithDeadline(parent, until)
|
||||
defer leaseCancel()
|
||||
ctx, cancel := context.WithTimeout(leaseCtx, WorkspaceAckTimeout)
|
||||
defer cancel()
|
||||
_, err := g.client.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: &g.id, HeadGen: g.headGen})
|
||||
return err
|
||||
// An answer lost to a busy master (its call timed out, or the master
|
||||
// was unavailable) is asked again until the lease deadline: the
|
||||
// master answers a repeat of a recorded ACK as recorded
|
||||
// (authority.Publisher.AckWorkspaceRevocation), and records one it
|
||||
// had not. Any other answer is final.
|
||||
for attempt := 1; ; attempt++ {
|
||||
ctx, cancel := context.WithTimeout(leaseCtx, WorkspaceAckTimeout)
|
||||
_, err := g.client.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: &g.id, HeadGen: g.headGen})
|
||||
cancel()
|
||||
if err == nil || !retryableAckError(err) || leaseCtx.Err() != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("workspace lease: revocation ACK attempt %d volume=%s epoch=%d got no answer (%v); asking again until the lease deadline %s", attempt, g.id.VolumeId, g.id.Epoch, err, until.Format(time.RFC3339Nano))
|
||||
select {
|
||||
case <-leaseCtx.Done():
|
||||
return err
|
||||
case <-time.After(ackRetryPause):
|
||||
}
|
||||
}
|
||||
}
|
||||
g.mu.Lock()
|
||||
cause := g.cause
|
||||
|
||||
@@ -310,7 +310,7 @@ stateDiagram-v2
|
||||
| Valid | StopPending | a chunk detach of this volume starts (before its drain); the guard renews at once. Scheduling only: StopPending admits, fences and ACKs exactly as Valid | `core/frontend/durable/provider_chunk.go` `DetachVolume`; `core/host/volume/workspace_runtime.go` `WorkspaceStopPending`; `core/host/volume/workspace_lease.go` `StopPending` | `INV-WS-STOP-PENDING-001` |
|
||||
| StopPending | StopPending | each sleep after a completed renewal is at most `stopPendingPoll` (250 ms); a renewal already in flight is not interrupted | `core/host/volume/workspace_lease.go` `renewDelay`, `Run` | `INV-WS-STOP-PENDING-001` |
|
||||
| StopPending | Valid | only the latest detach attempt, provably not applied, with serving resumed; an applied, fenced or unknown outcome, or an older attempt's resume, leaves StopPending | `core/frontend/durable/provider_chunk.go` `resumeAfterDetach`; `core/host/volume/workspace_runtime.go` `WorkspaceStopResumed`; `core/host/volume/workspace_lease.go` `ClearStopPending` | `INV-WS-STOP-PENDING-001` |
|
||||
| Fenced | Drained, Acked | the stop callback succeeded; only then, and only when revoked, the acknowledgement is sent | `core/host/volume/workspace_lease.go` `drain` | `INV-WS-REVOKE-ACK-001` |
|
||||
| Fenced | Drained, Acked | the stop callback succeeded; only then, and only when revoked, the acknowledgement is sent; a call that got no answer (`DeadlineExceeded`, `Unavailable`) is made again until the lease deadline, any other answer is final | `core/host/volume/workspace_lease.go` `drain`, `retryableAckError` | `INV-WS-REVOKE-ACK-001`, `INV-WS-REVOKE-ACK-RETRY-001` |
|
||||
| (start) | Attaching, Refused | the volume's host lock `/run/sw-block/locks/<volume id>.lock` is taken before the store opens; held by another live process, or its directory or file cannot be created or opened, refuses (`storage.ErrWALStoreLocked`, `ErrVolumeLockDirUnavailable`) | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (from `ensureHandle`) | `INV-WS-ONE-PROCESS-PER-HOST-001` |
|
||||
| Attaching | Refused | a local root from another claim or behind HEAD's position (`layout.ErrStaleLocalRoot`): final typed refusal with a cure, no serving or retry | `core/frontend/durable/provider_layout.go` `startLayoutRoot`; `provider_chunk.go` `recoverChunk`, `chunkAuthorityWait` | `INV-WS-STALE-LOCAL-ROOT-001` |
|
||||
| (startup) | Refused | `--chunk-filer` is not the only filer of its group: a master lists another filer or several, or no master lists it within 60 s (`ErrNotSingleFiler`) | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring` | `INV-WS-SINGLE-FILER-001` |
|
||||
@@ -802,7 +802,8 @@ Notes:
|
||||
| `INV-WS-SINGLE-FILER-001` | A chunk volume starts only when `--chunk-filer` is the only filer of its group: a master listing another filer or several refuses at once, whichever master answers first; a filer no master lists within 60 s is refused. A startup census, not a fence: a filer added to the group later is not detected. | M4 (startup) → Refused | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring`; `cmd/sw-block/chunk.go` `refuseUnlessSingleFiler` | `TestCheckSingleFilerRefusesAnotherOrSeveralFilers`, `TestCheckSingleFilerFailsClosed`, `TestCheckSingleFilerFavourableThenStalledRefuses`, `TestIsTargetComparesScopedAddresses`, `TestCheckSingleFilerPasses` (`core/frontend/chunkstore/single_filer_test.go`), `TestChunkWiringRefusesAMultiFilerGroup` (`cmd/blockvolume/single_filer_test.go`), `TestOpsChunk_WritingCommandsRunTheSingleFilerCheck` (`cmd/sw-block/chunk_start_check_test.go`), `TestOpsChunk_VerifyRunsTheSingleFilerCheck` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-LEASE-REGRANT-001` | Re-grant after expiry keeps the same holder and epoch, with no pending move or revocation, a certain store, and one durable write after the horizon/deadline plus skew barrier. Restart begins a new session and voids the old; ordinary reopen keeps HEAD identity (epoch, holder, claim) unchanged. | M2 Expired → Granted; M9 Start | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/frontend/chunkstore/layout/start.go` `Start` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut` (`core/authority/workspace_regrant_storage_test.go`); `TestStart_OwnEpochFreshRootRefusedBeforeClaim`, `TestStart_OwnEpochSameRootContinues` (`core/frontend/chunkstore/layout/start_test.go`); `TestClaim_WritesItsClaimID`, `TestRunClaim_VoidsTheOldSession` (`core/frontend/chunkstore/layout/claim_test.go`); `TestLocalReopenClaimsBeforeServing` (`core/frontend/durable/provider_reopen_belt_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory`; `INV-SNAPK-START-ROOT-001` | ACTIVE |
|
||||
| `INV-WS-LEASE-001` | A host admits frontend I/O and cuts only under an unexpired lease for its exact `{volume, replica, epoch}`; a fenced guard never reopens, even on a late renewal reply. | M4 lease guard: Valid → Fenced | `core/host/volume/workspace_lease.go` `permits`, `Refresh` | `TestWorkspaceLeaseExpiryFencesWithoutTimerAndCannotReopen`, `TestWorkspaceDelayedRenewalCannotUndoExpiry` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostRequiresLeaseBeforeFrontendAndCut` (`core/host/volume/workspace_runtime_test.go`); `TestWorkspacePausedGranteeRefusedAtAttach` (`core/host/master/workspace_paused_grantee_test.go`) | `WorkspaceTakeover` `NoDualServing` | ACTIVE |
|
||||
| `INV-WS-REVOKE-ACK-001` | A host acknowledges a revocation only after its frontend and cuts have stopped; a cancelled or expired drain sends no acknowledgement. | M4 lease guard: Revoking → Acked | `core/host/volume/workspace_lease.go` `drain` | `TestWorkspaceRevocationAckOnlyAfterFrontendAndCutsStop` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostCancelOrExpiryDuringRevokeDrainNeverACKs` (`core/host/volume/workspace_runtime_test.go`); `TestWorkspaceRevocationAckOutlastsTheMastersBoundedSteps`, `TestWorkspaceRevocationAckIsCutAtTheLeaseDeadline` (`core/host/volume/workspace_ack_budget_test.go`) | `WorkspaceTakeover` `CleanNoLoss` | ACTIVE |
|
||||
| `INV-WS-REVOKE-ACK-001` | A host acknowledges a revocation only after its frontend and cuts have stopped; a cancelled or expired drain sends no acknowledgement. | M4 lease guard: Revoking → Acked | `core/host/volume/workspace_lease.go` `drain` | `TestWorkspaceRevocationAckOnlyAfterFrontendAndCutsStop` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostCancelOrExpiryDuringRevokeDrainNeverACKs` (`core/host/volume/workspace_runtime_test.go`); `TestWorkspaceRevocationAckOutlastsTheMastersBoundedSteps`, `TestWorkspaceRevocationAckIsCutAtTheLeaseDeadline` (`core/host/volume/workspace_ack_budget_test.go`); `TestWorkspaceRevocationAckIsAskedAgainAfterALostAnswer`, `TestWorkspaceCloseoutFitsTheUnitsStopBudget` (`cmd/blockvolume/process_exit_ack_retry_test.go`) | `WorkspaceTakeover` `CleanNoLoss` | ACTIVE |
|
||||
| `INV-WS-REVOKE-ACK-RETRY-001` | A holder's revocation ACK is asked again only after a call that got no answer (`DeadlineExceeded`, `Unavailable`), within its lease deadline and the units' stop budget (19 s closeout); the master answers a repeat of a recorded ACK as recorded while the line is revoking. | M4 lease guard: Revoking → Acked; M2 Revoking → Revoked | `core/host/volume/workspace_lease.go` `drain`, `retryableAckError`; `cmd/blockvolume/process_exit.go` `workspaceLeaseCloseoutTimeout`; `core/authority/workspace.go` `AckWorkspaceRevocation` (a repeat returns nil) | `TestWorkspaceRevocationAckIsAskedAgainAfterALostAnswer`, `TestWorkspaceCloseoutFitsTheUnitsStopBudget` (`cmd/blockvolume/process_exit_ack_retry_test.go`); `TestWorkspaceRevocationAckIsCutAtTheLeaseDeadline` (`core/host/volume/workspace_ack_budget_test.go`); `TestWorkspaceRevocationAckRetryAgainstTheRealMaster` (`core/host/master/workspace_ack_retry_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-STOP-PENDING-001` | From when the detach hook of a chunk detach runs until the lease guard fences, or until that detach's resume clears stop-pending, each sleep of the guard after a completed renewal is at most 250 ms on the local monotonic clock. | M4 lease guard: Valid → StopPending → Valid \| Fenced | `core/host/volume/workspace_lease.go` `StopPending`, `ClearStopPending`, `renewDelay`, `Run`; `core/host/volume/workspace_runtime.go` `WorkspaceStopPending`, `WorkspaceStopResumed`; `core/frontend/durable/provider_chunk.go` `DetachVolume`, `detachVolume`, `resumeAfterDetach`; `cmd/blockvolume/main.go` `run` (wiring) | `TestWorkspaceLeaseStopPendingSchedule`, `TestWorkspaceHostStopResumedClearsOnlyTheLatestAttempt`, `TestWorkspaceHostFailedDetachStopPendingByOutcome`, `TestWorkspaceHostDetachHookFencesWithinPoll`, `TestWorkspaceLeaseStopPendingNeverBlocks` (`core/host/volume/workspace_lease_stop_pending_test.go`); `TestWALStoreChunk_DetachHookPrecedesDrain`, `TestWALStoreChunk_DetachResumeHookOnlyOnProvenAbort`, `TestWALStoreChunk_DetachCallsStopHook` (`core/frontend/durable/provider_chunk_detach_hook_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-SAME-HOST-CLEAN-MOVE-001` | A same-host move issues a higher epoch: a clean move needs the current holder's sealed HEAD and its recorded epoch/holder/position ACK, and the successor reads that sealed image; a forced move needs the normal lease barrier and a durable lost-range record. | M2 Acked or Expired → Moved; M9 detached → higher-epoch idle | `core/authority/workspace.go` `validateWorkspaceMoveRequest`, `prepareWorkspaceMoveLocked`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/frontend/chunkstore/layout/start.go` `Start`, `core/frontend/chunkstore/layout/claim.go` `Claim` | `TestWorkspaceSameHostForcedMoveRecordsLostRange` (`core/authority/workspace_same_host_forced_test.go`); `TestWorkspaceRPCSameHostForcedRecoveryRecordsLoss` (`core/host/master/workspace_same_host_forced_test.go`); `TestWorkspaceSameHostCleanMoveUsesOvernightSeal` (`core/authority/workspace_same_host_clean_test.go`); `TestWorkspaceRPCSameHostCleanMoveKeepsRepreparedBinding` (`core/host/master/workspace_same_host_clean_test.go`); `TestLayoutSameHostCleanSuccessorReadsSealedImage` (`core/frontend/durable/provider_layout_same_host_clean_test.go`) | `WorkspaceRegrant` `SameHostLoadsSealed`; `INV-SNAPK-DETACHED-001`. The B provider test performs a real plain detach, same-host higher-epoch fresh-root Start, and reads the sealed bytes. | ACTIVE |
|
||||
| `INV-WS-DELETE-NO-LIVE-HOLDER-001` | A workspace volume is marked deleting only with no live holder (`TERM-LIVE-HOLDER-001`): no line, a clean revocation ACK for the line, or HEAD below the line's epoch. A sealed HEAD without an ACK, a live or unreadable one is refused; the HEAD compare-and-swap to deleting fences a later claim. | M2 none/Granted/Revoking/Expired → Deleting | `core/authority/workspace_holder_state.go` `WorkspaceHolderState`; `core/authority/workspace.go` `RecordWorkspaceDeletion`; `core/host/master/services.go` `MarkVolumeDeleting`, `deleteHolderEvidence` | `TestWorkspaceHolderState` (`core/authority/workspace_holder_state_test.go`); `TestDeleteAdmitsANeverStartedLine` (`core/host/master/workspace_delete_never_started_test.go`); `TestDeleteAdmissionVerdicts` (`core/authority/workspace_delete_admission_test.go`); `TestMarkVolumeDeleting_RefusedWhileAssigned` (`core/host/master/volume_deleting_test.go`) | NeverStarted r2 `DeleteNeverStrandsALiveHolder`, `NoServedWriteLost`, re-run can finish, re-run can settle (exhaustive, 21 of 21 configurations as expected). Not modelled: two delete processes at the same instant; the gap between HEAD deleted and the volume marked deleted. Limit (v1): a never-started line that holds a lease is deleted once its lease horizon passed (about 60 s; the reservation refuses a live lease before it); the immediate exit is 1.0.1 | ACTIVE |
|
||||
@@ -834,7 +835,7 @@ Notes:
|
||||
- Part T fence ownership: `Host.FenceWorkspaceLease` uses `WorkspaceLeaseGuard.fenceLocked`, including before runtime publication; the zero-validity terminal guard preserves the first cause through installation and can grant no I/O. No second host fence latch exists. `TestWorkspaceHostFencePublishesOneTerminalCause`, `TestWorkspaceInstalledHostFenceRecordsCause`, `TestWorkspaceFenceBeforeHeldInstallIsTerminal` (`core/host/volume/workspace_terminal_test.go`).
|
||||
- Startup arbitration: sealed-replay/stale-local-root dispositions suppress the same wait's deadline defer (`TestChunkStartupRetainedDispositionWinsExpiredAttachContext`, `core/frontend/durable/provider_startup_outcome_test.go`). A stop request retires startup monitoring and its atomic-choice callback before resource cleanup; success is chosen only after the guard's ACK (`TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck`, `cmd/blockvolume/process_exit_authority_test.go`). Provider-validated startup selection briefly takes the process startup mutex; cancellation takes only that mutex. No reverse provider-lock acquisition or remote call occurs.
|
||||
|
||||
- ACK closeout: the guard sets `revoked` under its mutex before calling `drain` and invoking the stop callback. After a drain reply, its ACK call is bounded by the original lease deadline and the 5 s `WorkspaceAckTimeout` (above the master's 2 s HEAD read plus its ACK write and reconcile). The 6 s closeout wait (`WorkspaceAckTimeout` + 1 s) therefore expires before a newly selected retry's 5 s supervisor bound starts; a prior nonzero decision remains immutable. A restart can ACK the sealed HEAD only while the original revoking lease is still valid. Once it expires, re-grant refuses revoking/ACKed leases: repeated 75 is not recovery of an unconfirmed ACK, and operator recovery is required; no lease or ACK gate is bypassed.
|
||||
- ACK closeout: the guard sets `revoked` under its mutex before calling `drain` and invoking the stop callback. After a drain reply, each ACK call is bounded by the original lease deadline and the 5 s `WorkspaceAckTimeout` (above the master's 2 s HEAD read plus its ACK write and reconcile). A call that got no answer (`DeadlineExceeded`, `Unavailable`) is made again until the lease deadline: the master answers a repeat of a recorded ACK as recorded (`AckWorkspaceRevocation`), and any other answer is final. The 19 s closeout wait therefore expires before a newly selected retry's 5 s supervisor bound starts, and drain (5 s) + closeout (19 s) + exit wait (5 s) stays under the units' `TimeoutStopSec=30s`; a prior nonzero decision remains immutable. A restart can ACK the sealed HEAD only while the original revoking lease is still valid. Once it expires, re-grant refuses revoking/ACKed leases: repeated 75 is not recovery of an unconfirmed ACK, and operator recovery is required; no lease or ACK gate is bypassed.
|
||||
|
||||
Notes:
|
||||
|
||||
@@ -1151,7 +1152,7 @@ Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed sc
|
||||
|
||||
| Wait | Machine / invariant | Bound | Release and cancellation | Locks / remote work |
|
||||
|---|---|---|---|---|
|
||||
| Workspace revocation ACK closeout | M2 Revoking → Revoked; `INV-WS-STARTUP-RETRY-001` | `workspaceLeaseCloseoutTimeout` (`WorkspaceAckTimeout` + 1 s = 6 s), after the resource owner replies to the guard | `finishWorkspaceLease` owns the wait. ACK success selects normal exit; error/expiry selects 75 with `revoke_ack_unconfirmed`. The 5 s supervisor cleanup clock starts only after a nonzero outcome is selected. | No provider/storage lock held. |
|
||||
| Workspace revocation ACK closeout | M2 Revoking → Revoked; `INV-WS-STARTUP-RETRY-001` | `workspaceLeaseCloseoutTimeout` (19 s: the units' `TimeoutStopSec=30s` less the 5 s drain, the 5 s supervisor exit wait and 1 s margin), after the resource owner replies to the guard | `finishWorkspaceLease` owns the wait. ACK success selects normal exit; error/expiry selects 75 with `revoke_ack_unconfirmed`. Within it the guard asks again, until the lease deadline, after an ACK call that got no answer (`DeadlineExceeded`, `Unavailable`); the master answers a repeat of a recorded ACK as recorded. The 5 s supervisor cleanup clock starts only after a nonzero outcome is selected. | No provider/storage lock held. |
|
||||
| Workspace primary retry cleanup | M2 restart; `INV-WS-STARTUP-RETRY-001` | Existing `WorkspaceDrainTimeout` (5 s) after retry/no-retry outcome selection | Process supervisor owns the deadline and returns 75 or 78 even if resource-owner cleanup blocks; first outcome stays latched. Signal and ACKed revocation retain normal exit. | Provider latches by recovery generation under p.mu; wake is nonblocking; the supervisor holds no provider/storage lock. |
|
||||
| Workspace primary supervisor retries | M2 restart; `INV-WS-STARTUP-RETRY-001` | Shipped systemd units: `StartLimitIntervalSec=600`, `StartLimitBurst=10`, `RestartSec=5s`. While the master answers, each cycle is the assignment wait (30 s from contact) + 5 s, reaching the limit in about 6 minutes; while it gives no reply the process waits without exiting, so an outage costs one start (the fence), not the limit. If the assignment wait exceeds about 55 s, raise the interval too or the window never fills | systemd owns the restart window: after 10 starts in 600 s, another start within the window is refused and the unit fails; operator reset/start follows remediation. Exit 78 and ACKed exit 0 do not restart. | No application lock; `TestBlockvolumeUnitsBoundStartupRetries` (`internal/testops/blockvolume_systemd_test.go`) checks both shipped units. |
|
||||
| Offline seal | M5 PlainStop -> Quiesce; `INV-CUT-PLAIN-DETACH-001` | Caller context; positive HTTP timeoutMs. Completed uploads resume only within one blockvolume process and matching owner/HEAD/chunk versions; after restart the seal must fit seal_timeout_ms. | Provider owns drain, detached cut and settlement. Cancellation preserves unknown/fenced outcome safety; a closed frontend stays closed. | No admission lock held during store or remote I/O. |
|
||||
|
||||
Reference in new issue
Block a user