From 14f0d7401f66b8a929a304e42b32b4a18d8d2f0d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 17:26:46 -0800 Subject: [PATCH 001/204] hostlimit: background cuts wait while urgent work is pending; launch checks - A pool file, urgent-pending, signals urgent work on the host. An urgent cut holds it shared for its lease, and HoldUrgentPending lets a caller hold it across a stop or a drain. A Normal admission probes it exclusively without waiting and, while it is held, is refused with ErrUrgentPending (an ErrSlotsHeld, so the timer waits instead of failing). Urgent admissions are unaffected. - blockvolume checks --host-limit-dir before using it and refuses to start when it is missing or not a directory, under a temporary directory (/tmp, /var/tmp, /dev/shm, the process temp dir), on a network file system (NFS, CIFS, SMB2, FUSE on Linux), or already in use with different host-limit flags. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/blockvolume/main.go | 6 +- seaweed-block/core/hostlimit/launch.go | 56 +++++++++ seaweed-block/core/hostlimit/limiter.go | 31 +++++ seaweed-block/core/hostlimit/limiter_test.go | 6 + seaweed-block/core/hostlimit/lock_unix.go | 6 + seaweed-block/core/hostlimit/lock_windows.go | 6 + seaweed-block/core/hostlimit/pending.go | 33 ++++++ seaweed-block/core/hostlimit/pending_test.go | 110 ++++++++++++++++++ .../core/hostlimit/remotefs_linux.go | 24 ++++ .../core/hostlimit/remotefs_other.go | 6 + seaweed-block/docs/design/invariants.md | 4 +- 11 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 seaweed-block/core/hostlimit/launch.go create mode 100644 seaweed-block/core/hostlimit/pending.go create mode 100644 seaweed-block/core/hostlimit/pending_test.go create mode 100644 seaweed-block/core/hostlimit/remotefs_linux.go create mode 100644 seaweed-block/core/hostlimit/remotefs_other.go diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 689d1a19d9..2de7939da5 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -678,7 +678,11 @@ func run(f flags) int { cfg.ChunkHolder = chunkHolder(f) cfg.ChunkStagger = true if f.chunk.hostLimit.Directory != "" { - limiter, limitErr := hostlimit.New(f.chunk.hostLimit) + limitErr := hostlimit.CheckLaunch(f.chunk.hostLimit) + var limiter *hostlimit.Limiter + if limitErr == nil { + limiter, limitErr = hostlimit.New(f.chunk.hostLimit) + } if limitErr != nil { chunkErr = errors.Join(chunkErr, limitErr) } else { diff --git a/seaweed-block/core/hostlimit/launch.go b/seaweed-block/core/hostlimit/launch.go new file mode 100644 index 0000000000..276a93f16a --- /dev/null +++ b/seaweed-block/core/hostlimit/launch.go @@ -0,0 +1,56 @@ +package hostlimit + +import ( + "encoding/json" + "errors" + "fmt" + "os" + "path/filepath" + "strings" +) + +// CheckLaunch refuses a host-limit configuration whose premises do not +// hold, before the process uses it. The directory must exist as a real +// directory, outside temporary directories that cleaners empty, on a local +// file system (kernel file locks are not shared reliably over network +// file systems), and a configuration already published there by other +// processes must equal this one. The premise that every process on the +// host uses the same directory cannot be checked from one process. +func CheckLaunch(c Config) error { + return checkLaunch(c, []string{"/tmp", "/var/tmp", "/dev/shm", os.TempDir()}, remoteFS) +} + +func checkLaunch(c Config, tempRoots []string, remote func(string) (string, bool)) error { + if err := c.Validate(); err != nil { + return err + } + dir := filepath.Clean(c.Directory) + info, err := os.Lstat(dir) + if err != nil { + return fmt.Errorf("hostlimit: --host-limit-dir %s: %w", dir, err) + } + if !info.IsDir() || info.Mode()&os.ModeSymlink != 0 { + return fmt.Errorf("hostlimit: --host-limit-dir %s must be a directory, not a symlink or a file", dir) + } + for _, root := range tempRoots { + root = filepath.Clean(root) + if root != "" && root != "." && (dir == root || strings.HasPrefix(dir, root+string(filepath.Separator))) { + return fmt.Errorf("hostlimit: --host-limit-dir %s is under %s, which temporary-file cleaners empty", dir, root) + } + } + if fs, isRemote := remote(dir); isRemote { + return fmt.Errorf("hostlimit: --host-limit-dir %s is on %s, a network file system; slot locks need a local one", dir, fs) + } + existing, err := os.ReadFile(filepath.Join(dir, "configuration.json")) + if errors.Is(err, os.ErrNotExist) { + return nil + } + if err != nil { + return fmt.Errorf("hostlimit: --host-limit-dir %s: %w", dir, err) + } + expected, _ := json.Marshal(c) + if string(existing) != string(expected) { + return fmt.Errorf("hostlimit: --host-limit-dir %s is in use with other host-limit flags (%s); every process on the host must use identical flags (this one: %s)", dir, existing, expected) + } + return nil +} diff --git a/seaweed-block/core/hostlimit/limiter.go b/seaweed-block/core/hostlimit/limiter.go index 0d9590f46b..56799cb96a 100644 --- a/seaweed-block/core/hostlimit/limiter.go +++ b/seaweed-block/core/hostlimit/limiter.go @@ -23,6 +23,15 @@ var ErrBusy = errors.New("hostlimit: no background slot") // work: retrying once one is released can succeed. Other ErrBusy results // (an oversized payload, an unusable pool) do not change by waiting. var ErrSlotsHeld = fmt.Errorf("%w: every slot is held", ErrBusy) + +// ErrUrgentPending refuses a Normal admission while an urgent cut runs or +// a caller holds HoldUrgentPending on the host: new background cuts wait +// for it. It is an ErrSlotsHeld, so waiting callers treat it alike. +var ErrUrgentPending = fmt.Errorf("%w: an urgent cut is pending", ErrSlotsHeld) + +// urgentPendingFile is the pool file urgent work holds shared; Normal +// admission probes it exclusively, without waiting. It has no content. +const urgentPendingFile = "urgent-pending" var ErrConfig = errors.New("hostlimit: incompatible host configuration") var ErrRevoked = errors.New("hostlimit: cut budget revoked") @@ -72,6 +81,7 @@ type Stats struct { } type lease struct { file *os.File + pending *os.File // urgent only: the shared hold on urgentPendingFile started time.Time class Class fallback bool @@ -157,6 +167,20 @@ func (l *Limiter) pool(c Class) (*os.File, error) { if string(existing) != string(expected) { return nil, ErrConfig } + if c == Normal { + probe, err := open(urgentPendingFile) + if err != nil { + return nil, err + } + err = tryLock(probe) + _ = probe.Close() + if errors.Is(err, ErrBusy) { + return nil, ErrUrgentPending + } + if err != nil { + return nil, err + } + } names := []string{} if c == BackgroundFill || c == Idle { n, prefix := l.cfg.FillSlots, "fill" @@ -299,6 +323,10 @@ func (l *Limiter) Admit(ctx context.Context, payload int64, abort func(error)) ( l.next++ id := l.next x := &lease{file: f, started: time.Now(), class: c, fallback: fallback, payload: payload, abort: abort} + if c == Urgent && !fallback { + // Best effort: an urgent cut that cannot signal still runs. + x.pending, _ = holdShared(filepath.Join(l.cfg.Directory, urgentPendingFile)) + } l.live[id] = x l.stats.Admitted++ l.stats.PayloadReserved += payload @@ -399,6 +427,9 @@ func (l *Limiter) releaseLoop() { if x.file != nil { _ = x.file.Close() } + if x.pending != nil { + _ = x.pending.Close() + } l.mu.Lock() delete(l.live, id) l.fallback = false diff --git a/seaweed-block/core/hostlimit/limiter_test.go b/seaweed-block/core/hostlimit/limiter_test.go index fba52a4295..cc27928028 100644 --- a/seaweed-block/core/hostlimit/limiter_test.go +++ b/seaweed-block/core/hostlimit/limiter_test.go @@ -80,6 +80,12 @@ func TestSlotsUrgentAndJoinedRelease(t *testing.T) { a.Release(x) a.Release(x) settled(t, a) + // A free normal slot is not taken while the urgent cut runs. + if _, e = d.Admit(context.Background(), 1, nil); !errors.Is(e, ErrUrgentPending) { + t.Fatalf("normal admission during an urgent cut: %v", e) + } + b.Release(y) + settled(t, b) z, e := d.Admit(context.Background(), 1, nil) if e != nil { t.Fatal(e) diff --git a/seaweed-block/core/hostlimit/lock_unix.go b/seaweed-block/core/hostlimit/lock_unix.go index ff77b2a3da..09d8670651 100644 --- a/seaweed-block/core/hostlimit/lock_unix.go +++ b/seaweed-block/core/hostlimit/lock_unix.go @@ -15,3 +15,9 @@ func tryLock(f *os.File) error { } return err } + +// lockShared waits for a shared lock on f. An exclusive holder keeps it +// only for a non-blocking probe, so the wait is short. +func lockShared(f *os.File) error { + return syscall.Flock(int(f.Fd()), syscall.LOCK_SH) +} diff --git a/seaweed-block/core/hostlimit/lock_windows.go b/seaweed-block/core/hostlimit/lock_windows.go index 6cd06b16d9..bb108914ca 100644 --- a/seaweed-block/core/hostlimit/lock_windows.go +++ b/seaweed-block/core/hostlimit/lock_windows.go @@ -15,3 +15,9 @@ func tryLock(f *os.File) error { } return err } + +// lockShared waits for a shared lock on f. An exclusive holder keeps it +// only for a non-blocking probe, so the wait is short. +func lockShared(f *os.File) error { + return windows.LockFileEx(windows.Handle(f.Fd()), 0, 0, 1, 0, &windows.Overlapped{}) +} diff --git a/seaweed-block/core/hostlimit/pending.go b/seaweed-block/core/hostlimit/pending.go new file mode 100644 index 0000000000..40643ff396 --- /dev/null +++ b/seaweed-block/core/hostlimit/pending.go @@ -0,0 +1,33 @@ +package hostlimit + +import ( + "os" + "path/filepath" +) + +// HoldUrgentPending tells every limiter using dir that urgent work is +// pending on the host: until release is called, Normal admissions there +// are refused with ErrUrgentPending. Callers hold it across a stop or a +// drain, so background cuts do not take slots the stop is waiting for. +func HoldUrgentPending(dir string) (release func(), err error) { + f, err := holdShared(filepath.Join(dir, urgentPendingFile)) + if err != nil { + return nil, err + } + return func() { _ = f.Close() }, nil +} + +func holdShared(path string) (*os.File, error) { + if i, err := os.Lstat(path); err == nil && !i.Mode().IsRegular() { + return nil, &os.PathError{Op: "open", Path: path, Err: os.ErrInvalid} + } + f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o600) + if err != nil { + return nil, err + } + if err = lockShared(f); err != nil { + _ = f.Close() + return nil, err + } + return f, nil +} diff --git a/seaweed-block/core/hostlimit/pending_test.go b/seaweed-block/core/hostlimit/pending_test.go new file mode 100644 index 0000000000..2e59361431 --- /dev/null +++ b/seaweed-block/core/hostlimit/pending_test.go @@ -0,0 +1,110 @@ +package hostlimit + +import ( + "context" + "errors" + "os" + "path/filepath" + "strings" + "testing" + "time" +) + +// While a caller holds HoldUrgentPending, Normal admissions on the host +// wait (ErrUrgentPending, an ErrSlotsHeld); urgent ones still run. +func TestNormalWaitsWhileUrgentPendingIsHeld(t *testing.T) { + c := testConfig(t) + l := newTest(t, c) + release, err := HoldUrgentPending(c.Directory) + if err != nil { + t.Fatal(err) + } + if id, err := l.Acquire(context.Background(), Normal, nil); id != 0 || !errors.Is(err, ErrUrgentPending) || !errors.Is(err, ErrSlotsHeld) { + t.Fatalf("normal admission with an urgent pending: id=%d err=%v", id, err) + } + id, err := l.Acquire(context.Background(), Urgent, nil) + if err != nil { + t.Fatalf("urgent admission refused: %v", err) + } + l.Release(id) + release() + waitAdmitted(t, l, Normal) +} + +// An urgent cut holds the pending signal for its lease: another process's +// Normal admission waits until the urgent cut is released. +func TestUrgentLeaseHoldsThePendingSignal(t *testing.T) { + c := testConfig(t) + a, b := newTest(t, c), newTest(t, c) + id, err := a.Acquire(context.Background(), Urgent, nil) + if err != nil { + t.Fatal(err) + } + if _, err := b.Acquire(context.Background(), Normal, nil); !errors.Is(err, ErrUrgentPending) { + t.Fatalf("normal admission during an urgent lease: %v", err) + } + a.Release(id) + waitAdmitted(t, b, Normal) +} + +func waitAdmitted(t *testing.T, l *Limiter, c Class) { + t.Helper() + for deadline := time.Now().Add(2 * time.Second); ; time.Sleep(5 * time.Millisecond) { + id, err := l.Acquire(context.Background(), c, nil) + if err == nil { + l.Release(id) + return + } + if time.Now().After(deadline) { + t.Fatalf("still refused after the pending signal ended: %v", err) + } + } +} + +func TestCheckLaunch(t *testing.T) { + local := func(string) (string, bool) { return "", false } + c := testConfig(t) + if err := checkLaunch(c, nil, local); err != nil { + t.Fatalf("a fresh local directory refused: %v", err) + } + refused := map[string]struct { + c Config + roots []string + remote func(string) (string, bool) + want string + }{ + "missing": {DefaultConfig(filepath.Join(c.Directory, "missing")), nil, local, "missing"}, + "temp root": {c, []string{filepath.Dir(c.Directory)}, local, "temporary-file cleaners"}, + "remote": {c, nil, func(string) (string, bool) { return "NFS", true }, "network file system"}, + } + file := filepath.Join(t.TempDir(), "f") + if err := os.WriteFile(file, nil, 0o600); err != nil { + t.Fatal(err) + } + refused["file"] = struct { + c Config + roots []string + remote func(string) (string, bool) + want string + }{DefaultConfig(file), nil, local, "must be a directory"} + for name, tc := range refused { + if err := checkLaunch(tc.c, tc.roots, tc.remote); err == nil || !strings.Contains(err.Error(), tc.want) { + t.Fatalf("%s: %v; want %q", name, err, tc.want) + } + } + // A configuration published by other processes must be identical. + l := newTest(t, c) + id, err := l.Acquire(context.Background(), Normal, nil) + if err != nil { + t.Fatal(err) + } + l.Release(id) + if err := checkLaunch(c, nil, local); err != nil { + t.Fatalf("the same flags refused: %v", err) + } + other := c + other.NormalSlots = 3 + if err := checkLaunch(other, nil, local); err == nil || !strings.Contains(err.Error(), "identical flags") { + t.Fatalf("different flags accepted: %v", err) + } +} diff --git a/seaweed-block/core/hostlimit/remotefs_linux.go b/seaweed-block/core/hostlimit/remotefs_linux.go new file mode 100644 index 0000000000..972d1faee5 --- /dev/null +++ b/seaweed-block/core/hostlimit/remotefs_linux.go @@ -0,0 +1,24 @@ +//go:build linux + +package hostlimit + +import "syscall" + +// remoteFS names the network file system dir is on, if it is on one. +func remoteFS(dir string) (string, bool) { + var st syscall.Statfs_t + if syscall.Statfs(dir, &st) != nil { + return "", false + } + switch uint32(st.Type) { + case 0x6969: + return "NFS", true + case 0xFF534D42: + return "CIFS", true + case 0xFE534D42: + return "SMB2", true + case 0x65735546: + return "FUSE", true + } + return "", false +} diff --git a/seaweed-block/core/hostlimit/remotefs_other.go b/seaweed-block/core/hostlimit/remotefs_other.go new file mode 100644 index 0000000000..c19a5b490a --- /dev/null +++ b/seaweed-block/core/hostlimit/remotefs_other.go @@ -0,0 +1,6 @@ +//go:build !linux + +package hostlimit + +// remoteFS reports no network file system where it cannot tell. +func remoteFS(string) (string, bool) { return "", false } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index d9fa281f9f..4c6208790d 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -403,7 +403,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -186 rows: 164 ACTIVE, 19 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 171 new. +188 rows: 166 ACTIVE, 19 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 173 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -592,6 +592,8 @@ Notes: | `INV-CUT-ERROR-PRECEDENCE-001` | A chunk-control error body reports `cut_aborted` for a local cut abort even when the abort cancelled a remote upload, but an unknown CAS outcome, a fence or a closed or detached layer joined to it keeps its own code (`outcome_unknown`, `fenced`, `closing`). | M5 Copy, Upload → Aborted (HTTP error body) | `core/host/volume/chunk_control.go` `chunkErrorCode` | `TestStatusServer_ChunkErrorBodyIsTyped` (`core/host/volume/chunk_control_test.go`) | — | ACTIVE | | `INV-HOST-CUT-BUDGET-001` | Cooperating cut processes hold an OS slot before staging/barrier; payload and side caps are reserved per slot, including urgent slots. Cancellation never frees a slot before actual worker settlement. Active coordinated reservations exclude retained crash spill, fallback and RSS. Unavailable pools refuse ordinary background work; urgent/named fallback is explicitly degraded and cannot claim a host resource/rate bound. Pacing debt persists within one process, not across process turnover. | M7 admission/drain/release | `core/hostlimit`; durable `ChunkBudget`; blockvolume host-limit flags | `TestSlotsUrgentAndJoinedRelease`, `TestCOWAbortHoldsSlotUntilWorkerSettlement`, `TestHoldExpiryAndCloseDoNotSteal`, `TestKilledProcessReleasesButLiveHolderDoesNot`, `TestHostCutLimitDoesNotGateGuestIO`, `TestHostCOWCapAbortsCutAndRetainsPermitUntilJoin`, `TestCutPolicy_StaggerPreservesExplicitTimerReset`, `TestKilledInitializerDoesNotPublishPartialConfiguration`, `TestUnusablePoolClassPolicy`, `TestPacingDebtSurvivesOwnLeaseTurnover`, `TestPacingFreshProcessesDoNotShareDebt`, `TestChunkControl_NamedSnapshotUsesUrgentFallback`, `TestLastFallbackReleaseClearsActiveStatus`, `TestConfigurationLockFailurePreservesPoolPolicy`, `TestConfigurationLockContentionRefusesAllClasses` | `HostBudget` HeldUntilJoined/PayloadBound/SpillBound (bounded OS-lock abstraction; fallback excluded) | ACTIVE | | `INV-HOST-POOL-CONFIG-001` | A pool configuration is invisible until its complete synced temporary file is atomically renamed under the OS configuration lock. A killed initializer cannot leave a partial visible configuration that strands successors. | M7 configuration preparation/publication | `core/hostlimit` `publishConfig` | `TestKilledInitializerDoesNotPublishPartialConfiguration` | `HostBudget` NoPartialConfig/ConfigBeforeAdmission (filesystem atomicity checked natively) | ACTIVE | +| `INV-HOST-URGENT-PENDING-001` | While an urgent cut holds its slot, or a caller holds HoldUrgentPending, every Normal admission on the host is refused with ErrUrgentPending (a held-slot wait); urgent admissions still run. | M7 host cut admission (Normal before a slot) | `core/hostlimit/limiter.go` `pool`, `Admit`; `core/hostlimit/pending.go` `HoldUrgentPending` | `TestNormalWaitsWhileUrgentPendingIsHeld`, `TestUrgentLeaseHoldsThePendingSignal` (`core/hostlimit/pending_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | — | ACTIVE | +| `INV-HOST-LAUNCH-CHECK-001` | blockvolume refuses to start with a --host-limit-dir that is missing or not a directory, under a temporary directory, on a network file system, or already in use with different host-limit flags. | M7 host cut admission (process start) | `core/hostlimit/launch.go` `CheckLaunch`; `core/hostlimit/remotefs_linux.go`; `cmd/blockvolume/main.go` | `TestCheckLaunch` (`core/hostlimit/pending_test.go`) | — | ACTIVE | | `INV-CUT-INTENT-FIRST-001` | Before the first chunk or segment PUT of a cut or staging round, an intent naming every key of that kind the round preallocated is durable in the filer: one for all candidate chunks, however many upload waves the round uses, and one for all new segments. | M5 Intent → Upload → CAS | `core/storage/chunk_cut_payload.go` `streamCutPayloads`; `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS`, `TestChunkIntent_FailedPutIntentUploadsNothing` (`core/storage/chunk_layer_intent_test.go`); `TestCutPayloadIntentCountIndependentOfCandidates`, `TestCutPayloadReadsOverlapEarlierUploadsWithinBudget` (`core/storage/chunk_review271_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`); `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE | | `INV-CUT-INTENT-CLOSE-001` | Close deletes the intents of reusable uploads and leftover intents, but never an intent of a proposal whose CAS outcome is still unresolved. | M5 Close | `core/storage/chunk_layer.go` `Close`, `captureLocked`, `dropIntents` | `TestChunkCloseDropsReusableButKeepsUnknownCASRoots` (`core/storage/chunk_review271_test.go`); `TestHeadBeltOldCASUnconfirmedKeepsIntentsAndFrontier`, `TestHeadBeltLowerEpochConflictFencesWithoutCleanup`, `TestHeadBeltEmptyBaseForeignPublicationFences` (`core/storage/chunk_head_belt_test.go`) | — | ACTIVE | | `INV-CUT-SEGMENT-REUSE-001` | A cut rewrites only manifest segments whose chunk references changed, and an uploaded but unpublished segment leaves the published root unchanged. | M5 Manifest | `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `CutPipeline` `SegConsistent` | ACTIVE | From 2ff59b9529b971450d03066ef2b8dba96097059f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 17:27:48 -0800 Subject: [PATCH 002/204] hostlimit: gofmt Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/hostlimit/limiter.go | 1 + 1 file changed, 1 insertion(+) diff --git a/seaweed-block/core/hostlimit/limiter.go b/seaweed-block/core/hostlimit/limiter.go index 56799cb96a..d6486f6764 100644 --- a/seaweed-block/core/hostlimit/limiter.go +++ b/seaweed-block/core/hostlimit/limiter.go @@ -32,6 +32,7 @@ var ErrUrgentPending = fmt.Errorf("%w: an urgent cut is pending", ErrSlotsHeld) // urgentPendingFile is the pool file urgent work holds shared; Normal // admission probes it exclusively, without waiting. It has no content. const urgentPendingFile = "urgent-pending" + var ErrConfig = errors.New("hostlimit: incompatible host configuration") var ErrRevoked = errors.New("hostlimit: cut budget revoked") From 1bec4f79c90640785b31479d6e00f09742639659 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 21:58:15 -0800 Subject: [PATCH 003/204] volume: a refusal for held host cut slots has its own code, host_slot_busy The chunk control API answers a cut, snapshot or detach that host admission refused because every slot is held (or urgent work is pending) with 503 host_slot_busy, retryable, so a caller resends on exactly that refusal without reading messages; other capture refusals, a plain host busy included, keep capture_refused. Co-Authored-By: Claude Opus 5.5 --- .../core/host/volume/chunk_control.go | 9 ++++++ .../host/volume/chunk_host_slot_code_test.go | 30 +++++++++++++++++++ seaweed-block/docs/design/invariants.md | 3 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 seaweed-block/core/host/volume/chunk_host_slot_code_test.go diff --git a/seaweed-block/core/host/volume/chunk_control.go b/seaweed-block/core/host/volume/chunk_control.go index aeda86e92d..715eb803c9 100644 --- a/seaweed-block/core/host/volume/chunk_control.go +++ b/seaweed-block/core/host/volume/chunk_control.go @@ -247,6 +247,10 @@ func (s *StatusServer) chunkMux() http.Handler { return mux } +// codeHostSlotBusy refuses a cut, snapshot or detach because every host +// cut slot is held (retryable). +const codeHostSlotBusy = "host_slot_busy" + func writeChunkJSON(w http.ResponseWriter, status int, v any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) @@ -338,6 +342,11 @@ func chunkErrorCode(err error) (int, string, bool) { return http.StatusConflict, chunkstore.CodeNotChunkVolume, false case errors.Is(err, context.DeadlineExceeded): return http.StatusServiceUnavailable, chunkstore.CodeDeadlineExceeded, true + // Every host cut slot held (host admission, --host-limit-dir): a wait + // that ends when another cut releases its slot. Its own code, so a + // caller can resend on exactly this refusal without reading messages. + case errors.Is(err, hostlimit.ErrSlotsHeld): + return http.StatusServiceUnavailable, codeHostSlotBusy, true case errors.Is(err, storage.ErrChunkCaptureRefused): return http.StatusServiceUnavailable, "capture_refused", true default: diff --git a/seaweed-block/core/host/volume/chunk_host_slot_code_test.go b/seaweed-block/core/host/volume/chunk_host_slot_code_test.go new file mode 100644 index 0000000000..b3de2a4671 --- /dev/null +++ b/seaweed-block/core/host/volume/chunk_host_slot_code_test.go @@ -0,0 +1,30 @@ +package volume + +import ( + "fmt" + "net/http" + "testing" + + "github.com/seaweedfs/seaweed-block/core/hostlimit" + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// A refusal because every host cut slot is held has its own retryable +// code; other capture refusals, a plain host busy included, keep +// capture_refused. +func TestHostSlotHeldHasItsOwnCode(t *testing.T) { + for _, tc := range []struct { + err error + code string + }{ + {fmt.Errorf("%w: budget admission: %w", storage.ErrChunkCaptureRefused, hostlimit.ErrSlotsHeld), codeHostSlotBusy}, + {fmt.Errorf("%w: budget admission: %w", storage.ErrChunkCaptureRefused, hostlimit.ErrUrgentPending), codeHostSlotBusy}, + {fmt.Errorf("%w: budget admission: %w", storage.ErrChunkCaptureRefused, hostlimit.ErrBusy), "capture_refused"}, + {fmt.Errorf("%w: not a healthy primary", storage.ErrChunkCaptureRefused), "capture_refused"}, + } { + status, code, retryable := chunkErrorCode(tc.err) + if status != http.StatusServiceUnavailable || code != tc.code || !retryable { + t.Fatalf("%v: %d %s %v; want 503 %s retryable", tc.err, status, code, retryable, tc.code) + } + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index c0f3424945..9c309f8b1b 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -409,7 +409,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -223 rows: 200 ACTIVE, 20 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 208 new. +224 rows: 201 ACTIVE, 20 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 209 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -641,6 +641,7 @@ Notes: | `INV-HOST-POOL-CONFIG-001` | A pool configuration is invisible until its complete synced temporary file is atomically renamed under the OS configuration lock. A killed initializer cannot leave a partial visible configuration that strands successors. | M7 configuration preparation/publication | `core/hostlimit` `publishConfig` | `TestKilledInitializerDoesNotPublishPartialConfiguration` | `HostBudget` NoPartialConfig/ConfigBeforeAdmission (filesystem atomicity checked natively) | ACTIVE | | `INV-HOST-URGENT-PENDING-001` | While an urgent cut holds its slot, or a caller holds HoldUrgentPending, every Normal admission on the host is refused with ErrUrgentPending (a held-slot wait); urgent admissions still run. | M7 host cut admission (Normal before a slot) | `core/hostlimit/limiter.go` `pool`, `Admit`; `core/hostlimit/pending.go` `HoldUrgentPending` | `TestNormalWaitsWhileUrgentPendingIsHeld`, `TestUrgentLeaseHoldsThePendingSignal` (`core/hostlimit/pending_test.go`); `TestSlotsUrgentAndJoinedRelease` (`core/hostlimit/limiter_test.go`) | — | ACTIVE | | `INV-HOST-LAUNCH-CHECK-001` | blockvolume refuses to start with a --host-limit-dir that is missing or not a directory, under a temporary directory, on a network file system, or already in use with different host-limit flags. | M7 host cut admission (process start) | `core/hostlimit/launch.go` `CheckLaunch`; `core/hostlimit/remotefs_linux.go`; `cmd/blockvolume/main.go` | `TestCheckLaunch` (`core/hostlimit/pending_test.go`) | — | ACTIVE | +| `INV-HOST-SLOT-BUSY-CODE-001` | The chunk control API refuses a cut, snapshot or detach that host admission refused because every slot is held (or urgent work is pending) with 503 host_slot_busy, retryable; every other capture refusal keeps capture_refused. | M7 free → admitted (refused, wait) | `core/host/volume/chunk_control.go` `chunkErrorCode` | `TestHostSlotHeldHasItsOwnCode` (`core/host/volume/chunk_host_slot_code_test.go`) | — | ACTIVE | | `INV-CUT-INTENT-FIRST-001` | Before the first chunk or segment PUT of a cut or staging round, an intent naming every key of that kind the round preallocated is durable in the filer: one for all candidate chunks, however many upload waves the round uses, and one for all new segments. | M5 Intent → Upload → CAS | `core/storage/chunk_cut_payload.go` `streamCutPayloads`; `core/storage/chunk_layer.go` `captureLocked`, `stage`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestChunkIntent_WrittenBeforeFirstUploadAndDeletedAfterCAS`, `TestChunkIntent_FailedPutIntentUploadsNothing` (`core/storage/chunk_layer_intent_test.go`); `TestCutPayloadIntentCountIndependentOfCandidates`, `TestCutPayloadReadsOverlapEarlierUploadsWithinBudget` (`core/storage/chunk_review271_test.go`); `TestChunkPrecopy_StagedUploadsAreCoveredByIntents` (`core/storage/chunk_layer_precopy_test.go`); `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `ChunkLifecycleFixed` `GCSafe`; `WorkspaceTakeover` `NoLiveIntentExpired` | ACTIVE | | `INV-CUT-INTENT-CLOSE-001` | Close deletes the intents of reusable uploads and leftover intents, but never an intent of a proposal whose CAS outcome is still unresolved. | M5 Close | `core/storage/chunk_layer.go` `Close`, `captureLocked`, `dropIntents` | `TestChunkCloseDropsReusableButKeepsUnknownCASRoots` (`core/storage/chunk_review271_test.go`); `TestHeadBeltOldCASUnconfirmedKeepsIntentsAndFrontier`, `TestHeadBeltLowerEpochConflictFencesWithoutCleanup`, `TestHeadBeltEmptyBaseForeignPublicationFences` (`core/storage/chunk_head_belt_test.go`) | — | ACTIVE | | `INV-CUT-SEGMENT-REUSE-001` | A cut rewrites only manifest segments whose chunk references changed, and an uploaded but unpublished segment leaves the published root unchanged. | M5 Manifest | `core/frontend/chunkstore/manifest.go` `PrepareManifest` | `TestManifest_ReusesUnchangedRangeAndCrashKeepsOldRoot` (`core/frontend/chunkstore/manifest_test.go`) | `CutPipeline` `SegConsistent` | ACTIVE | From 66b6929923722e2c7d5f623976ac9c43e3ff5885 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:00:17 -0800 Subject: [PATCH 004/204] docs: promote 15 format-v3 rows whose statements a default test asserts Each promoted row runs in production by default and every clause of its statement is asserted by a named test in the default suite. 27 rows stay STUB; a note groups them by reason (a clause has no asserting test, the tests only exercise the path, or the asserting test needs a build tag). Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/design/invariants.md | 42 ++++++++++++++----------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..7efc9decdc 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -410,7 +410,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -303 rows: 217 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. +303 rows: 232 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -442,11 +442,11 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-CAPTURE-CANDIDATES-001` | A retained WAL entry already covered by HEAD is not dirt since HEAD. New post-HEAD WAL entries, UNKNOWN map chunks and map max-LSN above HEAD remain capture candidates. | M5 candidate selection | `chunk_layer.go` `captureCandidates` | `TestChunkLayerV3CapturedUncheckpointedWALIsCleanUntilRewritten`, `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestBaseInstallV3CompletePersistsTheMapUnknownOfBaseWrites` | Conservative reachability unchanged; narrower redundant work | ACTIVE | | `INV-WAL-V3-DESCRIPTOR-001` | A v3 descriptor slot is used only if it is valid: a matching CRC32C (Castagnoli), every reserved byte zero, an accepted impl, a nonzero slotGen at most 2^64-2, a nonzero nonce, and geometry consistent under checked arithmetic. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `decodeSlotV3`, `descriptorV3.validate`, `checkedAddV3` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3CounterExhaustion` (`core/storage/superblock_v3_test.go`) | — | STUB | | `INV-WAL-V3-DESCRIPTOR-BASE-001` | A valid v3 descriptor slot has CheckpointLSN ≤ mapCoveredCheckpoint ≤ W, and BASE fields that follow the rules of its BASE state. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `descriptorV3.validate` | `TestSlotV3VectorsDecodeAsExpected`, `TestSlotV3InstalledMayHaveCursorBelowTail` (`core/storage/superblock_v3_test.go`) | — | STUB | -| `INV-WAL-V3-DESCRIPTOR-SELECT-001` | Of the two v3 descriptor slots, open selects the valid selectable slot with the higher slotGen, and never a prepared migration slot. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`); `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW` (`core/storage/walstore_close_v3_test.go`) | — | STUB | -| `INV-WAL-V3-DESCRIPTOR-CONFLICT-001` | Open is refused when both v3 descriptor slots are valid but carry the same slotGen with different bytes, or disagree on the UUID or the geometry. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3`, `sameGeometryV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`) | — | STUB | -| `INV-WAL-V3-RECORD-001` | An impl-3 WAL record has a fixed 62-byte prefix, 70 bytes of overhead in all, a CRC32C (Castagnoli) and an explicit EntrySize. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `encodeWALEntryV3`, `payloadSizeV3` | `TestWALEntryV3_CanonicalBarrierBytes`, `TestWALEntryV3_TypeFootprints` | `WALRecovery` abstract record validity; physical byte rules are code-test obligations | STUB | +| `INV-WAL-V3-DESCRIPTOR-SELECT-001` | Of the two v3 descriptor slots, open selects the valid selectable slot with the higher slotGen, and never a prepared migration slot. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`); `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW` (`core/storage/walstore_close_v3_test.go`) | — | ACTIVE | +| `INV-WAL-V3-DESCRIPTOR-CONFLICT-001` | Open is refused when both v3 descriptor slots are valid but carry the same slotGen with different bytes, or disagree on the UUID or the geometry. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3`, `sameGeometryV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`) | — | ACTIVE | +| `INV-WAL-V3-RECORD-001` | An impl-3 WAL record has a fixed 62-byte prefix, 70 bytes of overhead in all, a CRC32C (Castagnoli) and an explicit EntrySize. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `encodeWALEntryV3`, `payloadSizeV3` | `TestWALEntryV3_CanonicalBarrierBytes`, `TestWALEntryV3_TypeFootprints` | `WALRecovery` abstract record validity; physical byte rules are code-test obligations | ACTIVE | | `INV-WAL-V3-RECORD-REFUSE-001` | The impl-3 record codec refuses unknown types or flags, a zero nonce, invalid per-type geometry, overflowing count, LSN, cursor or LBA spans, nonzero padding, a bad CRC or footer, and truncation, before allocating a payload. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `payloadSizeV3`, `decodeWALEntryV3`; `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALEntryV3_RefusesInvalidEncode`, `TestWALEntryV3_RefusesMalformedWire`, `FuzzWALEntryV3_DecodeNeverPanics` | — | STUB | -| `INV-WAL-V3-LSN-ORDER-001` | A v3 writer accepts only a first LSN above its highest consumed LSN; a batch consumes its whole validated range. Equal/lower requests return ErrWALLSNOrder before any pwrite or cursor change. Constructor coverage and a recovered kept frontier count as consumed; a fenced-away suffix does not. | M1 v3 append | `core/storage/wal_io_v3.go` `append`, `newWALWriterV3`, `restoreScanV3` | `TestWALLSNOrderV3_RefusesDuplicateAndLower`, `TestWALLSNOrderV3_BatchConsumesFullRange`, `TestWALLSNOrderV3_RestoreUsesKeptNotDroppedFrontier`, `TestWALLSNOrderV3_DescriptorFloorIsAlreadyConsumed`, `TestWALIOV3_ValidatedFrontierIntervals`, `TestWALIOV3_ConcurrentAppendsHaveUniqueCursors` | Physical LSN-strict prefix is a contract constraint; r16 model correspondence is pending | STUB | +| `INV-WAL-V3-LSN-ORDER-001` | A v3 writer accepts only a first LSN above its highest consumed LSN; a batch consumes its whole validated range. Equal/lower requests return ErrWALLSNOrder before any pwrite or cursor change. Constructor coverage and a recovered kept frontier count as consumed; a fenced-away suffix does not. | M1 v3 append | `core/storage/wal_io_v3.go` `append`, `newWALWriterV3`, `restoreScanV3` | `TestWALLSNOrderV3_RefusesDuplicateAndLower`, `TestWALLSNOrderV3_BatchConsumesFullRange`, `TestWALLSNOrderV3_RestoreUsesKeptNotDroppedFrontier`, `TestWALLSNOrderV3_DescriptorFloorIsAlreadyConsumed`, `TestWALIOV3_ValidatedFrontierIntervals`, `TestWALIOV3_ConcurrentAppendsHaveUniqueCursors` | Physical LSN-strict prefix is a contract constraint; r16 model correspondence is pending | ACTIVE | | `INV-WAL-V3-ADMISSION-001` | v3 write admission measures WAL pressure from the active v3 writer's physical head minus the both-slot reuse floor, as a fraction of WALSize. | M1 Serving (write admission) | `core/storage/walstore.go` `openInitializedV3`, `WALStore.walUsedFraction`; `core/storage/write_command_budget.go` `WALStore.writePressureSample` | `TestWALStoreV3AdmissionUsesNativeOccupancy` (`core/storage/walstore_admission_v3_test.go`); `TestWALStoreV3WritePressureSampleMatchesOccupancy` (`core/storage/write_command_budget_test.go`); liveness under pressure: `TestWALStoreChunkV3_SequentialBurstFlush` (public provider and NVMe handler, default 64 MiB WAL, 320 MiB literal readback), `TestWALStoreChunkV3_BurstPatternBindsFullLBA` (32/64/256 MiB alias controls) (`core/frontend/durable/provider_chunk_burst_test.go`) | Existing reuse/durability rules unchanged; pressure/liveness is not a new model claim | ACTIVE | | `INV-WAL-V3-ADMISSION-FAULT-001` | A terminal I/O fault latched while a v3 write waits on WAL pressure or for an admission slot ends that wait with the fault's original typed cause, also when the deadline has expired at the same check. | M1 Serving (write admission) | `core/storage/wal_admission.go` `walAdmission.acquireContext`, `walAdmission.terminalFault`; `core/storage/write_command_budget.go` `WALStore.writeBudgetError` | `TestWALStoreV3AdmissionReturnsFaultLatchedDuringPressureWait` (Write and WriteBatch); `TestWALStoreV3WriteBudgetKeepsTerminalFault` (`core/storage/write_command_budget_test.go`) | — | ACTIVE | | `INV-WAL-V3-ADMISSION-DEADLINE-001` | One command deadline, the earlier of the caller's deadline and the command's arrival plus `WriteCommandBudget`, bounds every adapter batch of a write and its store waits for the capture and lifecycle locks, on the local clock. | M1 Serving (write admission) | `core/frontend/write_budget.go` `WithWriteBudget`; `core/frontend/durable/storage_adapter.go` `StorageBackend.Write`, `writeBytes`; `core/storage/write_command_budget.go` `WALStore.writeAdmissionDeadline`, `WALStore.acquireWriteLock`; `core/storage/walstore.go` `WALStore.WriteContext`, `WALStore.WriteBatchContext` | `TestStorageBackendWriteKeepsOneDeadlineAcrossBatches`, `TestWALStoreV3WriteContextDeadlineIncludesCaptureWait`, `TestWALStoreV3WriteBudgetIncludesPostAdmissionWait`, `TestSessionWriteBudgetIncludesDispatchQueue` | — | ACTIVE | @@ -458,37 +458,37 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-RECLAIM-001` | A mapped v3 checkpoint at cp moves retainedTail only to the end of a complete validated record whose last LSN is at most cp minus the retention window, and, while a BASE is installing, never past BaseCursor. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/wal_io_v3.go` `walWriterV3.reclaimThroughV3` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | Existing dual-slot retirement and nonce/cursor contract; concrete index/recovery/caller wiring is a code-test obligation | STUB | | `INV-WAL-V3-RECLAIM-INDEX-001` | A physical v3 recovery rebuilds the writer's volatile record-boundary index only from trusted write records of the kept scan; an installing reopen indexes them without moving the writer's cursor. | M1 checkpoint / existing two-slot retirement | `core/storage/wal_io_v3.go` `walWriterV3.restoreScanV3`, `walWriterV3.rememberReclaimScanV3`, `walWriterV3.indexReclaimScanLockedV3`; `core/storage/walstore_v3.go` `WALStore.recoverV3` | `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | — | STUB | | `INV-WAL-V3-RECLAIM-PUBLISH-001` | A mapped v3 checkpoint publishes retainedTail, retainedHead, the map root, CheckpointLSN and W in one slot publication, followed by a metadata-only rollover when the fallback slot still pins a lower tail. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.rolloverIfPinned` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | — | STUB | -| `INV-WAL-V3-RECLAIM-FAIL-001` | When a v3 checkpoint publication or its rollover fails, no WAL byte is released for reuse and the dirty entries at or below the checkpoint stay unchanged for retry. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`, `WALStore.rolloverCheckpointV3Locked`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3` | `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | — | STUB | +| `INV-WAL-V3-RECLAIM-FAIL-001` | When a v3 checkpoint publication or its rollover fails, no WAL byte is released for reuse and the dirty entries at or below the checkpoint stay unchanged for retry. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`, `WALStore.rolloverCheckpointV3Locked`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3` | `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies`; `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-RECLAIM-EXCL-001` | No v3 writer is admitted between a checkpoint's slot publication and the end of both its rollover and its retirement of the dirty entries at or below the checkpoint. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`, `WALStore.retireCheckpointDirtyV3Locked` | `TestWALStoreV3ReclaimRetiresReferencesBeforeReuse` | — | STUB | -| `INV-WAL-V3-RECLAIM-SETTLE-001` | A pending v3 rollover (the fallback slot pinning a lower tail) is settled without a new checkpoint by the idle refresh, by a flusher cycle whose checkpoint does not advance, and by write admission. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.rolloverCheckpointV3Locked`, `WALStore.persistOwnedMapCheckpointV3`; `core/storage/walstore_v3.go` `WALStore.refreshW`, `WALStore.appendWriteV3` | `TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint` | — | STUB | +| `INV-WAL-V3-RECLAIM-SETTLE-001` | A pending v3 rollover (the fallback slot pinning a lower tail) is settled without a new checkpoint by the idle refresh, by a flusher cycle whose checkpoint does not advance, and by write admission. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.rolloverCheckpointV3Locked`, `WALStore.persistOwnedMapCheckpointV3`; `core/storage/walstore_v3.go` `WALStore.refreshW`, `WALStore.appendWriteV3` | `TestWALStoreV3ReclaimRolloverProgressWithoutNewCheckpoint` | — | ACTIVE | | `INV-WAL-V3-OWNER-001` | v3 read/write open and offline readonly open acquire the same exclusive nonblocking OS file lock before reading slots or changing bytes. Contention refuses with volume locked; descriptor close releases it, allowing retry. | M1 open admission | `core/storage/volume_lock*.go`; `walstore_v3.go`; `walstore_readonly_v3.go` | `TestWALStoreV3CreatorKeepsOwnershipThroughPublication` (`core/storage/volume_lock_v3_test.go`); `TestWALStoreV3OwnerExcludesOpenAndReadOnly` (`core/storage/volume_lock_v3_test.go`); `TestNativeReplacementLegacyBytesRefusedWithoutMutation` (`core/storage/legacy_replacement_v3_test.go`) | OS mutual exclusion is a caller obligation, outside the abstract crash model; existing open states unchanged | STUB | | `INV-WAL-V3-CATCHUP-001` | A v3 catch-up source that is installing refuses with `ErrBaseInstalling` and emits nothing, also for an empty request at the head. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.ScanLBAs`, `WALStore.scanLBAsV3` | `TestCatchUpV3InstallingAtHeadRefuses` (tag `swblock_format_v3_test`, actual catch-up sender) | Existing BASE and catch-up transitions unchanged; this physical scan/source-lifetime obligation is covered by deterministic caller tests | STUB | | `INV-WAL-V3-CATCHUP-BASE-001` | A v3 catch-up request covered by an installed BASE (fromLSN at or below BaseLSN) fails with typed `WALRecycled`: the peer needs a rebuild. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.scanLBAsV3` | `TestCatchUpV3CompletedBASEUsesRebuild`, `TestCatchUpV3CompletedBASESuffix` (tag `swblock_format_v3_test`) | — | STUB | -| `INV-WAL-V3-CATCHUP-DAMAGE-001` | Damage in the retained v3 WAL makes a catch-up fail with a typed WAL integrity error and emit nothing. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `v3CatchUpEntries` | `TestCatchUpV3CorruptFirstRecordFails`, `TestCatchUpV3CorruptMiddleRecordFails` (tag `swblock_format_v3_test`) | — | STUB | +| `INV-WAL-V3-CATCHUP-DAMAGE-001` | Damage in the retained v3 WAL makes a catch-up fail with a typed WAL integrity error and emit nothing. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `v3CatchUpEntries` | `TestWALStoreV3ScanLBAsIsAllOrNothing` (`core/storage/walstore_batch_v3_test.go`); `TestCatchUpV3CorruptFirstRecordFails`, `TestCatchUpV3CorruptMiddleRecordFails` (tag `swblock_format_v3_test`) | — | ACTIVE | | `INV-WAL-V3-CATCHUP-REVALIDATE-001` | A v3 catch-up emits entries only from a scan whose recovery generation, nonce, BASE state and ID, install epoch, retainedTail and CheckpointLSN are unchanged after the scan. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.scanLBAsV3` | `TestCatchUpV3InstallRetireABARefusesOldScan`, `TestCatchUpV3AfterCheckpointRingReuse`, `TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled` (tag `swblock_format_v3_test`) | — | STUB | -| `INV-WAL-V3-BINDING-001` | Every record and padding the v3 writer emits carries the selected nonce and its own absolute logical cursor and fits within WALSize of the both-slot reuse floor; an append that does not fit is refused. | M1 Recovering | `core/storage/wal_io_v3.go` `walWriterV3.append`, `walSnapshotV3` | `TestWALIOV3_RealWriterReopenScan`, `TestWALIOV3_WrapPaddingAndSlack`, `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`) | Record/lap admission is abstracted in composed WALFormatR5; physical framing/wrap boundaries remain code-test obligations | STUB | +| `INV-WAL-V3-BINDING-001` | Every record and padding the v3 writer emits carries the selected nonce and its own absolute logical cursor and fits within WALSize of the both-slot reuse floor; an append that does not fit is refused. | M1 Recovering | `core/storage/wal_io_v3.go` `walWriterV3.append`, `walSnapshotV3` | `TestWALIOV3_RealWriterReopenScan`, `TestWALIOV3_WrapPaddingAndSlack`, `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`) | Record/lap admission is abstracted in composed WALFormatR5; physical framing/wrap boundaries remain code-test obligations | ACTIVE | | `INV-WAL-V3-SCAN-BINDING-001` | The v3 scanner checks a record's nonce and exact expected cursor before it uses the record's Length or count, and trusts the record only after the whole record validates again. | M1 Recovering | `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALIOV3_StopsAtBindingBeforeEmbeddedRecord`, `TestWALIOV3_EmbeddedRecordInPayloadIsNotScanned` (`core/storage/wal_io_v3_test.go`) | — | STUB | | `INV-WAL-V3-SCAN-STOP-001` | The v3 scanner skips only geometric end-of-ring slack and stops at the first untrusted record, never searching inside a payload for a later record. | M1 Recovering | `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALIOV3_WrapPaddingAndSlack`, `TestWALIOV3_EmbeddedRecordInPayloadIsNotScanned`, `TestWALIOV3_StopsAtBindingBeforeEmbeddedRecord` (`core/storage/wal_io_v3_test.go`) | — | STUB | -| `INV-WAL-V3-MAP-PUBLISH-001` | Once a v3 store has bound a validated map, every descriptor publication carries the bound map tuple or a prepared candidate's, with merged CheckpointLSN ≤ map coverage C ≤ merged W. | M1 Serving (v3 map publication) | `core/storage/chunk_map_publication_v3.go` `validateMapPublicationV3`, `sameMapTupleV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedWithMapV3` | `TestMapPublicationV3_IsolatedMergedCoverageAndWPositive`, `TestMapPublicationV3_CoverageWAndNoUnpreparedRoot`, `TestWALStoreV3_AutomaticMapCheckpoint`, `TestWALStoreV3_AutomaticCheckpointMetadataOrderAndRetry` | WALFormatR5 map coverage / volatile proof epoch; physical caller wiring remains a code obligation | STUB | +| `INV-WAL-V3-MAP-PUBLISH-001` | Once a v3 store has bound a validated map, every descriptor publication carries the bound map tuple or a prepared candidate's, with merged CheckpointLSN ≤ map coverage C ≤ merged W. | M1 Serving (v3 map publication) | `core/storage/chunk_map_publication_v3.go` `validateMapPublicationV3`, `sameMapTupleV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedWithMapV3` | `TestMapPublicationV3_IsolatedMergedCoverageAndWPositive`, `TestMapPublicationV3_CoverageWAndNoUnpreparedRoot`, `TestWALStoreV3_AutomaticMapCheckpoint`, `TestWALStoreV3_AutomaticCheckpointMetadataOrderAndRetry`; `TestDescriptorV3MergeIsMonotonicAndRefusesForbiddenChanges` (`core/storage/descriptor_v3_test.go`) | WALFormatR5 map coverage / volatile proof epoch; physical caller wiring remains a code obligation | ACTIVE | | `INV-WAL-V3-MAP-PUBLISH-REPLACE-001` | A prepared v3 map candidate is published only with a higher map generation, coverage not below the bound map's, and the same sidecar and proof domain with its epoch and mutation token unchanged since preparation; a stale candidate writes no slot. | M1 Serving (v3 map publication) | `core/storage/chunk_map_publication_v3.go` `validateMapPublicationV3`, `prepareMapPublicationV3`, `mapPublicationProofV3.validV3` | `TestMapPublicationV3_ProofEpochAndMutationRefusal`, `TestMapPublicationV3_ProofChangedDuringPersistenceRefuses`, `TestMapPublicationV3_HeldPublicationsBothOrders`, `TestWALStoreV3_PreparedCheckpointRefusesChangedProof`, `TestCheckpointV3_EffectiveBaseWriteStillInvalidatesProof`, `TestCheckpointV3_DefiniteCutClearInvalidatesHeldProof`, `TestCheckpointV3_ExhaustedMutationCounterStillRefusesAppend` | — | STUB | | `INV-WAL-V3-MAP-PUBLISH-ROLLOVER-001` | A v3 publication without a prepared map candidate (a W-only publication or a rollover) carries the bound map root unchanged. | M1 Serving (v3 map publication) | `core/storage/chunk_map_publication_v3.go` `validateMapPublicationV3` | `TestMapPublicationV3_CoverageWAndNoUnpreparedRoot`, `TestCheckpointV3_AppendRolloverAfterPrepareKeepsRetainedSuffix` | — | STUB | | `INV-WAL-V3-FLUSH-LIFETIME-001` | A v3 flusher binds its dirty snapshot and extent materialization to the original even Recover generation. A cycle spanning Recover/reset publishes no checkpoint/map and retires no reused dirty entry. | M1 Recovering / checkpoint publication | `core/storage/flusher.go`; `walstore_map_checkpoint_v3.go`; `walstore_v3.go` `flushLifetimeValidV3` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` | Existing recovery/map proof lifetime; implementation correspondence | STUB | -| `INV-WAL-V3-MAP-BYTES-001` | A v3 map candidate names immutable pages and root in the store's owned sidecar, checked against the descriptor's identity and geometry. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`, `encodeMapPageV3`, `encodeMapRootV3` | `TestChunkLSNMapV3_PersistReloadAndReuse`, `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage` | WALFormatR5 abstract map dependency; physical encoding/digest/order are code obligations | STUB | +| `INV-WAL-V3-MAP-BYTES-001` | A v3 map candidate names immutable pages and root in the store's owned sidecar, checked against the descriptor's identity and geometry. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`, `encodeMapPageV3`, `encodeMapRootV3` | `TestChunkLSNMapV3_PersistReloadAndReuse`, `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage`, `TestChunkLSNMapV3_CorruptionAndBounds` | WALFormatR5 abstract map dependency; physical encoding/digest/order are code obligations | ACTIVE | | `INV-WAL-V3-MAP-VALIDATE-001` | A v3 map read returns no entry before the root and every page pass their domain-separated body digests, zero reserved and unused bytes, exact page counts, file bounds and non-aliasing page intervals. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `readChunkLSNMapV3`, `mapReadAtV3` | `TestChunkLSNMapV3_CanonicalVectors`, `TestChunkLSNMapV3_CorruptionAndBounds`, `TestChunkLSNMapV3_RejectsRehashedMalformedRecords`, `TestChunkLSNMapV3_EntryBoundBeforeRootIO`, `TestChunkLSNMapV3_WholePageHashIsNotBodyDigest` | — | STUB | -| `INV-WAL-V3-MAP-PERSIST-ORDER-001` | A v3 map candidate exists only after its new pages are written and fsynced, then its root is written and fsynced, then the sidecar's directory is fsynced. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage` | — | STUB | +| `INV-WAL-V3-MAP-PERSIST-ORDER-001` | A v3 map candidate exists only after its new pages are written and fsynced, then its root is written and fsynced, then the sidecar's directory is fsynced. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage` | — | ACTIVE | | `INV-WAL-V3-MAP-PERSIST-FAIL-001` | An error inside a v3 map persistence transaction yields no candidate and latches the store against later I/O; a preflight or Stat error latches nothing. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_FailureDoesNotPublishOrReuse`, `TestChunkLSNMapV3_PreflightErrorDoesNotLatch`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore` | — | STUB | -| `INV-WAL-V3-MAP-EXTENT-REUSE-001` | A v3 sidecar extent is reused only when no live root references it: neither slot's root, no in-flight candidate, and, until reopen, no candidate whose publication outcome is uncertain. | M1 (map preparation) | `core/storage/chunk_map_extents_v3.go` `slotsPublishedV3`, `abandonCandidateV3`, `liveSnapshotV3`, `registerRootV3`; `core/storage/chunk_map_publication_v3.go` `publishMapV3`, `openDescriptorMapV3` | `TestChunkMapExtentsV3FallbackRootIsNeverReused`, `TestChunkMapExtentsV3NewerInFlightCandidateIsNotReused`, `TestChunkMapExtentsV3CrashBeforePublicationOfAReusedExtent`, `TestChunkMapExtentsV3UncertainCandidateStaysPinned`, `TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned`, `TestChunkMapExtentsV3ReopenRegistersTheFallbackRoot` (`core/storage/chunk_map_extents_v3_test.go`); `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies` | — | STUB | +| `INV-WAL-V3-MAP-EXTENT-REUSE-001` | A v3 sidecar extent is reused only when no live root references it: neither slot's root, no in-flight candidate, and, until reopen, no candidate whose publication outcome is uncertain. | M1 (map preparation) | `core/storage/chunk_map_extents_v3.go` `slotsPublishedV3`, `abandonCandidateV3`, `liveSnapshotV3`, `registerRootV3`; `core/storage/chunk_map_publication_v3.go` `publishMapV3`, `openDescriptorMapV3` | `TestChunkMapExtentsV3FallbackRootIsNeverReused`, `TestChunkMapExtentsV3NewerInFlightCandidateIsNotReused`, `TestChunkMapExtentsV3CrashBeforePublicationOfAReusedExtent`, `TestChunkMapExtentsV3UncertainCandidateStaysPinned`, `TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned`, `TestChunkMapExtentsV3ReopenRegistersTheFallbackRoot` (`core/storage/chunk_map_extents_v3_test.go`); `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies` | — | ACTIVE | | `INV-WAL-V3-MAP-TRUNCATE-001` | When the v3 sidecar exceeds four times its live bytes, its free tail is truncated to the end of the highest live page and no lower. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkMapV3FileStaysBoundedUnderSteadyCheckpoints` (`core/storage/chunkmap_bounded_v3_test.go`); `TestChunkMapExtentsV3TruncationKeepsAFallbackAtTheTail`, `TestChunkMapExtentsV3TruncationFaultKeepsTheSlotRoots`, `TestChunkMapExtentsV3RejectedPublicationsStayBounded`, `TestChunkMapExtentsV3ProofStalePreparesStayBounded`, `TestChunkMapExtentsV3StatsAfterReopen` (`core/storage/chunk_map_extents_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-001` | Every v3 descriptor slot write after create's initial slot A goes through the one publisher, which writes the fallback slot with slotGen + 1 while holding `descMu`. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publish`, `descriptorPublisherV3.publishLockedCoreV3`; create: `core/storage/walstore_v3.go` `createWALStoreV3Configured` | `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-LOCKORDER-001` | The v3 publisher holds `WALStore.mu` only to take its snapshot and releases it before any slot I/O; the slot write and its fsync run in the store's fsync leaf. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishWithMapV3`; `core/storage/walstore.go` `WALStore.syncFile` | `TestDescriptorV3LockOrderRecorder` (`core/storage/descriptor_v3_test.go`) | — | STUB | -| `INV-WAL-V3-PUBLISH-MERGE-001` | A v3 publication rebases onto the authoritative descriptor: W and CheckpointLSN are max-merged, and a change of identity, geometry or (outside a reset) nonce, a retainedTail regression, or a map root change without a higher map generation is refused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `mergeDescriptorV3`, `mergeDescriptorV3Mode` | `TestDescriptorV3MergeIsMonotonicAndRefusesForbiddenChanges`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`); `TestResetV3OrdinaryPublicationsCannotChangeTheNonce` (`core/storage/reset_v3_test.go`) | — | STUB | +| `INV-WAL-V3-PUBLISH-MERGE-001` | A v3 publication rebases onto the authoritative descriptor: W and CheckpointLSN are max-merged, and a change of identity, geometry or (outside a reset) nonce, a retainedTail regression, or a map root change without a higher map generation is refused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `mergeDescriptorV3`, `mergeDescriptorV3Mode` | `TestDescriptorV3MergeIsMonotonicAndRefusesForbiddenChanges`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`); `TestResetV3OrdinaryPublicationsCannotChangeTheNonce` (`core/storage/reset_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-PUBLISH-BASE-EDGE-001` | A v3 publication whose BASE state change is not a DESIGN 8.5 edge (none → installing, installing → installing under a new ID, installing → installed under the same ID and BaseLSN, installed → none) is refused; installed → installing is refused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `baseTransitionAllowedV3` | `TestDescriptorV3BaseTransitionTable` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-FAIL-001` | A failed slot write (full or partial) or slot fsync publishes nothing: the authoritative descriptor stays, the store fault is latched, the candidate stays pinned as uncertain, and every later publication, rollover and WAL reuse is refused until reopen. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3`, `descriptorPublisherV3.rolloverIfPinned`, `descriptorPublisherV3.reuseFloorLocked` | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestDescriptorV3RolloverFsyncFailureKeepsTheFloorPinned` (`core/storage/descriptor_v3_test.go`); `TestCheckpointV3_AppendRolloverFaultRefusesHeldCandidate` | — | STUB | | `INV-WAL-V3-PUBLISH-LATCH-LEAF-001` | A descriptor slot write error latches the store fault inside the fsync leaf, before `fileSyncMu` is released, so a store Sync queued on `fileSyncMu` cannot acknowledge through the uncertain slot. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3`; `core/storage/walstore.go` `WALStore.syncFile`, `noteFsyncFailure` | `TestDescriptorV3QueuedStoreSyncCannotAckAfterSlotWriteError` (`core/storage/descriptor_v3_test.go`) | — | STUB | -| `INV-WAL-V3-PUBLISH-SUCCESS-BOUNDARY-001` | A store fault latched while a v3 publication is in flight makes that publication fail at its success boundary, without advancing the authoritative descriptor. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3` | `TestDescriptorV3FaultLatchedDuringPublicationRefusesAtSuccessBoundary` (`core/storage/descriptor_v3_test.go`) | — | STUB | +| `INV-WAL-V3-PUBLISH-SUCCESS-BOUNDARY-001` | A store fault latched while a v3 publication is in flight makes that publication fail at its success boundary, without advancing the authoritative descriptor. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3` | `TestDescriptorV3FaultLatchedDuringPublicationRefusesAtSuccessBoundary` (`core/storage/descriptor_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-PUBLISH-COUNTER-001` | A v3 publication whose slotGen, W, CheckpointLSN, retainedTail, retainedHead, map generation, map coverage, BaseLSN or BaseCursor would exceed 2^64-2 is refused with `ErrCounterExhausted` before any write. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `checkCountersV3`; `core/storage/superblock_v3.go` `nextSlotGenV3` | `TestDescriptorV3PublicationCounterExhaustion` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-ROLLOVER-001` | When the fallback slot's retainedTail is below the selected slot's under the same nonce, a metadata-only rollover republishes the current descriptor unchanged into it, so the reuse floor rises to the selected tail. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.rolloverIfPinned` | `TestDescriptorV3FullRingRolloverAdvancesTheFloorWithoutAnyChange` (`core/storage/descriptor_v3_test.go`) | — | STUB | -| `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001` | No v3 WAL reuse floor is computed across nonces: while the two descriptor slots carry different nonces there is no floor, and no WAL byte is reused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.reuseFloor`, `descriptorPublisherV3.reuseFloorLocked` | `TestDescriptorV3MixedNoncesNeverYieldAReuseFloor` (`core/storage/descriptor_v3_test.go`) | — | STUB | +| `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001` | No v3 WAL reuse floor is computed across nonces: while the two descriptor slots carry different nonces there is no floor, and no WAL byte is reused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.reuseFloor`, `descriptorPublisherV3.reuseFloorLocked` | `TestDescriptorV3MixedNoncesNeverYieldAReuseFloor` (`core/storage/descriptor_v3_test.go`); `TestWALStoreV3HalfResetRefusesWritesUntilRecover` (`core/storage/reset_store_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-W-001` | A v3 Sync acknowledges a write only after an fsync that covers the write's WAL record has completed. | M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.syncWALBatchV3`, `WALStore.syncWALBatchV3Internal`; `core/storage/walstore.go` `WALStore.Sync` | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes` (`core/storage/walstore_v3_test.go`) | `WALFormat` composed model | STUB | | `INV-WAL-V3-W-MODE-C-001` | In mode C (the default) a Sync batch publishes W = the previous batch's acknowledged W, and that publication's one fsync covers both the batch's WAL records and the slot. | M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.syncWALBatchV3Internal` | `TestWALStoreV3ModeCWindowIsExactlyTheNewestBatch` (`core/storage/walstore_v3_test.go`) | `WALFormat` composed model | STUB | | `INV-WAL-V3-W-MODE-A-001` | In mode A a Sync batch fsyncs the WAL first and only then publishes the slot with W = H, the highest LSN appended when the batch began. | M1 write lifecycle: Appended → Synced (v3) | `core/storage/walstore_v3.go` `WALStore.syncWALBatchV3Internal` | `TestWALStoreV3RecoversEveryAcknowledgedWriteInBothModes`, `TestWALStoreV3SetWModeCrashCases` (`core/storage/walstore_v3_test.go`) | `WALFormat` composed model | STUB | @@ -549,9 +549,13 @@ Notes: - `INV-WAL-V3-RESET-001`: Format bump v3, plan row 8 (DESIGN 8.6). Dark: no production path calls the reset, and it must not be activated before the reset model (r4.5) passes. The precondition is CheckpointLSN >= W rather than an empty retained range: retained old-incarnation bytes at or below the checkpoint are preserved in the extent. The map root is unchanged by a reset, so no map page is retired. - `INV-WAL-V3-BASE-001`: Format bump v3, plan row 9a (DESIGN r17.3.1 sections 8.1, 8.2, 8.4, 8.5, 8.7). Production reaches it through both callers below: the legacy single-lane caller by default, the dual-lane `Receiver` with `--recovery-mode=dual-lane`. Row 9b makes the seam `BaseInstallPreparer.BeginBaseInstall(baseLSN, installID) (InstallHandle, error)`: the dual-lane `Receiver` begins at SessionStart (BaseLSN = FromLSN, a fresh random ID) and its `RebuildSession` writes, applies and completes only through the handle, propagating the `MarkBaseComplete` error; stores without the seam keep their exact pre-seam behaviour through the lazy legacy handle (parallelwal's staging is now `BaseStager.BeginBaseStage`). Since row 10b the legacy single-lane caller (`core/transport/replica.go`) is on the handle too: the first admitted `MsgRebuildBlock` (or an empty rebuild's `MsgRebuildDone`) begins one install per connection at the lineage's frontier hint under a fresh random ID, blocks go through `WriteBase`, a different hint on the connection is refused, and done completes and then Syncs, closing the connection with no `MsgBarrierResp` when either fails; a reconnect is a superseding install under the coverage rule (tagged controls in `core/transport/replica_install_format_v3_test.go`). A v3 begin with an attached chunk layer that has no BASE transition hook is refused (`errV3NotYet`), writing nothing (`TestBaseInstallV3BeginRefusesWithAnUnsupportedAttachedChunkLayer`; a supported layer is drained as in `INV-WAL-V3-CHUNK-BASE-001`); since row 9c the v3 `SeedChunkFrontier` publishes CheckpointLSN = W = map coverage = lsn through the one checkpoint publication (`publishCheckpointV3`: data fsync, metadata and chunk barriers, owned-map candidate, the sole slot publisher under syncMu with the lifetime check), moves the volatile frontier only after it, publishes nothing on failure, and refuses local writes, an install, an attached layer or a store without an owned map; the provider's former refusal of a HEAD restore onto a v3 store is gone since row 12a (see the `INV-WAL-V3-MAP-PUBLISH-001` note); since row 11a an installing physical reopen (an installing ID this open did not begin) keeps its recovered bounds (E, R, intact or damaged) without fencing, publishing or admitting; a same-open Recover of this open's live install records none, so its still-valid handle cannot append past a cached cut that a resume would fence from; it republishes the live install's trusted records in the dirty map and keeps the volatile map coverage, or latches the store when the recovered cut is short of the live writer, and a covering superseding begin after it fences [E, floor + WALSize) and fsyncs before its two-slot installing publication, anchors at P = max(E, the persisted retainedHead) without lowering retainedHead, and restarts the writer at P (forward only); since row 11b the same-ID resume after a reopen (store level; no current caller resumes, both receivers begin fresh IDs) runs under `installMu` exclusive and appends nothing until the trusted-through-W check (intact suffix and E >= the persisted retainedHead), the fence of [E, floor + WALSize) with fsync and a retainedHead = E publication all held, refusing with `ErrInstallSuffixDamaged` and writing nothing otherwise; the writer continues at E and the recovered install-lane records are replayed. A begin while installed is refused until retirement (8.5 has no installed -> installing edge). - `INV-WAL-V3-MIGRATE-001`: Archived with the converter and its legacy fixtures; v2 inputs refuse open without mutation. -- `INV-WAL-V3-W-001`, `INV-WAL-V3-FENCE-001`: Format bump v3, plan rows 5 and 5b (DESIGN r15 sections 6.1 to 6.6). Since 5b the v3 format runs inside the real `WALStore`, through the shared committer, dirty map, flusher and leaf. Since activation (row 12b) production create and open (`CreateWALStoreWithOptions`, `OpenWALStoreWithOptions`) reach it. Without the row-7 map candidate (unmapped test fixtures only) the v3 checkpoint and tail do not advance. They are still STUBs although the path is active; their promotion is pending a per-row check of their tests. The test "crash" closes the file without further writes, so the slot-before-records reordering that mode C's lagged W guards against is covered by the composed model, not by these tests. Installing recovery is row 11. -- `INV-WAL-V3-PUBLISH-001`: Format bump v3, plan row 3 (DESIGN r15 sections 4, 5 and 5.1). The v3 store is wired in (rows 4 and 5) and activated (row 12b); the row is still a STUB although the path is active, its promotion pending a per-row check of its tests. The v2 checkpoint path (`persistCheckpointReleasing`) is retired. The map coverage predicates against the root are added by row 7, and the conditions on BASE edges by rows 9 to 11. -- `INV-WAL-V3-DESCRIPTOR-001`: Format bump v3, plan row 1 (DESIGN r15 section 2). Since the activation commit (plan row 12b) production walstore open and create reach the v3 codec; the row is still a STUB although the path is active, its promotion pending a per-row check of its tests. The map-dependency checks (root and pages present and hash-valid) are added by plan row 7. The tests decode vectors from an independent generator (`core/storage/testdata/format_v3/slot/gen_slot_vectors.py`). +- `INV-WAL-V3-W-001`, `INV-WAL-V3-FENCE-001`: Format bump v3, plan rows 5 and 5b (DESIGN r15 sections 6.1 to 6.6). Since 5b the v3 format runs inside the real `WALStore`, through the shared committer, dirty map, flusher and leaf. Since activation (row 12b) production create and open (`CreateWALStoreWithOptions`, `OpenWALStoreWithOptions`) reach it. Without the row-7 map candidate (unmapped test fixtures only) the v3 checkpoint and tail do not advance. `INV-WAL-V3-W-001` stays a STUB for the reason in the format v3 status note below; `INV-WAL-V3-FENCE-001` is still a STUB although the path is active, its promotion pending a per-row check of its tests. The test "crash" closes the file without further writes, so the slot-before-records reordering that mode C's lagged W guards against is covered by the composed model, not by these tests. Installing recovery is row 11. +- `INV-WAL-V3-PUBLISH-001`: Format bump v3, plan row 3 (DESIGN r15 sections 4, 5 and 5.1). The v3 store is wired in (rows 4 and 5) and activated (row 12b); the row stays a STUB for the reason in the format v3 status note below. The v2 checkpoint path (`persistCheckpointReleasing`) is retired. The map coverage predicates against the root are added by row 7, and the conditions on BASE edges by rows 9 to 11. +- `INV-WAL-V3-DESCRIPTOR-001`: Format bump v3, plan row 1 (DESIGN r15 section 2). Since the activation commit (plan row 12b) production walstore open and create reach the v3 codec; the row stays a STUB for the reason in the format v3 status note below. The map-dependency checks (root and pages present and hash-valid) are added by plan row 7. The tests decode vectors from an independent generator (`core/storage/testdata/format_v3/slot/gen_slot_vectors.py`). +- Format v3 status: the rows from `INV-WAL-V3-DESCRIPTOR-001` to `INV-WAL-V3-W-001` that were `STUB` (production reaches each by default) were checked clause by clause. A row is `ACTIVE` when a test in the default suite (no build tag) asserts every clause of its statement. The others stay `STUB`; the clause without an asserting test is in brackets. + - No test asserts the clause: `INV-WAL-V3-DESCRIPTOR-001` (geometry under checked arithmetic), `INV-WAL-V3-DESCRIPTOR-BASE-001` (mapCoveredCheckpoint ≤ W), `INV-WAL-V3-RECORD-REFUSE-001` (before allocating a payload), `INV-WAL-V3-OWNER-001` (read-only open takes the same exclusive lock; no byte changes under contention), `INV-WAL-V3-RECLAIM-001` (never past BaseCursor while installing), `INV-WAL-V3-RECLAIM-INDEX-001` (only trusted records of the kept scan), `INV-WAL-V3-RECLAIM-PUBLISH-001` (the five fields in one slot publication), `INV-WAL-V3-CATCHUP-REVALIDATE-001` (unchanged nonce and install epoch), `INV-WAL-V3-FLUSH-LIFETIME-001` (a cycle spanning a reset), `INV-WAL-V3-MAP-PUBLISH-ROLLOVER-001` (a rollover keeps the root), `INV-WAL-V3-MAP-VALIDATE-001` (file bounds; no entry returned on refusal), `INV-WAL-V3-MAP-PERSIST-FAIL-001` (a Stat error latches nothing), `INV-WAL-V3-MAP-TRUNCATE-001` (the four-times threshold; truncation to the end of the highest live page), `INV-WAL-V3-PUBLISH-001` (every slot write goes through the publisher), `INV-WAL-V3-PUBLISH-LOCKORDER-001` (snapshot under `WALStore.mu`; fsync in the leaf), `INV-WAL-V3-PUBLISH-BASE-EDGE-001` (installing → installed with another BaseLSN), `INV-WAL-V3-PUBLISH-FAIL-001` (after a failed slot fsync: latch, pin, rollover and reuse refusal), `INV-WAL-V3-PUBLISH-LATCH-LEAF-001` (a real store Sync; the test uses a stand-in leaf), `INV-WAL-V3-PUBLISH-COUNTER-001` (slotGen, retainedTail, map coverage, BaseLSN, BaseCursor), `INV-WAL-V3-PUBLISH-ROLLOVER-001` (written into the fallback slot, otherwise unchanged). + - The tests only exercise the path: `INV-WAL-V3-SCAN-BINDING-001` (nonce and cursor checked before Length or count), `INV-WAL-V3-SCAN-STOP-001` (no search inside a payload), `INV-WAL-V3-RECLAIM-EXCL-001` (the test writes after the window), `INV-WAL-V3-W-001` (mode C), `INV-WAL-V3-MAP-PUBLISH-REPLACE-001` (coverage not below the bound map's; same sidecar). + - Asserted only by tests under build tag `swblock_format_v3_test`: `INV-WAL-V3-CATCHUP-001` (an empty request at the head), `INV-WAL-V3-CATCHUP-BASE-001`. - `INV-WAL-V3-ACTIVATION-001` family: writable and read-only open validate the owned-map dependencies of the selected slot and of every valid fallback slot before the store or reader is returned, and refuse a valid legacy superblock with `ErrUnsupportedLegacyFormat` without changing a byte: see M1 — → Opened (tests `TestWALStoreV3_OpenRequiresBothMapGenerations`, `TestWALStoreV3_ReadOnlyRefusesIncompleteOrCorruptDependencies` with its fallback-page case, `TestNativeReplacementLegacyBytesRefusedWithoutMutation`). A zero chunk geometry option becomes 1024 blocks per chunk, so every public create is mapped; create persists an all-UNKNOWN initial map before its first slot. - `INV-WAL-V3-DESCRIPTOR-CONFLICT-001`: the old statement said the two slots must not disagree on identity; of the identity fields, open compares the UUID, together with the geometry. The next publication's slotGen comes from `nextSlotGenV3` (`INV-WAL-V3-PUBLISH-COUNTER-001`). `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW` is a store-level control of the selection: a v3 `Close` writes no slot, and reopen selects the newest one. - `INV-WAL-V3-RECORD-001`: codec success alone is not nonce, cursor or lap replay admission; that belongs to the scanner (`INV-WAL-V3-SCAN-BINDING-001`). From 8abbae408f790e421cf3f7ea1b9ab61d694aef32 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:10:20 -0800 Subject: [PATCH 005/204] test: scaffold real-binary standalone handover harness --- .../planned_handoff_integration_test.go | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go new file mode 100644 index 0000000000..7627a59ca5 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -0,0 +1,112 @@ +//go:build subprocess && chunkstore_integration + +package main_test + +import ( + "context" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" +) + +// plannedHandoffHarness owns real binaries, loopback endpoints and process +// lifetimes. The lifecycle test will use the commands and observables supplied +// with docs/volume-lifecycle.md; this scaffold makes no hand-over claim yet. +type plannedHandoffHarness struct { + dir string + master, volume, cli string + masterAddr, dataAddr, ctrlAddr, statusAddr, nvmeAddr string +} + +func newPlannedHandoffHarness(t *testing.T) *plannedHandoffHarness { + t.Helper() + if os.Getenv("CHUNKSTORE_WEED") == "" { + t.Fatal("CHUNKSTORE_WEED must name the pinned real SeaweedFS binary") + } + h := &plannedHandoffHarness{dir: t.TempDir()} + suffix := "" + if isWindows() { + suffix = ".exe" + } + for _, b := range []struct { + name string + dst *string + }{ + {"blockmaster", &h.master}, {"blockvolume", &h.volume}, {"sw-block", &h.cli}, + } { + *b.dst = filepath.Join(h.dir, b.name+suffix) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + cmd := exec.CommandContext(ctx, "go", "build", "-o", *b.dst, "github.com/seaweedfs/seaweed-block/cmd/"+b.name) + cmd.WaitDelay = 5 * time.Second + out, err := cmd.CombinedOutput() + cancel() + if err != nil { + t.Fatalf("build %s: %v\n%s", b.name, err, out) + } + } + h.masterAddr = leaseBinaryAddress(t) + h.dataAddr = leaseBinaryAddress(t) + h.ctrlAddr = leaseBinaryAddress(t) + h.statusAddr = leaseBinaryAddress(t) + h.nvmeAddr = leaseBinaryAddress(t) + return h +} + +// start registers cancellation and a bounded join before starting a daemon. +// Each child writes to its own file, and cleanup targets only that child. +func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args ...string) { + t.Helper() + log, err := os.Create(filepath.Join(h.dir, name+".log")) + if err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithCancel(context.Background()) + cmd := exec.CommandContext(ctx, binary, args...) + cmd.Dir, cmd.Stdout, cmd.Stderr = h.dir, log, log + cmd.WaitDelay = 5 * time.Second + done := make(chan error, 1) + started := false + t.Cleanup(func() { + cancel() + if started { + select { + case <-done: + case <-time.After(10 * time.Second): + t.Errorf("%s did not exit after cancellation", name) + } + } + _ = log.Close() + if t.Failed() { + data, _ := os.ReadFile(log.Name()) + if len(data) > 16000 { + data = data[len(data)-16000:] + } + t.Logf("%s log:\n%s", name, data) + } + }) + if err := cmd.Start(); err != nil { + t.Fatalf("start %s: %v", name, err) + } + started = true + go func() { done <- cmd.Wait() }() +} + +// command keeps stdout separate from stderr: detach stdout remains JSON while +// its sealed-generation line is read from stderr by the documented sequence. +func (h *plannedHandoffHarness) command(t *testing.T, args ...string) (string, string) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, h.cli, args...) + cmd.Dir = h.dir + cmd.WaitDelay = 5 * time.Second + var stdout, stderr strings.Builder + cmd.Stdout, cmd.Stderr = &stdout, &stderr + if err := cmd.Run(); err != nil { + t.Fatalf("sw-block %q: %v\nstdout: %s\nstderr: %s", args, err, stdout.String(), stderr.String()) + } + return stdout.String(), stderr.String() +} From 5d3cd7995ee5b21058cfcd3a239be00511a3c08b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:15:26 -0800 Subject: [PATCH 006/204] docs: two format-v3 statements say what the code does The lock-order row claimed the store lock is always released before slot I/O; recovery, BASE transitions, the checkpoint publication and rollovers hold it on purpose to exclude writers. The record-refusal row claimed CRC and footer are refused before a payload is allocated; the scanner must read a record to check them, after its size is bounded. Both rows stay STUB. Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/design/invariants.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 7efc9decdc..14da8ca917 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -445,7 +445,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-DESCRIPTOR-SELECT-001` | Of the two v3 descriptor slots, open selects the valid selectable slot with the higher slotGen, and never a prepared migration slot. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`); `TestWALStoreV3CloseKeepsTheNewestSlotAAndItsW` (`core/storage/walstore_close_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-DESCRIPTOR-CONFLICT-001` | Open is refused when both v3 descriptor slots are valid but carry the same slotGen with different bytes, or disagree on the UUID or the geometry. | M1 Opened (v3 descriptor selection) | `core/storage/superblock_v3.go` `selectSlotV3`, `sameGeometryV3` | `TestSlotV3Selection` (`core/storage/superblock_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-RECORD-001` | An impl-3 WAL record has a fixed 62-byte prefix, 70 bytes of overhead in all, a CRC32C (Castagnoli) and an explicit EntrySize. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `encodeWALEntryV3`, `payloadSizeV3` | `TestWALEntryV3_CanonicalBarrierBytes`, `TestWALEntryV3_TypeFootprints` | `WALRecovery` abstract record validity; physical byte rules are code-test obligations | ACTIVE | -| `INV-WAL-V3-RECORD-REFUSE-001` | The impl-3 record codec refuses unknown types or flags, a zero nonce, invalid per-type geometry, overflowing count, LSN, cursor or LBA spans, nonzero padding, a bad CRC or footer, and truncation, before allocating a payload. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `payloadSizeV3`, `decodeWALEntryV3`; `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALEntryV3_RefusesInvalidEncode`, `TestWALEntryV3_RefusesMalformedWire`, `FuzzWALEntryV3_DecodeNeverPanics` | — | STUB | +| `INV-WAL-V3-RECORD-REFUSE-001` | The impl-3 codec refuses unknown types or flags, a zero nonce, invalid per-type geometry, overflowing spans and truncation before allocating a payload; the scanner reads a record only after those checks bound its size, and refuses nonzero padding, a bad CRC or a bad footer before using its bytes. | M1 v3 record framing | `core/storage/wal_entry_v3.go` `payloadSizeV3`, `decodeWALEntryV3`; `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALEntryV3_RefusesInvalidEncode`, `TestWALEntryV3_RefusesMalformedWire`, `FuzzWALEntryV3_DecodeNeverPanics` | — | STUB | | `INV-WAL-V3-LSN-ORDER-001` | A v3 writer accepts only a first LSN above its highest consumed LSN; a batch consumes its whole validated range. Equal/lower requests return ErrWALLSNOrder before any pwrite or cursor change. Constructor coverage and a recovered kept frontier count as consumed; a fenced-away suffix does not. | M1 v3 append | `core/storage/wal_io_v3.go` `append`, `newWALWriterV3`, `restoreScanV3` | `TestWALLSNOrderV3_RefusesDuplicateAndLower`, `TestWALLSNOrderV3_BatchConsumesFullRange`, `TestWALLSNOrderV3_RestoreUsesKeptNotDroppedFrontier`, `TestWALLSNOrderV3_DescriptorFloorIsAlreadyConsumed`, `TestWALIOV3_ValidatedFrontierIntervals`, `TestWALIOV3_ConcurrentAppendsHaveUniqueCursors` | Physical LSN-strict prefix is a contract constraint; r16 model correspondence is pending | ACTIVE | | `INV-WAL-V3-ADMISSION-001` | v3 write admission measures WAL pressure from the active v3 writer's physical head minus the both-slot reuse floor, as a fraction of WALSize. | M1 Serving (write admission) | `core/storage/walstore.go` `openInitializedV3`, `WALStore.walUsedFraction`; `core/storage/write_command_budget.go` `WALStore.writePressureSample` | `TestWALStoreV3AdmissionUsesNativeOccupancy` (`core/storage/walstore_admission_v3_test.go`); `TestWALStoreV3WritePressureSampleMatchesOccupancy` (`core/storage/write_command_budget_test.go`); liveness under pressure: `TestWALStoreChunkV3_SequentialBurstFlush` (public provider and NVMe handler, default 64 MiB WAL, 320 MiB literal readback), `TestWALStoreChunkV3_BurstPatternBindsFullLBA` (32/64/256 MiB alias controls) (`core/frontend/durable/provider_chunk_burst_test.go`) | Existing reuse/durability rules unchanged; pressure/liveness is not a new model claim | ACTIVE | | `INV-WAL-V3-ADMISSION-FAULT-001` | A terminal I/O fault latched while a v3 write waits on WAL pressure or for an admission slot ends that wait with the fault's original typed cause, also when the deadline has expired at the same check. | M1 Serving (write admission) | `core/storage/wal_admission.go` `walAdmission.acquireContext`, `walAdmission.terminalFault`; `core/storage/write_command_budget.go` `WALStore.writeBudgetError` | `TestWALStoreV3AdmissionReturnsFaultLatchedDuringPressureWait` (Write and WriteBatch); `TestWALStoreV3WriteBudgetKeepsTerminalFault` (`core/storage/write_command_budget_test.go`) | — | ACTIVE | @@ -480,7 +480,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-MAP-EXTENT-REUSE-001` | A v3 sidecar extent is reused only when no live root references it: neither slot's root, no in-flight candidate, and, until reopen, no candidate whose publication outcome is uncertain. | M1 (map preparation) | `core/storage/chunk_map_extents_v3.go` `slotsPublishedV3`, `abandonCandidateV3`, `liveSnapshotV3`, `registerRootV3`; `core/storage/chunk_map_publication_v3.go` `publishMapV3`, `openDescriptorMapV3` | `TestChunkMapExtentsV3FallbackRootIsNeverReused`, `TestChunkMapExtentsV3NewerInFlightCandidateIsNotReused`, `TestChunkMapExtentsV3CrashBeforePublicationOfAReusedExtent`, `TestChunkMapExtentsV3UncertainCandidateStaysPinned`, `TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned`, `TestChunkMapExtentsV3ReopenRegistersTheFallbackRoot` (`core/storage/chunk_map_extents_v3_test.go`); `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies` | — | ACTIVE | | `INV-WAL-V3-MAP-TRUNCATE-001` | When the v3 sidecar exceeds four times its live bytes, its free tail is truncated to the end of the highest live page and no lower. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkMapV3FileStaysBoundedUnderSteadyCheckpoints` (`core/storage/chunkmap_bounded_v3_test.go`); `TestChunkMapExtentsV3TruncationKeepsAFallbackAtTheTail`, `TestChunkMapExtentsV3TruncationFaultKeepsTheSlotRoots`, `TestChunkMapExtentsV3RejectedPublicationsStayBounded`, `TestChunkMapExtentsV3ProofStalePreparesStayBounded`, `TestChunkMapExtentsV3StatsAfterReopen` (`core/storage/chunk_map_extents_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-001` | Every v3 descriptor slot write after create's initial slot A goes through the one publisher, which writes the fallback slot with slotGen + 1 while holding `descMu`. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publish`, `descriptorPublisherV3.publishLockedCoreV3`; create: `core/storage/walstore_v3.go` `createWALStoreV3Configured` | `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`) | — | STUB | -| `INV-WAL-V3-PUBLISH-LOCKORDER-001` | The v3 publisher holds `WALStore.mu` only to take its snapshot and releases it before any slot I/O; the slot write and its fsync run in the store's fsync leaf. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishWithMapV3`; `core/storage/walstore.go` `WALStore.syncFile` | `TestDescriptorV3LockOrderRecorder` (`core/storage/descriptor_v3_test.go`) | — | STUB | +| `INV-WAL-V3-PUBLISH-LOCKORDER-001` | Every v3 descriptor publication locks in the order `syncMu`, `WALStore.mu`, `descMu`, `fileSyncMu` and fsyncs the slot in that leaf. W publications hold no store lock during slot I/O; recovery, BASE transitions, checkpoint publication and rollovers hold `WALStore.mu` across it to exclude writers. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishWithMapV3`; `core/storage/walstore.go` `WALStore.syncFile` | `TestDescriptorV3LockOrderRecorder` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-MERGE-001` | A v3 publication rebases onto the authoritative descriptor: W and CheckpointLSN are max-merged, and a change of identity, geometry or (outside a reset) nonce, a retainedTail regression, or a map root change without a higher map generation is refused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `mergeDescriptorV3`, `mergeDescriptorV3Mode` | `TestDescriptorV3MergeIsMonotonicAndRefusesForbiddenChanges`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`); `TestResetV3OrdinaryPublicationsCannotChangeTheNonce` (`core/storage/reset_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-PUBLISH-BASE-EDGE-001` | A v3 publication whose BASE state change is not a DESIGN 8.5 edge (none → installing, installing → installing under a new ID, installing → installed under the same ID and BaseLSN, installed → none) is refused; installed → installing is refused. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `baseTransitionAllowedV3` | `TestDescriptorV3BaseTransitionTable` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-FAIL-001` | A failed slot write (full or partial) or slot fsync publishes nothing: the authoritative descriptor stays, the store fault is latched, the candidate stays pinned as uncertain, and every later publication, rollover and WAL reuse is refused until reopen. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishLockedCoreV3`, `descriptorPublisherV3.rolloverIfPinned`, `descriptorPublisherV3.reuseFloorLocked` | `TestDescriptorV3FsyncFailureIsStickyAndPublishesNothing`, `TestDescriptorV3SlotWriteErrorLatchesAndPinsTheCandidate`, `TestDescriptorV3RolloverFsyncFailureKeepsTheFloorPinned` (`core/storage/descriptor_v3_test.go`); `TestCheckpointV3_AppendRolloverFaultRefusesHeldCandidate` | — | STUB | @@ -553,7 +553,7 @@ Notes: - `INV-WAL-V3-PUBLISH-001`: Format bump v3, plan row 3 (DESIGN r15 sections 4, 5 and 5.1). The v3 store is wired in (rows 4 and 5) and activated (row 12b); the row stays a STUB for the reason in the format v3 status note below. The v2 checkpoint path (`persistCheckpointReleasing`) is retired. The map coverage predicates against the root are added by row 7, and the conditions on BASE edges by rows 9 to 11. - `INV-WAL-V3-DESCRIPTOR-001`: Format bump v3, plan row 1 (DESIGN r15 section 2). Since the activation commit (plan row 12b) production walstore open and create reach the v3 codec; the row stays a STUB for the reason in the format v3 status note below. The map-dependency checks (root and pages present and hash-valid) are added by plan row 7. The tests decode vectors from an independent generator (`core/storage/testdata/format_v3/slot/gen_slot_vectors.py`). - Format v3 status: the rows from `INV-WAL-V3-DESCRIPTOR-001` to `INV-WAL-V3-W-001` that were `STUB` (production reaches each by default) were checked clause by clause. A row is `ACTIVE` when a test in the default suite (no build tag) asserts every clause of its statement. The others stay `STUB`; the clause without an asserting test is in brackets. - - No test asserts the clause: `INV-WAL-V3-DESCRIPTOR-001` (geometry under checked arithmetic), `INV-WAL-V3-DESCRIPTOR-BASE-001` (mapCoveredCheckpoint ≤ W), `INV-WAL-V3-RECORD-REFUSE-001` (before allocating a payload), `INV-WAL-V3-OWNER-001` (read-only open takes the same exclusive lock; no byte changes under contention), `INV-WAL-V3-RECLAIM-001` (never past BaseCursor while installing), `INV-WAL-V3-RECLAIM-INDEX-001` (only trusted records of the kept scan), `INV-WAL-V3-RECLAIM-PUBLISH-001` (the five fields in one slot publication), `INV-WAL-V3-CATCHUP-REVALIDATE-001` (unchanged nonce and install epoch), `INV-WAL-V3-FLUSH-LIFETIME-001` (a cycle spanning a reset), `INV-WAL-V3-MAP-PUBLISH-ROLLOVER-001` (a rollover keeps the root), `INV-WAL-V3-MAP-VALIDATE-001` (file bounds; no entry returned on refusal), `INV-WAL-V3-MAP-PERSIST-FAIL-001` (a Stat error latches nothing), `INV-WAL-V3-MAP-TRUNCATE-001` (the four-times threshold; truncation to the end of the highest live page), `INV-WAL-V3-PUBLISH-001` (every slot write goes through the publisher), `INV-WAL-V3-PUBLISH-LOCKORDER-001` (snapshot under `WALStore.mu`; fsync in the leaf), `INV-WAL-V3-PUBLISH-BASE-EDGE-001` (installing → installed with another BaseLSN), `INV-WAL-V3-PUBLISH-FAIL-001` (after a failed slot fsync: latch, pin, rollover and reuse refusal), `INV-WAL-V3-PUBLISH-LATCH-LEAF-001` (a real store Sync; the test uses a stand-in leaf), `INV-WAL-V3-PUBLISH-COUNTER-001` (slotGen, retainedTail, map coverage, BaseLSN, BaseCursor), `INV-WAL-V3-PUBLISH-ROLLOVER-001` (written into the fallback slot, otherwise unchanged). + - No test asserts the clause: `INV-WAL-V3-DESCRIPTOR-001` (geometry under checked arithmetic), `INV-WAL-V3-DESCRIPTOR-BASE-001` (mapCoveredCheckpoint ≤ W), `INV-WAL-V3-RECORD-REFUSE-001` (before allocating a payload), `INV-WAL-V3-OWNER-001` (read-only open takes the same exclusive lock; no byte changes under contention), `INV-WAL-V3-RECLAIM-001` (never past BaseCursor while installing), `INV-WAL-V3-RECLAIM-INDEX-001` (only trusted records of the kept scan), `INV-WAL-V3-RECLAIM-PUBLISH-001` (the five fields in one slot publication), `INV-WAL-V3-CATCHUP-REVALIDATE-001` (unchanged nonce and install epoch), `INV-WAL-V3-FLUSH-LIFETIME-001` (a cycle spanning a reset), `INV-WAL-V3-MAP-PUBLISH-ROLLOVER-001` (a rollover keeps the root), `INV-WAL-V3-MAP-VALIDATE-001` (file bounds; no entry returned on refusal), `INV-WAL-V3-MAP-PERSIST-FAIL-001` (a Stat error latches nothing), `INV-WAL-V3-MAP-TRUNCATE-001` (the four-times threshold; truncation to the end of the highest live page), `INV-WAL-V3-PUBLISH-001` (every slot write goes through the publisher), `INV-WAL-V3-PUBLISH-LOCKORDER-001` (the callers that hold `WALStore.mu` across slot I/O), `INV-WAL-V3-PUBLISH-BASE-EDGE-001` (installing → installed with another BaseLSN), `INV-WAL-V3-PUBLISH-FAIL-001` (after a failed slot fsync: latch, pin, rollover and reuse refusal), `INV-WAL-V3-PUBLISH-LATCH-LEAF-001` (a real store Sync; the test uses a stand-in leaf), `INV-WAL-V3-PUBLISH-COUNTER-001` (slotGen, retainedTail, map coverage, BaseLSN, BaseCursor), `INV-WAL-V3-PUBLISH-ROLLOVER-001` (written into the fallback slot, otherwise unchanged). - The tests only exercise the path: `INV-WAL-V3-SCAN-BINDING-001` (nonce and cursor checked before Length or count), `INV-WAL-V3-SCAN-STOP-001` (no search inside a payload), `INV-WAL-V3-RECLAIM-EXCL-001` (the test writes after the window), `INV-WAL-V3-W-001` (mode C), `INV-WAL-V3-MAP-PUBLISH-REPLACE-001` (coverage not below the bound map's; same sidecar). - Asserted only by tests under build tag `swblock_format_v3_test`: `INV-WAL-V3-CATCHUP-001` (an empty request at the head), `INV-WAL-V3-CATCHUP-BASE-001`. - `INV-WAL-V3-ACTIVATION-001` family: writable and read-only open validate the owned-map dependencies of the selected slot and of every valid fallback slot before the store or reader is returned, and refuse a valid legacy superblock with `ErrUnsupportedLegacyFormat` without changing a byte: see M1 — → Opened (tests `TestWALStoreV3_OpenRequiresBothMapGenerations`, `TestWALStoreV3_ReadOnlyRefusesIncompleteOrCorruptDependencies` with its fallback-page case, `TestNativeReplacementLegacyBytesRefusedWithoutMutation`). A zero chunk geometry option becomes 1024 blocks per chunk, so every public create is mapped; create persists an all-UNKNOWN initial map before its first slot. From 86b421f0702ac28184986e51191b72af286688f5 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:19:49 -0800 Subject: [PATCH 007/204] docs: say which test asserts the catch-up damage row in the default suite Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 14da8ca917..5d694ca5c5 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -464,7 +464,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-OWNER-001` | v3 read/write open and offline readonly open acquire the same exclusive nonblocking OS file lock before reading slots or changing bytes. Contention refuses with volume locked; descriptor close releases it, allowing retry. | M1 open admission | `core/storage/volume_lock*.go`; `walstore_v3.go`; `walstore_readonly_v3.go` | `TestWALStoreV3CreatorKeepsOwnershipThroughPublication` (`core/storage/volume_lock_v3_test.go`); `TestWALStoreV3OwnerExcludesOpenAndReadOnly` (`core/storage/volume_lock_v3_test.go`); `TestNativeReplacementLegacyBytesRefusedWithoutMutation` (`core/storage/legacy_replacement_v3_test.go`) | OS mutual exclusion is a caller obligation, outside the abstract crash model; existing open states unchanged | STUB | | `INV-WAL-V3-CATCHUP-001` | A v3 catch-up source that is installing refuses with `ErrBaseInstalling` and emits nothing, also for an empty request at the head. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.ScanLBAs`, `WALStore.scanLBAsV3` | `TestCatchUpV3InstallingAtHeadRefuses` (tag `swblock_format_v3_test`, actual catch-up sender) | Existing BASE and catch-up transitions unchanged; this physical scan/source-lifetime obligation is covered by deterministic caller tests | STUB | | `INV-WAL-V3-CATCHUP-BASE-001` | A v3 catch-up request covered by an installed BASE (fromLSN at or below BaseLSN) fails with typed `WALRecycled`: the peer needs a rebuild. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.scanLBAsV3` | `TestCatchUpV3CompletedBASEUsesRebuild`, `TestCatchUpV3CompletedBASESuffix` (tag `swblock_format_v3_test`) | — | STUB | -| `INV-WAL-V3-CATCHUP-DAMAGE-001` | Damage in the retained v3 WAL makes a catch-up fail with a typed WAL integrity error and emit nothing. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `v3CatchUpEntries` | `TestWALStoreV3ScanLBAsIsAllOrNothing` (`core/storage/walstore_batch_v3_test.go`); `TestCatchUpV3CorruptFirstRecordFails`, `TestCatchUpV3CorruptMiddleRecordFails` (tag `swblock_format_v3_test`) | — | ACTIVE | +| `INV-WAL-V3-CATCHUP-DAMAGE-001` | Damage in the retained v3 WAL makes a catch-up fail with a typed WAL integrity error and emit nothing. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `v3CatchUpEntries` | `TestWALStoreV3ScanLBAsIsAllOrNothing` (`core/storage/walstore_batch_v3_test.go`; default suite, asserts both clauses for a damaged first and middle record); also `TestCatchUpV3CorruptFirstRecordFails`, `TestCatchUpV3CorruptMiddleRecordFails` (tag `swblock_format_v3_test`, not run by CI) | — | ACTIVE | | `INV-WAL-V3-CATCHUP-REVALIDATE-001` | A v3 catch-up emits entries only from a scan whose recovery generation, nonce, BASE state and ID, install epoch, retainedTail and CheckpointLSN are unchanged after the scan. | M1 BASE lifecycle / M3 CatchingUp | `core/storage/walstore_recovery.go` `WALStore.scanLBAsV3` | `TestCatchUpV3InstallRetireABARefusesOldScan`, `TestCatchUpV3AfterCheckpointRingReuse`, `TestCatchUpV3ScanOverlappingCheckpointReuseIsRecycled` (tag `swblock_format_v3_test`) | — | STUB | | `INV-WAL-V3-BINDING-001` | Every record and padding the v3 writer emits carries the selected nonce and its own absolute logical cursor and fits within WALSize of the both-slot reuse floor; an append that does not fit is refused. | M1 Recovering | `core/storage/wal_io_v3.go` `walWriterV3.append`, `walSnapshotV3` | `TestWALIOV3_RealWriterReopenScan`, `TestWALIOV3_WrapPaddingAndSlack`, `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`) | Record/lap admission is abstracted in composed WALFormatR5; physical framing/wrap boundaries remain code-test obligations | ACTIVE | | `INV-WAL-V3-SCAN-BINDING-001` | The v3 scanner checks a record's nonce and exact expected cursor before it uses the record's Length or count, and trusts the record only after the whole record validates again. | M1 Recovering | `core/storage/wal_io_v3.go` `scanWALV3Accepted` | `TestWALIOV3_StopsAtBindingBeforeEmbeddedRecord`, `TestWALIOV3_EmbeddedRecordInPayloadIsNotScanned` (`core/storage/wal_io_v3_test.go`) | — | STUB | From f5eab654a5952ae797dd3e38e8faba43190727cc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:40:19 -0800 Subject: [PATCH 008/204] test: reproduce expired startup under real systemd restart policy --- .../startup_systemd_integration_test.go | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go new file mode 100644 index 0000000000..c5686ce13d --- /dev/null +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -0,0 +1,256 @@ +//go:build linux && subprocess && chunkstore_integration && systemd_integration + +package main_test + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "net/http" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +// Real systemd owns every restart. No test goroutine relaunches the holder. +// The first assertion is RED on GAP-1: the expired startup stays alive. +func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { + if os.Getenv("GAP1_SYSTEMD_AUTHORIZED") != "1" { + t.Fatal("explicit booked WSL systemd qualification required; no skip counts as proof") + } + if os.Geteuid() != 0 { + t.Fatal("systemd qualification needs the booked root harness") + } + if os.Getenv("CHUNKSTORE_WEED") == "" { + t.Fatal("real CHUNKSTORE_WEED binary required") + } + if out, err := exec.Command("systemctl", "show", "--property=Version").CombinedOutput(); err != nil { + t.Fatalf("real systemd unavailable: %v %s", err, out) + } + root := t.TempDir() + bin := filepath.Join(root, "bin") + if err := os.Mkdir(bin, 0755); err != nil { + t.Fatal(err) + } + for _, name := range []string{"blockvolume", "blockmaster"} { + cmd := exec.Command("go", "build", "-p", "4", "-o", filepath.Join(bin, name), "../"+name) + if out, err := cmd.CombinedOutput(); err != nil { + t.Fatalf("real binary build: %v %s", err, out) + } + } + cluster := startWorkspaceWeed(t) + stem := fmt.Sprintf("codex03-gap1-%d", time.Now().UnixNano()) + volume := stem + base := "/" + stem + masterAddr := leaseBinaryAddress(t) + dataAddr, ctrlAddr, statusAddr, nvmeAddr := leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t) + cfg := fmt.Sprintf("nodes:\n - server_id: s1\n data_addr: %s\n ctrl_addr: %s\nvolumes:\n - id: %s\n size_bytes: 262144\n replication_factor: 1\n placements:\n - server_id: s1\n replica_id: r1\n source: existing_replica\n", dataAddr, ctrlAddr, volume) + spec := filepath.Join(root, "cluster.yaml") + if err := os.WriteFile(spec, []byte(cfg), 0600); err != nil { + t.Fatal(err) + } + startGAP1Unit(t, stem+"-master", false, filepath.Join(bin, "blockmaster"), + "--listen", masterAddr, "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), + "--cluster-spec", spec, "--lifecycle-product-loop-interval", "200ms", "--expected-slots-per-volume", "1", + "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+base) + w4WaitTCP(t, masterAddr, 20*time.Second) + conn, err := grpc.NewClient(masterAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = conn.Close() }) + ws := control.NewWorkspaceServiceClient(conn) + args := []string{"--master", masterAddr, "--server-id", "s1", "--volume-id", volume, "--replica-id", "r1", + "--data-addr", dataAddr, "--ctrl-addr", ctrlAddr, "--heartbeat-interval", "200ms", "--t1-readiness", "--status-addr", statusAddr, + "--durable-root", filepath.Join(root, "store"), "--durable-impl", "walstore-chunk", "--durable-blocks", "64", + "--chunk-filer", cluster.filerGRPC, "--chunk-path", base, "--chunk-control-endpoint", "--workspace-lease", + "--nvme-listen", nvmeAddr, "--nvme-subsysnqn", "nqn.2026-11.test:" + stem} + // Bootstrap is a different, non-restarting unit. Kill only this exact unit. + bootstrap := stem + "-bootstrap" + startGAP1Unit(t, bootstrap, false, filepath.Join(bin, "blockvolume"), args...) + waitGAP1(t, "bootstrap did not attach under a real lease", 60*time.Second, func() bool { return gap1Operational(t, statusAddr, volume) }) + remote := cluster.remote(t, base+"/"+volume) + before, err := remote.GetHead(context.Background()) + if err != nil || before.Gen == 0 { + t.Fatalf("bootstrap HEAD: %+v %v", before, err) + } + gap1Systemctl(t, "kill", "--signal=KILL", "--kill-whom=main", bootstrap) + waitGAP1(t, "bootstrap still running", 10*time.Second, func() bool { return gap1Unit(t, bootstrap)["MainPID"] == "0" }) + // QueryWorkspace is read-only. Do not renew or advance a fake master clock. + waitGAP1(t, "holder's reported validity never lapsed", 60*time.Second, func() bool { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + s, e := ws.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: volume}) + if e != nil || s.GetLease() == nil { + return false + } + t.Logf("captured master lease: %s", s.String()) + return s.Lease.ValidForNs <= 0 + }) + unit := stem + "-returning" + startGAP1Unit(t, unit, true, filepath.Join(bin, "blockvolume"), args...) + firstPID := gap1Unit(t, unit)["MainPID"] + if firstPID == "0" { + t.Fatal("returning unit did not start a real process") + } + // Existing assignment wait is30s. This is an outer failed-run guard, not + // an injected success delay or a replacement product deadline. + waitGAP1(t, "GAP-1: first startup never exited75; stayed alive non-serving", 45*time.Second, func() bool { + s := gap1Unit(t, unit) + if s["ExecMainStatus"] == "75" { + return true + } + if s["MainPID"] != "0" && s["MainPID"] != firstPID { + t.Fatalf("restart without captured75: %+v", s) + } + return false + }) + waitGAP1(t, "systemd did not restart/regrant/attach", 100*time.Second, func() bool { + s := gap1Unit(t, unit) + n, e := strconv.Atoi(s["NRestarts"]) + if e != nil { + t.Fatalf("invalid captured NRestarts: %+v", s) + } + if n > 2 { + t.Fatalf("barrier retry exceeded three total launches: %+v", s) + } + return n >= 1 && s["MainPID"] != "0" && s["MainPID"] != firstPID && gap1Operational(t, statusAddr, volume) + }) + after, err := remote.GetHead(context.Background()) + if err != nil || after.Gen <= before.Gen || after.Holder != before.Holder || after.Epoch != before.Epoch { + t.Fatalf("return did not claim HEAD: before%+v after%+v err%v", before, after, err) + } + // A real control cut must pass the lease and layer gates after restart. + req, err := http.NewRequest(http.MethodPost, "http://"+statusAddr+"/chunk/cut", bytes.NewBufferString(fmt.Sprintf(`{"volumeID":%q,"timeoutMs":3000}`, volume))) + if err != nil { + t.Fatal(err) + } + resp, err := (&http.Client{Timeout: 5 * time.Second}).Do(req) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + t.Fatalf("post-regrant real cut status%d", resp.StatusCode) + } + s := gap1Unit(t, unit) + if s["Result"] == "start-limit-hit" { + t.Fatalf("systemd rate limit hit: %+v", s) + } +} + +func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ...string) { + t.Helper() + policy := "no" + if restart { + policy = "on-failure" + } + cmdArgs := []string{"--unit=" + unit, "--property=Type=exec", "--property=Restart=" + policy, "--property=RestartSec=5s", "--property=RestartPreventExitStatus=78", "--property=TimeoutStopSec=10s", "--property=StartLimitIntervalSec=10s", "--property=StartLimitBurst=5", "--", exe} + cmdArgs = append(cmdArgs, args...) + ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + defer cancel() + out, err := exec.CommandContext(ctx, "systemd-run", cmdArgs...).CombinedOutput() + if err != nil { + t.Fatalf("systemd-run %s: %v %s", unit, err, out) + } + t.Cleanup(func() { + // Capture before stopping; never remove a run root owned by another run. + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + log, _ := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=short-monotonic").CombinedOutput() + cancel() + t.Logf("real unit %s journal:\n%s", unit, log) + ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) + _, err := exec.CommandContext(ctx, "systemctl", "stop", unit).CombinedOutput() + cancel() + if err != nil { + ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) + _ = exec.CommandContext(ctx, "systemctl", "kill", "--signal=KILL", unit).Run() + cancel() + t.Errorf("unit stop required kill: %s", unit) + } + ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) + _ = exec.CommandContext(ctx, "systemctl", "reset-failed", unit).Run() + cancel() + }) +} +func gap1Systemctl(t *testing.T, args ...string) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + if out, err := exec.CommandContext(ctx, "systemctl", args...).CombinedOutput(); err != nil { + t.Fatalf("systemctl: %v %s", err, out) + } +} +func gap1Unit(t *testing.T, unit string) map[string]string { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic").CombinedOutput() + if err != nil { + t.Fatalf("unit show: %v %s", err, b) + } + m := map[string]string{} + for _, l := range strings.Split(strings.TrimSpace(string(b)), "\n") { + k, v, ok := strings.Cut(l, "=") + if ok { + m[k] = v + } + } + for _, key := range []string{"MainPID", "NRestarts", "ExecMainStatus", "Result", "ExecMainStartTimestampMonotonic"} { + if _, ok := m[key]; !ok { + t.Fatalf("captured systemd response lacks %s: %s", key, b) + } + } + t.Logf("captured unit %s: %s", unit, strings.TrimSpace(string(b))) + return m +} +func gap1Operational(t *testing.T, addr, volume string) bool { + t.Helper() + r, e := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status/durable?volume=" + volume) + if e != nil { + return false + } + defer r.Body.Close() + var body struct { + Volumes []durable.VolumeStatus `json:"volumes"` + } + if r.StatusCode != http.StatusOK { + return false + } + if e = json.NewDecoder(r.Body).Decode(&body); e != nil { + return false + } + for _, v := range body.Volumes { + if v.VolumeID == volume { + return v.Operational && v.Chunk != nil && v.Chunk.Attached && !v.Chunk.Fenced + } + } + return false +} +func waitGAP1(t *testing.T, what string, bound time.Duration, ready func() bool) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), bound) + defer cancel() + tick := time.NewTicker(200 * time.Millisecond) + defer tick.Stop() + for { + if ready() { + return + } + select { + case <-ctx.Done(): + t.Fatal(what) + case <-tick.C: + } + } +} From 45e24335da93c3e4113cf869b6eb676e6b84aae3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:42:00 -0800 Subject: [PATCH 009/204] test: anchor lapse fixture to master expiry and captured status --- .../startup_systemd_integration_test.go | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index c5686ce13d..38d20bb177 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "fmt" + "io" "net/http" "os" "os/exec" @@ -79,6 +80,17 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { bootstrap := stem + "-bootstrap" startGAP1Unit(t, bootstrap, false, filepath.Join(bin, "blockvolume"), args...) waitGAP1(t, "bootstrap did not attach under a real lease", 60*time.Second, func() bool { return gap1Operational(t, statusAddr, volume) }) + // Calibrate verdict parsing against actual binary responses BEFORE kill. + status, payload, err := gap1Status(statusAddr, volume) + t.Logf("captured real status200: status%d body%s", status, payload) + if err != nil || !gap1StatusOperational(status, payload, volume) { + t.Fatalf("real status200 parser control: %v", err) + } + missing, body404, err := gap1Status(statusAddr, volume+"-not-served") + t.Logf("captured real status404: status%d body%s", missing, body404) + if err != nil || missing != http.StatusNotFound || gap1StatusOperational(missing, body404, volume) { + t.Fatalf("real status404 parser control: %v", err) + } remote := cluster.remote(t, base+"/"+volume) before, err := remote.GetHead(context.Background()) if err != nil || before.Gen == 0 { @@ -86,7 +98,10 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { } gap1Systemctl(t, "kill", "--signal=KILL", "--kill-whom=main", bootstrap) waitGAP1(t, "bootstrap still running", 10*time.Second, func() bool { return gap1Unit(t, bootstrap)["MainPID"] == "0" }) - // QueryWorkspace is read-only. Do not renew or advance a fake master clock. + // QueryWorkspace is read-only. These real binaries and this test share + // one WSL kernel wall clock. Use the reported MASTER expiry timestamp, + // not ValidForNs (which ends half a skew earlier and could renew live). + // No product barrier formula or fake master clock is introduced. waitGAP1(t, "holder's reported validity never lapsed", 60*time.Second, func() bool { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() @@ -95,11 +110,13 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { return false } t.Logf("captured master lease: %s", s.String()) - return s.Lease.ValidForNs <= 0 + return s.Lease.ValidForNs <= 0 && time.Now().UnixNano() >= s.Lease.ExpiresAtNs }) unit := stem + "-returning" startGAP1Unit(t, unit, true, filepath.Join(bin, "blockvolume"), args...) - firstPID := gap1Unit(t, unit)["MainPID"] + first := gap1Unit(t, unit) + t.Logf("captured effective restart policy: %+v", first) + firstPID := first["MainPID"] if firstPID == "0" { t.Fatal("returning unit did not start a real process") } @@ -107,6 +124,9 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { // an injected success delay or a replacement product deadline. waitGAP1(t, "GAP-1: first startup never exited75; stayed alive non-serving", 45*time.Second, func() bool { s := gap1Unit(t, unit) + if gap1Operational(t, statusAddr, volume) { + t.Fatal("fixture returned before the expired-grant barrier: cannot count this as a startup-timeout red") + } if s["ExecMainStatus"] == "75" { return true } @@ -195,7 +215,7 @@ func gap1Unit(t *testing.T, unit string) map[string]string { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic").CombinedOutput() + b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec").CombinedOutput() if err != nil { t.Fatalf("unit show: %v %s", err, b) } @@ -214,20 +234,21 @@ func gap1Unit(t *testing.T, unit string) map[string]string { t.Logf("captured unit %s: %s", unit, strings.TrimSpace(string(b))) return m } -func gap1Operational(t *testing.T, addr, volume string) bool { - t.Helper() +func gap1Status(addr, volume string) (int, []byte, error) { r, e := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status/durable?volume=" + volume) if e != nil { - return false + return 0, nil, e } defer r.Body.Close() - var body struct { - Volumes []durable.VolumeStatus `json:"volumes"` - } - if r.StatusCode != http.StatusOK { + body, e := io.ReadAll(io.LimitReader(r.Body, 1<<20)) + return r.StatusCode, body, e +} +func gap1StatusOperational(status int, payload []byte, volume string) bool { + if status != http.StatusOK { return false } - if e = json.NewDecoder(r.Body).Decode(&body); e != nil { + var body struct{ Volumes []durable.VolumeStatus } + if json.Unmarshal(payload, &body) != nil { return false } for _, v := range body.Volumes { @@ -237,6 +258,11 @@ func gap1Operational(t *testing.T, addr, volume string) bool { } return false } +func gap1Operational(t *testing.T, addr, volume string) bool { + t.Helper() + status, payload, e := gap1Status(addr, volume) + return e == nil && gap1StatusOperational(status, payload, volume) +} func waitGAP1(t *testing.T, what string, bound time.Duration, ready func() bool) { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), bound) From 42e8491478d7524806415c6e9e92967109af5fb5 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:49:16 -0800 Subject: [PATCH 010/204] test: expose the exhausted chunk assignment wait to its process owner --- .../durable/provider_startup_outcome_test.go | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 seaweed-block/core/frontend/durable/provider_startup_outcome_test.go diff --git a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go new file mode 100644 index 0000000000..c476da0133 --- /dev/null +++ b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go @@ -0,0 +1,58 @@ +package durable_test + +import ( + "context" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// INV-WS-STARTUP-RETRY-001: a bounded authority wait must expose a latched +// outcome to its process owner, rather than merely leaving status not-ready. +func TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome(t *testing.T) { + logs := &lockedLog{} + captureWriteLogs(t, logs) + v := &arrivingAssignment{seen: make(chan struct{}), assigned: make(chan struct{})} + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, + BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: time.Millisecond, + ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { + t.Error("remote reached without authority") + return storage.NewMemChunkRemote(), nil + }, + }, v) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = p.Close() }) + if _, err := p.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + v.active.Store(true) + if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil { + t.Fatal(err) + } + waitLog(t, logs, "assignment unavailable, not serving") + outcomes, ok := any(p).(interface{ ChunkStartupOutcome(string) (uint64, bool) }) + if !ok { + t.Fatal("assignment wait ended without a process-owner outcome; process stays up forever") + } + gen, failed := outcomes.ChunkStartupOutcome("v1") + if !failed || gen != 1 { + t.Fatalf("timeout outcome = generation %d, failed %v; want current generation 1", gen, failed) + } + if again, ok := outcomes.ChunkStartupOutcome("v1"); !ok || again != gen { + t.Fatal("outcome was consumed rather than latched") + } + if _, ok := outcomes.ChunkStartupOutcome("other"); ok { + t.Fatal("outcome escaped its volume") + } + if err := p.Close(); err != nil { + t.Fatal(err) + } + if _, ok := outcomes.ChunkStartupOutcome("v1"); ok { + t.Fatal("closed provider retained an actionable outcome") + } +} From 5d730c1ecc752a367d7a3ea76bb0c6861b7512b4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:52:54 -0800 Subject: [PATCH 011/204] fix: latch exhausted workspace startup and bound process retry exit --- seaweed-block/cmd/blockvolume/main.go | 32 ++-- seaweed-block/cmd/blockvolume/process_exit.go | 143 ++++++++++++++++++ .../cmd/blockvolume/process_exit_test.go | 73 +++++++++ .../core/frontend/durable/provider.go | 24 +-- .../core/frontend/durable/provider_chunk.go | 6 + .../core/frontend/durable/provider_startup.go | 32 ++++ .../durable/provider_startup_internal_test.go | 24 +++ .../core/host/volume/workspace_lease.go | 6 +- .../core/host/volume/workspace_runtime.go | 12 ++ seaweed-block/deploy/config/blockmaster.env | 7 +- .../systemd/sw-blockvolume-ublk.service | 1 + .../deploy/systemd/sw-blockvolume.service | 1 + .../docs/design/agent-workspace-design.md | 14 ++ seaweed-block/docs/design/invariants.md | 6 +- 14 files changed, 343 insertions(+), 38 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/process_exit.go create mode 100644 seaweed-block/cmd/blockvolume/process_exit_test.go create mode 100644 seaweed-block/core/frontend/durable/provider_startup.go create mode 100644 seaweed-block/core/frontend/durable/provider_startup_internal_test.go diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 73f0176fd2..7dc91a37d7 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -13,12 +13,10 @@ import ( "net" "os" "os/exec" - "os/signal" "path/filepath" "runtime/debug" "strconv" "strings" - "syscall" "time" "github.com/seaweedfs/seaweed-block/core/adapter" @@ -584,7 +582,7 @@ func durableCreateGeometry(f flags) (uint32, int, error) { return uint32(f.durableBlocks), int(f.durableBlockSize), nil } -func run(f flags) int { +func runVolume(f flags, exits *processExit) int { // Diagnostics first: parseFlags validated the directory, and nothing // has been activated yet, so a failure here leaves nothing to clean up. stopProfile, err := startCPUProfileSignal(f.cpuProfileDir) @@ -719,6 +717,9 @@ func run(f flags) int { return 1 } durableProv = dp + watchCtx, stopWatch := context.WithCancel(exits.parent) + defer stopWatch() + go watchChunkStartup(watchCtx, exits, f, h, dp) provider = dp if status != nil { status.SetDurableStatusSource(dp) @@ -772,7 +773,7 @@ func run(f flags) int { return 1 case durableStartupFaulted: fmt.Fprintln(os.Stderr, "blockvolume: durable recovery failed:", evidence) - return waitFaultedDurableRecovery(h, status, durableProv, evidence) + return waitFaultedDurableRecovery(exits.done, h, status, durableProv, evidence) default: fmt.Fprintln(os.Stderr, "blockvolume: durable recovered:", evidence) } @@ -1245,25 +1246,13 @@ func run(f flags) int { }) } - shutdownCtx, stopSignals := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) - defer stopSignals() + shutdownCtx := exits.parent var leaseRequests <-chan workspaceStopRequest var leaseDone <-chan error if f.workspaceLease { leaseRequests, leaseDone = startWorkspaceLease(shutdownCtx, h) } - var leaseStop *workspaceStopRequest - select { - case <-shutdownCtx.Done(): - case request := <-leaseRequests: - // The lease guard fenced and asks for the drain; it logs its cause as - // "workspace lease: fenced ...". Say here that this is why we stop (#205). - fmt.Fprintln(os.Stderr, "blockvolume: stopping: the workspace lease guard fenced and requested the drain") - leaseStop = &request - case err := <-leaseDone: - fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) - leaseDone = nil - } + leaseStop, leaseDone := waitWorkspaceStop(exits, f, h, leaseRequests, leaseDone) // The main goroutine owns shutdown. The lease callback waits for this // exact drain; it cannot ACK a merely requested or failed close. h.FenceWorkspaceLease() @@ -1477,12 +1466,9 @@ func rdmaBindAddressFact(listen string) volume.FrontendTransportPreflightFact { return volume.FrontendTransportPreflightFact{Name: "rdma_bind_address", Available: true, Reason: "rdma_bind_address_candidate", Detail: host} } -func waitFaultedDurableRecovery(h *volume.Host, status *volume.StatusServer, durableProv *durable.DurableProvider, evidence string) int { +func waitFaultedDurableRecovery(stop <-chan struct{}, h *volume.Host, status *volume.StatusServer, durableProv *durable.DurableProvider, evidence string) int { fmt.Fprintln(os.Stderr, "blockvolume: durable recovery faulted; status endpoint remains available and local readiness remains blocked:", evidence) - sig := make(chan os.Signal, 1) - signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM) - <-sig - signal.Stop(sig) + <-stop if durableProv != nil { _ = durableProv.Close() diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go new file mode 100644 index 0000000000..29ee1e8497 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -0,0 +1,143 @@ +package main + +import ( + "context" + "fmt" + "os" + "os/signal" + "sync" + "syscall" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/host/volume" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" +) + +const ( + exitWorkspaceRetry = 75 + exitWorkspaceSuperseded = 78 +) + +type workspaceExit struct { + code int + reason string +} + +// INV-WS-STARTUP-RETRY-001: the first outcome is immutable. The channel is a +// single latched wakeup, not a queue of competing shutdown events. +type processExit struct { + parent context.Context + once sync.Once + done chan struct{} + outcome workspaceExit +} + +func newProcessExit(ctx context.Context) *processExit { + return &processExit{parent: ctx, done: make(chan struct{})} +} +func (e *processExit) choose(out workspaceExit) { + e.once.Do(func() { + if e.parent.Err() != nil { + out = workspaceExit{reason: "signal"} + } + e.outcome = out + close(e.done) + }) +} + +// The original resource owner still drains everything. This outer process +// owner bounds even a stuck Close or deferred cleanup; main alone calls Exit. +func run(f flags) int { + ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + defer stop() + return superviseProcess(ctx, func(e *processExit) int { return runVolume(f, e) }) +} + +func superviseProcess(ctx context.Context, work func(*processExit) int) int { + e := newProcessExit(ctx) + finished := make(chan int, 1) + go func() { finished <- work(e) }() + select { + case code := <-finished: + select { + case <-e.done: + return reportWorkspaceExit(e.outcome) + default: + return code + } + case <-ctx.Done(): + e.choose(workspaceExit{reason: "signal"}) + case <-e.done: + } + if e.outcome.code == 0 { + return <-finished + } + timer := time.NewTimer(volume.WorkspaceDrainTimeout) + defer timer.Stop() + return finishWorkspaceExit(e.outcome, finished, timer.C) +} + +func finishWorkspaceExit(out workspaceExit, finished <-chan int, deadline <-chan time.Time) int { + select { + case <-finished: + case <-deadline: + } + return reportWorkspaceExit(out) +} + +func reportWorkspaceExit(out workspaceExit) int { + if out.code != 0 { + fmt.Fprintf(os.Stderr, "blockvolume: exiting status=%d reason=%s\n", out.code, out.reason) + } + return out.code +} + +// Only a positive, volume-specific other-replica fact permits no-retry. A +// higher epoch for the same replica must restart for the new assignment. +func workspaceRetryOutcome(volumeID, replicaID, reason string, other *control.AssignmentFact) workspaceExit { + if other != nil && other.VolumeId == volumeID && other.ReplicaId != "" && other.ReplicaId != replicaID { + return workspaceExit{exitWorkspaceSuperseded, "superseded"} + } + return workspaceExit{exitWorkspaceRetry, reason} +} + +func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.Host, p *durable.DurableProvider) { + if !f.workspaceLease || f.durableImpl != "walstore-chunk" { + return + } + for { + if _, failed := p.ChunkStartupOutcome(f.volumeID); failed { + e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "assignment_timeout", h.LastOtherLine())) + return + } + select { + case <-ctx.Done(): + return + case <-e.done: + return + case <-p.ChunkStartupUpdates(): + } + } +} + +func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan workspaceStopRequest, done <-chan error) (*workspaceStopRequest, <-chan error) { + select { + case <-e.parent.Done(): + e.choose(workspaceExit{reason: "signal"}) + return nil, done + case <-e.done: + return nil, done + case request := <-requests: + out := workspaceExit{reason: "revoked"} + if !h.WorkspaceLeaseRevoking() { + out = workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine()) + } + e.choose(out) + return &request, done + case err := <-done: + fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) + e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine())) + return nil, nil + } +} diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go new file mode 100644 index 0000000000..7a570a7ae0 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -0,0 +1,73 @@ +package main + +import ( + "context" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "testing" + "time" +) + +func TestWorkspaceRetryNeedsPositiveOtherReplica(t *testing.T) { + for _, tc := range []struct { + name string + fact *control.AssignmentFact + code int + }{ + {"absent", nil, 75}, + {"same replica higher epoch", &control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 99}, 75}, + {"another volume", &control.AssignmentFact{VolumeId: "other", ReplicaId: "other"}, 75}, + {"empty holder", &control.AssignmentFact{VolumeId: "v"}, 75}, + {"other replica", &control.AssignmentFact{VolumeId: "v", ReplicaId: "other"}, 78}, + } { + t.Run(tc.name, func(t *testing.T) { + out := workspaceRetryOutcome("v", "r", "assignment_timeout", tc.fact) + if out.code != tc.code { + t.Fatalf("outcome=%+v want %d", out, tc.code) + } + }) + } +} + +func TestWorkspaceExitFirstOutcomeIsLatched(t *testing.T) { + for _, first := range []workspaceExit{{75, "lease_expired"}, {78, "superseded"}, {0, "revoked"}} { + e := newProcessExit(context.Background()) + e.choose(first) + e.choose(workspaceExit{75, "assignment_timeout"}) + <-e.done + if e.outcome != first { + t.Fatalf("first=%+v changed to %+v", first, e.outcome) + } + } + ctx, cancel := context.WithCancel(context.Background()) + cancel() + e := newProcessExit(ctx) + e.choose(workspaceExit{78, "superseded"}) + if e.outcome.code != 0 || e.outcome.reason != "signal" { + t.Fatalf("observed signal lost: %+v", e.outcome) + } +} + +func TestWorkspaceExitDoesNotWaitForBlockedFrontendClose(t *testing.T) { + finished := make(chan int) // a frontend Close that never returns + deadline := make(chan time.Time, 1) + deadline <- time.Time{} + if code := finishWorkspaceExit(workspaceExit{75, "lease_expired"}, finished, deadline); code != 75 { + t.Fatalf("code=%d", code) + } + // Cleanup errors do not overwrite an already selected retry/no-retry status. + done := make(chan int, 1) + done <- 1 + if code := finishWorkspaceExit(workspaceExit{78, "superseded"}, done, make(chan time.Time)); code != 78 { + t.Fatalf("code=%d", code) + } +} + +func TestWorkspacePlannedStopKeepsSuccess(t *testing.T) { + code := superviseProcess(context.Background(), func(e *processExit) int { + e.choose(workspaceExit{reason: "revoked"}) + return 0 // the close/ACK owner completed normally + }) + if code != 0 { + t.Fatalf("planned stop would restart: %d", code) + } +} diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 83aa2241ad..d5b282877c 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -233,10 +233,11 @@ type DurableProvider struct { cfg ProviderConfig view frontend.ProjectionView - mu sync.Mutex - volumes map[string]*volHandle // keyed by volumeID - opening map[string]*sync.Mutex // keyed by volumeID; serializes open/create - closed bool + mu sync.Mutex + volumes map[string]*volHandle // keyed by volumeID + opening map[string]*sync.Mutex // keyed by volumeID; serializes open/create + closed bool + startupUpdates chan struct{} // wake only; the generation-bound result stays on the handle // testAfterChunkResolve, test-only, runs in CutVolume right after the // volume's handle and layer are resolved. @@ -286,6 +287,7 @@ type volHandle struct { // latest recovery's. recoverGen uint64 waitGen uint64 + startupEnded uint64 // recovery generation with a terminal startup outcome; guarded by p.mu chunk storage.ChunkLayer // after RecoverVolume chunkLineage chunkLineage // immutable authority captured by this attachment // Private until the owner commit succeeds; retained for attach retry. @@ -392,12 +394,13 @@ func NewDurableProvider(cfg ProviderConfig, view frontend.ProjectionView) (*Dura } closeCtx, closeCancel := context.WithCancel(context.Background()) return &DurableProvider{ - cfg: cfg, - view: view, - volumes: map[string]*volHandle{}, - opening: map[string]*sync.Mutex{}, - closeCtx: closeCtx, - closeCancel: closeCancel, + cfg: cfg, + view: view, + volumes: map[string]*volHandle{}, + opening: map[string]*sync.Mutex{}, + closeCtx: closeCtx, + closeCancel: closeCancel, + startupUpdates: make(chan struct{}, 1), }, nil } @@ -947,6 +950,7 @@ func (p *DurableProvider) RecoverVolume(ctx context.Context, volumeID string) (R p.mu.Lock() h.recoverGen++ // any earlier recovery's authority wait is now stale gen = h.recoverGen + h.startupEnded = 0 p.mu.Unlock() } report := Recover(h.storage, volumeID) diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 7018eb0363..706be6bcf1 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -124,6 +124,9 @@ func (p *DurableProvider) recoverChunk(ctx context.Context, volumeID string, h * p.startChunkAuthorityWait(volumeID, h, gen) return false, nil } + if errors.Is(err, storage.ErrChunkLayerFenced) && !errors.Is(err, ErrChunkStaleLocalRoot) { + p.endChunkStartup(h, gen) + } return err == nil, err } @@ -173,6 +176,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen if p.current(h, gen) && h.chunk == nil { ended = fmt.Sprintf("assignment unavailable, not serving (projection lacks %s)", chunkAuthorityGap(p.view.Projection(), volumeID)) h.backend.SetOperational(false, "chunk assignment unavailable: "+waitCtx.Err().Error()) + p.endChunkStartup(h, gen) } }() defer func() { @@ -237,6 +241,8 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen h.backend.SetOperational(false, "chunk layer attach refused: "+err.Error()) } h.attachMu.Unlock() + } else { + p.endChunkStartup(h, gen) } return case errors.Is(err, errChunkNoAuthority): diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go new file mode 100644 index 0000000000..7efc2b75af --- /dev/null +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -0,0 +1,32 @@ +package durable + +// ChunkStartupUpdates wakes the process owner when a startup wait ends. It is +// not an event queue: the owner must read ChunkStartupOutcome for its volume. +// INV-WS-STARTUP-RETRY-001 keeps stale recoveries from terminating a newer one. +func (p *DurableProvider) ChunkStartupUpdates() <-chan struct{} { return p.startupUpdates } + +// ChunkStartupOutcome is a latched, generation-bound startup failure. A new +// recovery or Close invalidates it; reading it does not consume it. It grants +// no assignment and makes no claim about whether this holder was superseded. +func (p *DurableProvider) ChunkStartupOutcome(volumeID string) (uint64, bool) { + p.mu.Lock() + defer p.mu.Unlock() + h := p.volumes[volumeID] + if p.closed || h == nil || h.startupEnded == 0 || h.startupEnded != h.recoverGen { + return 0, false + } + return h.startupEnded, true +} + +func (p *DurableProvider) endChunkStartup(h *volHandle, gen uint64) { + p.mu.Lock() + defer p.mu.Unlock() + if p.closed || gen != h.recoverGen || h.startupEnded != 0 { + return + } + h.startupEnded = gen + select { + case p.startupUpdates <- struct{}{}: + default: + } +} diff --git a/seaweed-block/core/frontend/durable/provider_startup_internal_test.go b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go new file mode 100644 index 0000000000..6d747b639d --- /dev/null +++ b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go @@ -0,0 +1,24 @@ +package durable + +import "testing" + +func TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake(t *testing.T) { + h := &volHandle{recoverGen: 1} + p := &DurableProvider{volumes: map[string]*volHandle{"v": h}, startupUpdates: make(chan struct{}, 1)} + p.endChunkStartup(h, 1) + h.recoverGen = 2 + h.startupEnded = 0 // RecoverVolume invalidates the old generation under p.mu. + p.endChunkStartup(h, 1) + if _, ok := p.ChunkStartupOutcome("v"); ok { + t.Fatal("stale wait ended the new recovery") + } + p.endChunkStartup(h, 2) // full wake channel must not discard the current latched result + <-p.ChunkStartupUpdates() + if gen, ok := p.ChunkStartupOutcome("v"); !ok || gen != 2 { + t.Fatalf("current result lost: %d %v", gen, ok) + } + p.endChunkStartup(h, 1) + if gen, ok := p.ChunkStartupOutcome("v"); !ok || gen != 2 { + t.Fatal("late old completion overwrote the current result") + } +} diff --git a/seaweed-block/core/host/volume/workspace_lease.go b/seaweed-block/core/host/volume/workspace_lease.go index 3a829129a8..339cfc1383 100644 --- a/seaweed-block/core/host/volume/workspace_lease.go +++ b/seaweed-block/core/host/volume/workspace_lease.go @@ -57,6 +57,10 @@ type WorkspaceLeaseGuard struct { // revocation to its ACK also includes that renewal, the drain and the ACK. const stopPendingPoll = 250 * time.Millisecond +// 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 + // StopPending records that a graceful stop of this workspace has begun (the // chunk layer is being detached) and wakes Run to renew at once; while it // stays pending Run sleeps at most stopPendingPoll between renewals. @@ -280,7 +284,7 @@ func (g *WorkspaceLeaseGuard) drainAfterFence(ctx context.Context, err error) er func (g *WorkspaceLeaseGuard) drain(parent context.Context, ack bool) error { if !g.stopped { - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), WorkspaceDrainTimeout) gen, err := g.stop(ctx) cancel() if err != nil { diff --git a/seaweed-block/core/host/volume/workspace_runtime.go b/seaweed-block/core/host/volume/workspace_runtime.go index 13e8d55c15..d6fad91ccf 100644 --- a/seaweed-block/core/host/volume/workspace_runtime.go +++ b/seaweed-block/core/host/volume/workspace_runtime.go @@ -110,3 +110,15 @@ func (h *Host) FenceWorkspaceLease() { g.mu.Unlock() } } + +// WorkspaceLeaseRevoking distinguishes the ACK-owning planned drain from a +// retryable fence without interpreting an error string (M2 Revoking -> Revoked). +func (h *Host) WorkspaceLeaseRevoking() bool { + g := h.view.workspaceGuard.Load() + if g == nil { + return false + } + g.mu.Lock() + defer g.mu.Unlock() + return g.revoked +} diff --git a/seaweed-block/deploy/config/blockmaster.env b/seaweed-block/deploy/config/blockmaster.env index 4c160d497b..3169518dff 100644 --- a/seaweed-block/deploy/config/blockmaster.env +++ b/seaweed-block/deploy/config/blockmaster.env @@ -39,7 +39,8 @@ SWB_MASTER_WORKSPACE_HEAD_BASE_URL= # --workspace-max-clock-skew (default 20s; must be >0 and <60s). Host leases # shorten by half of it; forced moves wait the full bound. SWB_MASTER_WORKSPACE_MAX_CLOCK_SKEW=20s -# Extra blockmaster flags, split on spaces. The --launcher-*, --lifecycle-*, -# --cluster-spec, --failback-runtime-rpc and --frontend-publication-runtime-* -# flags belong to the Kubernetes path and are set by the Helm chart. +# Extra blockmaster flags, split on spaces. +# A standalone workspace volume (lease, planned hand-over) needs --cluster-spec, +# --lifecycle-store and the --workspace-* flags here: see docs/volume-lifecycle.md. +# Kubernetes launcher/runtime flags are configured separately by the Helm chart. SWB_MASTER_EXTRA_ARGS= diff --git a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service index 50a3ca26f8..ee1904fa86 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service @@ -69,6 +69,7 @@ ExecStart=/usr/local/bin/blockvolume \ KillSignal=SIGTERM TimeoutStopSec=30s Restart=on-failure +RestartPreventExitStatus=78 RestartSec=5s NoNewPrivileges=true diff --git a/seaweed-block/deploy/systemd/sw-blockvolume.service b/seaweed-block/deploy/systemd/sw-blockvolume.service index 6cbcb6a6fa..7ad8a3ed5e 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume.service @@ -68,6 +68,7 @@ ExecStart=/usr/local/bin/blockvolume \ KillSignal=SIGTERM TimeoutStopSec=30s Restart=on-failure +RestartPreventExitStatus=78 RestartSec=5s NoNewPrivileges=true diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 7679f68611..cd498ef1bf 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -479,3 +479,17 @@ stateDiagram-v2 ``` Guest I/O never acquires a slot. An unavailable pool skips background cuts; urgent and named seals may use per-process fallback with an alarm. Active coordinated reservations exclude orphaned crash spill. Upload pacing debt survives leases in one process, but a new process starts fresh, so arbitrary process turnover has no fixed host-rate bound. + +### Workspace primary supervisor retry + +A workspace chunk primary that exhausts its existing assignment wait, or whose +lease fences while serving, exits 75 after fail-closed cleanup bounded by the +existing five-second lease-drain limit. systemd restarts on failure with +RestartSec=5s. Only a master fact naming another replica permits exit 78; +RestartPreventExitStatus=78 suppresses automatic restarts until an operator +explicitly starts the unit. A higher epoch for the same replica retries. +An ACKed planned revocation and a signal stop retain their normal exit status. +Sealed same-epoch recovery stays non-serving for seal replay after assignment. +Local-root, WAL-corruption and I/O diagnostics retain their existing wait. +No restart bypasses the master barrier, durable re-grant, or HEAD claim. +See M2 and INV-WS-STARTUP-RETRY-001 in the invariant ledger. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..5921d64e39 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -100,6 +100,7 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current holder/epoch, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a master fact naming another replica exits 78. Revocation ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -410,7 +411,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -303 rows: 217 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. +304 rows: 218 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 289 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -670,7 +671,9 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; only a master fact naming another replica permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryNeedsPositiveOtherReplica`, `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +- `INV-WS-STARTUP-RETRY-001`: exit 78 is an optimisation, permitted only by an observed master fact for this volume naming another replica. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. Notes: - `INV-WS-SINGLE-FILER-001`: the same census runs in every `sw-block ops chunk` command that writes chunk metadata (snapshot-delete, fork, retain, volume-delete, gc --apply), and in verify, which writes nothing but would report false findings against a split filer view, before it reads or writes; other read-only commands and modes do not run it. @@ -942,6 +945,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 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. | | 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. | | Plain seal remote proof | M5 RemoteProof; `INV-WS-SEAL-REPLAY-001` | Earlier caller context or existing 2 s HEAD-operation bound for the filer read; attachment serialization retains its owner's cooperative caller bound | Provider registers with Close; closeBoundRemote cancels the read, and Close joins it. Failure keeps frontend admission closed. | Attachment mutex serializes against recover/detach; no backend/store/map lock spans the filer read. | | Frontend pre-copy admission | M5 tentative admission -> resume; `INV-CUT-PRECOPY-001` (not reachable in this release) | Earlier of caller deadline and this command arrival + 5 s; one bound across retries, no inherited pause clock | Owner `finishPrecopyLocked`: resume or terminal Close clears the pause and grants all waiters in FIFO arrival order under one `b.mu` hold; each rechecks the ordinary gate. Expiry removes only its waiter and refuses with typed `ErrBackendBusy` + deadline cause (guest-visible: yes). Only a typed pause refusal requeues a granted waiter under the original command deadline; already-observed stale-primary and other gate errors are returned unchanged. Grant versus queue expiry is decided under the same lock; timely grants survive later queue-timer expiry but never caller expiry or a terminal gate. No dependency on another command's completion. | No `ioMu`, store lock, or remote call while queued. Admitted I/O retains normal per-LBA serialization and lifecycle accounting. | From 8b4fd25776e81a381d6a9ac235b8f69a826d6e65 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:53:57 -0800 Subject: [PATCH 012/204] fix: preserve acknowledged planned-stop status and witness stuck cleanup exit --- seaweed-block/cmd/blockvolume/main.go | 11 +------- seaweed-block/cmd/blockvolume/process_exit.go | 25 ++++++++++++++++++- .../cmd/blockvolume/process_exit_test.go | 24 ++++++++++++++++++ 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 7dc91a37d7..6ef619b49f 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -1305,16 +1305,7 @@ func runVolume(f flags, exits *processExit) int { } leaseStop.reply <- workspaceStopResult{gen: gen, err: drainErr} } - if leaseDone != nil { - select { - case err := <-leaseDone: - if err != nil { - fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout:", err) - } - case <-time.After(3 * time.Second): - fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout deadline") - } - } + finishWorkspaceLease(exits, f, h, leaseDone) if err := h.Close(); err != nil { fmt.Fprintln(os.Stderr, "blockvolume: close:", err) return 1 diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 29ee1e8497..1c22244168 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -62,6 +62,9 @@ func superviseProcess(ctx context.Context, work func(*processExit) int) int { case code := <-finished: select { case <-e.done: + if e.outcome.code == 0 { + return code + } return reportWorkspaceExit(e.outcome) default: return code @@ -133,7 +136,9 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan if !h.WorkspaceLeaseRevoking() { out = workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine()) } - e.choose(out) + if out.code != 0 { + e.choose(out) + } return &request, done case err := <-done: fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) @@ -141,3 +146,21 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan return nil, nil } } + +// An ACKed revocation completes with status zero. A failure to confirm that +// ACK is retryable; a signal observed first still retains the signal status. +func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan error) { + if done == nil { + return + } + select { + case err := <-done: + if err == nil { + return + } + fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout:", err) + case <-time.After(3 * time.Second): + fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout deadline") + } + e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine())) +} diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go index 7a570a7ae0..7c0d24a8fe 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -2,7 +2,10 @@ package main import ( "context" + "errors" control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "os" + "os/exec" "testing" "time" ) @@ -71,3 +74,24 @@ func TestWorkspacePlannedStopKeepsSuccess(t *testing.T) { t.Fatalf("planned stop would restart: %d", code) } } + +// A real child process contains the stuck resource owner. An injected event +// tests the select above; this witness also covers deferred-cleanup isolation. +func TestWorkspaceRetryProcessExitsWhenCloseBlocks(t *testing.T) { + if os.Getenv("GAP1_BLOCKED_CLOSE_CHILD") == "1" { + code := superviseProcess(context.Background(), func(e *processExit) int { + e.choose(workspaceExit{75, "lease_expired"}) + select {} // the frontend/resource owner's Close never returns + }) + os.Exit(code) + } + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestWorkspaceRetryProcessExitsWhenCloseBlocks$") + cmd.Env = append(os.Environ(), "GAP1_BLOCKED_CLOSE_CHILD=1") + out, err := cmd.CombinedOutput() + var exit *exec.ExitError + if ctx.Err() != nil || !errors.As(err, &exit) || exit.ExitCode() != 75 { + t.Fatalf("blocked close exit: %v %s", err, out) + } +} From d638377ee6117de199d51f23f47ac18c4d363187 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:55:52 -0800 Subject: [PATCH 013/204] test: retain an assigned sealed restart for exact seal replay --- .../durable/provider_startup_outcome_test.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go index c476da0133..b61b3ac534 100644 --- a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go +++ b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go @@ -2,6 +2,7 @@ package durable_test import ( "context" + "reflect" "testing" "time" @@ -56,3 +57,47 @@ func TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome(t *testing.T) { t.Fatal("closed provider retained an actionable outcome") } } + +func TestChunkStartupSealedAssignmentStaysForReplay(t *testing.T) { + logs := &lockedLog{} + captureWriteLogs(t, logs) + ctx := hangGuard(t) + remote := storage.NewMemChunkRemote() + root := t.TempDir() + first := chunkProvider(t, root, remote, v1View(), 0) + openRecovered(t, first) + sealed, _, err := first.DetachVolumePlain(ctx, "v1") + if err != nil { + t.Fatal(err) + } + if err := first.Close(); err != nil { + t.Fatal(err) + } + view := v1View() + assigned := view.Projection() + waiting := assigned + waiting.Epoch = 0 + waiting.Healthy = false + view.set(waiting) + second := chunkProvider(t, root, remote, view, 0) + if _, err := second.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + if _, err := second.RecoverVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + view.set(assigned) + waitLog(t, logs, "sealed assignment, retained for replay") + if _, failed := second.ChunkStartupOutcome("v1"); failed { + t.Fatal("sealed assignment became a process retry") + } + replay, _, err := second.DetachVolumePlain(ctx, "v1") + if err != nil || !reflect.DeepEqual(replay.Head, sealed.Head) { + t.Fatalf("sealed replay changed: %+v %v", replay, err) + } + for _, status := range second.DurableStatuses() { + if status.Operational { + t.Fatal("sealed restart served") + } + } +} From d060e9ab3f50203f44fcc6690f0bf1a0f6bf6dbb Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:59:38 -0800 Subject: [PATCH 014/204] fix: retain sealed startup and atomically choose the current recovery exit --- seaweed-block/cmd/blockvolume/main.go | 1 + seaweed-block/cmd/blockvolume/process_exit.go | 16 ++++++++++++++-- .../core/frontend/durable/provider_chunk.go | 6 ++++++ .../core/frontend/durable/provider_startup.go | 15 +++++++++++++++ .../durable/provider_startup_internal_test.go | 16 ++++++++++++++++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 6ef619b49f..4e58bc784c 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -760,6 +760,7 @@ func runVolume(f flags, exits *processExit) int { // (wal_corrupt / io_error) faults fail-closed and is reported at // once by a primary assignment; see openAndRecoverDurable. outcome, evidence, sErr := openAndRecoverDurable(dp, h, f.volumeID, 10*time.Second) + chooseChunkStartupExit(exits, f, h, dp) switch outcome { case durableStartupFatal: fmt.Fprintln(os.Stderr, "blockvolume: durable storage open:", sErr) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 1c22244168..79e3d673dd 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -110,10 +110,10 @@ func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.H return } for { - if _, failed := p.ChunkStartupOutcome(f.volumeID); failed { - e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "assignment_timeout", h.LastOtherLine())) + if chooseChunkStartupExit(e, f, h, p) { return } + select { case <-ctx.Done(): return @@ -164,3 +164,15 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e } e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine())) } + +func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p *durable.DurableProvider) bool { + if !f.workspaceLease || f.durableImpl != "walstore-chunk" { + return false + } + gen, failed := p.ChunkStartupOutcome(f.volumeID) + if !failed { + return false + } + out := workspaceRetryOutcome(f.volumeID, f.replicaID, "assignment_timeout", h.LastOtherLine()) + return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.choose(out) }) +} diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 706be6bcf1..206d3e5616 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -232,6 +232,12 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen case errors.Is(err, errProviderClosed): ended = "provider closed" return + case errors.Is(err, storage.ErrChunkLayerDetached): + // INV-WS-STARTUP-RETRY-001: an assigned sealed incarnation stays + // non-serving for exact seal replay; restarting cannot unseal it. + ended = "sealed assignment, retained for replay" + h.backend.SetOperational(false, "sealed assignment; replay only") + return case errors.Is(err, storage.ErrChunkLayerFenced): ended = "fenced, not serving" log.Printf("durable: chunk layer for volume=%s: %v (not serving)", volumeID, err) diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go index 7efc2b75af..ff61f0978d 100644 --- a/seaweed-block/core/frontend/durable/provider_startup.go +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -30,3 +30,18 @@ func (p *DurableProvider) endChunkStartup(h *volHandle, gen uint64) { default: } } + +// ChooseChunkStartupExit validates and selects an outcome in one provider-lock +// section, so recovery cannot change generation between observation and choice. +// choose must only latch the process outcome; it must not block or call back +// into the provider. No remote work or resource cleanup belongs in this call. +func (p *DurableProvider) ChooseChunkStartupExit(volumeID string, gen uint64, choose func()) bool { + p.mu.Lock() + defer p.mu.Unlock() + h := p.volumes[volumeID] + if p.closed || h == nil || h.startupEnded != gen || gen == 0 || h.recoverGen != gen { + return false + } + choose() + return true +} diff --git a/seaweed-block/core/frontend/durable/provider_startup_internal_test.go b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go index 6d747b639d..61fff6fdb6 100644 --- a/seaweed-block/core/frontend/durable/provider_startup_internal_test.go +++ b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go @@ -22,3 +22,19 @@ func TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake(t *testing.T) { t.Fatal("late old completion overwrote the current result") } } + +func TestChunkStartupExitRechecksGenerationBeforeChoice(t *testing.T) { + h := &volHandle{recoverGen: 2, startupEnded: 2} + p := &DurableProvider{volumes: map[string]*volHandle{"v": h}} + calls := 0 + if p.ChooseChunkStartupExit("v", 1, func() { calls++ }) || calls != 0 { + t.Fatal("stale observation selected process exit") + } + if !p.ChooseChunkStartupExit("v", 2, func() { calls++ }) || calls != 1 { + t.Fatal("current result was not selectable") + } + p.closed = true + if p.ChooseChunkStartupExit("v", 2, func() { calls++ }) || calls != 1 { + t.Fatal("closed provider selected exit") + } +} From 2170b6449a94063831d99102ab88f9689480c58f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:02:58 -0800 Subject: [PATCH 015/204] test: qualify systemd with the shipped workspace restart policy --- .../startup_systemd_integration_test.go | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 38d20bb177..676e91017c 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -175,7 +175,12 @@ func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ... if restart { policy = "on-failure" } - cmdArgs := []string{"--unit=" + unit, "--property=Type=exec", "--property=Restart=" + policy, "--property=RestartSec=5s", "--property=RestartPreventExitStatus=78", "--property=TimeoutStopSec=10s", "--property=StartLimitIntervalSec=10s", "--property=StartLimitBurst=5", "--", exe} + shipped := gap1ShippedPolicy(t) + cmdArgs := []string{"--unit=" + unit, "--property=Type=exec", "--property=Restart=" + policy, + "--property=RestartSec=" + shipped["RestartSec"], + "--property=RestartPreventExitStatus=" + shipped["RestartPreventExitStatus"], + "--property=TimeoutStopSec=" + shipped["TimeoutStopSec"], + "--property=StartLimitIntervalSec=10s", "--property=StartLimitBurst=5", "--", exe} cmdArgs = append(cmdArgs, args...) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() @@ -280,3 +285,35 @@ func waitGAP1(t *testing.T, what string, bound time.Duration, ready func() bool) } } } + +// The transient unit exercises the shipped restart policy, not an independently +// tuned retry loop. Both deployed frontend variants must carry the same policy. +func gap1ShippedPolicy(t *testing.T) map[string]string { + t.Helper() + var first map[string]string + for _, name := range []string{"sw-blockvolume.service", "sw-blockvolume-ublk.service"} { + raw, err := os.ReadFile(filepath.Join("..", "..", "deploy", "systemd", name)) + if err != nil { + t.Fatal(err) + } + fields := map[string]string{} + for _, line := range strings.Split(string(raw), "\n") { + key, value, ok := strings.Cut(strings.TrimSpace(line), "=") + if ok { + fields[key] = value + } + } + if fields["Restart"] != "on-failure" || fields["RestartPreventExitStatus"] != "78" || fields["RestartSec"] != "5s" { + t.Fatalf("shipped policy changed: %s %+v", name, fields) + } + if first != nil { + for _, key := range []string{"Restart", "RestartSec", "RestartPreventExitStatus", "TimeoutStopSec"} { + if fields[key] != first[key] { + t.Fatalf("unit policies differ at %s", key) + } + } + } + first = fields + } + return first +} From 0d564ec2135ebb971043abe0aacb2329065bb38b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:04:03 -0800 Subject: [PATCH 016/204] test: require recorded revoke ACK and terminal systemd success after planned stop --- .../startup_systemd_integration_test.go | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 676e91017c..e251aaf4cc 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -167,6 +167,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if s["Result"] == "start-limit-hit" { t.Fatalf("systemd rate limit hit: %+v", s) } + gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, after.Holder, s["NRestarts"]) } func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ...string) { @@ -220,7 +221,7 @@ func gap1Unit(t *testing.T, unit string) map[string]string { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec").CombinedOutput() + b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec,ActiveState,SubState").CombinedOutput() if err != nil { t.Fatalf("unit show: %v %s", err, b) } @@ -317,3 +318,53 @@ func gap1ShippedPolicy(t *testing.T) map[string]string { } return first } + +// A successful planned revoke is not a retry outcome. The master's ACK and +// systemd's terminal inactive/dead state prove no automatic restart is queued. +func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClient, unit, addr, volume string, epoch uint64, holder, restarts string) { + t.Helper() + req, err := http.NewRequest(http.MethodPost, "http://"+addr+"/chunk/detach", bytes.NewBufferString(fmt.Sprintf(`{"volumeID":%q,"plain":true,"timeoutMs":5000}`, volume))) + if err != nil { + t.Fatal(err) + } + resp, err := (&http.Client{Timeout: 10 * time.Second}).Do(req) + if err != nil { + t.Fatal(err) + } + body, readErr := io.ReadAll(resp.Body) + _ = resp.Body.Close() + t.Logf("captured plain seal response: status%d body%s", resp.StatusCode, body) + if readErr != nil || resp.StatusCode != http.StatusOK { + t.Fatalf("plain seal: %v status%d", readErr, resp.StatusCode) + } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + _, err = ws.RevokeWorkspace(ctx, &control.WorkspaceIdentity{VolumeId: volume, ReplicaId: holder, Epoch: epoch}) + cancel() + if err != nil { + t.Fatal(err) + } + waitGAP1(t, "planned revoke never recorded ACK and exited normally", 20*time.Second, func() bool { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + status, err := ws.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: volume}) + if err != nil || status.GetRevocationAck() == nil { + return false + } + ack := status.GetRevocationAck() + t.Logf("captured planned-stop ACK: %s", ack.String()) + if ack.GetIdentity().GetVolumeId() != volume || ack.GetIdentity().GetReplicaId() != holder || ack.GetIdentity().GetEpoch() != epoch || ack.GetHeadGen() == 0 { + t.Fatalf("wrong planned ACK: %s", ack.String()) + } + state := gap1Unit(t, unit) + if state["NRestarts"] != restarts { + t.Fatalf("planned stop restarted: %+v", state) + } + if state["MainPID"] != "0" { + return false + } + if state["ExecMainStatus"] != "0" || state["ActiveState"] != "inactive" || state["SubState"] != "dead" { + t.Fatalf("planned stop is not terminal success: %+v", state) + } + return true + }) +} From 41dfb5ec901d913229e04e78b8e65ce1e11a8e5a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:06:21 -0800 Subject: [PATCH 017/204] docs: trace workspace process exits and show supervisor restart lifecycle --- seaweed-block/cmd/blockvolume/main.go | 2 +- seaweed-block/cmd/blockvolume/process_exit.go | 7 ++++++- .../docs/design/agent-workspace-design.md | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 4e58bc784c..65dcfc3e5c 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -1254,7 +1254,7 @@ func runVolume(f flags, exits *processExit) int { leaseRequests, leaseDone = startWorkspaceLease(shutdownCtx, h) } leaseStop, leaseDone := waitWorkspaceStop(exits, f, h, leaseRequests, leaseDone) - // The main goroutine owns shutdown. The lease callback waits for this + // The resource owner performs shutdown. The lease callback waits for this // exact drain; it cannot ACK a merely requested or failed close. h.FenceWorkspaceLease() var drainErr error diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 79e3d673dd..48b79fb064 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -54,6 +54,7 @@ func run(f flags) int { return superviseProcess(ctx, func(e *processExit) int { return runVolume(f, e) }) } +// INV-WS-STARTUP-RETRY-001: M2 process exit owns the cleanup bound. func superviseProcess(ctx context.Context, work func(*processExit) int) int { e := newProcessExit(ctx) finished := make(chan int, 1) @@ -96,7 +97,8 @@ func reportWorkspaceExit(out workspaceExit) int { return out.code } -// Only a positive, volume-specific other-replica fact permits no-retry. A +// INV-WS-STARTUP-RETRY-001: only a positive, volume-specific other-replica +// fact permits no-retry. A // higher epoch for the same replica must restart for the new assignment. func workspaceRetryOutcome(volumeID, replicaID, reason string, other *control.AssignmentFact) workspaceExit { if other != nil && other.VolumeId == volumeID && other.ReplicaId != "" && other.ReplicaId != replicaID { @@ -105,6 +107,7 @@ func workspaceRetryOutcome(volumeID, replicaID, reason string, other *control.As return workspaceExit{exitWorkspaceRetry, reason} } +// M2 startup outcome; INV-WS-STARTUP-RETRY-001. Workspace chunk primaries only. func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.Host, p *durable.DurableProvider) { if !f.workspaceLease || f.durableImpl != "walstore-chunk" { return @@ -124,6 +127,7 @@ func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.H } } +// M2 process exit / Revoking -> Revoked; INV-WS-STARTUP-RETRY-001. func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan workspaceStopRequest, done <-chan error) (*workspaceStopRequest, <-chan error) { select { case <-e.parent.Done(): @@ -149,6 +153,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan // An ACKed revocation completes with status zero. A failure to confirm that // ACK is retryable; a signal observed first still retains the signal status. +// M2 Revoking -> Revoked; INV-WS-REVOKE-ACK-001, INV-WS-STARTUP-RETRY-001. func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan error) { if done == nil { return diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index cd498ef1bf..9eab6ab1b6 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -493,3 +493,19 @@ Sealed same-epoch recovery stays non-serving for seal replay after assignment. Local-root, WAL-corruption and I/O diagnostics retain their existing wait. No restart bypasses the master barrier, durable re-grant, or HEAD claim. See M2 and INV-WS-STARTUP-RETRY-001 in the invariant ledger. + +```mermaid +stateDiagram-v2 + [*] --> AwaitingAssignment + AwaitingAssignment --> Serving: grant and HEAD claim + AwaitingAssignment --> Exit75: assignment wait exhausted + Serving --> Exit75: lease fence + AwaitingAssignment --> Exit78: master names another replica + Serving --> Exit78: lease fence and another-replica fact + Exit75 --> AwaitingAssignment: supervisor starts new process + Exit78 --> AwaitingAssignment: explicit operator start + AwaitingAssignment --> SealedReplay: assigned same-epoch sealed HEAD + SealedReplay --> Exit75: lease fence + SealedReplay --> [*]: signal + Serving --> [*]: revoke ACK or signal +``` From b257486f3ee7c9df82f56b435fcae5359173c659 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:12:21 -0800 Subject: [PATCH 018/204] test: verify flushed NVMe records before and after supervised holder return --- .../startup_nvme_integration_test.go | 179 ++++++++++++++++++ .../startup_systemd_integration_test.go | 10 + 2 files changed, 189 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go diff --git a/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go b/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go new file mode 100644 index 0000000000..247faffe94 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go @@ -0,0 +1,179 @@ +//go:build linux && subprocess && chunkstore_integration && systemd_integration + +package main_test + +import ( + "bytes" + "net" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/nvme" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" +) + +// This small initiator uses the same exported wire types and admin/IO queue +// handshake as core/frontend/nvme/client_support_test.go. It talks only to the +// real blockvolume in this harness; no kernel device or unrelated NQN is used. +type gap1NVMe struct { + admin, io net.Conn + r *nvme.Reader + w *nvme.Writer + cid uint16 +} + +func gap1ConnectNVMe(t *testing.T, addr, nqn string) *gap1NVMe { + t.Helper() + c := &gap1NVMe{} + t.Cleanup(c.close) + var controller uint16 = 0xffff + for q := uint16(0); q < 2; q++ { + conn, err := net.DialTimeout("tcp", addr, 5*time.Second) + if err != nil { + t.Fatal(err) + } + if q == 0 { + c.admin = conn + } else { + c.io = conn + } + _ = conn.SetDeadline(time.Now().Add(10 * time.Second)) + r, w := nvme.NewReader(conn), nvme.NewWriter(conn) + if err := w.SendHeaderOnly(0, &nvme.ICRequest{PDUFormatVersion: 0, PDUMaxR2T: 1}, 120); err != nil { + t.Fatal(err) + } + h, err := r.Dequeue() + if err != nil || h.Type != 1 { + t.Fatalf("NVMe IC response: %+v %v", h, err) + } + var ic nvme.ICResponse + if err := r.Receive(&ic); err != nil { + t.Fatal(err) + } + c.cid++ + cmd := nvme.CapsuleCommand{OpCode: 0x7f, FCType: 1, CID: c.cid, D10: uint32(q) << 16} + data := make([]byte, 1024) + (&nvme.ConnectData{HostID: [16]byte{1, 2, 3, 4}, CNTLID: controller, SubNQN: nqn, HostNQN: "nqn.2026-11.test:gap1-host"}).Marshal(data) + if err := w.SendWithData(4, 0, &cmd, 64, data); err != nil { + t.Fatal(err) + } + reply := gap1NVMeReply(t, r, c.cid) + if q == 0 { + controller = uint16(reply.DW0) + if controller == 0 { + t.Fatal("no controller assigned") + } + } + if q == 1 { + c.r, c.w = r, w + } + } + return c +} + +func (c *gap1NVMe) close() { + if c.io != nil { + _ = c.io.Close() + } + if c.admin != nil { + _ = c.admin.Close() + } +} + +func gap1NVMeReply(t *testing.T, r *nvme.Reader, cid uint16) nvme.CapsuleResponse { + t.Helper() + h, err := r.Dequeue() + if err != nil || h.Type != 5 { + t.Fatalf("NVMe capsule header: %+v %v", h, err) + } + var reply nvme.CapsuleResponse + if err := r.Receive(&reply); err != nil { + t.Fatal(err) + } + if reply.CID != cid || reply.Status != 0 { + t.Fatalf("NVMe CID %d: %+v", cid, reply) + } + return reply +} + +func (c *gap1NVMe) writeFlush(t *testing.T, lba uint64, payload []byte) { + t.Helper() + if len(payload) != 4096 { + t.Fatal("harness writes exactly one block") + } + c.cid++ + cmd := nvme.CapsuleCommand{OpCode: 1, CID: c.cid, NSID: 1, D10: uint32(lba), D11: uint32(lba >> 32)} + if err := c.w.SendHeaderOnly(4, &cmd, 64); err != nil { + t.Fatal(err) + } + h, err := c.r.Dequeue() + if err != nil || h.Type != 9 { + t.Fatalf("NVMe R2T: %+v %v", h, err) + } + var r2t nvme.R2THeader + if err := c.r.Receive(&r2t); err != nil { + t.Fatal(err) + } + if r2t.CCCID != c.cid || r2t.DATAO != 0 || r2t.DATAL != uint32(len(payload)) { + t.Fatalf("wrong R2T %+v", r2t) + } + data := nvme.H2CDataHeader{CCCID: c.cid, TAG: r2t.TAG, DATAO: 0, DATAL: uint32(len(payload))} + if err := c.w.SendWithData(6, 0, &data, 16, payload); err != nil { + t.Fatal(err) + } + gap1NVMeReply(t, c.r, c.cid) + c.cid++ + flush := nvme.CapsuleCommand{OpCode: 0, CID: c.cid, NSID: 1} + if err := c.w.SendHeaderOnly(4, &flush, 64); err != nil { + t.Fatal(err) + } + gap1NVMeReply(t, c.r, c.cid) // only this completed Flush makes the record durable +} + +func (c *gap1NVMe) readExact(t *testing.T, lba uint64, want []byte) { + t.Helper() + c.cid++ + cmd := nvme.CapsuleCommand{OpCode: 2, CID: c.cid, NSID: 1, D10: uint32(lba), D11: uint32(lba >> 32)} + if err := c.w.SendHeaderOnly(4, &cmd, 64); err != nil { + t.Fatal(err) + } + h, err := c.r.Dequeue() + if err != nil || h.Type != 7 { + t.Fatalf("NVMe read data: %+v %v", h, err) + } + var header nvme.C2HDataHeader + if err := c.r.Receive(&header); err != nil { + t.Fatal(err) + } + if header.CCCID != c.cid || header.DATAO != 0 || header.DATAL != uint32(len(want)) || c.r.Length() != len(want) { + t.Fatalf("wrong read frame %+v length%d", header, c.r.Length()) + } + got := make([]byte, c.r.Length()) + if err := c.r.ReceiveData(got); err != nil { + t.Fatal(err) + } + gap1NVMeReply(t, c.r, c.cid) + if !bytes.Equal(got, want) { + t.Fatal("fsync-acknowledged NVMe record changed after supervised restart") + } +} + +// Calibration of the witness client only, not a systemd/re-grant proof. +func TestGAP1NVMeWitnessRoundTripsAcknowledgedBlock(t *testing.T) { + backend := testback.NewRecordingBackend(frontend.Identity{VolumeID: "v", ReplicaID: "r", Epoch: 1, EndpointVersion: 1}) + nqn := "nqn.2026-11.test:gap1-witness-calibration" + target := nvme.NewTarget(nvme.TargetConfig{Listen: "127.0.0.1:0", SubsysNQN: nqn, VolumeID: "v", Provider: testback.NewStaticProvider(backend), Handler: nvme.HandlerConfig{NSID: 1, BlockSize: 4096, VolumeSize: 64 * 4096}}) + addr, err := target.Start() + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = target.Close() }) + c := gap1ConnectNVMe(t, addr, nqn) + want := bytes.Repeat([]byte{0x6d}, 4096) + c.writeFlush(t, 8, want) + c.readExact(t, 8, want) + if backend.WriteCount() != 1 || backend.SyncCount() != 1 || backend.ReadCount() != 1 { + t.Fatalf("witness bypassed backend write/flush/read: %d/%d/%d", backend.WriteCount(), backend.SyncCount(), backend.ReadCount()) + } +} diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index e251aaf4cc..9477c529cd 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -91,6 +91,11 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if err != nil || missing != http.StatusNotFound || gap1StatusOperational(missing, body404, volume) { t.Fatalf("real status404 parser control: %v", err) } + want := bytes.Repeat([]byte{0x6d}, 4096) + client := gap1ConnectNVMe(t, nvmeAddr, "nqn.2026-11.test:"+stem) + client.writeFlush(t, 8, want) + client.readExact(t, 8, want) + client.close() remote := cluster.remote(t, base+"/"+volume) before, err := remote.GetHead(context.Background()) if err != nil || before.Gen == 0 { @@ -150,6 +155,11 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if err != nil || after.Gen <= before.Gen || after.Holder != before.Holder || after.Epoch != before.Epoch { t.Fatalf("return did not claim HEAD: before%+v after%+v err%v", before, after, err) } + returned := gap1ConnectNVMe(t, nvmeAddr, "nqn.2026-11.test:"+stem) + returned.readExact(t, 8, want) + returned.writeFlush(t, 9, want) + returned.readExact(t, 9, want) + returned.close() // A real control cut must pass the lease and layer gates after restart. req, err := http.NewRequest(http.MethodPost, "http://"+statusAddr+"/chunk/cut", bytes.NewBufferString(fmt.Sprintf(`{"volumeID":%q,"timeoutMs":3000}`, volume))) if err != nil { From 103b944c037662946bfd59eeeef11745354a9d04 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:12:34 -0800 Subject: [PATCH 019/204] test: compare NVMe data frame lengths in wire units --- seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go b/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go index 247faffe94..e743064263 100644 --- a/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_nvme_integration_test.go @@ -146,7 +146,7 @@ func (c *gap1NVMe) readExact(t *testing.T, lba uint64, want []byte) { if err := c.r.Receive(&header); err != nil { t.Fatal(err) } - if header.CCCID != c.cid || header.DATAO != 0 || header.DATAL != uint32(len(want)) || c.r.Length() != len(want) { + if header.CCCID != c.cid || header.DATAO != 0 || header.DATAL != uint32(len(want)) || c.r.Length() != uint32(len(want)) { t.Fatalf("wrong read frame %+v length%d", header, c.r.Length()) } got := make([]byte, c.r.Length()) From 59a6767e2ee66b788022b8175e1a1baf3c795fc0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:14:10 -0800 Subject: [PATCH 020/204] test: qualify no-retry exit from a real other-replica master fact --- .../startup_systemd_integration_test.go | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 9477c529cd..b67cda4218 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -18,6 +18,7 @@ import ( "time" "github.com/seaweedfs/seaweed-block/core/frontend/durable" + hostvolume "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/credentials/insecure" @@ -178,6 +179,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { t.Fatalf("systemd rate limit hit: %+v", s) } gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, after.Holder, s["NRestarts"]) + gap1SupersededDoesNotRestart(t, stem, filepath.Join(bin, "blockvolume"), args, root, volume) } func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ...string) { @@ -378,3 +380,57 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie return true }) } + +// The master keeps the real r1 authority line. This process has never had an +// assignment and names r-old, so only the observed different-replica fact may +// permit 78. Run after the live holder has ACKed and exited, avoiding a node +// registration change while that holder is serving. +func gap1SupersededDoesNotRestart(t *testing.T, stem, exe string, args []string, root, volume string) { + t.Helper() + changed := append([]string(nil), args...) + addr := leaseBinaryAddress(t) + replacements := map[string]string{"--replica-id": "r-old", "--data-addr": leaseBinaryAddress(t), "--ctrl-addr": leaseBinaryAddress(t), "--status-addr": addr, "--durable-root": filepath.Join(root, "superseded-store"), "--nvme-listen": leaseBinaryAddress(t), "--nvme-subsysnqn": "nqn.2026-11.test:" + stem + "-superseded"} + for i := 0; i+1 < len(changed); i++ { + if value, ok := replacements[changed[i]]; ok { + changed[i+1] = value + } + } + unit := stem + "-superseded" + startGAP1Unit(t, unit, true, exe, changed...) + waitGAP1(t, "superseded process never observed the master's other-replica fact", 15*time.Second, func() bool { + resp, err := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status?volume=" + volume) + if err != nil { + return false + } + defer resp.Body.Close() + raw, err := io.ReadAll(resp.Body) + if err != nil { + return false + } + t.Logf("captured real supersede status: status%d body%s", resp.StatusCode, raw) + if resp.StatusCode != http.StatusOK { + return false + } + var status hostvolume.StatusProjection + if err := json.Unmarshal(raw, &status); err != nil { + t.Fatal(err) + } + if status.Healthy || status.FrontendPrimaryReady { + t.Fatalf("unassigned old identity served: %+v", status) + } + return status.AuthorityRole == hostvolume.AuthorityRoleSuperseded + }) + waitGAP1(t, "positive supersede did not exit78 without restart", 45*time.Second, func() bool { + s := gap1Unit(t, unit) + if s["NRestarts"] != "0" { + t.Fatalf("superseded unit restarted: %+v", s) + } + if s["MainPID"] != "0" { + return false + } + if s["ExecMainStatus"] != "78" || s["ActiveState"] != "failed" || s["SubState"] != "failed" { + t.Fatalf("supersede not a terminal no-retry exit: %+v", s) + } + return true + }) +} From 741cdbfbc9a609505c8623654284d084b7d1a235 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:17:12 -0800 Subject: [PATCH 021/204] fix: deliver the first process exit through one immutable buffered slot --- seaweed-block/cmd/blockvolume/process_exit.go | 26 ++++++++++--------- .../cmd/blockvolume/process_exit_test.go | 14 +++++++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 48b79fb064..43f54269b1 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -27,21 +27,21 @@ type workspaceExit struct { // INV-WS-STARTUP-RETRY-001: the first outcome is immutable. The channel is a // single latched wakeup, not a queue of competing shutdown events. type processExit struct { - parent context.Context - once sync.Once - done chan struct{} - outcome workspaceExit + parent context.Context + once sync.Once + done chan struct{} + decision chan workspaceExit } func newProcessExit(ctx context.Context) *processExit { - return &processExit{parent: ctx, done: make(chan struct{})} + return &processExit{parent: ctx, done: make(chan struct{}), decision: make(chan workspaceExit, 1)} } func (e *processExit) choose(out workspaceExit) { e.once.Do(func() { if e.parent.Err() != nil { out = workspaceExit{reason: "signal"} } - e.outcome = out + e.decision <- out // exactly one send; the sole slot cannot block under a provider lock close(e.done) }) } @@ -59,27 +59,29 @@ func superviseProcess(ctx context.Context, work func(*processExit) int) int { e := newProcessExit(ctx) finished := make(chan int, 1) go func() { finished <- work(e) }() + var out workspaceExit select { case code := <-finished: select { - case <-e.done: - if e.outcome.code == 0 { + case out = <-e.decision: + if out.code == 0 { return code } - return reportWorkspaceExit(e.outcome) + return reportWorkspaceExit(out) default: return code } case <-ctx.Done(): e.choose(workspaceExit{reason: "signal"}) - case <-e.done: + out = <-e.decision + case out = <-e.decision: } - if e.outcome.code == 0 { + if out.code == 0 { return <-finished } timer := time.NewTimer(volume.WorkspaceDrainTimeout) defer timer.Stop() - return finishWorkspaceExit(e.outcome, finished, timer.C) + return finishWorkspaceExit(out, finished, timer.C) } func finishWorkspaceExit(out workspaceExit, finished <-chan int, deadline <-chan time.Time) int { diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go index 7c0d24a8fe..1c54c93b4a 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -37,16 +37,22 @@ func TestWorkspaceExitFirstOutcomeIsLatched(t *testing.T) { e.choose(first) e.choose(workspaceExit{75, "assignment_timeout"}) <-e.done - if e.outcome != first { - t.Fatalf("first=%+v changed to %+v", first, e.outcome) + if got := <-e.decision; got != first { + t.Fatalf("first=%+v changed to %+v", first, got) + } + e.choose(workspaceExit{78, "superseded"}) + select { + case got := <-e.decision: + t.Fatalf("later outcome published: %+v", got) + default: } } ctx, cancel := context.WithCancel(context.Background()) cancel() e := newProcessExit(ctx) e.choose(workspaceExit{78, "superseded"}) - if e.outcome.code != 0 || e.outcome.reason != "signal" { - t.Fatalf("observed signal lost: %+v", e.outcome) + if got := <-e.decision; got.code != 0 || got.reason != "signal" { + t.Fatalf("observed signal lost: %+v", got) } } From 5646cad9283676a86f18a985949ae6e985946302 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:17:48 -0800 Subject: [PATCH 022/204] fix: keep signal and acknowledged revoke status immutable during cleanup --- seaweed-block/cmd/blockvolume/process_exit.go | 7 +++---- seaweed-block/cmd/blockvolume/process_exit_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 43f54269b1..4a6bc7d259 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -64,9 +64,6 @@ func superviseProcess(ctx context.Context, work func(*processExit) int) int { case code := <-finished: select { case out = <-e.decision: - if out.code == 0 { - return code - } return reportWorkspaceExit(out) default: return code @@ -77,7 +74,8 @@ func superviseProcess(ctx context.Context, work func(*processExit) int) int { case out = <-e.decision: } if out.code == 0 { - return <-finished + <-finished + return 0 } timer := time.NewTimer(volume.WorkspaceDrainTimeout) defer timer.Stop() @@ -163,6 +161,7 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e select { case err := <-done: if err == nil { + e.choose(workspaceExit{reason: "revoked"}) return } fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout:", err) diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go index 1c54c93b4a..38b96416a9 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -101,3 +101,15 @@ func TestWorkspaceRetryProcessExitsWhenCloseBlocks(t *testing.T) { t.Fatalf("blocked close exit: %v %s", err, out) } } + +func TestWorkspaceSignalFirstKeepsZeroAfterLaterFailure(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + code := superviseProcess(ctx, func(e *processExit) int { + e.choose(workspaceExit{78, "superseded"}) + return 1 // a later cleanup error cannot replace the chosen signal status + }) + if code != 0 { + t.Fatalf("first signal status changed to %d", code) + } +} From cf019bfb3f30df0a6422d597a8304f7ae18c86d3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:25:21 -0800 Subject: [PATCH 023/204] test: preserve failed systemd runtime state and acknowledged record hash --- .../startup_systemd_integration_test.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index b67cda4218..545d686286 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -5,6 +5,7 @@ package main_test import ( "bytes" "context" + "crypto/sha256" "encoding/json" "fmt" "io" @@ -51,6 +52,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { } } cluster := startWorkspaceWeed(t) + gap1PreserveFailure(t, root, cluster.dir) stem := fmt.Sprintf("codex03-gap1-%d", time.Now().UnixNano()) volume := stem base := "/" + stem @@ -95,6 +97,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { want := bytes.Repeat([]byte{0x6d}, 4096) client := gap1ConnectNVMe(t, nvmeAddr, "nqn.2026-11.test:"+stem) client.writeFlush(t, 8, want) + t.Logf("acknowledged NVMe record: lba=8 bytes=%d sha256=%x", len(want), sha256.Sum256(want)) client.readExact(t, 8, want) client.close() remote := cluster.remote(t, base+"/"+volume) @@ -434,3 +437,29 @@ func gap1SupersededDoesNotRestart(t *testing.T, stem, exe string, args []string, return true }) } + +// Register before the units: their exact-unit cleanup runs first, then this +// retains failed-run local state before testing.TempDir removes it. Nothing is +// deleted from the evidence directory, including a partial copy on failure. +func gap1PreserveFailure(t *testing.T, roots ...string) { + t.Helper() + destination := os.Getenv("GAP1_EVIDENCE_DIR") + if destination == "" { + return + } + t.Cleanup(func() { + if !t.Failed() { + return + } + if err := os.MkdirAll(destination, 0700); err != nil { + t.Logf("evidence mkdir: %v", err) + return + } + for i, root := range roots { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + out, err := exec.CommandContext(ctx, "cp", "-a", "--sparse=always", root, filepath.Join(destination, fmt.Sprintf("runtime-%d", i))).CombinedOutput() + cancel() + t.Logf("failed-run state retained: source=%s destination=%s err=%v output=%s", root, destination, err, out) + } + }) +} From 99781fe33743fd7b644343c1a0a967dfefbd692b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:26:25 -0800 Subject: [PATCH 024/204] test: use the supported systemd kill-who option in WSL qualification --- .../cmd/blockvolume/startup_systemd_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 545d686286..2a2140e9cf 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -105,7 +105,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if err != nil || before.Gen == 0 { t.Fatalf("bootstrap HEAD: %+v %v", before, err) } - gap1Systemctl(t, "kill", "--signal=KILL", "--kill-whom=main", bootstrap) + gap1Systemctl(t, "kill", "--signal=KILL", "--kill-who=main", bootstrap) waitGAP1(t, "bootstrap still running", 10*time.Second, func() bool { return gap1Unit(t, bootstrap)["MainPID"] == "0" }) // QueryWorkspace is read-only. These real binaries and this test share // one WSL kernel wall clock. Use the reported MASTER expiry timestamp, From cb6ad61c81d541b571f09b7660dd315784e21f17 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:29:32 -0800 Subject: [PATCH 025/204] test: prove successful transient exits from captured systemd journal identities --- .../startup_systemd_integration_test.go | 86 +++++++++++++++++-- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 2a2140e9cf..c5edc07775 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -54,6 +54,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { cluster := startWorkspaceWeed(t) gap1PreserveFailure(t, root, cluster.dir) stem := fmt.Sprintf("codex03-gap1-%d", time.Now().UnixNano()) + gap1ProbeTerminalSuccess(t, stem+"-policy-probe") volume := stem base := "/" + stem masterAddr := leaseBinaryAddress(t) @@ -181,7 +182,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if s["Result"] == "start-limit-hit" { t.Fatalf("systemd rate limit hit: %+v", s) } - gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, after.Holder, s["NRestarts"]) + gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, after.Holder, s["NRestarts"], s["InvocationID"]) gap1SupersededDoesNotRestart(t, stem, filepath.Join(bin, "blockvolume"), args, root, volume) } @@ -213,7 +214,7 @@ func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ... ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) _, err := exec.CommandContext(ctx, "systemctl", "stop", unit).CombinedOutput() cancel() - if err != nil { + if err != nil && gap1Unit(t, unit)["LoadState"] != "not-found" { ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) _ = exec.CommandContext(ctx, "systemctl", "kill", "--signal=KILL", unit).Run() cancel() @@ -236,7 +237,7 @@ func gap1Unit(t *testing.T, unit string) map[string]string { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec,ActiveState,SubState").CombinedOutput() + b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec,ActiveState,SubState,LoadState,InvocationID").CombinedOutput() if err != nil { t.Fatalf("unit show: %v %s", err, b) } @@ -336,7 +337,7 @@ func gap1ShippedPolicy(t *testing.T) map[string]string { // A successful planned revoke is not a retry outcome. The master's ACK and // systemd's terminal inactive/dead state prove no automatic restart is queued. -func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClient, unit, addr, volume string, epoch uint64, holder, restarts string) { +func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClient, unit, addr, volume string, epoch uint64, holder, restarts, invocation string) { t.Helper() req, err := http.NewRequest(http.MethodPost, "http://"+addr+"/chunk/detach", bytes.NewBufferString(fmt.Sprintf(`{"volumeID":%q,"plain":true,"timeoutMs":5000}`, volume))) if err != nil { @@ -371,7 +372,9 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie t.Fatalf("wrong planned ACK: %s", ack.String()) } state := gap1Unit(t, unit) - if state["NRestarts"] != restarts { + // systemd may unload a successful transient unit, resetting its + // counters. In that case use the exact invocation's journal proof. + if state["LoadState"] != "not-found" && state["NRestarts"] != restarts { t.Fatalf("planned stop restarted: %+v", state) } if state["MainPID"] != "0" { @@ -380,7 +383,11 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie if state["ExecMainStatus"] != "0" || state["ActiveState"] != "inactive" || state["SubState"] != "dead" { t.Fatalf("planned stop is not terminal success: %+v", state) } - return true + starts, parseErr := strconv.Atoi(restarts) + if parseErr != nil || invocation == "" { + t.Fatalf("missing pre-stop systemd identity: starts=%q invocation=%q", restarts, invocation) + } + return gap1JournalTerminalSuccess(t, unit, invocation, starts+1) }) } @@ -463,3 +470,70 @@ func gap1PreserveFailure(t *testing.T, roots ...string) { } }) } + +// Captured systemd249 journal records supply stable manager message IDs. The +// raw journal is logged when this witness succeeds; no fabricated PID status +// can turn an unknown unit into an ACKed successful invocation. +func gap1JournalTerminalSuccess(t *testing.T, unit, invocation string, expectedStarts int) bool { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + raw, err := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=json").CombinedOutput() + if err != nil { + t.Fatalf("unit journal: %v %s", err, raw) + } + starts := 0 + started := map[string]bool{} + succeeded := map[string]bool{} + for _, line := range bytes.Split(raw, []byte{'\n'}) { + if len(line) == 0 { + continue + } + var entry struct { + Unit string `json:"UNIT"` + Invocation string `json:"INVOCATION_ID"` + Message string `json:"MESSAGE_ID"` + PID string `json:"_PID"` + JobResult string `json:"JOB_RESULT"` + } + if err := json.Unmarshal(line, &entry); err != nil { + t.Fatalf("captured journal JSON: %v", err) + } + if entry.Unit != unit+".service" || entry.PID != "1" { + continue + } + switch entry.Message { + case "39f53479d3a045ac8e11786248231fbf": + if entry.JobResult == "done" { + starts++ + started[entry.Invocation] = true + } + case "7ad2d189f7e94e70a38c781354912448": + succeeded[entry.Invocation] = true + } + } + if starts > expectedStarts { + t.Fatalf("unexpected restart in captured unit journal: starts%d want%d", starts, expectedStarts) + } + if invocation == "" && expectedStarts == 1 { + for id := range started { + invocation = id + } + } + complete := invocation != "" && starts == expectedStarts && started[invocation] && succeeded[invocation] + if complete { + t.Logf("captured terminal-success journal for %s invocation%s: %s", unit, invocation, raw) + } + return complete +} + +// Calibrate the terminal parser against the real supervisor before any holder +// is killed. Successful transient units can be collected; their journal is the +// proof, never the default zeros returned for an unknown unit. +func gap1ProbeTerminalSuccess(t *testing.T, unit string) { + t.Helper() + startGAP1Unit(t, unit, true, "/bin/true") + waitGAP1(t, "systemd terminal-success parser preflight failed", 5*time.Second, func() bool { + return gap1JournalTerminalSuccess(t, unit, "", 1) + }) +} From 60123091339d7242e270d0caeae7406ca4ab2a25 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:34:41 -0800 Subject: [PATCH 026/204] test: use replica identity for planned revoke witness --- .../cmd/blockvolume/startup_systemd_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index c5edc07775..63dbb63889 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -182,7 +182,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if s["Result"] == "start-limit-hit" { t.Fatalf("systemd rate limit hit: %+v", s) } - gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, after.Holder, s["NRestarts"], s["InvocationID"]) + gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, "r1", s["NRestarts"], s["InvocationID"]) gap1SupersededDoesNotRestart(t, stem, filepath.Join(bin, "blockvolume"), args, root, volume) } From 30039c4b01c7947830527ae2d0a479c6257f9d24 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:18:06 -0800 Subject: [PATCH 027/204] storage: a map prepare refuses a prior root released before its live-set snapshot A preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) captures prior under descMu and prepares later. If, in between, another root is published and a second publication writes it into the other slot, prior is released: its extents are free in the live snapshot, yet the prepare reused prior's page references for unchanged pages and could allocate its own page or root into the same extent. The candidate then names a page whose bytes no longer match its hash, and the next open of the volume fails (open validates only the newest slot's map). prepareLockedV3 now checks prior's liveness in the same liveMu section that snapshots the live set (liveSnapshotWithPriorV3) and refuses a released prior with mapCoverageRefusal("prior_released") before the latching defer; the caller's next cycle prepares from the current root. The refusal is counted in ChunkMapStats.PriorReleased. From the snapshot on, nothing else allocates while m.mu is held and the candidate pins every page it references, the reused ones included, until it is published or superseded. INV-WAL-V3-MAP-PRIOR-LIVE-001 (Part B: 304 rows, 218 ACTIVE). Co-Authored-By: Claude Opus 5.5 --- seaweed-block/.gitignore | 3 + .../core/storage/chunk_lsn_map_v3.go | 22 +++- .../core/storage/chunk_map_extents_v3.go | 31 +++-- .../core/storage/chunk_map_extents_v3_test.go | 111 ++++++++++++++++++ seaweed-block/docs/design/invariants.md | 3 +- 5 files changed, 160 insertions(+), 10 deletions(-) diff --git a/seaweed-block/.gitignore b/seaweed-block/.gitignore index 08eb15459b..bd7441d732 100644 --- a/seaweed-block/.gitignore +++ b/seaweed-block/.gitignore @@ -30,3 +30,6 @@ coverage.out # MkDocs engineering wiki build output /site/ + +# Windows builds of the binaries (never committed) +/*.exe diff --git a/seaweed-block/core/storage/chunk_lsn_map_v3.go b/seaweed-block/core/storage/chunk_lsn_map_v3.go index caac02dcb7..263a599604 100644 --- a/seaweed-block/core/storage/chunk_lsn_map_v3.go +++ b/seaweed-block/core/storage/chunk_lsn_map_v3.go @@ -244,6 +244,9 @@ type chunkLSNMapV3 struct { syncFile func() error syncDirectory func() error latchPersistence func(error) + // testBeforeLiveSnapshot runs in prepareLockedV3 just before the live-set + // snapshot (tests only: a publication landing there). + testBeforeLiveSnapshot func() // liveMu guards live (chunk_map_extents_v3.go); never held across I/O. liveMu sync.Mutex live chunkMapLiveV3 @@ -370,7 +373,24 @@ func (m *chunkLSNMapV3) prepareLockedV3(g, C uint64, entries []chunkLSNEntryV3, // The live set: every page and root extent a live root references. // Roots are only added here (under m.mu); the publisher's report only // removes them, so this snapshot is a superset for the whole prepare. - used, liveBytes := usedPagesV3(m.liveSnapshotV3()) + // Every root publisher (the flusher's checkpoint, the chunk layer's + // captured-map publication, BASE complete) prepares through here, and a + // caller captured prior before this prepare: a publication in between can + // have released it (INV-WAL-V3-MAP-PRIOR-LIVE-001). Its pages are reused + // only if it is live in the same liveMu section as this snapshot; then its + // extents are in `used`, nothing else allocates while m.mu is held, and the + // candidate below pins every page it references, the reused ones included. + // Otherwise the prepare is refused, not latched, and retried by the caller + // from the current root. + if h := m.testBeforeLiveSnapshot; h != nil { + h() + } + live, priorLive := m.liveSnapshotWithPriorV3(prior) + if !priorLive { + m.live.priorRefused.Add(1) + return nil, mapCoverageRefusal("prior_released") + } + used, liveBytes := usedPagesV3(live) defer func() { if err != nil { m.failed = err diff --git a/seaweed-block/core/storage/chunk_map_extents_v3.go b/seaweed-block/core/storage/chunk_map_extents_v3.go index 85fe268188..859d3766a1 100644 --- a/seaweed-block/core/storage/chunk_map_extents_v3.go +++ b/seaweed-block/core/storage/chunk_map_extents_v3.go @@ -36,16 +36,18 @@ type mapRootExtentsV3 struct { // chunkMapLiveV3 is the live set of one owned map. type chunkMapLiveV3 struct { - roots map[mapRootKeyV3]mapRootExtentsV3 - inflight map[mapRootKeyV3]bool - truncations atomic.Uint64 - fileBytes atomic.Uint64 // set at open, after each prepare and truncation + roots map[mapRootKeyV3]mapRootExtentsV3 + inflight map[mapRootKeyV3]bool + truncations atomic.Uint64 + priorRefused atomic.Uint64 // prepares refused because their prior root was released + fileBytes atomic.Uint64 // set at open, after each prepare and truncation } // ChunkMapStats reports the owned map file's size, the bytes its live roots -// reference, and how many times its free tail was truncated. +// reference, how many times its free tail was truncated, and how many +// prepares were refused because their prior root had been released. type ChunkMapStats struct { - FileBytes, LiveBytes, Truncations uint64 + FileBytes, LiveBytes, Truncations, PriorReleased uint64 } // registerRootV3 records a slot-named root read at open. Caller holds no lock @@ -112,13 +114,26 @@ func (p *preparedMapPublicationV3) abandonV3() { // liveSnapshotV3 copies the live roots' extents under liveMu. func (m *chunkLSNMapV3) liveSnapshotV3() []mapRootExtentsV3 { + out, _ := m.liveSnapshotWithPriorV3(nil) + return out +} + +// liveSnapshotWithPriorV3 copies the live roots' extents and reports whether +// prior's root is still live, in ONE liveMu section +// (INV-WAL-V3-MAP-PRIOR-LIVE-001): the prior's extents are then in the +// snapshot exactly when the prepare may reuse its pages. A nil prior is live. +func (m *chunkLSNMapV3) liveSnapshotWithPriorV3(prior *chunkMapCandidateV3) ([]mapRootExtentsV3, bool) { m.liveMu.Lock() defer m.liveMu.Unlock() + priorLive := true + if prior != nil { + _, priorLive = m.live.roots[mapRootKeyV3{prior.rootOffset, prior.generation}] + } out := make([]mapRootExtentsV3, 0, len(m.live.roots)) for _, x := range m.live.roots { out = append(out, x) } - return out + return out, priorLive } // usedPagesV3 returns the sorted, distinct 4 KiB page indexes a live-set @@ -205,7 +220,7 @@ func (a *extentAllocatorV3) alloc(n uint64) uint64 { // bytes are computed on demand from a snapshot. func (m *chunkLSNMapV3) Stats() ChunkMapStats { _, live := usedPagesV3(m.liveSnapshotV3()) - return ChunkMapStats{FileBytes: m.live.fileBytes.Load(), LiveBytes: live, Truncations: m.live.truncations.Load()} + return ChunkMapStats{FileBytes: m.live.fileBytes.Load(), LiveBytes: live, Truncations: m.live.truncations.Load(), PriorReleased: m.live.priorRefused.Load()} } // ChunkMapStatsV3 reports the owned map file's bounded-growth counters, or diff --git a/seaweed-block/core/storage/chunk_map_extents_v3_test.go b/seaweed-block/core/storage/chunk_map_extents_v3_test.go index ed343e1a35..bc2ad22a53 100644 --- a/seaweed-block/core/storage/chunk_map_extents_v3_test.go +++ b/seaweed-block/core/storage/chunk_map_extents_v3_test.go @@ -511,3 +511,114 @@ func TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned(t *testing.T) t.Fatalf("reopen selected map generation %d, want the durable one %d", g, prepared.candidate.generation) } } + +// INV-WAL-V3-MAP-PRIOR-LIVE-001. A preparer captures prior (the current root) +// and releases the descriptor lock before it prepares. If, in that gap, +// another preparer publishes a new root and a second publication (a W sync or +// a rollover) writes it into the other slot, prior is released: its extents +// are free in the live snapshot. A prepare from that prior must not lend its +// page references: the same prepare may allocate its own page or root into +// the released extent, and the candidate then names a page whose bytes no +// longer match its hash (the next open fails). Prepare refuses a released +// prior without latching; a prepare from the current root then succeeds. +func TestChunkMapExtentsV3ReleasedPriorIsRefused(t *testing.T) { + m, d, path := extentsMapV3(t) + same := []chunkLSNEntryV3{{LSN: 500}} + c1, err := m.Prepare(1, 7, same, nil) + if err != nil { + t.Fatal(err) + } + publishV3(m, d, c1, c1) // both slots name c1; the flusher captures prior = c1 + c2 := prepV3(t, m, 2, c1) // the chunk layer's cut: the page is rewritten + publishV3(m, d, c2, c1) // slot A names c2, slot B still c1 + publishV3(m, d, c2, c2) // the next publication: neither slot names c1 (released) + c3, err := m.Prepare(3, 7, same, c1) // the flusher's prepare from its captured prior + if err == nil { + _, _, openErr := openChunkLSNMapV3(path, c3.descriptor(d), m.chunkBlocks) + t.Fatalf("prepare from a released prior succeeded: page ref %d reused, root at %d; opening the candidate: %v", + c3.refs[0].Offset, c3.rootOffset, openErr) + } + if !errors.Is(err, ErrMapCoverageStale) { + t.Fatalf("prepare from a released prior: %v, want a map coverage refusal", err) + } + if m.failed != nil { + t.Fatalf("the refusal latched the map: %v", m.failed) + } + if st := m.Stats(); st.PriorReleased != 1 { + t.Fatalf("PriorReleased %d, want the refusal counted once", st.PriorReleased) + } + c4, err := m.Prepare(3, 7, same, c2) + if err != nil { + t.Fatalf("prepare from the current root after the refusal: %v", err) + } + m2, _, err := openChunkLSNMapV3(path, c4.descriptor(d), m.chunkBlocks) + if err != nil { + t.Fatalf("open of the candidate prepared from the current root: %v", err) + } + m2.Close() +} + +// INV-WAL-V3-MAP-PRIOR-LIVE-001, the release landing INSIDE the prepare, just +// before its live-set snapshot (the hook): the liveness check must sit in the +// snapshot's own liveMu section. Mutant: the check in a separate section +// before the snapshot passes while prior is live, the release lands, and the +// candidate reuses prior's page while its root takes that extent (the open +// fails the page hash). +func TestChunkMapExtentsV3ReleasedPriorIsRefusedInsideThePrepare(t *testing.T) { + m, d, path := extentsMapV3(t) + same := []chunkLSNEntryV3{{LSN: 500}} + c1, err := m.Prepare(1, 7, same, nil) + if err != nil { + t.Fatal(err) + } + publishV3(m, d, c1, c1) + c2 := prepV3(t, m, 2, c1) + m.testBeforeLiveSnapshot = func() { + m.testBeforeLiveSnapshot = nil + publishV3(m, d, c2, c1) // the other publisher, then the next publication: + publishV3(m, d, c2, c2) // c1 is released while this prepare runs + } + c3, err := m.Prepare(3, 7, same, c1) + if err == nil { + _, _, openErr := openChunkLSNMapV3(path, c3.descriptor(d), m.chunkBlocks) + t.Fatalf("prepare whose prior was released before its snapshot succeeded: page ref %d, root at %d; opening the candidate: %v", + c3.refs[0].Offset, c3.rootOffset, openErr) + } + if !errors.Is(err, ErrMapCoverageStale) || m.failed != nil { + t.Fatalf("refusal %v, latched %v: want a non-latching map coverage refusal", err, m.failed) + } +} + +// INV-WAL-V3-MAP-PRIOR-LIVE-001, the release landing AFTER the prepare, +// before the candidate's publication: the candidate is in flight and pins +// every page it references, the reused ones included, so a later prepare +// cannot take them and the candidate stays readable. Mutant: registering the +// candidate with only its newly written extents lets the next prepare +// overwrite the reused page. +func TestChunkMapExtentsV3InFlightCandidatePinsItsReusedPages(t *testing.T) { + m, d, path := extentsMapV3(t) + same := []chunkLSNEntryV3{{LSN: 500}} + c1, err := m.Prepare(1, 7, same, nil) + if err != nil { + t.Fatal(err) + } + publishV3(m, d, c1, c1) + c2 := prepV3(t, m, 2, c1) + c3, err := m.Prepare(3, 7, same, c1) // prior live: c3 reuses c1's page + if err != nil { + t.Fatal(err) + } + if c3.refs[0] != c1.refs[0] { + t.Fatalf("setup: c3 page ref %+v, want c1's reused %+v", c3.refs[0], c1.refs[0]) + } + publishV3(m, d, c2, c1) + publishV3(m, d, c2, c2) // c1 released; c3 (gen 3 > current 2) still in flight + if _, err := m.Prepare(4, 7, []chunkLSNEntryV3{{LSN: 900}}, c2); err != nil { + t.Fatal(err) + } + m2, _, err := openChunkLSNMapV3(path, c3.descriptor(d), m.chunkBlocks) + if err != nil { + t.Fatalf("in-flight candidate unreadable after a later prepare: %v", err) + } + m2.Close() +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..6879f4a97f 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -410,7 +410,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -303 rows: 217 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. +304 rows: 218 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 289 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -478,6 +478,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-MAP-PERSIST-ORDER-001` | A v3 map candidate exists only after its new pages are written and fsynced, then its root is written and fsynced, then the sidecar's directory is fsynced. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage` | — | STUB | | `INV-WAL-V3-MAP-PERSIST-FAIL-001` | An error inside a v3 map persistence transaction yields no candidate and latches the store against later I/O; a preflight or Stat error latches nothing. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_FailureDoesNotPublishOrReuse`, `TestChunkLSNMapV3_PreflightErrorDoesNotLatch`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore` | — | STUB | | `INV-WAL-V3-MAP-EXTENT-REUSE-001` | A v3 sidecar extent is reused only when no live root references it: neither slot's root, no in-flight candidate, and, until reopen, no candidate whose publication outcome is uncertain. | M1 (map preparation) | `core/storage/chunk_map_extents_v3.go` `slotsPublishedV3`, `abandonCandidateV3`, `liveSnapshotV3`, `registerRootV3`; `core/storage/chunk_map_publication_v3.go` `publishMapV3`, `openDescriptorMapV3` | `TestChunkMapExtentsV3FallbackRootIsNeverReused`, `TestChunkMapExtentsV3NewerInFlightCandidateIsNotReused`, `TestChunkMapExtentsV3CrashBeforePublicationOfAReusedExtent`, `TestChunkMapExtentsV3UncertainCandidateStaysPinned`, `TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned`, `TestChunkMapExtentsV3ReopenRegistersTheFallbackRoot` (`core/storage/chunk_map_extents_v3_test.go`); `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies` | — | STUB | +| `INV-WAL-V3-MAP-PRIOR-LIVE-001` | A map prepare reuses pages only of a prior root that is live in the same section that snapshots the live set; otherwise it is refused, not latched, and retried from the current root. | M1 (map preparation; ORDER: capture of prior, then the live-set snapshot) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `TestChunkMapExtentsV3ReleasedPriorIsRefused`, `TestChunkMapExtentsV3ReleasedPriorIsRefusedInsideThePrepare`, `TestChunkMapExtentsV3InFlightCandidatePinsItsReusedPages` (`core/storage/chunk_map_extents_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-MAP-TRUNCATE-001` | When the v3 sidecar exceeds four times its live bytes, its free tail is truncated to the end of the highest live page and no lower. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkMapV3FileStaysBoundedUnderSteadyCheckpoints` (`core/storage/chunkmap_bounded_v3_test.go`); `TestChunkMapExtentsV3TruncationKeepsAFallbackAtTheTail`, `TestChunkMapExtentsV3TruncationFaultKeepsTheSlotRoots`, `TestChunkMapExtentsV3RejectedPublicationsStayBounded`, `TestChunkMapExtentsV3ProofStalePreparesStayBounded`, `TestChunkMapExtentsV3StatsAfterReopen` (`core/storage/chunk_map_extents_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-001` | Every v3 descriptor slot write after create's initial slot A goes through the one publisher, which writes the fallback slot with slotGen + 1 while holding `descMu`. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publish`, `descriptorPublisherV3.publishLockedCoreV3`; create: `core/storage/walstore_v3.go` `createWALStoreV3Configured` | `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-LOCKORDER-001` | The v3 publisher holds `WALStore.mu` only to take its snapshot and releases it before any slot I/O; the slot write and its fsync run in the store's fsync leaf. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishWithMapV3`; `core/storage/walstore.go` `WALStore.syncFile` | `TestDescriptorV3LockOrderRecorder` (`core/storage/descriptor_v3_test.go`) | — | STUB | From 4007c3dfa28797912cde6ddb95e1330abd0ce421 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 23:49:33 -0800 Subject: [PATCH 028/204] invariants: M1 Part A trace of the map prepare refusal (Serving -> Serving (map prepare refused)); row names the transitions Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6879f4a97f..d7aead0b88 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -47,6 +47,7 @@ stateDiagram-v2 Opened --> Recovering: RecoverVolume Recovering --> Serving: Recover ok, backend operational Recovering --> RecoveryFailed: Recover error (typed reason) + Serving --> Serving: map prepare refused (prior root released, no latch, retry) Serving --> FaultLatched: fsync or WAL append fails FaultLatched --> Closed: Close RecoveryFailed --> Closed: Close @@ -61,7 +62,8 @@ stateDiagram-v2 | Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001` | | Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001`, `INV-WAL-V3-W-RECOVERY-001` | | Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; write admission samples the active writer's native pressure before waiting; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001`, `INV-WAL-V3-ADMISSION-001`, `INV-WAL-V3-W-001` | -| Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001` | +| Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001`, `INV-WAL-V3-MAP-PRIOR-LIVE-001` | +| Serving | Serving (map prepare refused) | a map preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) captured prior and a publication released it before the prepare's live-set snapshot: the prepare reuses no page, writes nothing, refuses with `prior_released` without latching, counts it, and the caller's next cycle prepares from the current root | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `INV-WAL-V3-MAP-PRIOR-LIVE-001` | | Serving | FaultLatched | the first failed `fsync` of the store file, or a WAL append whose write failed | `core/storage/walstore.go` `noteFsyncFailure`, `syncFile`; `core/storage/walstore_v3.go` `appendWriteV3` | `INV-WAL-FSYNC-STICKY-001`, `INV-WAL-APPEND-STICKY-001` | | FaultLatched | FaultLatched | every later `Sync`, write, checkpoint and `Recover` on the same open store is refused | `core/storage/walstore.go` `stickyIOFault` | `INV-WAL-FSYNC-STICKY-001` | | any | Closed | `Close`; a store with a latched fault does not write the final superblock | `core/storage/walstore.go` `WALStore.Close` | — | @@ -478,7 +480,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-MAP-PERSIST-ORDER-001` | A v3 map candidate exists only after its new pages are written and fsynced, then its root is written and fsynced, then the sidecar's directory is fsynced. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_OrderOwnedOpenAndClippedPage` | — | STUB | | `INV-WAL-V3-MAP-PERSIST-FAIL-001` | An error inside a v3 map persistence transaction yields no candidate and latches the store against later I/O; a preflight or Stat error latches nothing. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkLSNMapV3_FailureDoesNotPublishOrReuse`, `TestChunkLSNMapV3_PreflightErrorDoesNotLatch`, `TestWALStoreV3_AutomaticMapPersistenceFailureLatchesStore` | — | STUB | | `INV-WAL-V3-MAP-EXTENT-REUSE-001` | A v3 sidecar extent is reused only when no live root references it: neither slot's root, no in-flight candidate, and, until reopen, no candidate whose publication outcome is uncertain. | M1 (map preparation) | `core/storage/chunk_map_extents_v3.go` `slotsPublishedV3`, `abandonCandidateV3`, `liveSnapshotV3`, `registerRootV3`; `core/storage/chunk_map_publication_v3.go` `publishMapV3`, `openDescriptorMapV3` | `TestChunkMapExtentsV3FallbackRootIsNeverReused`, `TestChunkMapExtentsV3NewerInFlightCandidateIsNotReused`, `TestChunkMapExtentsV3CrashBeforePublicationOfAReusedExtent`, `TestChunkMapExtentsV3UncertainCandidateStaysPinned`, `TestChunkMapExtentsV3DurableButRefusedPublicationStaysPinned`, `TestChunkMapExtentsV3ReopenRegistersTheFallbackRoot` (`core/storage/chunk_map_extents_v3_test.go`); `TestMapPublicationV3_UncertainFinalResponsePinsCandidate`, `TestWALStoreV3_UncertainMapCheckpointPinsDependencies` | — | STUB | -| `INV-WAL-V3-MAP-PRIOR-LIVE-001` | A map prepare reuses pages only of a prior root that is live in the same section that snapshots the live set; otherwise it is refused, not latched, and retried from the current root. | M1 (map preparation; ORDER: capture of prior, then the live-set snapshot) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `TestChunkMapExtentsV3ReleasedPriorIsRefused`, `TestChunkMapExtentsV3ReleasedPriorIsRefusedInsideThePrepare`, `TestChunkMapExtentsV3InFlightCandidatePinsItsReusedPages` (`core/storage/chunk_map_extents_v3_test.go`) | — | ACTIVE | +| `INV-WAL-V3-MAP-PRIOR-LIVE-001` | A map prepare reuses pages only of a prior root that is live in the same section that snapshots the live set; otherwise it is refused, not latched, and retried from the current root. | M1 Serving → Serving (checkpoint) and Serving → Serving (map prepare refused) (ORDER: capture of prior, then the live-set snapshot) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `TestChunkMapExtentsV3ReleasedPriorIsRefused`, `TestChunkMapExtentsV3ReleasedPriorIsRefusedInsideThePrepare`, `TestChunkMapExtentsV3InFlightCandidatePinsItsReusedPages` (`core/storage/chunk_map_extents_v3_test.go`) | — | ACTIVE | | `INV-WAL-V3-MAP-TRUNCATE-001` | When the v3 sidecar exceeds four times its live bytes, its free tail is truncated to the end of the highest live page and no lower. | M1 (map preparation) | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3` | `TestChunkMapV3FileStaysBoundedUnderSteadyCheckpoints` (`core/storage/chunkmap_bounded_v3_test.go`); `TestChunkMapExtentsV3TruncationKeepsAFallbackAtTheTail`, `TestChunkMapExtentsV3TruncationFaultKeepsTheSlotRoots`, `TestChunkMapExtentsV3RejectedPublicationsStayBounded`, `TestChunkMapExtentsV3ProofStalePreparesStayBounded`, `TestChunkMapExtentsV3StatsAfterReopen` (`core/storage/chunk_map_extents_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-001` | Every v3 descriptor slot write after create's initial slot A goes through the one publisher, which writes the fallback slot with slotGen + 1 while holding `descMu`. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publish`, `descriptorPublisherV3.publishLockedCoreV3`; create: `core/storage/walstore_v3.go` `createWALStoreV3Configured` | `TestDescriptorV3PublishAlternatesSlotsAndReopenSelectsNewest`, `TestDescriptorV3ConcurrentPublishersNeverRegress` (`core/storage/descriptor_v3_test.go`) | — | STUB | | `INV-WAL-V3-PUBLISH-LOCKORDER-001` | The v3 publisher holds `WALStore.mu` only to take its snapshot and releases it before any slot I/O; the slot write and its fsync run in the store's fsync leaf. | M1 Serving (v3 descriptor publication) | `core/storage/descriptor_v3.go` `descriptorPublisherV3.publishWithMapV3`; `core/storage/walstore.go` `WALStore.syncFile` | `TestDescriptorV3LockOrderRecorder` (`core/storage/descriptor_v3_test.go`) | — | STUB | From f82e56d74009ed279d6c3500b0d2582c1740cf67 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:09:06 -0800 Subject: [PATCH 029/204] invariants: MAP-PRIOR-LIVE note from the model: the harmful pair, the outage until the page is rewritten, recovery today Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 1 + 1 file changed, 1 insertion(+) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index d7aead0b88..0e4807590c 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -564,6 +564,7 @@ Notes: - `INV-WAL-V3-BINDING-001` family: a writer whose pwrite failed refuses every later append, and the store latches the fault: see M1 Serving → FaultLatched and FaultLatched → FaultLatched (test `TestWALIOV3_FloorAndPwriteFailureRefuse`). A scan result (`walScanResultV3`) is a typed read-only result, never an acknowledgement or serving permission; recovery decides from it (`INV-WAL-V3-W-RECOVERY-001`). The scan start for a BASE descriptor is in `INV-WAL-V3-BASE-SUPERSEDED-001`. - `INV-WAL-V3-MAP-PUBLISH-001` family: binding validates the map root and pages of the selected slot and of every valid fallback slot before serving: see M1 — → Opened (tests `TestMapPublicationV3_BindValidatesBothSlotDependencies`, `TestWALStoreV3_OpenRequiresBothMapGenerations`, `TestWALStoreV3_MappedCreateOpenOwnsMap`, `TestDurableProviderV3_MissingMapRefusesBeforeBackend`). Recover invalidates the map proof epoch at its start and at its end, on success and on failure: see M1 Recovering → Serving (tests `TestWALStoreV3_RealRecoverInvalidatesMapProofAtStartAndEnd`, `TestWALStoreV3_FailedRecoverInvalidatesMapProofAtBothBoundaries`, `TestWALStoreV3_AutomaticMapRecoverRebuildsCoverage`). A candidate whose slot publication outcome is unknown stays pinned until reopen (`INV-WAL-V3-MAP-EXTENT-REUSE-001`, `INV-WAL-V3-PUBLISH-FAIL-001`). Controls of the capture, seed and provider callers described in the next note, not of the publication rule itself: `TestDurableProviderV3_InvalidHEADFrontierRefusesBeforeClaim`, `TestDurableProviderV3_HEADRestoreAfterLostClaimResponse`, `TestDurableProviderV3_MappedCheckpointCaptureAndReopen`, `TestDurableProviderV3_DefaultSelectorCreatesV3`, `TestChunkLayerV3_MapOnlyCaptureNeedsNoLegacyBitmap`, `TestChunkLayerV3_IgnoresProvidedLegacyBitmap`, `TestChunkLayerV3_MapOnlyFreshZeroHEADPreservesLocalWrites`, `TestChunkLayerV3_MapOnlyRefusesLegacyBASEHeaderMutation`, `TestChunkLayerV3_MapStatusConcurrentClose`, `TestChunkLayerV3_CaptureUsesOwnedMapAfterCheckpoint`, `TestChunkLayerV3_MaxLSNSelectsAfterReopenWithCleanLegacyBitmap`, `TestChunkLayerV3_ChangedCaptureTokenKeepsUNKNOWN`, `TestChunkLayerV3_UnsettledCaptureNeverClearsUNKNOWN`, `TestChunkLayerV3_RefusesMapGeometryBeforeRemote`, `TestChunkLayerV3_CheckpointProgressUnderContinuousAppends`, `TestChunkLayerV3_CheckpointProgressAtWALPressure`, `TestCheckpointV3_NewerBatchReplaysAfterPreparedPrefix`, `TestCheckpointV3_LazyFillDoesNotInvalidatePreparedPrefix`, `TestCheckpointV3_NoFlushPressureWithRealPin`, `TestCheckpointV3_SpeculativeMaximumAfterDroppedSuffix`, `TestCheckpointV3_HeldHydrationWithLocalWriteAndFlush`; `TestDurableProviderV3_HEADRestorePreservesRemoteImageAndNextLSN` is also a control of `INV-WAL-V3-ACTIVATION-PROVIDER-001`. - `INV-WAL-V3-MAP-BYTES-001` family: root and pages are addressed by offset and SHA-256; with 4096-byte alignment, distinct page offsets that do not overlap the root rule out a partial overlap. Truncation keeps a root the fallback slot names readable. +- `INV-WAL-V3-MAP-PRIOR-LIVE-001`: every root preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) goes through the guard, but the harmful pair without it is narrower: a stale flusher prepare, a chunk-layer publication in its gap that cleared no UNKNOWN entry (so the proof does not move), then any publication that releases the flusher's prior. BASE complete is harmless on both sides (as the intervening publisher it invalidates the proof under the same lock; as the stale preparer it is refused by coverage). No other allocation is needed for the damage: the stale prepare's own new page or root lands on the freed extent (lowest free extent first). The outage it caused was not one open: later roots reuse the bad page reference for the unchanged page, so the volume stays unopenable until two root publications have rewritten that page, and a failing fallback root refuses open too. A store damaged before the fix is not cured by a restart; there is no offline rebuild of the owned map from the WAL and the extent, so recovery is a replica rebuild or a HEAD restore onto a fresh store (an offline map rebuild is the post-RC tool this failure would need). Modeled: bounded simulation reaches the bad state in 18 steps without the guard and never with it; each of the three facts (the check in the snapshot's liveMu section, prepares under the map lock, the candidate pinning its reused references) fails as a mutant; exhaustive model checking is pending. - `INV-WAL-V3-PUBLISH-001` family: create writes the initial descriptor into slot A directly (`createWALStoreV3Configured`) before the store opens; every later slot write is the publisher's. The lock graph is metadata callbacks, then `WALStore.mu` (snapshot only), then `descMu`, then `fileSyncMu` (the leaf, inside `syncFile`). An fsync error is latched by the leaf itself (`noteFsyncFailure`); the publisher latches a slot write error because the leaf does not. The success-boundary refusal is the #172 rule. `TestCheckpointV3_AppendRolloverFaultRefusesHeldCandidate` drives the failure rule through an append's rollover. - `INV-WAL-V3-W-001` family: because mode C's slot carries the previous batch's W, the acknowledged writes above the slot W are at most those of the newest acknowledged batch, which is unprotected only against media corruption before the next Sync or the idle refresh (`INV-WAL-V3-W-REFRESH-001`; test `TestWALStoreV3ModeCWindowIsExactlyTheNewestBatch`). For an installing descriptor, recovery reports a short prefix (R < W*) or a scan error as `ErrBaseIncomplete`, not `wal_corrupt` (`installingErrorV3`; test `TestWALStoreV3InstallingScanErrorIsTypedNotReady` covers the scan error). A Sync acknowledges nothing when a store fault has latched by its final check (`INV-WAL-FSYNC-STICKY-001`). - `INV-WAL-V3-FENCE-001`: with mixed slot nonces (a reset stopped between its two publications) the fence interval is empty, because old-nonce bytes fail the scanner's nonce binding (`fenceRangesV3`). A fence write error latches the store inside the leaf. From 1943f93ce6fb899ba3e846de7ad85ea203100021 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:37:54 -0800 Subject: [PATCH 030/204] test: observe supersede fact for never-assigned replica --- .../startup_systemd_integration_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 63dbb63889..49db69ecf8 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -428,7 +428,21 @@ func gap1SupersededDoesNotRestart(t *testing.T, stem, exe string, args []string, if status.Healthy || status.FrontendPrimaryReady { t.Fatalf("unassigned old identity served: %+v", status) } - return status.AuthorityRole == hostvolume.AuthorityRoleSuperseded + // A never-assigned replica remains ModeIdle, so /status intentionally + // reports unknown even after recording the other-replica fact. Prove + // receipt in this process before checking its terminal78 decision. + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + journal, err := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=cat").CombinedOutput() + if err != nil { + t.Fatalf("supersede journal: %v %s", err, journal) + } + observed := fmt.Sprintf("volume %s authority is now r1@1 (not this replica r-old); recording supersede", volume) + if strings.Contains(string(journal), observed) { + t.Logf("captured authoritative other-replica observation: %s", observed) + return true + } + return false }) waitGAP1(t, "positive supersede did not exit78 without restart", 45*time.Second, func() bool { s := gap1Unit(t, unit) From ef9bcb00322509706d4821b0fd955f279f9e460a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:44:27 -0800 Subject: [PATCH 031/204] test: expose stale supersede and unconfirmed ACK exit causes --- .../process_exit_authority_test.go | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/process_exit_authority_test.go diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go new file mode 100644 index 0000000000..e231155d2e --- /dev/null +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -0,0 +1,136 @@ +package main + +import ( + "context" + "errors" + "github.com/seaweedfs/seaweed-block/core/host/volume" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" + "net" + "testing" + "time" +) + +type exitAssignmentStream struct { + control.UnimplementedAssignmentServiceServer + control.UnimplementedObservationServiceServer + facts chan *control.AssignmentFact +} + +func (s *exitAssignmentStream) ReportHeartbeat(context.Context, *control.HeartbeatReport) (*control.HeartbeatAck, error) { + return &control.HeartbeatAck{}, nil +} +func (s *exitAssignmentStream) SubscribeAssignments(_ *control.SubscribeRequest, stream control.AssignmentService_SubscribeAssignmentsServer) error { + for { + select { + case <-stream.Context().Done(): + return stream.Context().Err() + case f := <-s.facts: + if err := stream.Send(f); err != nil { + return err + } + } + } +} +func exitAuthorityHost(t *testing.T) (*volume.Host, func(string, uint64)) { + t.Helper() + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + srv := grpc.NewServer() + stream := &exitAssignmentStream{facts: make(chan *control.AssignmentFact, 4)} + control.RegisterAssignmentServiceServer(srv, stream) + control.RegisterObservationServiceServer(srv, stream) + go srv.Serve(ln) + t.Cleanup(srv.Stop) + h, err := volume.New(volume.Config{MasterAddr: ln.Addr().String(), ServerID: "s", VolumeID: "v", ReplicaID: "r", DataAddr: "127.0.0.1:1", CtrlAddr: "127.0.0.1:2"}) + if err != nil { + t.Fatal(err) + } + h.Start() + t.Cleanup(func() { + if err := h.Close(); err != nil { + t.Error(err) + } + }) + return h, func(replica string, epoch uint64) { + t.Helper() + stream.facts <- &control.AssignmentFact{VolumeId: "v", ReplicaId: replica, Epoch: epoch, EndpointVersion: 1} + deadline := time.NewTimer(3 * time.Second) + defer deadline.Stop() + tick := time.NewTicker(time.Millisecond) + defer tick.Stop() + for { + ready := false + if replica == "r" { + ready = h.Adapter().Projection().Epoch == epoch + } else { + f := h.LastOtherLine() + ready = f != nil && f.ReplicaId == replica && f.Epoch == epoch + } + if ready { + return + } + select { + case <-deadline.C: + t.Fatal("assignment observation did not arrive") + case <-tick.C: + } + } + } +} + +// Exercise the real Host subscription and the process stop seam, including a +// historical other-replica record retained after the master assigns us again. +func TestWorkspaceRetryUsesNewestOwnAssignment(t *testing.T) { + for _, tc := range []struct { + name string + facts []struct { + replica string + epoch uint64 + } + want int + }{ + {"old other then own", []struct { + replica string + epoch uint64 + }{{"other", 6}, {"r", 7}}, 75}, + {"own then newer other", []struct { + replica string + epoch uint64 + }{{"r", 5}, {"other", 6}}, 78}, + {"never assigned", []struct { + replica string + epoch uint64 + }{{"other", 6}}, 78}, + {"same replica higher epoch", []struct { + replica string + epoch uint64 + }{{"r", 5}, {"r", 7}}, 75}, + } { + t.Run(tc.name, func(t *testing.T) { + h, send := exitAuthorityHost(t) + for _, f := range tc.facts { + send(f.replica, f.epoch) + } + e := newProcessExit(context.Background()) + done := make(chan error, 1) + done <- errors.New("lease ended") + waitWorkspaceStop(e, flags{volumeID: "v", replicaID: "r"}, h, nil, done) + if out := <-e.decision; out.code != tc.want { + t.Fatalf("lease end classified %+v, want%d", out, tc.want) + } + }) + } +} +func TestWorkspaceUnconfirmedRevokeHasOwnReason(t *testing.T) { + h, _ := exitAuthorityHost(t) + e := newProcessExit(context.Background()) + done := make(chan error, 1) + done <- errors.New("ACK answer lost") + finishWorkspaceLease(e, flags{volumeID: "v", replicaID: "r"}, h, done) + if out := <-e.decision; out.code != 75 || out.reason != "revoke_ack_unconfirmed" { + t.Fatalf("unconfirmed ACK classified %+v", out) + } +} From 3daa1d216273450843493dfcaa942a5de11dee1c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:46:24 -0800 Subject: [PATCH 032/204] fix: compare supersede exits with latest own authority lineage --- seaweed-block/cmd/blockvolume/process_exit.go | 22 ++++++------- .../cmd/blockvolume/process_exit_test.go | 22 ------------- seaweed-block/core/host/volume/host.go | 5 +++ .../core/host/volume/workspace_startup.go | 30 ++++++++++++++++++ .../host/volume/workspace_startup_test.go | 31 +++++++++++++++++++ .../docs/design/agent-workspace-design.md | 2 ++ seaweed-block/docs/design/invariants.md | 9 ++++-- 7 files changed, 85 insertions(+), 36 deletions(-) create mode 100644 seaweed-block/core/host/volume/workspace_startup.go create mode 100644 seaweed-block/core/host/volume/workspace_startup_test.go diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 4a6bc7d259..8a3ae07c37 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -11,12 +11,13 @@ import ( "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/host/volume" - control "github.com/seaweedfs/seaweed-block/core/rpc/control" ) const ( exitWorkspaceRetry = 75 exitWorkspaceSuperseded = 78 + // Existing post-drain ACK wait; M2 Revoking -> Revoked, Part D. + workspaceLeaseCloseoutTimeout = 3 * time.Second ) type workspaceExit struct { @@ -97,11 +98,10 @@ func reportWorkspaceExit(out workspaceExit) int { return out.code } -// INV-WS-STARTUP-RETRY-001: only a positive, volume-specific other-replica -// fact permits no-retry. A -// higher epoch for the same replica must restart for the new assignment. -func workspaceRetryOutcome(volumeID, replicaID, reason string, other *control.AssignmentFact) workspaceExit { - if other != nil && other.VolumeId == volumeID && other.ReplicaId != "" && other.ReplicaId != replicaID { +// INV-WS-STARTUP-RETRY-001: only a newer other-replica authority fact +// permits no-retry. Host owns the lineage observation and shared predicate. +func workspaceRetryOutcome(reason string, h *volume.Host) workspaceExit { + if h.IsCurrentReplicaSuperseded() { return workspaceExit{exitWorkspaceSuperseded, "superseded"} } return workspaceExit{exitWorkspaceRetry, reason} @@ -138,7 +138,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan case request := <-requests: out := workspaceExit{reason: "revoked"} if !h.WorkspaceLeaseRevoking() { - out = workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine()) + out = workspaceRetryOutcome("lease_expired", h) } if out.code != 0 { e.choose(out) @@ -146,7 +146,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan return &request, done case err := <-done: fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) - e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine())) + e.choose(workspaceRetryOutcome("lease_expired", h)) return nil, nil } } @@ -165,10 +165,10 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e return } fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout:", err) - case <-time.After(3 * time.Second): + case <-time.After(workspaceLeaseCloseoutTimeout): fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout deadline") } - e.choose(workspaceRetryOutcome(f.volumeID, f.replicaID, "lease_expired", h.LastOtherLine())) + e.choose(workspaceExit{exitWorkspaceRetry, "revoke_ack_unconfirmed"}) } func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p *durable.DurableProvider) bool { @@ -179,6 +179,6 @@ func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p *durable. if !failed { return false } - out := workspaceRetryOutcome(f.volumeID, f.replicaID, "assignment_timeout", h.LastOtherLine()) + out := workspaceRetryOutcome("assignment_timeout", h) return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.choose(out) }) } diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go index 38b96416a9..444d13caa0 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -3,34 +3,12 @@ package main import ( "context" "errors" - control "github.com/seaweedfs/seaweed-block/core/rpc/control" "os" "os/exec" "testing" "time" ) -func TestWorkspaceRetryNeedsPositiveOtherReplica(t *testing.T) { - for _, tc := range []struct { - name string - fact *control.AssignmentFact - code int - }{ - {"absent", nil, 75}, - {"same replica higher epoch", &control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 99}, 75}, - {"another volume", &control.AssignmentFact{VolumeId: "other", ReplicaId: "other"}, 75}, - {"empty holder", &control.AssignmentFact{VolumeId: "v"}, 75}, - {"other replica", &control.AssignmentFact{VolumeId: "v", ReplicaId: "other"}, 78}, - } { - t.Run(tc.name, func(t *testing.T) { - out := workspaceRetryOutcome("v", "r", "assignment_timeout", tc.fact) - if out.code != tc.code { - t.Fatalf("outcome=%+v want %d", out, tc.code) - } - }) - } -} - func TestWorkspaceExitFirstOutcomeIsLatched(t *testing.T) { for _, first := range []workspaceExit{{75, "lease_expired"}, {78, "superseded"}, {0, "revoked"}} { e := newProcessExit(context.Background()) diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 920ac49717..3ac6f3860b 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -203,6 +203,9 @@ type Host struct { otherMu sync.Mutex lastOther *control.AssignmentFact + selfLineageMu sync.RWMutex + selfEpoch, selfEV uint64 + frontendMu sync.RWMutex frontendTargets []*control.FrontendTarget } @@ -847,6 +850,8 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { return } + h.recordSelfAssignment(fact) + // The recovery watchdog runs from the primary assignment, before any // admission step can fail (#128 rule 6). h.wd.primaryAssigned(fact.Epoch) diff --git a/seaweed-block/core/host/volume/workspace_startup.go b/seaweed-block/core/host/volume/workspace_startup.go new file mode 100644 index 0000000000..629abd5d38 --- /dev/null +++ b/seaweed-block/core/host/volume/workspace_startup.go @@ -0,0 +1,30 @@ +package volume + +import control "github.com/seaweedfs/seaweed-block/core/rpc/control" + +// INV-WS-STARTUP-RETRY-001: remember the newest assignment observed for us, +// including one whose local readiness admission subsequently refuses. +func (h *Host) recordSelfAssignment(f *control.AssignmentFact) { + if f.VolumeId != h.cfg.VolumeID { + return + } + h.selfLineageMu.Lock() + defer h.selfLineageMu.Unlock() + if f.Epoch > h.selfEpoch || f.Epoch == h.selfEpoch && f.EndpointVersion > h.selfEV { + h.selfEpoch, h.selfEV = f.Epoch, f.EndpointVersion + } +} + +// IsCurrentReplicaSuperseded reuses the authority predicate with the newest +// observed own lineage, zero before any own assignment. Keep that lineage +// stable through the comparison; a historical other line alone cannot mean78. +// This is exit classification only: frontend admission keeps its own lineage. +func (h *Host) IsCurrentReplicaSuperseded() bool { + h.selfLineageMu.RLock() + defer h.selfLineageMu.RUnlock() + other := h.LastOtherLine() + if other == nil || other.VolumeId != h.cfg.VolumeID { + return false + } + return h.IsSuperseded(h.cfg.ReplicaID, h.selfEpoch, h.selfEV) +} diff --git a/seaweed-block/core/host/volume/workspace_startup_test.go b/seaweed-block/core/host/volume/workspace_startup_test.go new file mode 100644 index 0000000000..28330e77f5 --- /dev/null +++ b/seaweed-block/core/host/volume/workspace_startup_test.go @@ -0,0 +1,31 @@ +package volume + +import ( + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "testing" +) + +func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { + h, _, _ := newStubbedHost(t, "v", "r", &orderingRecorder{}) + h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "other", Epoch: 6, EndpointVersion: 1}) + if !h.IsCurrentReplicaSuperseded() { + t.Fatal("never-assigned newer other line did not supersede") + } + h.BlockLocalReadiness("local recovery pending") + h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 7, EndpointVersion: 1}) + if h.IsCurrentReplicaSuperseded() { + t.Fatal("blocked own assignment left historical other line current for exit") + } + // Exit classification must not change frontend admission at its old lineage. + if !h.IsSuperseded("r", 5, 1) { + t.Fatal("exit observation weakened serving supersede predicate") + } + h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 4, EndpointVersion: 1}) + if h.IsCurrentReplicaSuperseded() { + t.Fatal("older own delivery lowered the exit lineage") + } + h.recordOtherLine(&control.AssignmentFact{VolumeId: "other-volume", ReplicaId: "other", Epoch: 99}) + if h.IsCurrentReplicaSuperseded() { + t.Fatal("another volume produced a no-retry outcome") + } +} diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 9eab6ab1b6..c8a8882f37 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -509,3 +509,5 @@ stateDiagram-v2 SealedReplay --> [*]: signal Serving --> [*]: revoke ACK or signal ``` + +GAP-1 exit classification compares a newer other-replica fact with the newest own assignment this process observed, including a locally blocked assignment; historical other facts do not suppress restart. The shared `Host.IsSuperseded` predicate is reused without changing frontend admission. An unconfirmed revocation ACK exits75 with `revoke_ack_unconfirmed`. Restart can retry ACK only while the original revoking lease remains valid; after expiry the revoking/recorded-ACK re-grant guards still refuse, so restart alone cannot resolve that case and operator recovery is required. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 5921d64e39..eac66bed24 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -100,7 +100,7 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current holder/epoch, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001` | -| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a master fact naming another replica exits 78. Revocation ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a newer master fact naming another replica exits 78. Revocation ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -671,9 +671,11 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; only a master fact naming another replica permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryNeedsPositiveOtherReplica`, `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; only a newer master fact naming another replica permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | + +- `INV-WS-STARTUP-RETRY-001`: exit 78 is an optimisation, permitted only by a NEWER observed master fact for this volume naming another replica, compared with the latest own assignment observed by this process (zero before any). Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- 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 2 s RPC timeout. The existing 3 s closeout wait 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. -- `INV-WS-STARTUP-RETRY-001`: exit 78 is an optimisation, permitted only by an observed master fact for this volume naming another replica. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. Notes: - `INV-WS-SINGLE-FILER-001`: the same census runs in every `sw-block ops chunk` command that writes chunk metadata (snapshot-delete, fork, retain, volume-delete, gc --apply), and in verify, which writes nothing but would report false findings against a split filer view, before it reads or writes; other read-only commands and modes do not run it. @@ -945,6 +947,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` | Existing `workspaceLeaseCloseoutTimeout` (3 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 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. | | 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. | | Plain seal remote proof | M5 RemoteProof; `INV-WS-SEAL-REPLAY-001` | Earlier caller context or existing 2 s HEAD-operation bound for the filer read; attachment serialization retains its owner's cooperative caller bound | Provider registers with Close; closeBoundRemote cancels the read, and Close joins it. Failure keeps frontend admission closed. | Attachment mutex serializes against recover/detach; no backend/store/map lock spans the filer read. | From ad7b9dad404513c12239b69fdb93a641e4edbf62 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:46:58 -0800 Subject: [PATCH 033/204] fix: distinguish observed assignment from replica fence epoch --- .../core/host/volume/workspace_startup.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/host/volume/workspace_startup.go b/seaweed-block/core/host/volume/workspace_startup.go index 629abd5d38..3de4ee4516 100644 --- a/seaweed-block/core/host/volume/workspace_startup.go +++ b/seaweed-block/core/host/volume/workspace_startup.go @@ -8,10 +8,10 @@ func (h *Host) recordSelfAssignment(f *control.AssignmentFact) { if f.VolumeId != h.cfg.VolumeID { return } - h.selfLineageMu.Lock() - defer h.selfLineageMu.Unlock() - if f.Epoch > h.selfEpoch || f.Epoch == h.selfEpoch && f.EndpointVersion > h.selfEV { - h.selfEpoch, h.selfEV = f.Epoch, f.EndpointVersion + h.ownAssignmentMu.Lock() + defer h.ownAssignmentMu.Unlock() + if f.Epoch > h.ownAssignmentEpoch || f.Epoch == h.ownAssignmentEpoch && f.EndpointVersion > h.ownAssignmentEV { + h.ownAssignmentEpoch, h.ownAssignmentEV = f.Epoch, f.EndpointVersion } } @@ -20,11 +20,11 @@ func (h *Host) recordSelfAssignment(f *control.AssignmentFact) { // stable through the comparison; a historical other line alone cannot mean78. // This is exit classification only: frontend admission keeps its own lineage. func (h *Host) IsCurrentReplicaSuperseded() bool { - h.selfLineageMu.RLock() - defer h.selfLineageMu.RUnlock() + h.ownAssignmentMu.RLock() + defer h.ownAssignmentMu.RUnlock() other := h.LastOtherLine() if other == nil || other.VolumeId != h.cfg.VolumeID { return false } - return h.IsSuperseded(h.cfg.ReplicaID, h.selfEpoch, h.selfEV) + return h.IsSuperseded(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) } From 92c886c12933af956cd7bb7070fb145d91ae2a5a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:47:14 -0800 Subject: [PATCH 034/204] fix: name observed assignment fields consistently --- seaweed-block/core/host/volume/host.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 3ac6f3860b..b7591515d8 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -203,8 +203,8 @@ type Host struct { otherMu sync.Mutex lastOther *control.AssignmentFact - selfLineageMu sync.RWMutex - selfEpoch, selfEV uint64 + ownAssignmentMu sync.RWMutex + ownAssignmentEpoch, ownAssignmentEV uint64 frontendMu sync.RWMutex frontendTargets []*control.FrontendTarget From 5ca0611bd22f1c2196c52963029e522aae9a6760 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:49:03 -0800 Subject: [PATCH 035/204] test: reject moved r1 assignments on the restarted old server --- .../host/volume/assignment_holder_test.go | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 seaweed-block/core/host/volume/assignment_holder_test.go diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go new file mode 100644 index 0000000000..c13f4198d8 --- /dev/null +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -0,0 +1,75 @@ +package volume + +import ( + "strings" + "testing" + "time" + + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" +) + +// r2.34 AUTHORITY: replica r1 and loopback addresses are reused after a move. +// Field 9 is encoded on the wire so this regression also runs on the old schema. +func holderAssignment(t *testing.T, server string) *control.AssignmentFact { + t.Helper() + f := &control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 2, EndpointVersion: 1, DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304"} + b, err := proto.Marshal(f) + if err != nil { + t.Fatal(err) + } + if server != "" { + b = protowire.AppendTag(b, 9, protowire.BytesType) + b = protowire.AppendString(b, server) + } + if err = proto.Unmarshal(b, f); err != nil { + t.Fatal(err) + } + return f +} + +func TestAssignmentHolderIdentityRestartedOldProcess(t *testing.T) { + for _, server := range []string{"new-host", ""} { + t.Run("server="+server, func(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + // Forced move has kept r1; the restarted old process receives r1@2. + // Endpoint-only matching is deliberately indistinguishable here. + h.applyFact(holderAssignment(t, server)) + if p := h.realAdpt.Projection(); p.Epoch != 0 { + t.Errorf("old process adopted foreign/missing server: %+v", p) + } + if h.LastOtherLine() == nil { + t.Error("foreign primary line was not recorded") + } + for _, cmd := range h.t1exec.Commands() { + if strings.HasPrefix(cmd, "PublishHealthy:") { + t.Errorf("foreign line published healthy: %s", cmd) + } + } + if h.view.Projection().Healthy { + t.Error("foreign assignment made the frontend healthy") + } + }) + } +} + +func TestAssignmentHolderIdentityMatchingServerStillAdopts(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + h.applyFact(holderAssignment(t, "new-host")) + deadline := time.Now().Add(time.Second) + for !h.view.Projection().Healthy && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if p := h.view.Projection(); !p.Healthy || p.Epoch != 2 { + t.Fatalf("matching holder did not become healthy: %+v", p) + } +} From b31577dea0999a94fef7a19eda23155cd0a1ee2b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:50:43 -0800 Subject: [PATCH 036/204] test: refuse lease grants renewals and regrants for a foreign server --- .../master/workspace_holder_identity_test.go | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 seaweed-block/core/host/master/workspace_holder_identity_test.go diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go new file mode 100644 index 0000000000..2642941df5 --- /dev/null +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -0,0 +1,79 @@ +package master + +import ( + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/protobuf/encoding/protowire" + "google.golang.org/protobuf/proto" + "testing" +) + +func leaseHolderIdentity(t *testing.T, epoch uint64, server string) *control.WorkspaceIdentity { + t.Helper() + q := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: epoch} + b, err := proto.Marshal(q) + if err != nil { + t.Fatal(err) + } + if server != "" { + b = protowire.AppendTag(b, 4, protowire.BytesType) + b = protowire.AppendString(b, server) + } + if err = proto.Unmarshal(b, q); err != nil { + t.Fatal(err) + } + return q +} + +func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) { + h, conn, ctx := reviewBindingHost(t) + reviewCreate(t, conn, ctx, "v") + ws := control.NewWorkspaceServiceClient(conn) + b := &control.WorkspaceBinding{VolumeId: "v", ServerId: "node-a", DataAddr: "127.0.0.1:10000", CtrlAddr: "127.0.0.1:10001"} + if _, err := ws.RegisterWorkspaceBinding(ctx, b); err != nil { + t.Fatal(err) + } + if _, err := ws.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "v", ServerId: "node-a", ReplicaId: "r1"}); err != nil { + t.Fatal(err) + } + reviewHeartbeat(t, conn, ctx, "v", "node-a", b.DataAddr, b.CtrlAddr) + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + line := waitAuthorityLine(t, h.Publisher(), "v") + refuse := func(stage string, epoch uint64) { + t.Helper() + for _, server := range []string{"", "node-b"} { + before := h.Publisher().WorkspaceState("v") + if _, err := ws.RenewWorkspaceLease(ctx, leaseHolderIdentity(t, epoch, server)); err == nil { + t.Errorf("%s accepted lease for server %q", stage, server) + } + after := h.Publisher().WorkspaceState("v") + if !proto.Equal(leaseFact("v", before.Lease), leaseFact("v", after.Lease)) { + t.Errorf("%s refused identity changed lease", stage) + } + } + } + refuse("first grant", line.Epoch) + id := leaseHolderIdentity(t, line.Epoch, "node-a") + if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { + t.Fatal("matching server grant", err) + } + refuse("renew", line.Epoch) + if _, err := ws.RevokeWorkspace(ctx, id); err != nil { + t.Fatal(err) + } + if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil { + t.Fatal(err) + } + if _, err := ws.RegisterWorkspaceBinding(ctx, b); err != nil { + t.Fatal(err) + } + g, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "same-host", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: line.Epoch, TargetReplicaId: "r1", TargetServerId: "node-a", TargetDataAddr: b.DataAddr, TargetCtrlAddr: b.CtrlAddr, Kind: "clean"}) + if err != nil { + t.Fatal(err) + } + refuse("re-grant", g.NewEpoch) + if _, err := ws.RenewWorkspaceLease(ctx, leaseHolderIdentity(t, g.NewEpoch, "node-a")); err != nil { + t.Fatal("matching server re-grant", err) + } +} From 61695b30ef9a96d023cd450e96db2a7e7886d0b7 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:50:55 -0800 Subject: [PATCH 037/204] test: compare optional lease snapshots without dereferencing nil --- .../core/host/master/workspace_holder_identity_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go index 2642941df5..653d9906a7 100644 --- a/seaweed-block/core/host/master/workspace_holder_identity_test.go +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -4,6 +4,7 @@ import ( control "github.com/seaweedfs/seaweed-block/core/rpc/control" "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/proto" + "reflect" "testing" ) @@ -48,7 +49,7 @@ func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) t.Errorf("%s accepted lease for server %q", stage, server) } after := h.Publisher().WorkspaceState("v") - if !proto.Equal(leaseFact("v", before.Lease), leaseFact("v", after.Lease)) { + if !reflect.DeepEqual(before.Lease, after.Lease) { t.Errorf("%s refused identity changed lease", stage) } } From 7ea0eb513215763531a06b01f20dccce2b28bfbe Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:51:13 -0800 Subject: [PATCH 038/204] test: retain nil pre-grant workspace snapshot in refusal control --- .../core/host/master/workspace_holder_identity_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go index 653d9906a7..eac051f7b2 100644 --- a/seaweed-block/core/host/master/workspace_holder_identity_test.go +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -49,7 +49,7 @@ func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) t.Errorf("%s accepted lease for server %q", stage, server) } after := h.Publisher().WorkspaceState("v") - if !reflect.DeepEqual(before.Lease, after.Lease) { + if !reflect.DeepEqual(before, after) { t.Errorf("%s refused identity changed lease", stage) } } From 114fe6b74c05942576eed6a18d404c3d8c0111cc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:52:25 -0800 Subject: [PATCH 039/204] fix: require server identity for assignment adoption and workspace leases --- seaweed-block/core/host/master/services.go | 1 + .../core/host/master/workspace_binding.go | 19 +- .../core/host/master/workspace_service.go | 5 + .../core/host/volume/assignment_holder.go | 12 + seaweed-block/core/host/volume/host.go | 15 +- .../core/host/volume/workspace_runtime.go | 2 +- seaweed-block/core/rpc/control/control.pb.go | 1124 +++++++++-------- .../core/rpc/control/workspace.pb.go | 13 +- seaweed-block/core/rpc/proto/control.proto | 3 + seaweed-block/core/rpc/proto/workspace.proto | 2 +- 10 files changed, 630 insertions(+), 566 deletions(-) create mode 100644 seaweed-block/core/host/volume/assignment_holder.go diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 08d7f00c54..5fab9c3ebc 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -464,6 +464,7 @@ func (s *services) SubscribeAssignments(req *control.SubscribeRequest, stream co fact := &control.AssignmentFact{ VolumeId: info.VolumeID, ReplicaId: info.ReplicaID, + ServerId: s.host.workspaceSourceHost(info.VolumeID, info.ReplicaID, info.Epoch), Epoch: info.Epoch, EndpointVersion: info.EndpointVersion, DataAddr: info.DataAddr, diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 126cb67d44..1497b33f64 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -73,10 +73,21 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string } } } - if p, ok := h.lifecycle.Placements.GetPlacement(volume); ok { - for _, slot := range p.Slots { - if slot.ReplicaID == replica { - return slot.ServerID + if h.lifecycle != nil { + if p, ok := h.lifecycle.Placements.GetPlacement(volume); ok { + for _, slot := range p.Slots { + if slot.ReplicaID == replica { + return slot.ServerID + } + } + } + } + for _, v := range h.topo.Volumes { + if v.VolumeID == volume { + for _, slot := range v.Slots { + if slot.ReplicaID == replica { + return slot.ServerID + } } } } diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 30ef4387bc..d33b5b5688 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -90,6 +90,11 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil { return nil, err } + // r2.34 AUTHORITY: a replica id can move between servers. + line, ok := s.host.Publisher().VolumeAuthorityLine(q.GetVolumeId()) + if !ok || line.ReplicaID != q.GetReplicaId() || line.Epoch != q.GetEpoch() || q.GetServerId() == "" || q.GetServerId() != s.host.workspaceSourceHost(q.GetVolumeId(), line.ReplicaID, line.Epoch) { + return nil, status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder") + } l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch()) if err != nil { return nil, workspaceError(err) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go new file mode 100644 index 0000000000..f1961de2c6 --- /dev/null +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -0,0 +1,12 @@ +package volume + +import control "github.com/seaweedfs/seaweed-block/core/rpc/control" + +// assignmentNamesSelf implements r2.34 AUTHORITY. Missing server identity is +// refused; endpoints qualify identity only when the master carries them. +func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { + return f.GetServerId() != "" && f.GetServerId() == h.cfg.ServerID && + f.GetVolumeId() == h.cfg.VolumeID && f.GetReplicaId() == h.cfg.ReplicaID && + (f.GetDataAddr() == "" || f.GetDataAddr() == h.cfg.DataAddr) && + (f.GetCtrlAddr() == "" || f.GetCtrlAddr() == h.cfg.CtrlAddr) +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 920ac49717..259e9eae14 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -528,7 +528,10 @@ func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool } other := h.lastOther if other.ReplicaId == selfReplicaID { - return false + if h.assignmentNamesSelf(other) { + return false + } + return other.Epoch > selfEpoch || other.Epoch == selfEpoch && other.EndpointVersion >= selfEV } if other.Epoch > selfEpoch { return true @@ -803,6 +806,16 @@ func (h *Host) streamOnce(ctx context.Context) error { // OnAssignment could flip the projection Healthy before peers were // installed, admitting local-only writes with zero fan-out. func (h *Host) applyFact(fact *control.AssignmentFact) { + // r2.34 AUTHORITY: matching r1 and loopback endpoints do not identify a host. + if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) { + h.wd.notPrimary() + h.recordOtherLine(fact) + if err := h.fenceSelfWithPeers(selfRolePrimary, fact.Epoch, false); err != nil { + h.log.Printf("blockvolume: foreign holder ingress fence: %v", err) + } + h.log.Printf("blockvolume: volume %s assignment server=%q replica=%q is not this process server=%q; fenced, never adopted", h.cfg.VolumeID, fact.ServerId, fact.ReplicaId, h.cfg.ServerID) + return + } if fact.ReplicaId != h.cfg.ReplicaID { h.wd.notPrimary() // Another replica is authoritative for this volume line. Record that diff --git a/seaweed-block/core/host/volume/workspace_runtime.go b/seaweed-block/core/host/volume/workspace_runtime.go index 13e8d55c15..39cba218a6 100644 --- a/seaweed-block/core/host/volume/workspace_runtime.go +++ b/seaweed-block/core/host/volume/workspace_runtime.go @@ -32,7 +32,7 @@ func (h *Host) runWorkspaceLease(ctx context.Context, stop func(context.Context, } p := h.view.Projection() if p.Epoch > 0 { - id := &control.WorkspaceIdentity{VolumeId: h.cfg.VolumeID, ReplicaId: h.cfg.ReplicaID, Epoch: p.Epoch} + id := &control.WorkspaceIdentity{VolumeId: h.cfg.VolumeID, ReplicaId: h.cfg.ReplicaID, ServerId: h.cfg.ServerID, Epoch: p.Epoch} guard, err := NewWorkspaceLeaseGuard(h.view, control.NewWorkspaceServiceClient(h.conn), id, func(c context.Context) (uint64, error) { return stop(c, id) }, nil) if err != nil { return err diff --git a/seaweed-block/core/rpc/control/control.pb.go b/seaweed-block/core/rpc/control/control.pb.go index edbc5802f6..e5b3bf4ecc 100644 --- a/seaweed-block/core/rpc/control/control.pb.go +++ b/seaweed-block/core/rpc/control/control.pb.go @@ -18,15 +18,15 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.12.4 +// protoc v7.34.1 // source: control.proto package control import ( - timestamp "github.com/golang/protobuf/ptypes/timestamp" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -46,11 +46,11 @@ type HeartbeatReport struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` - SentAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=sent_at,json=sentAt,proto3" json:"sent_at,omitempty"` - Reachable bool `protobuf:"varint,3,opt,name=reachable,proto3" json:"reachable,omitempty"` - Eligible bool `protobuf:"varint,4,opt,name=eligible,proto3" json:"eligible,omitempty"` - Slots []*HeartbeatSlot `protobuf:"bytes,5,rep,name=slots,proto3" json:"slots,omitempty"` + ServerId string `protobuf:"bytes,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + SentAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=sent_at,json=sentAt,proto3" json:"sent_at,omitempty"` + Reachable bool `protobuf:"varint,3,opt,name=reachable,proto3" json:"reachable,omitempty"` + Eligible bool `protobuf:"varint,4,opt,name=eligible,proto3" json:"eligible,omitempty"` + Slots []*HeartbeatSlot `protobuf:"bytes,5,rep,name=slots,proto3" json:"slots,omitempty"` // machine_id and durable_root_dev identify the file system of the // reporting process's durable root (the machine's /etc/machine-id and // the root's st_dev). Raw observation facts: the master compares them @@ -103,7 +103,7 @@ func (x *HeartbeatReport) GetServerId() string { return "" } -func (x *HeartbeatReport) GetSentAt() *timestamp.Timestamp { +func (x *HeartbeatReport) GetSentAt() *timestamppb.Timestamp { if x != nil { return x.SentAt } @@ -412,8 +412,8 @@ type HeartbeatAck struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AcceptedAt *timestamp.Timestamp `protobuf:"bytes,1,opt,name=accepted_at,json=acceptedAt,proto3" json:"accepted_at,omitempty"` - Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + AcceptedAt *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=accepted_at,json=acceptedAt,proto3" json:"accepted_at,omitempty"` + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (x *HeartbeatAck) Reset() { @@ -448,7 +448,7 @@ func (*HeartbeatAck) Descriptor() ([]byte, []int) { return file_control_proto_rawDescGZIP(), []int{3} } -func (x *HeartbeatAck) GetAcceptedAt() *timestamp.Timestamp { +func (x *HeartbeatAck) GetAcceptedAt() *timestamppb.Timestamp { if x != nil { return x.AcceptedAt } @@ -467,8 +467,8 @@ type ClusterEventAck struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AcceptedAt *timestamp.Timestamp `protobuf:"bytes,1,opt,name=accepted_at,json=acceptedAt,proto3" json:"accepted_at,omitempty"` - EventId string `protobuf:"bytes,2,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` + AcceptedAt *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=accepted_at,json=acceptedAt,proto3" json:"accepted_at,omitempty"` + EventId string `protobuf:"bytes,2,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` } func (x *ClusterEventAck) Reset() { @@ -503,7 +503,7 @@ func (*ClusterEventAck) Descriptor() ([]byte, []int) { return file_control_proto_rawDescGZIP(), []int{4} } -func (x *ClusterEventAck) GetAcceptedAt() *timestamp.Timestamp { +func (x *ClusterEventAck) GetAcceptedAt() *timestamppb.Timestamp { if x != nil { return x.AcceptedAt } @@ -701,6 +701,8 @@ type AssignmentFact struct { // protection; fake-master / test harnesses MAY use 0 for // unversioned apply (does not advance the monotonic guard). PeerSetGeneration uint64 `protobuf:"varint,8,opt,name=peer_set_generation,json=peerSetGeneration,proto3" json:"peer_set_generation,omitempty"` + // Required holder identity. Empty (pre-release master) is never adopted. + ServerId string `protobuf:"bytes,9,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` } func (x *AssignmentFact) Reset() { @@ -791,6 +793,13 @@ func (x *AssignmentFact) GetPeerSetGeneration() uint64 { return 0 } +func (x *AssignmentFact) GetServerId() string { + if x != nil { + return x.ServerId + } + return "" +} + type StatusRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1311,7 +1320,7 @@ type ClusterStatusResponse struct { unknownFields protoimpl.UnknownFields SchemaVersion string `protobuf:"bytes,1,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` - CapturedAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` + CapturedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` ProductRevision string `protobuf:"bytes,3,opt,name=product_revision,json=productRevision,proto3" json:"product_revision,omitempty"` Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` Nodes []*NodeEvidence `protobuf:"bytes,5,rep,name=nodes,proto3" json:"nodes,omitempty"` @@ -1360,7 +1369,7 @@ func (x *ClusterStatusResponse) GetSchemaVersion() string { return "" } -func (x *ClusterStatusResponse) GetCapturedAt() *timestamp.Timestamp { +func (x *ClusterStatusResponse) GetCapturedAt() *timestamppb.Timestamp { if x != nil { return x.CapturedAt } @@ -1427,7 +1436,7 @@ type NodeEvidence struct { InternalIp string `protobuf:"bytes,4,opt,name=internal_ip,json=internalIp,proto3" json:"internal_ip,omitempty"` Schedulable bool `protobuf:"varint,5,opt,name=schedulable,proto3" json:"schedulable,omitempty"` Ready bool `protobuf:"varint,6,opt,name=ready,proto3" json:"ready,omitempty"` - LastHeartbeatAt *timestamp.Timestamp `protobuf:"bytes,7,opt,name=last_heartbeat_at,json=lastHeartbeatAt,proto3" json:"last_heartbeat_at,omitempty"` + LastHeartbeatAt *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=last_heartbeat_at,json=lastHeartbeatAt,proto3" json:"last_heartbeat_at,omitempty"` ReplicaCount int32 `protobuf:"varint,8,opt,name=replica_count,json=replicaCount,proto3" json:"replica_count,omitempty"` RequiredImages []string `protobuf:"bytes,9,rep,name=required_images,json=requiredImages,proto3" json:"required_images,omitempty"` MissingImages []string `protobuf:"bytes,10,rep,name=missing_images,json=missingImages,proto3" json:"missing_images,omitempty"` @@ -1510,7 +1519,7 @@ func (x *NodeEvidence) GetReady() bool { return false } -func (x *NodeEvidence) GetLastHeartbeatAt() *timestamp.Timestamp { +func (x *NodeEvidence) GetLastHeartbeatAt() *timestamppb.Timestamp { if x != nil { return x.LastHeartbeatAt } @@ -1970,21 +1979,21 @@ type ClusterEvent struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EventId string `protobuf:"bytes,1,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` - EventTime *timestamp.Timestamp `protobuf:"bytes,2,opt,name=event_time,json=eventTime,proto3" json:"event_time,omitempty"` - VolumeId string `protobuf:"bytes,3,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` - ReplicaId string `protobuf:"bytes,4,opt,name=replica_id,json=replicaId,proto3" json:"replica_id,omitempty"` - NodeName string `protobuf:"bytes,5,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"` - EventType string `protobuf:"bytes,6,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` - Severity string `protobuf:"bytes,7,opt,name=severity,proto3" json:"severity,omitempty"` - Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` - ReasonCode string `protobuf:"bytes,9,opt,name=reason_code,json=reasonCode,proto3" json:"reason_code,omitempty"` - OldValue string `protobuf:"bytes,10,opt,name=old_value,json=oldValue,proto3" json:"old_value,omitempty"` - NewValue string `protobuf:"bytes,11,opt,name=new_value,json=newValue,proto3" json:"new_value,omitempty"` - Epoch uint64 `protobuf:"varint,12,opt,name=epoch,proto3" json:"epoch,omitempty"` - EndpointVersion uint64 `protobuf:"varint,13,opt,name=endpoint_version,json=endpointVersion,proto3" json:"endpoint_version,omitempty"` - CorrelationId string `protobuf:"bytes,14,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"` - EvidenceRef string `protobuf:"bytes,15,opt,name=evidence_ref,json=evidenceRef,proto3" json:"evidence_ref,omitempty"` + EventId string `protobuf:"bytes,1,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty"` + EventTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=event_time,json=eventTime,proto3" json:"event_time,omitempty"` + VolumeId string `protobuf:"bytes,3,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` + ReplicaId string `protobuf:"bytes,4,opt,name=replica_id,json=replicaId,proto3" json:"replica_id,omitempty"` + NodeName string `protobuf:"bytes,5,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"` + EventType string `protobuf:"bytes,6,opt,name=event_type,json=eventType,proto3" json:"event_type,omitempty"` + Severity string `protobuf:"bytes,7,opt,name=severity,proto3" json:"severity,omitempty"` + Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` + ReasonCode string `protobuf:"bytes,9,opt,name=reason_code,json=reasonCode,proto3" json:"reason_code,omitempty"` + OldValue string `protobuf:"bytes,10,opt,name=old_value,json=oldValue,proto3" json:"old_value,omitempty"` + NewValue string `protobuf:"bytes,11,opt,name=new_value,json=newValue,proto3" json:"new_value,omitempty"` + Epoch uint64 `protobuf:"varint,12,opt,name=epoch,proto3" json:"epoch,omitempty"` + EndpointVersion uint64 `protobuf:"varint,13,opt,name=endpoint_version,json=endpointVersion,proto3" json:"endpoint_version,omitempty"` + CorrelationId string `protobuf:"bytes,14,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"` + EvidenceRef string `protobuf:"bytes,15,opt,name=evidence_ref,json=evidenceRef,proto3" json:"evidence_ref,omitempty"` } func (x *ClusterEvent) Reset() { @@ -2026,7 +2035,7 @@ func (x *ClusterEvent) GetEventId() string { return "" } -func (x *ClusterEvent) GetEventTime() *timestamp.Timestamp { +func (x *ClusterEvent) GetEventTime() *timestamppb.Timestamp { if x != nil { return x.EventTime } @@ -2129,9 +2138,9 @@ type ListVolumesResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SchemaVersion string `protobuf:"bytes,1,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` - CapturedAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` - Volumes []*VolumeEvidence `protobuf:"bytes,3,rep,name=volumes,proto3" json:"volumes,omitempty"` + SchemaVersion string `protobuf:"bytes,1,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` + CapturedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` + Volumes []*VolumeEvidence `protobuf:"bytes,3,rep,name=volumes,proto3" json:"volumes,omitempty"` } func (x *ListVolumesResponse) Reset() { @@ -2173,7 +2182,7 @@ func (x *ListVolumesResponse) GetSchemaVersion() string { return "" } -func (x *ListVolumesResponse) GetCapturedAt() *timestamp.Timestamp { +func (x *ListVolumesResponse) GetCapturedAt() *timestamppb.Timestamp { if x != nil { return x.CapturedAt } @@ -2192,10 +2201,10 @@ type VolumeTimelineResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SchemaVersion string `protobuf:"bytes,1,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` - CapturedAt *timestamp.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` - VolumeId string `protobuf:"bytes,3,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` - Events []*ClusterEvent `protobuf:"bytes,4,rep,name=events,proto3" json:"events,omitempty"` + SchemaVersion string `protobuf:"bytes,1,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` + CapturedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=captured_at,json=capturedAt,proto3" json:"captured_at,omitempty"` + VolumeId string `protobuf:"bytes,3,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` + Events []*ClusterEvent `protobuf:"bytes,4,rep,name=events,proto3" json:"events,omitempty"` } func (x *VolumeTimelineResponse) Reset() { @@ -2237,7 +2246,7 @@ func (x *VolumeTimelineResponse) GetSchemaVersion() string { return "" } -func (x *VolumeTimelineResponse) GetCapturedAt() *timestamp.Timestamp { +func (x *VolumeTimelineResponse) GetCapturedAt() *timestamppb.Timestamp { if x != nil { return x.CapturedAt } @@ -3004,7 +3013,7 @@ var file_control_proto_rawDesc = []byte{ 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x22, - 0xb9, 0x02, 0x0a, 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, + 0xd6, 0x02, 0x0a, 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, @@ -3023,530 +3032,531 @@ var file_control_proto_rawDesc = []byte{ 0x70, 0x74, 0x6f, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x70, 0x65, 0x65, 0x72, 0x53, 0x65, - 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x2c, 0x0a, 0x0d, 0x53, + 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x64, 0x12, 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x70, + 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x19, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x73, + 0x74, 0x75, 0x63, 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x6c, + 0x61, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x74, + 0x75, 0x63, 0x6b, 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x12, + 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, + 0x74, 0x68, 0x79, 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, + 0x6e, 0x22, 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, + 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, - 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, - 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, - 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, - 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, - 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, - 0x19, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, - 0x65, 0x5f, 0x73, 0x74, 0x75, 0x63, 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x16, 0x6c, 0x61, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, - 0x65, 0x53, 0x74, 0x75, 0x63, 0x6b, 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, - 0x58, 0x0a, 0x12, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, - 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x79, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, - 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, - 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, - 0x14, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, - 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, - 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, - 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, - 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, - 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, - 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, - 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, - 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, - 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, - 0x6e, 0x63, 0x65, 0x52, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, - 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, - 0x6e, 0x5f, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, - 0x6e, 0x6f, 0x6e, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, - 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, - 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, - 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, - 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, - 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x5f, 0x69, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, - 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, - 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, - 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, - 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, - 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, - 0x62, 0x65, 0x61, 0x74, 0x41, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, - 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, - 0x61, 0x67, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, - 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6e, 0x67, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, - 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, - 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, - 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, - 0x73, 0x22, 0x98, 0x06, 0x0a, 0x0e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, - 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, - 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, - 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, - 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, - 0x66, 0x69, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, - 0x6d, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, - 0x72, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0f, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, - 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, - 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, - 0x72, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, - 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, - 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, - 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, - 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, - 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, - 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, - 0x69, 0x6e, 0x74, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, - 0x0f, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, - 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, - 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, - 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, - 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, - 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, - 0x5f, 0x6c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, - 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, - 0x0a, 0x16, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, - 0x65, 0x72, 0x5f, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, - 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, - 0x6e, 0x6f, 0x77, 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x12, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, - 0x69, 0x65, 0x72, 0x4c, 0x73, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0e, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, - 0x34, 0x0a, 0x16, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, - 0x64, 0x79, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x14, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, - 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x10, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x41, 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, - 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, - 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, - 0x6d, 0x61, 0x72, 0x79, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, - 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, - 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, - 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, - 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, - 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, - 0x64, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, - 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x22, 0xf8, 0x03, 0x0a, 0x0c, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, - 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, - 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, - 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x69, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, - 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, - 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, - 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, - 0x74, 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, 0x47, 0x65, 0x74, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x49, 0x64, 0x22, 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x24, 0x0a, 0x0e, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, + 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, + 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, + 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, + 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, 0x6e, 0x6f, 0x64, + 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x52, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, - 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, - 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, - 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, - 0x7a, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, - 0x73, 0x69, 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, - 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x69, 0x7a, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x09, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, - 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, - 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x4e, 0x0a, 0x19, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x22, 0x48, 0x0a, 0x1a, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x05, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, - 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, - 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, - 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, - 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, - 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, - 0x34, 0x0a, 0x16, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x14, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, - 0x67, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, - 0x45, 0x6c, 0x69, 0x67, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, - 0x72, 0x65, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x1c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, - 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, - 0x38, 0x0a, 0x18, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x69, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x16, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, - 0x65, 0x72, 0x43, 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, - 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, - 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, - 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x52, 0x65, 0x66, 0x73, 0x22, 0xa7, 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, - 0x72, 0x74, 0x65, 0x64, 0x12, 0x38, 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, - 0x79, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, - 0x79, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, - 0x0a, 0x1d, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, - 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, - 0x6d, 0x61, 0x72, 0x79, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x12, 0x50, 0x0a, 0x25, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x5f, 0x73, 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, - 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x21, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, - 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, - 0x61, 0x63, 0x6b, 0x12, 0x2e, 0x0a, 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x5f, 0x6d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x11, 0x6e, 0x6f, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, - 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, - 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, - 0x01, 0x0a, 0x12, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, - 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, - 0x72, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, - 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, - 0x6f, 0x72, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, - 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, - 0x32, 0x81, 0x01, 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, - 0x69, 0x62, 0x65, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, - 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, - 0x63, 0x74, 0x30, 0x01, 0x32, 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, - 0x0a, 0x16, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, - 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, - 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, + 0x6f, 0x6c, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, + 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, + 0x52, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, + 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, + 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x6e, + 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x45, + 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, + 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, + 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, + 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, + 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x49, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, + 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, + 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6c, + 0x61, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x61, 0x74, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, + 0x6d, 0x70, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x41, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, + 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6d, 0x61, + 0x67, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6e, 0x67, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, + 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, + 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x72, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x72, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6c, 0x61, + 0x73, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x98, + 0x06, 0x0a, 0x0e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, + 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, + 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, + 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, + 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, + 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, + 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, + 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0f, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, + 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6f, 0x62, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x16, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x27, 0x0a, + 0x0f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x52, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, + 0x79, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, + 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x44, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x11, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x72, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, + 0x78, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, + 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, + 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, 0x0f, 0x52, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, + 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, + 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, + 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, + 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, + 0x6c, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6c, 0x61, + 0x74, 0x63, 0x68, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x64, 0x75, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x64, + 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x64, 0x75, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, 0x6e, 0x6f, 0x77, + 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, + 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x12, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, + 0x4c, 0x73, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, + 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x34, 0x0a, 0x16, + 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x5f, + 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x61, + 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x65, 0x61, 0x73, + 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, + 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, + 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, + 0x41, 0x64, 0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x41, 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x5f, 0x70, + 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x10, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, + 0x79, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x12, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, + 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x64, 0x5f, 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, 0x64, 0x12, 0x2d, + 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xf8, 0x03, + 0x0a, 0x0c, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, + 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, + 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, + 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, + 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, + 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, + 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, + 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, + 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, + 0x65, 0x64, 0x41, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, + 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, + 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x49, 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, + 0x74, 0x73, 0x22, 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, + 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, + 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, + 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, + 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, + 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, + 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x22, 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, + 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, + 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, + 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, + 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x4e, 0x0a, 0x19, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, + 0x48, 0x0a, 0x1a, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, 0x0f, 0x46, 0x61, + 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, + 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x41, + 0x64, 0x64, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x74, + 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3d, 0x0a, + 0x1b, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, + 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x65, 0x78, + 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, + 0x63, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, 0x67, 0x69, 0x62, + 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, 0x45, 0x6c, 0x69, + 0x67, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, + 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x42, 0x65, + 0x66, 0x6f, 0x72, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x38, 0x0a, 0x18, + 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, + 0x5f, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, + 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x43, + 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, + 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, + 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, + 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x0b, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, + 0x73, 0x22, 0xa7, 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, + 0x64, 0x12, 0x38, 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x65, + 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x70, + 0x6f, 0x63, 0x68, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, 0x0a, 0x1d, 0x73, + 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x61, 0x66, + 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, + 0x79, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x50, + 0x0a, 0x25, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x5f, 0x73, 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, + 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x21, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x77, 0x61, 0x70, + 0x70, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x12, 0x2e, 0x0a, 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, + 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6e, + 0x6f, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, + 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, + 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, + 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x12, + 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, + 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, + 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, + 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, 0x73, + 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, + 0x65, 0x6e, 0x74, 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81, 0x01, + 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, + 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x30, + 0x01, 0x32, 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x16, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, + 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, - 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, - 0x0a, 0x12, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x73, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, - 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, - 0x01, 0x32, 0xec, 0x04, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, + 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, + 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, 0x65, 0x61, + 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, + 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x12, 0x57, + 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x73, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x74, 0x63, + 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xec, + 0x04, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x7d, 0x0a, 0x12, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x7e, 0x0a, 0x13, 0x41, 0x62, 0x6f, 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x7f, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x12, 0x6b, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, + 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, + 0x12, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, + 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x32, 0x79, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x66, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, - 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, - 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7e, 0x0a, 0x13, + 0x41, 0x62, 0x6f, 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, + 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7f, 0x0a, 0x14, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, + 0x74, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, + 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, + 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, + 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x66, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, + 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, + 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -3595,7 +3605,7 @@ var file_control_proto_goTypes = []interface{}{ (*MarkVolumeDeletingResponse)(nil), // 29: seaweedfs.block.control.MarkVolumeDeletingResponse (*FailbackRequest)(nil), // 30: seaweedfs.block.control.FailbackRequest (*FailbackResponse)(nil), // 31: seaweedfs.block.control.FailbackResponse - (*timestamp.Timestamp)(nil), // 32: google.protobuf.Timestamp + (*timestamppb.Timestamp)(nil), // 32: google.protobuf.Timestamp } var file_control_proto_depIdxs = []int32{ 32, // 0: seaweedfs.block.control.HeartbeatReport.sent_at:type_name -> google.protobuf.Timestamp diff --git a/seaweed-block/core/rpc/control/workspace.pb.go b/seaweed-block/core/rpc/control/workspace.pb.go index 29fd611ef7..92d006c675 100644 --- a/seaweed-block/core/rpc/control/workspace.pb.go +++ b/seaweed-block/core/rpc/control/workspace.pb.go @@ -26,6 +26,7 @@ type WorkspaceIdentity struct { VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` ReplicaId string `protobuf:"bytes,2,opt,name=replica_id,json=replicaId,proto3" json:"replica_id,omitempty"` Epoch uint64 `protobuf:"varint,3,opt,name=epoch,proto3" json:"epoch,omitempty"` + ServerId string `protobuf:"bytes,4,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -81,6 +82,13 @@ func (x *WorkspaceIdentity) GetEpoch() uint64 { return 0 } +func (x *WorkspaceIdentity) GetServerId() string { + if x != nil { + return x.ServerId + } + return "" +} + type WorkspaceVolume struct { state protoimpl.MessageState `protogen:"open.v1"` VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` @@ -1122,12 +1130,13 @@ var File_workspace_proto protoreflect.FileDescriptor const file_workspace_proto_rawDesc = "" + "\n" + - "\x0fworkspace.proto\x12\x17seaweedfs.block.control\"e\n" + + "\x0fworkspace.proto\x12\x17seaweedfs.block.control\"\x82\x01\n" + "\x11WorkspaceIdentity\x12\x1b\n" + "\tvolume_id\x18\x01 \x01(\tR\bvolumeId\x12\x1d\n" + "\n" + "replica_id\x18\x02 \x01(\tR\treplicaId\x12\x14\n" + - "\x05epoch\x18\x03 \x01(\x04R\x05epoch\".\n" + + "\x05epoch\x18\x03 \x01(\x04R\x05epoch\x12\x1b\n" + + "\tserver_id\x18\x04 \x01(\tR\bserverId\".\n" + "\x0fWorkspaceVolume\x12\x1b\n" + "\tvolume_id\x18\x01 \x01(\tR\bvolumeId\"\x10\n" + "\x0eWorkspaceEmpty\"\xc8\x01\n" + diff --git a/seaweed-block/core/rpc/proto/control.proto b/seaweed-block/core/rpc/proto/control.proto index ca4940aeab..650a8008fb 100644 --- a/seaweed-block/core/rpc/proto/control.proto +++ b/seaweed-block/core/rpc/proto/control.proto @@ -236,6 +236,9 @@ message AssignmentFact { // protection; fake-master / test harnesses MAY use 0 for // unversioned apply (does not advance the monotonic guard). uint64 peer_set_generation = 8; + + // Required holder identity. Empty (pre-release master) is never adopted. + string server_id = 9; } message StatusRequest { diff --git a/seaweed-block/core/rpc/proto/workspace.proto b/seaweed-block/core/rpc/proto/workspace.proto index 5a227f6c79..eadcdb5b66 100644 --- a/seaweed-block/core/rpc/proto/workspace.proto +++ b/seaweed-block/core/rpc/proto/workspace.proto @@ -21,7 +21,7 @@ service WorkspaceService { // write): advisory, re-checked by MoveWorkspace. rpc PreviewWorkspaceMove(WorkspaceMove) returns (WorkspaceMovePreview); } -message WorkspaceIdentity { string volume_id = 1; string replica_id = 2; uint64 epoch = 3; } +message WorkspaceIdentity { string volume_id = 1; string replica_id = 2; uint64 epoch = 3; string server_id = 4; } message WorkspaceVolume { string volume_id = 1; } message WorkspaceEmpty {} message WorkspaceLeaseFact { From e08888aac1daa77e1ad69e98ace1b05d8b43baae Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:53:35 -0800 Subject: [PATCH 040/204] test: expose retained timeout and planned-drain startup races --- .../process_exit_authority_test.go | 115 +++++++++++++++++- .../durable/provider_startup_outcome_test.go | 48 ++++++++ 2 files changed, 160 insertions(+), 3 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index e231155d2e..6ffe4db778 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -3,10 +3,14 @@ package main import ( "context" "errors" + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/host/volume" control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "github.com/seaweedfs/seaweed-block/core/storage" "google.golang.org/grpc" "net" + "sync/atomic" "testing" "time" ) @@ -14,9 +18,23 @@ import ( type exitAssignmentStream struct { control.UnimplementedAssignmentServiceServer control.UnimplementedObservationServiceServer - facts chan *control.AssignmentFact + control.UnimplementedWorkspaceServiceServer + revoke bool + ackError error + acks atomic.Int32 + facts chan *control.AssignmentFact } +func (s *exitAssignmentStream) RenewWorkspaceLease(_ context.Context, id *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) { + return &control.WorkspaceLeaseFact{VolumeId: id.VolumeId, ReplicaId: id.ReplicaId, Epoch: id.Epoch, ValidForNs: int64(30 * time.Second), Revoking: s.revoke}, nil +} +func (s *exitAssignmentStream) AckWorkspaceRevoked(_ context.Context, a *control.WorkspaceRevocationAck) (*control.WorkspaceEmpty, error) { + if a.GetHeadGen() != 1 { + return nil, errors.New("ACK lacks the stored detached proof") + } + s.acks.Add(1) + return &control.WorkspaceEmpty{}, s.ackError +} func (s *exitAssignmentStream) ReportHeartbeat(context.Context, *control.HeartbeatReport) (*control.HeartbeatAck, error) { return &control.HeartbeatAck{}, nil } @@ -32,7 +50,7 @@ func (s *exitAssignmentStream) SubscribeAssignments(_ *control.SubscribeRequest, } } } -func exitAuthorityHost(t *testing.T) (*volume.Host, func(string, uint64)) { +func exitAuthorityHost(t *testing.T, configure ...func(*exitAssignmentStream)) (*volume.Host, func(string, uint64)) { t.Helper() ln, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { @@ -40,11 +58,15 @@ func exitAuthorityHost(t *testing.T) (*volume.Host, func(string, uint64)) { } srv := grpc.NewServer() stream := &exitAssignmentStream{facts: make(chan *control.AssignmentFact, 4)} + for _, f := range configure { + f(stream) + } + control.RegisterWorkspaceServiceServer(srv, stream) control.RegisterAssignmentServiceServer(srv, stream) control.RegisterObservationServiceServer(srv, stream) go srv.Serve(ln) t.Cleanup(srv.Stop) - h, err := volume.New(volume.Config{MasterAddr: ln.Addr().String(), ServerID: "s", VolumeID: "v", ReplicaID: "r", DataAddr: "127.0.0.1:1", CtrlAddr: "127.0.0.1:2"}) + h, err := volume.New(volume.Config{WorkspaceLease: true, MasterAddr: ln.Addr().String(), ServerID: "s", VolumeID: "v", ReplicaID: "r", DataAddr: "127.0.0.1:1", CtrlAddr: "127.0.0.1:2"}) if err != nil { t.Fatal(err) } @@ -134,3 +156,90 @@ func TestWorkspaceUnconfirmedRevokeHasOwnReason(t *testing.T) { t.Fatalf("unconfirmed ACK classified %+v", out) } } + +type exitWaitingProjection struct{} + +func (exitWaitingProjection) Projection() frontend.Projection { + return frontend.Projection{VolumeID: "v", ReplicaID: "r"} +} + +func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { + for _, failAck := range []bool{false, true} { + t.Run(map[bool]string{false: "ACK succeeds", true: "ACK lost"}[failAck], func(t *testing.T) { + var stream *exitAssignmentStream + h, send := exitAuthorityHost(t, func(s *exitAssignmentStream) { + stream = s + s.revoke = true + if failAck { + s.ackError = errors.New("ACK answer lost") + } + }) + 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"} + // The real guard sets revoked, sends its stop request, and waits for the + // resource owner's drain reply. No success is selected yet. + request, leaseDone := waitWorkspaceStop(e, f, h, requests, done) + if request == nil || !h.WorkspaceLeaseRevoking() { + t.Fatal("real planned drain not acquired") + } + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: time.Nanosecond, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return storage.NewMemChunkRemote(), nil }}, exitWaitingProjection{}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = p.Close() }) + if _, err = p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + if _, err = p.RecoverVolume(ctx, "v"); err != nil { + t.Fatal(err) + } + select { + case <-p.ChunkStartupUpdates(): + case <-time.After(3 * time.Second): + t.Fatal("controlled startup expiry absent") + } + chooseChunkStartupExit(e, f, h, p) + select { + case out := <-e.decision: + t.Fatalf("startup overrode the pending real drain: %+v", out) + default: + } + remote := storage.NewMemChunkRemote() + _, err = remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 1, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Epoch: 1, Holder: "s/r", Gen: 1}}) + if err != nil { + t.Fatal(err) + } + gen, err := workspaceDetachedGeneration(ctx, func(string) (storage.ChunkRemote, error) { return remote, nil }, request.id, "s/r") + if err != nil { + t.Fatal(err) + } + request.reply <- workspaceStopResult{gen: gen} + finishWorkspaceLease(e, f, h, leaseDone) + doneConsumed = true + out := <-e.decision + if stream.acks.Load() != 1 { + t.Fatal("real guard did not send proof ACK") + } + if !failAck && out.code != 0 { + t.Fatalf("ACKed stop restarted: %+v", out) + } + if failAck && (out.code != 75 || out.reason != "revoke_ack_unconfirmed") { + t.Fatalf("unconfirmed ACK: %+v", out) + } + }) + } +} diff --git a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go index b61b3ac534..03206667a6 100644 --- a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go +++ b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go @@ -2,6 +2,7 @@ package durable_test import ( "context" + "errors" "reflect" "testing" "time" @@ -101,3 +102,50 @@ func TestChunkStartupSealedAssignmentStaysForReplay(t *testing.T) { } } } + +// The attach check returns a retained disposition only AFTER its context's +// deadline. This makes the timeout-defer boundary causal, not a scheduler race. +func TestChunkStartupRetainedDispositionWinsExpiredAttachContext(t *testing.T) { + for _, tc := range []struct { + name string + err error + }{ + {"sealed", storage.ErrChunkLayerDetached}, + {"stale local root", errors.Join(storage.ErrChunkLayerFenced, durable.ErrChunkStaleLocalRoot)}, + } { + t.Run(tc.name, func(t *testing.T) { + logs := &lockedLog{} + captureWriteLogs(t, logs) + view := v1View() + assigned := view.Projection() + waiting := assigned + waiting.Epoch = 0 + waiting.Healthy = false + view.set(waiting) + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, + ChunkAssignmentTimeout: 250 * time.Millisecond, + ChunkAttachCheck: func(ctx context.Context, _ string, _ durable.ChunkGeometry) error { <-ctx.Done(); return tc.err }, + ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { + t.Error("retained attach reached remote") + return storage.NewMemChunkRemote(), nil + }, + }, view) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = p.Close() }) + if _, err = p.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + if _, err = p.RecoverVolume(context.Background(), "v1"); err != nil { + t.Fatal(err) + } + view.set(assigned) + waitLog(t, logs, "chunk authority wait for volume=v1 ended") + if _, failed := p.ChunkStartupOutcome("v1"); failed { + t.Fatal("deadline defer replaced retained attach disposition with process retry") + } + }) + } +} From 14aaa35e1f656d6492f7aac78962e7c6b2661ade Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:56:08 -0800 Subject: [PATCH 041/204] test: provide explicit server identities in existing host fixtures --- .../replication_ingress_binary_test.go | 2 +- .../master/journal_isolation_fold_test.go | 4 +- .../core/host/master/workspace_binding.go | 3 ++ .../master/workspace_binding_review_test.go | 8 ++-- .../host/master/workspace_binding_test.go | 2 +- .../master/workspace_exited_holder_test.go | 4 +- .../master/workspace_lease_horizon_test.go | 4 +- .../workspace_lost_range_readout_test.go | 2 +- .../master/workspace_move_integration_test.go | 2 +- .../host/master/workspace_move_slot_test.go | 2 +- .../master/workspace_paused_grantee_test.go | 2 +- .../master/workspace_renewal_boundary_test.go | 2 +- .../workspace_renewal_slowstore_test.go | 8 ++-- .../master/workspace_same_host_clean_test.go | 2 +- .../host/master/workspace_service_test.go | 8 ++-- .../core/host/master/workspace_skew_test.go | 4 +- .../master/workspace_unclaimed_grant_test.go | 4 +- .../core/host/volume/apply_fact_test.go | 26 +++++------ .../assignment_identity_fixture_test.go | 28 ++++++++++++ .../core/host/volume/chunk_bootstrap_test.go | 2 +- .../volume/chunk_seed_replication_test.go | 2 +- .../host/volume/g1_admission_latch_test.go | 30 ++++++------- .../core/host/volume/g2_self_fence_test.go | 4 +- .../host/volume/recovery_typed_reason_test.go | 6 +-- .../host/volume/recovery_watchdog_test.go | 26 +++++------ .../core/host/volume/rf1_only_test.go | 44 +++++++++---------- .../host/volume/supersede_integration_test.go | 4 +- .../core/host/volume/workspace_lease.go | 2 +- .../host/volume/workspace_runtime_test.go | 2 +- 29 files changed, 135 insertions(+), 104 deletions(-) create mode 100644 seaweed-block/core/host/volume/assignment_identity_fixture_test.go diff --git a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go index ab3d0422d3..150b08ce9e 100644 --- a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go +++ b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go @@ -166,7 +166,7 @@ func TestBinaryReplicationIngressFollowsAssignedSlots(t *testing.T) { ingressRefused(t, data) ingressRefused(t, dual) fact := func(e uint64, peers []*control.ReplicaDescriptor) *control.AssignmentFact { - return &control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: e, EndpointVersion: e, DataAddr: data, CtrlAddr: ctrl, PeerSetGeneration: e, Peers: peers} + return &control.AssignmentFact{ServerId: "s1", VolumeId: "v1", ReplicaId: "r1", Epoch: e, EndpointVersion: e, DataAddr: data, CtrlAddr: ctrl, PeerSetGeneration: e, Peers: peers} } m.facts <- fact(1, nil) ingressWait(t, "RF1 assignment not applied", func() bool { return epoch(1) }) diff --git a/seaweed-block/core/host/master/journal_isolation_fold_test.go b/seaweed-block/core/host/master/journal_isolation_fold_test.go index 35f3a9cdc4..220c0f5034 100644 --- a/seaweed-block/core/host/master/journal_isolation_fold_test.go +++ b/seaweed-block/core/host/master/journal_isolation_fold_test.go @@ -42,7 +42,7 @@ func (r *isolationRig) issueMove(t *testing.T, vol, requestID string) (*control. if line.Epoch != 1 || line.ReplicaID != "r1" { t.Fatalf("fixture authority line: %+v", line) } - id := &control.WorkspaceIdentity{VolumeId: vol, ReplicaId: "r1", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: vol, ReplicaId: "r1", Epoch: 1} if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err != nil { t.Fatal(err) } @@ -311,7 +311,7 @@ func TestStatusReportsExtensionWriteLatency(t *testing.T) { reviewLegacyBind(t, h, c, ctx, "vol-b") line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} - id := &control.WorkspaceIdentity{VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} if _, err := svc.RenewWorkspaceLease(ctx, id); err != nil { t.Fatal(err) // first grant: not an extension } diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 1497b33f64..5346b8935f 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -71,6 +71,9 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string if r.Issued && r.NewReplicaID == replica && r.NewEpoch == epoch { return r.NewHost } + if r.Issued && r.OldReplicaID == replica && r.OldEpoch == epoch { + return r.OldHost + } } } if h.lifecycle != nil { diff --git a/seaweed-block/core/host/master/workspace_binding_review_test.go b/seaweed-block/core/host/master/workspace_binding_review_test.go index bae394f195..269caba18a 100644 --- a/seaweed-block/core/host/master/workspace_binding_review_test.go +++ b/seaweed-block/core/host/master/workspace_binding_review_test.go @@ -88,7 +88,7 @@ func TestWorkspaceBindingLegacyMoveCannotTakePreparedReservation(t *testing.T) { if _, e := client.RegisterWorkspaceBinding(ctx, &control.WorkspaceBinding{VolumeId: "prepared", ServerId: "node-b", DataAddr: "127.0.0.1:9200", CtrlAddr: "127.0.0.1:9100"}); e != nil { t.Fatal(e) } - id := &control.WorkspaceIdentity{VolumeId: "legacy", ReplicaId: "r1", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "legacy", ReplicaId: "r1", Epoch: 1} if _, e := client.RenewWorkspaceLease(ctx, id); e != nil { t.Fatal(e) } @@ -114,7 +114,7 @@ func TestWorkspaceBindingDeleteCannotReleaseLiveAuthority(t *testing.T) { if _, e := client.RegisterWorkspaceBinding(ctx, b); e != nil { t.Fatal(e) } - if _, e := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{VolumeId: "live", ReplicaId: "r1", Epoch: 1}); e != nil { + if _, e := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "live", ReplicaId: "r1", Epoch: 1}); e != nil { t.Fatal(e) } if _, e := control.NewLifecycleServiceClient(c).DeleteVolume(ctx, &control.DeleteVolumeRequest{VolumeId: "live"}); e == nil { @@ -126,7 +126,7 @@ func TestWorkspaceBindingDeleteCannotReleaseLiveAuthority(t *testing.T) { if _, bound, e := h.Lifecycle().WorkspaceBindings.Get("live"); e != nil || !bound { t.Fatal("refused deletion removed binding", bound, e) } - id := &control.WorkspaceIdentity{VolumeId: "live", ReplicaId: "r1", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "live", ReplicaId: "r1", Epoch: 1} if _, e := client.RevokeWorkspace(ctx, id); e != nil { t.Fatal(e) } @@ -255,7 +255,7 @@ func TestWorkspaceBindingRemoteReadDoesNotBlockAck(t *testing.T) { }) reviewLegacyBind(t, h, c, ctx, "ack") client := control.NewWorkspaceServiceClient(c) - id := &control.WorkspaceIdentity{VolumeId: "ack", ReplicaId: "r1", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "ack", ReplicaId: "r1", Epoch: 1} if _, e := client.RenewWorkspaceLease(ctx, id); e != nil { t.Fatal(e) } diff --git a/seaweed-block/core/host/master/workspace_binding_test.go b/seaweed-block/core/host/master/workspace_binding_test.go index 07b3a67767..0b6eeef493 100644 --- a/seaweed-block/core/host/master/workspace_binding_test.go +++ b/seaweed-block/core/host/master/workspace_binding_test.go @@ -120,7 +120,7 @@ func workspaceBindingsMove(t *testing.T, forced bool) { t.Fatal(err) } line := waitAuthorityLine(t, h.Publisher(), vol) - id := &control.WorkspaceIdentity{VolumeId: vol, ReplicaId: "r1", Epoch: line.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: vol, ReplicaId: "r1", Epoch: line.Epoch} lease, e := client.RenewWorkspaceLease(ctx, id) if e != nil { t.Fatal(e) diff --git a/seaweed-block/core/host/master/workspace_exited_holder_test.go b/seaweed-block/core/host/master/workspace_exited_holder_test.go index 7e066b6f6b..3a1df34d97 100644 --- a/seaweed-block/core/host/master/workspace_exited_holder_test.go +++ b/seaweed-block/core/host/master/workspace_exited_holder_test.go @@ -78,7 +78,7 @@ func TestWorkspaceExitedHolderForcedMoveThenCleanDelete(t *testing.T) { t.Fatal(err) } oldLine := waitAuthorityLine(t, m.Publisher(), "vol-a") - oldID := &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: oldLine.ReplicaID, Epoch: oldLine.Epoch} + oldID := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: oldLine.ReplicaID, Epoch: oldLine.Epoch} if _, err = ws.RenewWorkspaceLease(ctx, oldID); err != nil { t.Fatal(err) } @@ -188,7 +188,7 @@ func TestWorkspaceExitedHolderForcedMoveThenCleanDelete(t *testing.T) { } // The new holder detaches cleanly and ACKs; the delete is then admitted. - newID := &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: newLine.ReplicaID, Epoch: newLine.Epoch} + newID := &control.WorkspaceIdentity{ServerId: "node-b", VolumeId: "vol-a", ReplicaId: newLine.ReplicaID, Epoch: newLine.Epoch} if _, err := ws.RenewWorkspaceLease(ctx, newID); err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_lease_horizon_test.go b/seaweed-block/core/host/master/workspace_lease_horizon_test.go index c0ae355df8..2acca42067 100644 --- a/seaweed-block/core/host/master/workspace_lease_horizon_test.go +++ b/seaweed-block/core/host/master/workspace_lease_horizon_test.go @@ -55,7 +55,7 @@ func TestWorkspaceLeaseGuardFencesByHorizonUnderStalledStore(t *testing.T) { t.Cleanup(func() { releaseOnce.Do(func() { close(stall.release) }) }) // runs first: unblock the extender var stops atomic.Int32 g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, - deadlineLeaseClient{p: p, inflight: &inflight}, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, + deadlineLeaseClient{p: p, inflight: &inflight}, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { stops.Add(1); return 7, nil }, nil) if err != nil { t.Fatal(err) @@ -112,7 +112,7 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { reviewLegacyBind(t, h, c, ctx, "vol-b") line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} - id := &control.WorkspaceIdentity{VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} first, err := svc.RenewWorkspaceLease(ctx, id) if err != nil { t.Fatal(err) diff --git a/seaweed-block/core/host/master/workspace_lost_range_readout_test.go b/seaweed-block/core/host/master/workspace_lost_range_readout_test.go index c13969c27d..07c288e846 100644 --- a/seaweed-block/core/host/master/workspace_lost_range_readout_test.go +++ b/seaweed-block/core/host/master/workspace_lost_range_readout_test.go @@ -97,7 +97,7 @@ func forcedMoveHost(t *testing.T, cfg Config) (*Host, func(), control.WorkspaceS t.Fatal(err) } line := waitAuthorityLine(t, h.Publisher(), "vol-f") - if _, err := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{VolumeId: "vol-f", ReplicaId: "r1", Epoch: line.Epoch}); err != nil { + if _, err := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-f", ReplicaId: "r1", Epoch: line.Epoch}); err != nil { t.Fatal(err) } return h, stop, client, &control.WorkspaceMove{RequestId: "force-1", VolumeId: "vol-f", ExpectedReplicaId: "r1", ExpectedEpoch: line.Epoch, TargetReplicaId: "r1", diff --git a/seaweed-block/core/host/master/workspace_move_integration_test.go b/seaweed-block/core/host/master/workspace_move_integration_test.go index 63bb0a3a32..8d1a0643fd 100644 --- a/seaweed-block/core/host/master/workspace_move_integration_test.go +++ b/seaweed-block/core/host/master/workspace_move_integration_test.go @@ -80,7 +80,7 @@ func TestIntegrationWorkspaceProductionDetachAndForcedMove(t *testing.T) { } defer conn.Close() client := control.NewWorkspaceServiceClient(conn) - id := &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch} lease, err := client.RenewWorkspaceLease(ctx, id) if err != nil { t.Fatal(err) diff --git a/seaweed-block/core/host/master/workspace_move_slot_test.go b/seaweed-block/core/host/master/workspace_move_slot_test.go index f6a31dbac6..6362bd1c8e 100644 --- a/seaweed-block/core/host/master/workspace_move_slot_test.go +++ b/seaweed-block/core/host/master/workspace_move_slot_test.go @@ -75,7 +75,7 @@ func TestWorkspaceMoveToAnotherSlotOnTheTargetHost(t *testing.T) { t.Fatalf("fixture lines a1=%+v a2=%+v", a1, a2) } // a2 stops cleanly on node-b: lease, revocation, ACK of its detached HEAD. - id := &control.WorkspaceIdentity{VolumeId: "a2", ReplicaId: "r1", Epoch: a2.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-b", VolumeId: "a2", ReplicaId: "r1", Epoch: a2.Epoch} if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_paused_grantee_test.go b/seaweed-block/core/host/master/workspace_paused_grantee_test.go index 69af179701..6a89dc26b9 100644 --- a/seaweed-block/core/host/master/workspace_paused_grantee_test.go +++ b/seaweed-block/core/host/master/workspace_paused_grantee_test.go @@ -159,7 +159,7 @@ func TestWorkspacePausedGranteeRefusedAtAttach(t *testing.T) { // The grantee renews (its guard is valid), then pauses before its claim. guard, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 2, EndpointVersion: 1, Healthy: true}}, skewLeaseClient{p}, - &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 2}, func(context.Context) (uint64, error) { return 0, nil }, func() time.Time { return hostNow }) + &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r", Epoch: 2}, func(context.Context) (uint64, error) { return 0, nil }, func() time.Time { return hostNow }) if err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_renewal_boundary_test.go b/seaweed-block/core/host/master/workspace_renewal_boundary_test.go index 4cf6c385c3..f49a9629ea 100644 --- a/seaweed-block/core/host/master/workspace_renewal_boundary_test.go +++ b/seaweed-block/core/host/master/workspace_renewal_boundary_test.go @@ -65,7 +65,7 @@ func TestWorkspaceHeldRenewalBoundary(t *testing.T) { p := authority.NewPublisher(dir, authority.WithStore(store), authority.WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return time.Unix(0, masterNS.Load()) }), authority.WithWorkspaceMaxClockSkew(4*time.Second)) seedSkewPublisher(t, p, dir) client := &heldSkewLeaseClient{skewLeaseClient: skewLeaseClient{p}, entered: make(chan *control.WorkspaceLeaseFact, 1), release: make(chan struct{})} - g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, client, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return time.Unix(0, hostNS.Load()) }) + g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, client, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return time.Unix(0, hostNS.Load()) }) if err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go index 2180dc080c..1ca711fc9f 100644 --- a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go +++ b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go @@ -150,11 +150,11 @@ func TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore(t *testing.T) { dir := &skewDirective{asks: make(chan authority.AssignmentAsk, 1)} p := authority.NewPublisher(dir, authority.WithStore(slow), authority.WithWorkspaceLeaseConfig(6*time.Second, nil)) t.Cleanup(p.CloseWorkspaceExtenders) // join extenders before the store closes - t.Cleanup(slow.release) // runs before the join above: frees a held Put first + t.Cleanup(slow.release) // runs before the join above: frees a held Put first seedSkewPublisher(t, p, dir) var stops atomic.Int32 g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, - deadlineLeaseClient{p: p, inflight: &inflight, slow: slow}, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, + deadlineLeaseClient{p: p, inflight: &inflight, slow: slow}, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { stops.Add(1); return 7, nil }, nil) if err != nil { t.Fatal(err) @@ -166,7 +166,7 @@ func TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore(t *testing.T) { cancel() <-runDone // Run returns on cancel; the go test timeout bounds a hang }) - t.Cleanup(slow.release) // first of all cleanups: a held Put never blocks the joins + t.Cleanup(slow.release) // first of all cleanups: a held Put never blocks the joins for !g.Projection().Healthy { // progress: the first grant time.Sleep(20 * time.Millisecond) } @@ -215,7 +215,7 @@ func TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite(t *testing.T) { reviewLegacyBind(t, h, c, ctx, "vol-b") line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} - id := &control.WorkspaceIdentity{VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} if _, err := svc.RenewWorkspaceLease(ctx, id); err != nil { t.Fatal(err) // first grant } diff --git a/seaweed-block/core/host/master/workspace_same_host_clean_test.go b/seaweed-block/core/host/master/workspace_same_host_clean_test.go index 6134a2c3d9..cd39d477b4 100644 --- a/seaweed-block/core/host/master/workspace_same_host_clean_test.go +++ b/seaweed-block/core/host/master/workspace_same_host_clean_test.go @@ -27,7 +27,7 @@ func TestWorkspaceRPCSameHostCleanMoveKeepsRepreparedBinding(t *testing.T) { if line := waitAuthorityLine(t, h.Publisher(), "v"); line.Epoch != 1 { t.Fatal(line) } - id := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r1", Epoch: 1} if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_service_test.go b/seaweed-block/core/host/master/workspace_service_test.go index 7efb8e8986..cd0159093e 100644 --- a/seaweed-block/core/host/master/workspace_service_test.go +++ b/seaweed-block/core/host/master/workspace_service_test.go @@ -72,7 +72,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { client := control.NewWorkspaceServiceClient(conn) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - id := &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: "r2", Epoch: 1} + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: "r2", Epoch: 1} stops := 0 g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "vol-a", ReplicaID: "r2", Epoch: 1, Healthy: true}}, client, id, func(context.Context) (uint64, error) { stops++; return 9, nil }, nil) @@ -107,7 +107,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { t.Fatal(err) } initial, err := stream.Recv() - if err != nil || initial.ReplicaId != "r2" || initial.Epoch != 1 { + if err != nil || initial.ServerId != "node-a" || initial.ReplicaId != "r2" || initial.Epoch != 1 { t.Fatal("initial assignment", initial, err) } beforeLine, _ := h.Publisher().VolumeAuthorityLine("vol-a") @@ -133,7 +133,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { t.Fatal(grant) } delivered, err := stream.Recv() - if err != nil || delivered.ReplicaId != "r2" || delivered.Epoch != 2 || delivered.DataAddr != q.TargetDataAddr || delivered.CtrlAddr != q.TargetCtrlAddr || len(delivered.Peers) != 0 { + if err != nil || delivered.ServerId != "node-b" || delivered.ReplicaId != "r2" || delivered.Epoch != 2 || delivered.DataAddr != q.TargetDataAddr || delivered.CtrlAddr != q.TargetCtrlAddr || len(delivered.Peers) != 0 { t.Fatal("same-ID move was not delivered on the existing stream with no retired peer", delivered, err) } cancelStream() @@ -144,7 +144,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { if _, err := client.RenewWorkspaceLease(ctx, id); err == nil { t.Fatal("old authority renewed") } - if _, err := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: "r2", Epoch: 2}); err != nil { + if _, err := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-b", VolumeId: "vol-a", ReplicaId: "r2", Epoch: 2}); err != nil { t.Fatal(err) } if err := h.Close(ctx); err != nil { diff --git a/seaweed-block/core/host/master/workspace_skew_test.go b/seaweed-block/core/host/master/workspace_skew_test.go index 530294eeea..2b52a2b8ef 100644 --- a/seaweed-block/core/host/master/workspace_skew_test.go +++ b/seaweed-block/core/host/master/workspace_skew_test.go @@ -43,7 +43,7 @@ func TestWorkspaceSkewSeparatesOldServingFromForcedGrant(t *testing.T) { dir := &skewDirective{asks: make(chan authority.AssignmentAsk, 1)} p := authority.NewPublisher(dir, authority.WithStore(store), authority.WithWorkspaceLeaseConfig(3*time.Second, func() time.Time { return masterNow })) seedSkewPublisher(t, p, dir) - g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, skewLeaseClient{p}, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return hostNow }) + g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true}}, skewLeaseClient{p}, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return hostNow }) if err != nil { t.Fatal(err) } @@ -135,7 +135,7 @@ func TestWorkspaceClockSkewConfigReachesLeaseReply(t *testing.T) { t.Fatal(err) } line := waitAuthorityLine(t, h.Publisher(), "vol-a") - reply, err := (&services{host: h}).RenewWorkspaceLease(context.Background(), &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch}) + reply, err := (&services{host: h}).RenewWorkspaceLease(context.Background(), &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch}) if err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/host/master/workspace_unclaimed_grant_test.go b/seaweed-block/core/host/master/workspace_unclaimed_grant_test.go index 3a6b4defa4..5696a78b7e 100644 --- a/seaweed-block/core/host/master/workspace_unclaimed_grant_test.go +++ b/seaweed-block/core/host/master/workspace_unclaimed_grant_test.go @@ -92,7 +92,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) { t.Fatal(err) } oldLine := waitAuthorityLine(t, m.Publisher(), "vol-a") - oldID := &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: oldLine.ReplicaID, Epoch: oldLine.Epoch} + oldID := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: oldLine.ReplicaID, Epoch: oldLine.Epoch} if _, err = ws.RenewWorkspaceLease(ctx, oldID); err != nil { t.Fatal(err) } @@ -148,7 +148,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) { if !grant.Issued || grant.NewEpoch != grantee+1 || line.Epoch != grant.NewEpoch || grant.HeadGen != seed.Gen || grant.RemoteLsn != seed.RemoteLSN { t.Fatalf("forced grant %+v line %+v; want epoch %d on HEAD gen %d lsn %d", grant, line, grantee+1, seed.Gen, seed.RemoteLSN) } - if _, err := ws.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{VolumeId: "vol-a", ReplicaId: "r1", Epoch: grantee}); err == nil { + if _, err := ws.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: "r1", Epoch: grantee}); err == nil { t.Fatal("the dead grantee's epoch renewed after the forced move") } diff --git a/seaweed-block/core/host/volume/apply_fact_test.go b/seaweed-block/core/host/volume/apply_fact_test.go index f901405c7d..d95f735737 100644 --- a/seaweed-block/core/host/volume/apply_fact_test.go +++ b/seaweed-block/core/host/volume/apply_fact_test.go @@ -132,7 +132,7 @@ func TestHost_ApplyFact_Self_InstallsReplicaSetBeforeAssignment(t *testing.T) { PeerSetGeneration: 42, } - h.applyFact(fact) + h.applyFixtureFact(fact) // Both collaborators called exactly once. if got := r.callCount.Load(); got != 1 { @@ -188,7 +188,7 @@ func TestHost_ApplyFact_Self_UpdateReplicaSetFailure_SkipsOnAssignment(t *testin PeerSetGeneration: 7, } - h.applyFact(fact) + h.applyFixtureFact(fact) // UpdateReplicaSet was called (once). if got := r.callCount.Load(); got != 1 { @@ -223,7 +223,7 @@ func TestHost_ApplyFact_Self_LocalReadinessBlocked_SkipsReplicationAndAdapter(t }, } - h.applyFact(fact) + h.applyFixtureFact(fact) if got := r.callCount.Load(); got != 0 { t.Fatalf("local readiness block must skip UpdateReplicaSet: got %d calls", got) @@ -258,7 +258,7 @@ func TestHost_ApplyFact_SupportingReplica_LocalReadinessBlocked_SkipsAdapter(t * }, } - h.applyFact(fact) + h.applyFixtureFact(fact) if got := a.callCount.Load(); got != 0 { t.Fatalf("local readiness block must skip supporting OnAssignment: got %d calls", got) @@ -294,7 +294,7 @@ func TestHost_ApplyFact_SupportingReplica_ReplaysAfterLocalReadinessClears(t *te }}, } - h.applyFact(fact) + h.applyFixtureFact(fact) h.ClearLocalReadinessBlock() h.replayLocalReadinessFactIfReady() @@ -337,7 +337,7 @@ func TestHost_ApplyFact_Self_ReplaysAfterLocalReadinessClearsWithReplicationFirs }}, } - h.applyFact(fact) + h.applyFixtureFact(fact) h.ClearLocalReadinessBlock() h.replayLocalReadinessFactIfReady() @@ -372,7 +372,7 @@ func TestHost_ApplyFact_Supersede_NeverCallsAdapterOrReplication(t *testing.T) { PeerSetGeneration: 100, } - h.applyFact(fact) + h.applyFixtureFact(fact) if a.callCount.Load() != 0 { t.Fatalf("supersede must not call adapter: got %d calls", a.callCount.Load()) @@ -411,7 +411,7 @@ func TestHost_ApplyFact_SupportingReplica_UsesSelfPeerDescriptorWithoutReplicati PeerSetGeneration: 100, } - h.applyFact(fact) + h.applyFixtureFact(fact) if got := a.callCount.Load(); got != 1 { t.Fatalf("supporting replica should apply self peer lineage once: got %d calls", got) @@ -454,7 +454,7 @@ func TestHost_ApplyFact_SupportingReplica_UsesSelfPeerDescriptorWithoutReplicati PeerSetGeneration: 101, } - h.applyFact(primaryFact) + h.applyFixtureFact(primaryFact) if got := a.callCount.Load(); got != 2 { t.Fatalf("promotion after supporting assignment should apply adapter again: got %d calls", got) @@ -490,7 +490,7 @@ func TestHost_ApplyFact_SupportingReplica_InvalidSelfPeerDescriptorStaysSupersed }}, } - h.applyFact(fact) + h.applyFixtureFact(fact) if got := a.callCount.Load(); got != 0 { t.Fatalf("invalid supporting peer descriptor must not call adapter: got %d calls", got) @@ -521,7 +521,7 @@ func TestHost_ApplyFact_SupportingReplica_MismatchedSelfPeerLineageStaysSupersed }}, } - h.applyFact(fact) + h.applyFixtureFact(fact) if got := a.callCount.Load(); got != 0 { t.Fatalf("mismatched supporting peer lineage must not call adapter: got %d calls", got) @@ -548,7 +548,7 @@ func TestHost_ApplyFact_SupportingReplica_ReportsReplicaReadyButNotFrontendPrima h.view = NewAdapterProjectionView(a, "vol1", "r2", h) s := NewStatusServer(h.view) - h.applyFact(&control.AssignmentFact{ + h.applyFixtureFact(&control.AssignmentFact{ VolumeId: "vol1", ReplicaId: "r1", Epoch: 7, @@ -619,7 +619,7 @@ func TestHost_ApplyFact_ObserverOnly_NoReplicationCallsOnAssignment(t *testing.T }}, } - h.applyFact(fact) + h.applyFixtureFact(fact) if a.callCount.Load() != 1 { t.Fatalf("observer-only must call adapter: got %d", a.callCount.Load()) diff --git a/seaweed-block/core/host/volume/assignment_identity_fixture_test.go b/seaweed-block/core/host/volume/assignment_identity_fixture_test.go new file mode 100644 index 0000000000..100310bb7c --- /dev/null +++ b/seaweed-block/core/host/volume/assignment_identity_fixture_test.go @@ -0,0 +1,28 @@ +package volume + +import ( + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/protobuf/proto" +) + +// applyFixtureFact supplies the explicit holder identity for pre-r2.34 tests +// whose subject is peer ordering, readiness or recovery. Identity-refusal +// regressions call applyFact directly and never use this fixture constructor. +func (h *Host) applyFixtureFact(f *control.AssignmentFact) { + f = proto.Clone(f).(*control.AssignmentFact) + if h.cfg.ServerID == "" { + h.cfg.ServerID = "fixture-server" + } + if f.ServerId == "" { + f.ServerId = h.cfg.ServerID + } + if f.ReplicaId == h.cfg.ReplicaID { + if h.cfg.DataAddr == "" { + h.cfg.DataAddr = f.DataAddr + } + if h.cfg.CtrlAddr == "" { + h.cfg.CtrlAddr = f.CtrlAddr + } + } + h.applyFact(f) +} diff --git a/seaweed-block/core/host/volume/chunk_bootstrap_test.go b/seaweed-block/core/host/volume/chunk_bootstrap_test.go index a451f269dd..a7b35ef46a 100644 --- a/seaweed-block/core/host/volume/chunk_bootstrap_test.go +++ b/seaweed-block/core/host/volume/chunk_bootstrap_test.go @@ -34,7 +34,7 @@ func TestWALStoreChunk_ProductionStartupPublishesUnderAssignedEpoch(t *testing.T // main.go: block readiness before Start; the assignment arrives and // is retained, not applied. h.BlockLocalReadiness("awaiting durable recovery") - h.applyFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 5, EndpointVersion: 2, PeerSetGeneration: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 5, EndpointVersion: 2, PeerSetGeneration: 1}) if p := h.ProjectionView().Projection(); p.Healthy || p.Epoch != 0 { t.Fatalf("assignment applied while readiness was blocked: %+v", p) } diff --git a/seaweed-block/core/host/volume/chunk_seed_replication_test.go b/seaweed-block/core/host/volume/chunk_seed_replication_test.go index efc367b340..a687a309fd 100644 --- a/seaweed-block/core/host/volume/chunk_seed_replication_test.go +++ b/seaweed-block/core/host/volume/chunk_seed_replication_test.go @@ -62,7 +62,7 @@ func restoredHostWrites(t *testing.T, inheritedLSN uint64, observerAfterSeed boo // main.go order: readiness blocked, the assignment (epoch 5) retained. h.BlockLocalReadiness("awaiting durable recovery") - h.applyFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 5, EndpointVersion: 2, PeerSetGeneration: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 5, EndpointVersion: 2, PeerSetGeneration: 1}) dp, err := durable.NewDurableProvider(durable.ProviderConfig{ Impl: durable.ImplWALStoreChunk, diff --git a/seaweed-block/core/host/volume/g1_admission_latch_test.go b/seaweed-block/core/host/volume/g1_admission_latch_test.go index a86aa67d70..dfe98932b4 100644 --- a/seaweed-block/core/host/volume/g1_admission_latch_test.go +++ b/seaweed-block/core/host/volume/g1_admission_latch_test.go @@ -59,7 +59,7 @@ func TestG1_FailedRoleAdmissionStopsAPreviouslyHealthyFrontend(t *testing.T) { if err := h.SetSelfFence(fencer); err != nil { t.Fatal(err) } - h.applyFact(selfFact(2)) + h.applyFixtureFact(selfFact(2)) if a.callCount.Load() != 1 { t.Fatal("fixture: primary at epoch 2 not adopted") } @@ -74,7 +74,7 @@ func TestG1_FailedRoleAdmissionStopsAPreviouslyHealthyFrontend(t *testing.T) { } fencer.fail.Store(true) - h.applyFact(selfFact(3)) // the epoch advance whose floor persist fails + h.applyFixtureFact(selfFact(3)) // the epoch advance whose floor persist fails if a.callCount.Load() != 1 { t.Fatal("the epoch-3 role was adopted though its floor persist failed") } @@ -92,7 +92,7 @@ func TestG1_FailedRoleAdmissionStopsAPreviouslyHealthyFrontend(t *testing.T) { } fencer.fail.Store(false) - h.applyFact(selfFact(3)) // master's stream replay redelivers + h.applyFixtureFact(selfFact(3)) // master's stream replay redelivers if failed, _ := h.RoleAdmissionFailure(); failed { t.Fatal("latch not cleared by a successful redelivery") } @@ -115,7 +115,7 @@ func TestG1_SupportingAdmissionFailsClosed(t *testing.T) { if err := h.SetSelfFence(fencer); err != nil { t.Fatal(err) } - h.applyFact(&control.AssignmentFact{ + h.applyFixtureFact(&control.AssignmentFact{ VolumeId: "vol1", ReplicaId: "rA", Epoch: 2, EndpointVersion: 1, DataAddr: "127.0.0.1:3", CtrlAddr: "127.0.0.1:4", PeerSetGeneration: 2, Peers: []*control.ReplicaDescriptor{{ReplicaId: "rB", Epoch: 2, EndpointVersion: 1, DataAddr: "127.0.0.1:5", CtrlAddr: "127.0.0.1:6"}}, @@ -132,7 +132,7 @@ func TestG1_SupportingAdmissionFailsClosed(t *testing.T) { // failure is returned (the binary then does not serve) and latched. func TestG1_SetSelfFenceReturnsTheReplayError(t *testing.T) { h, _, _ := newStubbedHost(t, "vol1", "rB", &orderingRecorder{}) - h.applyFact(selfFact(2)) // no listener yet: the role is recorded + h.applyFixtureFact(selfFact(2)) // no listener yet: the role is recorded fencer := &switchFencer{} fencer.fail.Store(true) if err := h.SetSelfFence(fencer); err == nil { @@ -175,7 +175,7 @@ func TestG1_StaleReplayDoesNotClearANewerAdmissionFailure(t *testing.T) { if err := h.SetSelfFence(fencer); err != nil { t.Fatal(err) } - h.applyFact(selfFact(2)) + h.applyFixtureFact(selfFact(2)) store := memorywal.NewStore(8, 4096) t.Cleanup(func() { _ = store.Close() }) backend := durable.NewStorageBackend(store, h.view, frontend.Identity{VolumeID: "vol1", ReplicaID: "rB", Epoch: 2, EndpointVersion: 1}) @@ -184,8 +184,8 @@ func TestG1_StaleReplayDoesNotClearANewerAdmissionFailure(t *testing.T) { if _, err := backend.Write(ctx, 0, []byte("baseline")); err != nil { t.Fatal(err) } - h.applyFact(selfFact(3)) // fails: latched - h.applyFact(selfFact(2)) // stale replay; its role call would succeed + h.applyFixtureFact(selfFact(3)) // fails: latched + h.applyFixtureFact(selfFact(2)) // stale replay; its role call would succeed if failed, _ := h.RoleAdmissionFailure(); !failed { t.Fatal("a stale epoch-2 replay cleared the unresolved epoch-3 admission failure") } @@ -193,7 +193,7 @@ func TestG1_StaleReplayDoesNotClearANewerAdmissionFailure(t *testing.T) { t.Fatalf("stale replay reopened writes: %v", err) } fencer.failAt.Store(0) - h.applyFact(selfFact(3)) // the current epoch, now durable + h.applyFixtureFact(selfFact(3)) // the current epoch, now durable if failed, _ := h.RoleAdmissionFailure(); failed { t.Fatal("the current epoch's success did not clear the latch") } @@ -207,10 +207,10 @@ func TestG1_StaleSupportingReplayDoesNotClearTheLatch(t *testing.T) { if err := h.SetSelfFence(fencer); err != nil { t.Fatal(err) } - h.applyFact(supportingFact(2)) - h.applyFact(supportingFact(3)) // fails + h.applyFixtureFact(supportingFact(2)) + h.applyFixtureFact(supportingFact(3)) // fails calls := a.callCount.Load() - h.applyFact(supportingFact(2)) // stale + h.applyFixtureFact(supportingFact(2)) // stale if failed, _ := h.RoleAdmissionFailure(); !failed { t.Fatal("a stale supporting replay cleared the latch") } @@ -218,7 +218,7 @@ func TestG1_StaleSupportingReplayDoesNotClearTheLatch(t *testing.T) { t.Fatal("a stale supporting replay was admitted") } fencer.failAt.Store(0) - h.applyFact(supportingFact(3)) + h.applyFixtureFact(supportingFact(3)) if failed, _ := h.RoleAdmissionFailure(); failed { t.Fatal("the current supporting admission did not clear the latch") } @@ -234,8 +234,8 @@ func TestG1_InstallReplayTargetsTheCurrentRole(t *testing.T) { if err := h.SetSelfFence(failing); err != nil { t.Fatal(err) } - h.applyFact(selfFact(3)) // fails - h.applyFact(selfFact(2)) // stale + h.applyFixtureFact(selfFact(3)) // fails + h.applyFixtureFact(selfFact(2)) // stale recorder := &recordingFencer{} if err := h.SetSelfFence(recorder); err != nil { t.Fatalf("install replay: %v", err) diff --git a/seaweed-block/core/host/volume/g2_self_fence_test.go b/seaweed-block/core/host/volume/g2_self_fence_test.go index ae461495f2..12bac92e19 100644 --- a/seaweed-block/core/host/volume/g2_self_fence_test.go +++ b/seaweed-block/core/host/volume/g2_self_fence_test.go @@ -82,7 +82,7 @@ func TestG2_PromotedHostRefusesShipFromDeposedPrimary(t *testing.T) { } // Master promotes B to primary at epoch 2: the production role path. - h.applyFact(&control.AssignmentFact{ + h.applyFixtureFact(&control.AssignmentFact{ VolumeId: "vol1", ReplicaId: "rB", // self Epoch: 2, @@ -119,7 +119,7 @@ func (s stubFencer) AdmitAsReplica(uint64) error { return nil } func TestG2_HostDoesNotAdoptPrimaryWhenItsListenerCannotBeFenced(t *testing.T) { h, a, _ := newStubbedHost(t, "vol1", "rB", &orderingRecorder{}) h.SetSelfFence(stubFencer{err: errors.New("2 replication mutation(s) still in flight")}) - h.applyFact(&control.AssignmentFact{ + h.applyFixtureFact(&control.AssignmentFact{ VolumeId: "vol1", ReplicaId: "rB", Epoch: 2, diff --git a/seaweed-block/core/host/volume/recovery_typed_reason_test.go b/seaweed-block/core/host/volume/recovery_typed_reason_test.go index edb9011f1e..8fb0ea837a 100644 --- a/seaweed-block/core/host/volume/recovery_typed_reason_test.go +++ b/seaweed-block/core/host/volume/recovery_typed_reason_test.go @@ -98,7 +98,7 @@ func TestLocalRecoveryFailure_CorruptWALReportsWALCorruptAtOnce(t *testing.T) { if got := h.ReportLocalRecoveryFailure(report.Err); got != UnhealthyWALCorrupt { t.Fatalf("ReportLocalRecoveryFailure(%v)=%q; want %s", report.Err, got, UnhealthyWALCorrupt) } - h.applyFact(selfPrimaryFact(1)) // refused by the readiness block, but primary-assigned + h.applyFixtureFact(selfPrimaryFact(1)) // refused by the readiness block, but primary-assigned if s := reportSlot(t, h); s.Eligible || s.UnhealthyReason != UnhealthyWALCorrupt { t.Fatalf("primary-assigned after corrupt recovery: eligible=%t reason=%q; want ineligible, %s at once", s.Eligible, s.UnhealthyReason, UnhealthyWALCorrupt) } @@ -119,14 +119,14 @@ func TestLocalRecoveryFailure_ScopeAndUnclassifiedFallback(t *testing.T) { if s := reportSlot(t, h); !s.Eligible || s.UnhealthyReason != "" { t.Fatalf("not primary-assigned: %+v; want not flagged", s) } - h.applyFact(selfPrimaryFact(1)) + h.applyFixtureFact(selfPrimaryFact(1)) if s := reportSlot(t, h); s.UnhealthyReason != UnhealthyIOError { t.Fatalf("primary-assigned with an I/O recovery failure: reason=%q; want %s", s.UnhealthyReason, UnhealthyIOError) } h2, clk2 := watchdogHost(t, 10*time.Second) h2.ReportLocalRecoveryFailure(errors.New("unclassified")) - h2.applyFact(selfPrimaryFact(1)) + h2.applyFixtureFact(selfPrimaryFact(1)) if s := reportSlot(t, h2); s.UnhealthyReason != "" { t.Fatalf("unclassified failure inside the timeout: reason=%q; want none yet", s.UnhealthyReason) } diff --git a/seaweed-block/core/host/volume/recovery_watchdog_test.go b/seaweed-block/core/host/volume/recovery_watchdog_test.go index 072d170b1c..5ec6552fb2 100644 --- a/seaweed-block/core/host/volume/recovery_watchdog_test.go +++ b/seaweed-block/core/host/volume/recovery_watchdog_test.go @@ -46,7 +46,7 @@ func reportSlot(t *testing.T, h *Host) *control.HeartbeatSlot { // unhealthy (Eligible=false, recovery_timeout) once the timeout elapses. func TestRecoveryWatchdog_PrimaryNotReadyPastTimeoutReportsUnhealthy(t *testing.T) { h, clk := watchdogHost(t, 30*time.Second) - h.applyFact(selfPrimaryFact(1)) + h.applyFixtureFact(selfPrimaryFact(1)) clk.advance(29 * time.Second) if s := reportSlot(t, h); !s.Eligible || s.UnhealthyReason != "" || s.ReadyForPrimary { @@ -64,8 +64,8 @@ func TestRecoveryWatchdog_PrimaryNotReadyPastTimeoutReportsUnhealthy(t *testing. // A supporting replica in a long catch-up is never flagged. func TestRecoveryWatchdog_SupportingReplicaNotFlagged(t *testing.T) { h, clk := watchdogHost(t, 30*time.Second) - h.applyFact(selfPrimaryFact(1)) - h.applyFact(&control.AssignmentFact{ // another replica is now primary + h.applyFixtureFact(selfPrimaryFact(1)) + h.applyFixtureFact(&control.AssignmentFact{ // another replica is now primary VolumeId: "v1", ReplicaId: "r2", Epoch: 2, EndpointVersion: 1, DataAddr: "127.0.0.1:9301", CtrlAddr: "127.0.0.1:9302", }) @@ -127,7 +127,7 @@ func TestRecoveryWatchdog_RoleAdmissionFailure(t *testing.T) { // catch-up state. func TestRecoveryWatchdog_StatusShowsReasonAndCatchUp(t *testing.T) { h, clk := watchdogHost(t, time.Second) - h.applyFact(selfPrimaryFact(1)) + h.applyFixtureFact(selfPrimaryFact(1)) clk.advance(2 * time.Second) s := NewStatusServer(h.view) if got := s.statusProjection().UnhealthyReason; got != UnhealthyRecoveryTimeout { @@ -148,7 +148,7 @@ func TestRecoveryWatchdog_StatusShowsReasonAndCatchUp(t *testing.T) { // no recovery_timeout, however long it lasts. func TestRecoveryWatchdog_ReadyThenLaterNotReadyReportsNoTimeout(t *testing.T) { h, clk := watchdogHost(t, 10*time.Second) - h.applyFact(selfPrimaryFact(1)) + h.applyFixtureFact(selfPrimaryFact(1)) clk.advance(time.Second) if r := h.unhealthyReason(readyAt(1), true); r != "" { t.Fatalf("ready: %q", r) @@ -157,7 +157,7 @@ func TestRecoveryWatchdog_ReadyThenLaterNotReadyReportsNoTimeout(t *testing.T) { if r := h.unhealthyReason(readyAt(1), 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 + h.applyFixtureFact(selfPrimaryFact(1)) // the same assignment replayed: still disarmed clk.advance(time.Hour) if r := h.unhealthyReason(readyAt(1), false); r != "" { t.Fatalf("same assignment replayed: %q; want still disarmed", r) @@ -169,7 +169,7 @@ func TestRecoveryWatchdog_ReadyThenLaterNotReadyReportsNoTimeout(t *testing.T) { // 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)) + old.applyFixtureFact(selfPrimaryFact(1)) if r := old.unhealthyReason(readyAt(1), true); r != "" { t.Fatalf("old process ready: %q", r) } @@ -178,7 +178,7 @@ func TestRecoveryWatchdog_NewIncarnationRearms(t *testing.T) { if restarted.incarnation == old.incarnation { t.Fatalf("restarted process kept incarnation %q", old.incarnation) } - restarted.applyFact(selfPrimaryFact(1)) // same primary epoch + restarted.applyFixtureFact(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) @@ -213,13 +213,13 @@ func TestRecoveryWatchdog_OldEpochReadyDoesNotDisarmNewAssignment(t *testing.T) ready := &engine.PromotionReadyFact{Ready: true, Epoch: 2, EndpointVersion: 1, ReplicaID: "rB"} readyView(h, "vol1", "rB", ready) - h.applyFact(selfFact(2)) + h.applyFixtureFact(selfFact(2)) if s := reportSlot(t, h); !s.Eligible || s.UnhealthyReason != "" { t.Fatalf("ready primary at epoch 2: %+v", s) } repl.returnErr = errors.New("injected: peer set install failed") - h.applyFact(selfFact(3)) // refused: the adapter stays at epoch 2 + h.applyFixtureFact(selfFact(3)) // refused: the adapter stays at epoch 2 if a.callCount.Load() != 1 { t.Fatal("fixture: the epoch-3 assignment was adopted") } @@ -247,19 +247,19 @@ func TestRecoveryWatchdog_G1LatchWinsOverOldReady(t *testing.T) { if err := h.SetSelfFence(fencer); err != nil { t.Fatal(err) } - h.applyFact(selfFact(2)) + h.applyFixtureFact(selfFact(2)) if s := reportSlot(t, h); !s.Eligible || s.UnhealthyReason != "" { t.Fatalf("ready primary at epoch 2: %+v", s) } fencer.fail.Store(true) - h.applyFact(selfFact(3)) // role call fails: G1 latch + h.applyFixtureFact(selfFact(3)) // role call fails: G1 latch if s := reportSlot(t, h); s.Eligible || s.UnhealthyReason != UnhealthyRoleAdmission { t.Fatalf("G1 latch with an old ready fact: eligible=%t reason=%q; want %s", s.Eligible, s.UnhealthyReason, UnhealthyRoleAdmission) } fencer.fail.Store(false) - h.applyFact(selfFact(3)) // redelivery succeeds + h.applyFixtureFact(selfFact(3)) // redelivery succeeds *ready = engine.PromotionReadyFact{Ready: true, Epoch: 3, EndpointVersion: 1, ReplicaID: "rB"} if s := reportSlot(t, h); !s.Eligible || s.UnhealthyReason != "" { t.Fatalf("after successful redelivery and an epoch-3 ready fact: eligible=%t reason=%q; want cleared", s.Eligible, s.UnhealthyReason) diff --git a/seaweed-block/core/host/volume/rf1_only_test.go b/seaweed-block/core/host/volume/rf1_only_test.go index fd9b0b3b16..5d0c6003ff 100644 --- a/seaweed-block/core/host/volume/rf1_only_test.go +++ b/seaweed-block/core/host/volume/rf1_only_test.go @@ -42,7 +42,7 @@ func TestRF1Only_RetainedReplicatedFactReplayedBeforeSelfFence(t *testing.T) { h.replication = nil h.BlockLocalReadiness("awaiting durable recovery") - h.applyFact(rf2PrimaryFact(3)) // stored for replay + h.applyFixtureFact(rf2PrimaryFact(3)) // stored for replay h.ClearLocalReadinessBlock() h.replicationMu.Lock() h.setReplicationLocked(rv) // what SetReplicationVolume does, then it replays @@ -63,7 +63,7 @@ func TestRF1Only_RetainedReplicatedFactReplayedBeforeSelfFence(t *testing.T) { // A supporting-replica fact (another primary lists this replica) is refused too. sup := rf2PrimaryFact(4) sup.ReplicaId, sup.Peers[0].ReplicaId = "r2", "r1" - h.applyFact(sup) + h.applyFixtureFact(sup) if r.callCount.Load() != 0 || a.callCount.Load() != 0 || len(ready) != 0 { t.Fatal("supporting replica admitted on an RF1-only volume") } @@ -74,7 +74,7 @@ func TestRF1Only_RetainedReplicatedFactReplayedBeforeSelfFence(t *testing.T) { // The master moves the volume to RF1: adopted, latch cleared, ready emitted. rf1 := rf2PrimaryFact(5) rf1.Peers = nil - h.applyFact(rf1) + h.applyFixtureFact(rf1) if a.callCount.Load() != 1 || len(ready) != 1 { t.Fatalf("RF1 primary not adopted: adopt=%d ready=%d", a.callCount.Load(), len(ready)) } @@ -87,7 +87,7 @@ func TestRF1Only_RetainedReplicatedFactReplayedBeforeSelfFence(t *testing.T) { // and is adopted (today's behaviour for replicated volumes). func TestRF1Only_UnsetKeepsReplicatedAdoption(t *testing.T) { h, a, r := newStubbedHost(t, "vol1", "r1", &orderingRecorder{}) - h.applyFact(rf2PrimaryFact(3)) + h.applyFixtureFact(rf2PrimaryFact(3)) if r.callCount.Load() != 1 || a.callCount.Load() != 1 { t.Fatalf("replicated fact not applied: peers=%d adopt=%d", r.callCount.Load(), a.callCount.Load()) } @@ -102,25 +102,25 @@ func TestRF1Only_UnsetKeepsReplicatedAdoption(t *testing.T) { // epoch or newer, once its role is admitted, clears it. func TestRF1Only_StaleRF1FactDoesNotClearANewerRefusal(t *testing.T) { f := newRF1BackendHost(t) - f.h.applyFact(rf1Fact(2)) + f.h.applyFixtureFact(rf1Fact(2)) if f.a.callCount.Load() != 1 { t.Fatal("fixture: RF1@2 not adopted") } f.mustWrite(t, 2, 0xD2) - f.h.applyFact(rf2PrimaryFact(3)) + f.h.applyFixtureFact(rf2PrimaryFact(3)) f.assertRefusedAt(t, 3) - f.h.applyFact(rf1Fact(2)) // stale replay below the refused epoch + f.h.applyFixtureFact(rf1Fact(2)) // stale replay below the refused epoch f.assertRefusedAt(t, 3) if f.a.callCount.Load() != 1 || f.r.callCount.Load() != 1 { t.Fatalf("stale RF1@2 adopted or RF2 peers installed: adopt=%d peerSets=%d", f.a.callCount.Load(), f.r.callCount.Load()) } f.fencer.fail.Store(true) // RF1@3 whose role fence fails: a failed attempt does not clear the refusal - f.h.applyFact(rf1Fact(3)) + f.h.applyFixtureFact(rf1Fact(3)) if _, reason := f.h.RoleAdmissionFailure(); !strings.Contains(reason, "refuses a primary role") || f.a.callCount.Load() != 1 { t.Fatalf("failed RF1@3 attempt cleared the refusal: %q adopt=%d", reason, f.a.callCount.Load()) } f.fencer.fail.Store(false) - f.h.applyFact(rf1Fact(3)) + f.h.applyFixtureFact(rf1Fact(3)) if failed, reason := f.h.RoleAdmissionFailure(); failed || f.a.callCount.Load() != 2 { t.Fatalf("RF1@3 did not reconcile: %v %q adopt=%d", failed, reason, f.a.callCount.Load()) } @@ -199,22 +199,22 @@ func (f *rf1Fixture) assertRefusedAt(t *testing.T, epoch uint64) { // clear that newer refusal nor adopt. RF1@3 then admits and serves at epoch 3. func TestRF1Only_HeldRF1ReplayDoesNotClearANewerRefusal(t *testing.T) { f := newRF1BackendHost(t) - f.h.applyFact(rf1Fact(2)) + f.h.applyFixtureFact(rf1Fact(2)) f.mustWrite(t, 2, 0xA2) fired := false f.h.rf1BeforeAdmit = func() { if !fired { fired = true - f.h.applyFact(rf2PrimaryFact(3)) + f.h.applyFixtureFact(rf2PrimaryFact(3)) } } - f.h.applyFact(rf1Fact(2)) + f.h.applyFixtureFact(rf1Fact(2)) f.h.rf1BeforeAdmit = nil if !fired || f.a.callCount.Load() != 1 { t.Fatalf("fixture fired=%v; held RF1@2 adopted=%d", fired, f.a.callCount.Load()) } f.assertRefusedAt(t, 3) - f.h.applyFact(rf1Fact(3)) + f.h.applyFixtureFact(rf1Fact(3)) if failed, reason := f.h.RoleAdmissionFailure(); failed || f.a.callCount.Load() != 2 || f.a.lastInfo.Epoch != 3 { t.Fatalf("current RF1@3 not admitted: %v %q adopt=%d", failed, reason, f.a.callCount.Load()) } @@ -241,7 +241,7 @@ func (u *holdingUpdater) UpdateReplicaSet(gen uint64, targets []replication.Repl // replay then resumes. Bounded by timeouts. func TestRF1Only_ParallelHeldReplayAndNewerRefusal(t *testing.T) { f := newRF1BackendHost(t) - f.h.applyFact(rf1Fact(2)) + f.h.applyFixtureFact(rf1Fact(2)) f.mustWrite(t, 2, 0xB2) u := &holdingUpdater{inner: f.r, entered: make(chan struct{}), release: make(chan struct{})} u.armed.Store(true) @@ -273,14 +273,14 @@ func TestRF1Only_ParallelHeldReplayAndNewerRefusal(t *testing.T) { } }) replayStarted = true - go func() { defer close(replay); f.h.applyFact(rf1Fact(2)) }() + go func() { defer close(replay); f.h.applyFixtureFact(rf1Fact(2)) }() select { case <-u.entered: case <-time.After(5 * time.Second): t.Fatal("replay worker did not reach the peer-set update") } streamStarted = true - go func() { defer close(stream); f.h.applyFact(rf2PrimaryFact(3)) }() + go func() { defer close(stream); f.h.applyFixtureFact(rf2PrimaryFact(3)) }() select { case <-stream: case <-time.After(5 * time.Second): @@ -296,7 +296,7 @@ func TestRF1Only_ParallelHeldReplayAndNewerRefusal(t *testing.T) { t.Fatalf("parked RF1@2 adopted after the newer refusal: adopt=%d", f.a.callCount.Load()) } f.assertRefusedAt(t, 3) - f.h.applyFact(rf1Fact(3)) + f.h.applyFixtureFact(rf1Fact(3)) if failed, reason := f.h.RoleAdmissionFailure(); failed || f.a.callCount.Load() != 2 { t.Fatalf("current RF1@3 not admitted: %v %q", failed, reason) } @@ -306,18 +306,18 @@ func TestRF1Only_ParallelHeldReplayAndNewerRefusal(t *testing.T) { // A stale RF2 below an admitted RF1 epoch does not re-latch the refusal. func TestRF1Only_StaleRF2AfterNewerRF1DoesNotRelatch(t *testing.T) { f := newRF1BackendHost(t) - f.h.applyFact(rf1Fact(2)) - f.h.applyFact(rf2PrimaryFact(3)) - f.h.applyFact(rf1Fact(4)) + f.h.applyFixtureFact(rf1Fact(2)) + f.h.applyFixtureFact(rf2PrimaryFact(3)) + f.h.applyFixtureFact(rf1Fact(4)) if failed, reason := f.h.RoleAdmissionFailure(); failed || f.a.callCount.Load() != 2 { t.Fatalf("RF1@4 not admitted: %v %q adopt=%d", failed, reason, f.a.callCount.Load()) } - f.h.applyFact(rf2PrimaryFact(3)) // stale replay + f.h.applyFixtureFact(rf2PrimaryFact(3)) // stale replay if failed, reason := f.h.RoleAdmissionFailure(); failed { t.Fatalf("stale RF2@3 re-latched after RF1@4: %q", reason) } f.mustWrite(t, 4, 0xC4) - f.h.applyFact(rf2PrimaryFact(4)) // same epoch, peers added: refused + f.h.applyFixtureFact(rf2PrimaryFact(4)) // same epoch, peers added: refused if failed, _ := f.h.RoleAdmissionFailure(); !failed { t.Fatal("RF2 at the admitted epoch not refused") } diff --git a/seaweed-block/core/host/volume/supersede_integration_test.go b/seaweed-block/core/host/volume/supersede_integration_test.go index 7a3d2cc35d..8fb4e7ce68 100644 --- a/seaweed-block/core/host/volume/supersede_integration_test.go +++ b/seaweed-block/core/host/volume/supersede_integration_test.go @@ -62,10 +62,10 @@ func TestHost_RecordOtherLine_SameReplica_NotSuperseded(t *testing.T) { proj := &mutableProjector{p: engine.ReplicaProjection{ Mode: engine.ModeHealthy, Epoch: 2, EndpointVersion: 2, }} - h := &Host{cfg: Config{VolumeID: "v1", ReplicaID: "r1"}} + h := &Host{cfg: Config{ServerID: "node-a", VolumeID: "v1", ReplicaID: "r1"}} h.view = NewAdapterProjectionView(proj, "v1", "r1", h) h.recordOtherLine(&control.AssignmentFact{ - VolumeId: "v1", ReplicaId: "r1", Epoch: 2, EndpointVersion: 2, + ServerId: "node-a", VolumeId: "v1", ReplicaId: "r1", Epoch: 2, EndpointVersion: 2, }) if !h.view.Projection().Healthy { t.Fatal("same-replica lastOther must not trigger supersede") diff --git a/seaweed-block/core/host/volume/workspace_lease.go b/seaweed-block/core/host/volume/workspace_lease.go index 3a829129a8..53fe671969 100644 --- a/seaweed-block/core/host/volume/workspace_lease.go +++ b/seaweed-block/core/host/volume/workspace_lease.go @@ -142,7 +142,7 @@ func NewWorkspaceLeaseGuard(base frontend.ProjectionView, client WorkspaceLeaseC if now == nil { now = time.Now } - return &WorkspaceLeaseGuard{base: base, client: client, id: control.WorkspaceIdentity{VolumeId: id.VolumeId, ReplicaId: id.ReplicaId, Epoch: id.Epoch}, stop: stop, now: now, kick: make(chan struct{}, 1), after: time.After}, nil + return &WorkspaceLeaseGuard{base: base, client: client, id: control.WorkspaceIdentity{VolumeId: id.VolumeId, ReplicaId: id.ReplicaId, ServerId: id.ServerId, Epoch: id.Epoch}, stop: stop, now: now, kick: make(chan struct{}, 1), after: time.After}, nil } func (g *WorkspaceLeaseGuard) Projection() frontend.Projection { diff --git a/seaweed-block/core/host/volume/workspace_runtime_test.go b/seaweed-block/core/host/volume/workspace_runtime_test.go index 824d57d149..b8ea211a20 100644 --- a/seaweed-block/core/host/volume/workspace_runtime_test.go +++ b/seaweed-block/core/host/volume/workspace_runtime_test.go @@ -26,7 +26,7 @@ func workspaceRuntimeHost(t *testing.T, addr string, required bool) *Host { t.Fatal(err) } t.Cleanup(func() { _ = h.Close() }) - h.applyFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 3, EndpointVersion: 1, DataAddr: "127.0.0.1:9100", CtrlAddr: "127.0.0.1:9101"}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v1", ReplicaId: "r1", Epoch: 3, EndpointVersion: 1, DataAddr: "127.0.0.1:9100", CtrlAddr: "127.0.0.1:9101"}) end := time.Now().Add(time.Second) for h.realAdpt.Projection().Mode != engine.ModeHealthy && time.Now().Before(end) { time.Sleep(time.Millisecond) From 027e4da2f0e5a2b16dc2fa193cd22edeb9d41f49 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:56:21 -0800 Subject: [PATCH 042/204] test: the documented standalone planned hand-over to the same host, end to end Runs the lifecycle chapter's commands in order against real blockmaster, blockvolume, sw-block and SeaweedFS on loopback: cluster spec and lifecycle store, adopt, write and flush a block over NVMe/TCP, plain detach, revoke with the sealed generation, the old process acknowledges and exits 0 by itself, show the ACK, clean move to the same host (and its replay), reopen at the new epoch, and the block reads back unchanged. The checks that read each step's output are shared with a default-build test that runs them on output captured from the real binaries (testdata/planned-handoff), each also refusing another step's output. The NVMe/TCP host runs in the test process: no root, no nvme_tcp. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_checks_test.go | 254 +++++++++++ .../planned_handoff_integration_test.go | 419 +++++++++++++++++- .../planned-handoff/detach-plain.stderr | 1 + .../planned-handoff/detach-plain.stdout | 1 + .../planned-handoff/head-reopened.stdout | 1 + .../planned-handoff/head-sealed.stdout | 1 + .../testdata/planned-handoff/logs.txt | 9 + .../planned-handoff/move-clean.stdout | 2 + .../testdata/planned-handoff/revoke.stdout | 2 + .../planned-handoff/show-acked.stdout | 8 + .../planned-handoff/show-before-start.stdout | 7 + .../planned-handoff/show-granted.stdout | 8 + .../planned-handoff/show-moved.stdout | 9 + .../planned-handoff/status-primary.json | 1 + 14 files changed, 715 insertions(+), 8 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stderr create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-sealed.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/logs.txt create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/revoke.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-acked.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-before-start.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-granted.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-moved.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/status-primary.json diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go new file mode 100644 index 0000000000..82b6dd78f3 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go @@ -0,0 +1,254 @@ +package main_test + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "regexp" + "strconv" + "strings" + "testing" +) + +// The checks below read the product's own output for each step of the +// planned hand-over (docs/volume-lifecycle.md). The binary test applies +// them to live output; TestPlannedHandoffChecksReadCapturedProductOutput +// applies them to output captured from the real binaries +// (testdata/planned-handoff), so they run in every default test run. + +func checkShowBeforeStart(out string) error { + return wantLines(out, "volume: v1 (query snapshot, not authority to serve)", "replica: none", "recorded ACK: none") +} + +func checkShowGranted(out string, e uint64) error { + return wantLines(out, "replica: r1", fmt.Sprintf("epoch: %d", e), "lease state: granted", + fmt.Sprintf("holder: r1@%d (logical replica)", e), "recorded ACK: none") +} + +// adoptedEpoch reads E from blockvolume's adoption line. +func adoptedEpoch(line string) (uint64, error) { + e, err := matchUint(regexp.MustCompile(`blockvolume: volume v1 adopted as PRIMARY at r1@(\d+) `), line) + if err == nil && e == 0 { + err = fmt.Errorf("adopted at epoch 0: %q", line) + } + return e, err +} + +// sealedGen reads G from a plain detach: one JSON object on stdout and +// exactly the sealed-generation line on stderr. +func sealedGen(stdout, stderr string, e uint64) (uint64, error) { + var a struct { + VolumeID string `json:"volumeID"` + HeadGen uint64 `json:"headGen"` + HeadEpoch uint64 `json:"headEpoch"` + CutLSN uint64 `json:"cutLSN"` + LastWrittenLSN uint64 `json:"lastWrittenLSN"` + } + if err := json.Unmarshal([]byte(stdout), &a); err != nil { + return 0, fmt.Errorf("plain detach stdout is not the JSON answer: %v: %q", err, stdout) + } + if a.VolumeID != "v1" || a.HeadGen == 0 || a.HeadEpoch != e || a.CutLSN == 0 || a.LastWrittenLSN == 0 { + return 0, fmt.Errorf("plain detach answer %+v; want v1, a generation, epoch %d and both LSNs after a write", a, e) + } + if strings.TrimSpace(stderr) != fmt.Sprintf("sealed HEAD generation: %d", a.HeadGen) { + return 0, fmt.Errorf("plain detach stderr %q; want exactly the sealed generation line", stderr) + } + return a.HeadGen, nil +} + +type detachedBy struct { + Holder string `json:"holder"` + Epoch uint64 `json:"epoch"` + Gen uint64 `json:"gen"` +} + +type headRecord struct { + Gen uint64 `json:"gen"` + Epoch uint64 `json:"epoch"` + Holder string `json:"holder"` + State string `json:"state"` + RemoteLSN uint64 `json:"remoteLSN"` + DetachedBy *detachedBy `json:"detachedBy"` +} + +func parseHead(out string) (headRecord, error) { + var shown struct { + Head *headRecord `json:"head"` + } + if err := json.Unmarshal([]byte(out), &shown); err != nil || shown.Head == nil { + return headRecord{}, fmt.Errorf("chunk show stdout has no head: %v: %q", err, out) + } + return *shown.Head, nil +} + +// sealedHeadLSN checks HEAD after the seal and returns its remote LSN (L). +func sealedHeadLSN(out string, e, g uint64) (uint64, error) { + h, err := parseHead(out) + if err != nil { + return 0, err + } + if h.Gen != g || h.Epoch != e || h.Holder != "s1/r1" || h.State != "detached" || + h.DetachedBy == nil || *h.DetachedBy != (detachedBy{Holder: "s1/r1", Epoch: e, Gen: g}) { + return 0, fmt.Errorf("HEAD after the seal %+v; want gen %d epoch %d holder s1/r1 detached by itself", h, g, e) + } + return h.RemoteLSN, nil +} + +func checkRevoke(out string, e, g uint64) error { + if !strings.HasPrefix(out, fmt.Sprintf("revocation requested: volume v1 holder r1@%d expiry_ns ", e)) { + return fmt.Errorf("revoke stdout %q", out) + } + return wantLines(out, fmt.Sprintf("operator-stated sealed HEAD generation: %d (not verified); workspace show must report ACK at this generation before move --clean", g)) +} + +func showsAck(out string, e, g uint64) bool { + return hasLine(out, fmt.Sprintf("recorded ACK: r1@%d HEAD generation %d", e, g)) +} + +// movedEpoch reads E2 from the clean move's answer. +func movedEpoch(out string, e, g, l uint64) (uint64, error) { + issued := regexp.MustCompile(fmt.Sprintf(`^clean move issued: volume v1 request move-v1-1: r1@%d -> r1@(\d+) on s1 \(sealed HEAD gen %d, remote LSN %d\)$`, e, g, l)) + first, _, _ := strings.Cut(out, "\n") + e2, err := matchUint(issued, strings.TrimRight(first, "\r")) + if err != nil { + return 0, err + } + if e2 <= e { + return 0, fmt.Errorf("clean move issued epoch %d; want above %d", e2, e) + } + return e2, wantLines(out, "next: start volume v1 on s1 (this command moved authority only)") +} + +func checkClaimDone(line string, e2 uint64) error { + if !strings.Contains(line, "durable: HEAD claim for volume=v1 done in") || !strings.Contains(line, fmt.Sprintf(`epoch=%d holder="s1/r1"`, e2)) { + return fmt.Errorf("HEAD claim %q; want done at epoch %d holder s1/r1", line, e2) + } + return nil +} + +func checkShowMoved(out string, e, e2, g, l uint64) error { + return wantLines(out, fmt.Sprintf("epoch: %d", e2), "lease state: granted", + fmt.Sprintf("holder: r1@%d (logical replica)", e2), "recorded ACK: none", + fmt.Sprintf("move: request=move-v1-1 kind=clean issued=true s1/r1@%d -> s1/r1@%d HEAD generation %d remote LSN %d", e, e2, g, l)) +} + +func checkHeadReopened(out string, e2, g, l uint64) error { + h, err := parseHead(out) + if err != nil { + return err + } + if h.State != "active" || h.Epoch != e2 || h.Holder != "s1/r1" || h.Gen <= g || h.RemoteLSN != l || h.DetachedBy != nil { + return fmt.Errorf("HEAD after the reopen %+v; want active, epoch %d, holder s1/r1, gen above %d, remote LSN %d, not detached", h, e2, g, l) + } + return nil +} + +// statusPrimary reports whether a /status?volume=v1 body shows a healthy +// primary at epoch. +func statusPrimary(body []byte, epoch uint64) bool { + var st struct { + Epoch uint64 + Healthy bool + AuthorityRole string + } + return json.Unmarshal(body, &st) == nil && st.Epoch == epoch && st.Healthy && st.AuthorityRole == "primary" +} + +func hasLine(out, want string) bool { + for _, l := range strings.Split(out, "\n") { + if strings.TrimRight(l, "\r") == want { + return true + } + } + return false +} + +func wantLines(out string, want ...string) error { + for _, w := range want { + if !hasLine(out, w) { + return fmt.Errorf("no line %q in:\n%s", w, out) + } + } + return nil +} + +func matchUint(re *regexp.Regexp, s string) (uint64, error) { + m := re.FindStringSubmatch(s) + if m == nil { + return 0, fmt.Errorf("%q does not match %s", s, re) + } + return strconv.ParseUint(m[1], 10, 64) +} + +// TestPlannedHandoffChecksReadCapturedProductOutput runs every check on the +// output the real binaries printed in one passing hand-over (E=1, G=3, L=1, +// E2=2), and each check on an output of another step, which it must refuse. +func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { + read := func(name string) string { + b, err := os.ReadFile(filepath.Join("testdata", "planned-handoff", name)) + if err != nil { + t.Fatal(err) + } + return strings.ReplaceAll(string(b), "\r\n", "\n") + } + logLine := func(s string) string { + for _, l := range strings.Split(read("logs.txt"), "\n") { + if strings.Contains(l, s) { + return l + } + } + t.Fatalf("logs.txt has no line with %q", s) + return "" + } + ok := func(what string, err error) { + t.Helper() + if err != nil { + t.Errorf("%s: %v", what, err) + } + } + refused := func(what string, err error) { + t.Helper() + if err == nil { + t.Errorf("%s: accepted the output of another step", what) + } + } + const e, g, l, e2 = 1, 3, 1, 2 + + ok("show before start", checkShowBeforeStart(read("show-before-start.stdout"))) + refused("show before start", checkShowBeforeStart(read("show-granted.stdout"))) + if got, err := adoptedEpoch(logLine("adopted as PRIMARY at r1@1 ")); err != nil || got != e { + t.Errorf("adopted epoch %d, %v; want %d", got, err, e) + } + ok("show granted", checkShowGranted(read("show-granted.stdout"), e)) + refused("show granted", checkShowGranted(read("show-acked.stdout"), e)) + if got, err := sealedGen(read("detach-plain.stdout"), read("detach-plain.stderr"), e); err != nil || got != g { + t.Errorf("sealed gen %d, %v; want %d", got, err, g) + } + _, err := sealedGen(read("detach-plain.stdout"), "", e) + refused("sealed gen without its stderr line", err) + if got, err := sealedHeadLSN(read("head-sealed.stdout"), e, g); err != nil || got != l { + t.Errorf("sealed HEAD LSN %d, %v; want %d", got, err, l) + } + _, err = sealedHeadLSN(read("head-reopened.stdout"), e, g) + refused("sealed HEAD", err) + ok("revoke", checkRevoke(read("revoke.stdout"), e, g)) + refused("revoke", checkRevoke(read("move-clean.stdout"), e, g)) + if !showsAck(read("show-acked.stdout"), e, g) || showsAck(read("show-granted.stdout"), e, g) { + t.Error("the ACK line is not told apart from a show without it") + } + if got, err := movedEpoch(read("move-clean.stdout"), e, g, l); err != nil || got != e2 { + t.Errorf("moved epoch %d, %v; want %d", got, err, e2) + } + _, err = movedEpoch(read("move-clean.stdout"), e, g+1, l) + refused("clean move at another generation", err) + ok("claim done", checkClaimDone(logLine(`gen=4 epoch=2 holder="s1/r1"`), e2)) + refused("claim done", checkClaimDone(logLine(`gen=2 epoch=1 holder="s1/r1"`), e2)) + ok("show moved", checkShowMoved(read("show-moved.stdout"), e, e2, g, l)) + refused("show moved", checkShowMoved(read("show-granted.stdout"), e, e2, g, l)) + ok("HEAD reopened", checkHeadReopened(read("head-reopened.stdout"), e2, g, l)) + refused("HEAD reopened", checkHeadReopened(read("head-sealed.stdout"), e2, g, l)) + if !statusPrimary([]byte(read("status-primary.json")), e2) || statusPrimary([]byte(read("status-primary.json")), e) { + t.Error("status check does not read the epoch of a healthy primary") + } +} diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 7627a59ca5..e7270fa060 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -3,18 +3,177 @@ package main_test import ( + "bytes" "context" + "crypto/sha256" + "fmt" + "io" + "net" + "net/http" "os" "os/exec" "path/filepath" "strings" "testing" "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/nvme" ) +// TestStandalonePlannedHandoffToTheSameHost runs the planned hand-over back +// to the same host with the commands of docs/volume-lifecycle.md, in its +// order and form, against real blockmaster, blockvolume, sw-block and +// SeaweedFS processes on loopback: cluster spec, start, write, plain detach, +// revoke with the sealed generation, the old process acknowledges and exits +// by itself, show the ACK, clean move to the same host, start again, and the +// written block reads back unchanged. +func TestStandalonePlannedHandoffToTheSameHost(t *testing.T) { + h := newPlannedHandoffHarness(t) + cluster := startWorkspaceWeed(t) + chunkPath := fmt.Sprintf("/handoff-%d", time.Now().UnixNano()) + const nqn = "nqn.2026-11.io.seaweedfs:handoff" + must := func(err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } + } + mustU := func(v uint64, err error) uint64 { + t.Helper() + must(err) + return v + } + + // 1. The cluster spec. + spec := filepath.Join(h.dir, "cluster-spec.yaml") + must(os.WriteFile(spec, []byte(fmt.Sprintf(`nodes: + - server_id: s1 + data_addr: %s + ctrl_addr: %s +volumes: + - id: v1 + size_bytes: 268435456 + replication_factor: 1 + placements: + - server_id: s1 + replica_id: r1 +`, h.dataAddr, h.ctrlAddr)), 0o644)) + + // 2. blockmaster with the lifecycle store and the cluster spec. + mstate := filepath.Join(h.dir, "master") + master := h.start(t, "blockmaster", h.master, + "--authority-store", filepath.Join(mstate, "authority"), "--lifecycle-store", filepath.Join(mstate, "lifecycle"), + "--cluster-spec", spec, "--expected-slots-per-volume", "1", "--listen", h.masterAddr, + "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+chunkPath) + if l := master.waitLog(t, 30*time.Second, "blockmaster: lock acquired, reloaded="); !strings.Contains(l, "listen="+h.masterAddr) { + t.Fatalf("blockmaster start line %q does not name listen=%s", l, h.masterAddr) + } + if master.has("blockmaster: WARNING: --topology not supplied or empty") { + t.Fatal("blockmaster warned about a missing topology although the cluster spec gives it") + } + + // 3. The setup answers before any blockvolume runs. + show := []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} + out, _ := h.command(t, show...) + must(checkShowBeforeStart(out)) + + // 4. blockvolume adopts the volume. + volArgs := []string{"--master", h.masterAddr, "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", + "--data-addr", h.dataAddr, "--ctrl-addr", h.ctrlAddr, "--status-addr", h.statusAddr, + "--durable-root", filepath.Join(h.dir, "vol"), "--durable-impl", "walstore-chunk", + "--durable-blocks", "65536", "--durable-blocksize", "4096", + "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath, "--chunk-control-endpoint", + "--workspace-lease", "--nvme-listen", h.nvmeAddr, "--nvme-subsysnqn", nqn} + vol1 := h.start(t, "blockvolume-1", h.volume, volArgs...) + e := mustU(adoptedEpoch(vol1.waitLog(t, 60*time.Second, "blockvolume: volume v1 adopted as PRIMARY at r1@"))) + vol1.waitLog(t, 60*time.Second, "durable: HEAD claim for volume=v1 done in") + h.waitPrimary(t, e) + + // 5. The lease. + out, _ = h.command(t, show...) + must(checkShowGranted(out, e)) + + // 6, 7. Write a known block and flush it, then disconnect the writer. + block := bytes.Repeat([]byte("planned-handoff!"), 4096/16) + want := sha256.Sum256(block) + c := dialNVMe(t, h.nvmeAddr, nqn) + c.write(t, 0, block) + c.flush(t) + c.close() + + // 8. Seal with a plain detach. + out, errOut := h.command(t, "ops", "chunk", "detach", "--plain", "--volume", "v1", "--status-addr", h.statusAddr, "--timeout", "120s") + g := mustU(sealedGen(out, errOut, e)) + + // 9. The seal is in the object store. + chunkShow := []string{"ops", "chunk", "show", "--volume", "v1", "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath} + out, _ = h.command(t, chunkShow...) + l := mustU(sealedHeadLSN(out, e, g)) + + // 10. Revoke with the sealed generation. + out, _ = h.command(t, "ops", "workspace", "revoke", "--master", h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--sealed-gen", fmt.Sprint(g)) + must(checkRevoke(out, e, g)) + + // 11. The old blockvolume acknowledges and exits by itself (a signal + // would suppress the ACK). + if err := vol1.wait(45 * time.Second); err != nil { + t.Fatalf("blockvolume after the revocation: %v; want a clean exit by itself", err) + } + if !vol1.has(fmt.Sprintf("workspace lease: fenced volume=v1 replica=r1 epoch=%d: revoked by the master", e)) || + !vol1.has("blockvolume: stopping: the workspace lease guard fenced and requested the drain") { + t.Fatal("blockvolume log does not show the revocation fence and drain") + } + if vol1.has("blockvolume: workspace lease closeout:") { + t.Fatal("blockvolume reported a closeout error") + } + + // 12. The master recorded the ACK at the sealed generation. + poll(t, 30*time.Second, fmt.Sprintf("workspace show never reported the ACK of r1@%d at generation %d", e, g), func() bool { + out, _ := h.command(t, show...) + return showsAck(out, e, g) + }) + + // 13. Clean move to the same host; a rerun replays the issued move. + move := []string{"ops", "workspace", "move", "--clean", "--master", h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--target-host", "s1", "--target-data", h.dataAddr, "--target-ctrl", h.ctrlAddr, + "--request-id", "move-v1-1"} + moved, _ := h.command(t, move...) + e2 := mustU(movedEpoch(moved, e, g, l)) + if again, _ := h.command(t, move...); again != moved { + t.Fatalf("clean move rerun answered %q; want the issued move again %q", again, moved) + } + + // 14. Start again with the same root, within the new lease (30 s). + vol2 := h.start(t, "blockvolume-2", h.volume, volArgs...) + vol2.waitLog(t, 60*time.Second, fmt.Sprintf(`durable: HEAD claim for volume=v1 starting: target epoch=%d holder="s1/r1"`, e2)) + must(checkClaimDone(vol2.waitLog(t, 60*time.Second, "durable: HEAD claim for volume=v1 done in"), e2)) + vol2.waitLog(t, 60*time.Second, fmt.Sprintf("blockvolume: volume v1 adopted as PRIMARY at r1@%d", e2)) + for _, bad := range []string{"refusing to attach volume=v1", "assignment unavailable, not serving"} { + if vol2.has(bad) { + t.Fatalf("the restarted blockvolume logged %q", bad) + } + } + h.waitPrimary(t, e2) + + // 15. The new lease and the move record. + out, _ = h.command(t, show...) + must(checkShowMoved(out, e, e2, g, l)) + + // 16. The new epoch claimed HEAD. + out, _ = h.command(t, chunkShow...) + must(checkHeadReopened(out, e2, g, l)) + + // 17. The block written before the hand-over reads back unchanged. + c = dialNVMe(t, h.nvmeAddr, nqn) + defer c.close() + if got := sha256.Sum256(c.read(t, 0, 4096)); got != want { + t.Fatalf("block 0 after the hand-over has sha256 %x; want %x", got, want) + } +} + // plannedHandoffHarness owns real binaries, loopback endpoints and process -// lifetimes. The lifecycle test will use the commands and observables supplied -// with docs/volume-lifecycle.md; this scaffold makes no hand-over claim yet. +// lifetimes. type plannedHandoffHarness struct { dir string master, volume, cli string @@ -55,9 +214,18 @@ func newPlannedHandoffHarness(t *testing.T) *plannedHandoffHarness { return h } +// daemon is one started child: its log file and its exit. +type daemon struct { + name, log string + done chan struct{} + err error +} + // start registers cancellation and a bounded join before starting a daemon. // Each child writes to its own file, and cleanup targets only that child. -func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args ...string) { +// Cancellation kills the child; a test that needs a child to exit by itself +// waits for it with wait. +func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args ...string) *daemon { t.Helper() log, err := os.Create(filepath.Join(h.dir, name+".log")) if err != nil { @@ -67,20 +235,20 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. cmd := exec.CommandContext(ctx, binary, args...) cmd.Dir, cmd.Stdout, cmd.Stderr = h.dir, log, log cmd.WaitDelay = 5 * time.Second - done := make(chan error, 1) + d := &daemon{name: name, log: log.Name(), done: make(chan struct{})} started := false t.Cleanup(func() { cancel() if started { select { - case <-done: + case <-d.done: case <-time.After(10 * time.Second): t.Errorf("%s did not exit after cancellation", name) } } _ = log.Close() if t.Failed() { - data, _ := os.ReadFile(log.Name()) + data, _ := os.ReadFile(d.log) if len(data) > 16000 { data = data[len(data)-16000:] } @@ -91,14 +259,64 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. t.Fatalf("start %s: %v", name, err) } started = true - go func() { done <- cmd.Wait() }() + go func() { d.err = cmd.Wait(); close(d.done) }() + return d +} + +// wait waits up to timeout for the child to exit by itself and returns its +// exit error (nil: status 0). +func (d *daemon) wait(timeout time.Duration) error { + select { + case <-d.done: + return d.err + case <-time.After(timeout): + return fmt.Errorf("%s still running after %s", d.name, timeout) + } +} + +// line returns the first log line containing s ("" if none). +func (d *daemon) line(s string) string { + data, _ := os.ReadFile(d.log) + for _, l := range strings.Split(string(data), "\n") { + if strings.Contains(l, s) { + return l + } + } + return "" +} + +func (d *daemon) has(s string) bool { return d.line(s) != "" } + +// waitLog waits for a log line containing s and returns it. A child that +// exits first fails the test at once. +func (d *daemon) waitLog(t *testing.T, timeout time.Duration, s string) string { + t.Helper() + end := time.Now().Add(timeout) + for { + if l := d.line(s); l != "" { + return l + } + select { + case <-d.done: + if l := d.line(s); l != "" { + return l + } + t.Fatalf("%s exited (%v) before logging %q", d.name, d.err, s) + default: + } + if time.Now().After(end) { + t.Fatalf("%s did not log %q within %s", d.name, s, timeout) + } + time.Sleep(100 * time.Millisecond) + } } // command keeps stdout separate from stderr: detach stdout remains JSON while // its sealed-generation line is read from stderr by the documented sequence. +// The bound covers the detach's own --timeout 120s. func (h *plannedHandoffHarness) command(t *testing.T, args ...string) (string, string) { t.Helper() - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second) defer cancel() cmd := exec.CommandContext(ctx, h.cli, args...) cmd.Dir = h.dir @@ -110,3 +328,188 @@ func (h *plannedHandoffHarness) command(t *testing.T, args ...string) (string, s } return stdout.String(), stderr.String() } + +// waitPrimary polls the status endpoint until the volume serves as a +// healthy primary at epoch. +func (h *plannedHandoffHarness) waitPrimary(t *testing.T, epoch uint64) { + t.Helper() + c := &http.Client{Timeout: 5 * time.Second} + poll(t, 60*time.Second, fmt.Sprintf("status never showed a healthy primary at epoch %d", epoch), func() bool { + resp, err := c.Get("http://" + h.statusAddr + "/status?volume=v1") + if err != nil { + return false + } + defer resp.Body.Close() + b, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) + return statusPrimary(b, epoch) + }) +} + +func poll(t *testing.T, timeout time.Duration, what string, fn func() bool) { + t.Helper() + end := time.Now().Add(timeout) + for !fn() { + if time.Now().After(end) { + t.Fatal(what) + } + time.Sleep(time.Second) + } +} + +// nvmeInitiator is the smallest NVMe/TCP host the test needs: one admin and +// one IO queue, Write, Flush and Read of namespace 1. It runs in the test +// process, so the test needs neither root nor the kernel's nvme_tcp. +type nvmeInitiator struct { + admin, io net.Conn + r *nvme.Reader + w *nvme.Writer + cid uint16 +} + +func dialNVMe(t *testing.T, addr, subNQN string) *nvmeInitiator { + t.Helper() + c := &nvmeInitiator{} + cd := nvme.ConnectData{HostID: [16]byte{0x5e, 0xa1}, SubNQN: subNQN, HostNQN: "nqn.2026-11.io.seaweedfs:handoff-test"} + var cntlID uint16 + for qid := uint32(0); qid <= 1; qid++ { + conn, err := net.DialTimeout("tcp", addr, 5*time.Second) + if err != nil { + t.Fatalf("nvme dial %s: %v", addr, err) + } + _ = conn.SetDeadline(time.Now().Add(60 * time.Second)) + r, w := nvme.NewReader(conn), nvme.NewWriter(conn) + if err := w.SendHeaderOnly(0x0, &nvme.ICRequest{PDUMaxR2T: 1}, 120); err != nil { + t.Fatalf("nvme ICReq: %v", err) + } + if ch, err := r.Dequeue(); err != nil || ch.Type != 0x1 { + t.Fatalf("nvme ICResp: type %v err %v", ch, err) + } + if err := r.Receive(&nvme.ICResponse{}); err != nil { + t.Fatalf("nvme ICResp body: %v", err) + } + // The admin queue asks for a controller; the IO queue names it. + cd.CNTLID = 0xFFFF + if qid == 1 { + cd.CNTLID = cntlID + } + buf := make([]byte, 1024) + cd.Marshal(buf) + c.cid++ + cmd := nvme.CapsuleCommand{OpCode: 0x7F, FCType: 0x01, CID: c.cid, D10: qid << 16} + if err := w.SendWithData(0x4, 0, &cmd, 64, buf); err != nil { + t.Fatalf("nvme Connect qid %d: %v", qid, err) + } + resp := nvmeResponse(t, r) + if resp.Status != 0 { + t.Fatalf("nvme Connect qid %d status 0x%04x", qid, resp.Status) + } + if qid == 0 { + c.admin, cntlID = conn, uint16(resp.DW0&0xFFFF) + } else { + c.io, c.r, c.w = conn, r, w + } + } + return c +} + +func nvmeResponse(t *testing.T, r *nvme.Reader) nvme.CapsuleResponse { + t.Helper() + ch, err := r.Dequeue() + if err != nil || ch.Type != 0x5 { + t.Fatalf("nvme response: type %v err %v", ch, err) + } + var resp nvme.CapsuleResponse + if err := r.Receive(&resp); err != nil { + t.Fatalf("nvme response body: %v", err) + } + return resp +} + +func (c *nvmeInitiator) ioCmd(op uint8, lba uint64, blocks int) nvme.CapsuleCommand { + c.cid++ + cmd := nvme.CapsuleCommand{OpCode: op, CID: c.cid, NSID: 1} + if blocks > 0 { + cmd.D10, cmd.D11, cmd.D12 = uint32(lba), uint32(lba>>32), uint32(blocks-1) + } + return cmd +} + +func (c *nvmeInitiator) write(t *testing.T, lba uint64, data []byte) { + t.Helper() + cmd := c.ioCmd(0x01, lba, len(data)/4096) + if err := c.w.SendHeaderOnly(0x4, &cmd, 64); err != nil { + t.Fatalf("nvme Write: %v", err) + } + ch, err := c.r.Dequeue() + if err != nil || ch.Type != 0x9 { + t.Fatalf("nvme Write: want R2T, got type %v err %v", ch, err) + } + var r2t nvme.R2THeader + if err := c.r.Receive(&r2t); err != nil { + t.Fatalf("nvme R2T: %v", err) + } + h2c := nvme.H2CDataHeader{CCCID: cmd.CID, TAG: r2t.TAG, DATAL: uint32(len(data))} + if err := c.w.SendWithData(0x6, 0, &h2c, 16, data); err != nil { + t.Fatalf("nvme H2CData: %v", err) + } + if resp := nvmeResponse(t, c.r); resp.Status != 0 { + t.Fatalf("nvme Write status 0x%04x", resp.Status) + } +} + +func (c *nvmeInitiator) flush(t *testing.T) { + t.Helper() + cmd := c.ioCmd(0x00, 0, 0) + if err := c.w.SendHeaderOnly(0x4, &cmd, 64); err != nil { + t.Fatalf("nvme Flush: %v", err) + } + if resp := nvmeResponse(t, c.r); resp.Status != 0 { + t.Fatalf("nvme Flush status 0x%04x", resp.Status) + } +} + +func (c *nvmeInitiator) read(t *testing.T, lba uint64, n int) []byte { + t.Helper() + cmd := c.ioCmd(0x02, lba, n/4096) + if err := c.w.SendHeaderOnly(0x4, &cmd, 64); err != nil { + t.Fatalf("nvme Read: %v", err) + } + var data []byte + for { + ch, err := c.r.Dequeue() + if err != nil { + t.Fatalf("nvme Read: %v", err) + } + if ch.Type == 0x5 { + var resp nvme.CapsuleResponse + if err := c.r.Receive(&resp); err != nil || resp.Status != 0 { + t.Fatalf("nvme Read status 0x%04x err %v", resp.Status, err) + } + break + } + if ch.Type != 0x7 { + t.Fatalf("nvme Read: unexpected PDU type 0x%x", ch.Type) + } + var dh nvme.C2HDataHeader + if err := c.r.Receive(&dh); err != nil { + t.Fatalf("nvme C2HData: %v", err) + } + part := make([]byte, c.r.Length()) + if err := c.r.ReceiveData(part); err != nil { + t.Fatalf("nvme C2HData payload: %v", err) + } + data = append(data, part...) + } + if len(data) != n { + t.Fatalf("nvme Read returned %d bytes; want %d", len(data), n) + } + return data +} + +func (c *nvmeInitiator) close() { + for _, conn := range []net.Conn{c.io, c.admin} { + if conn != nil { + _ = conn.Close() + } + } +} diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stderr b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stderr new file mode 100644 index 0000000000..cf507d69b7 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stderr @@ -0,0 +1 @@ +sealed HEAD generation: 3 diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stdout new file mode 100644 index 0000000000..4bc78cc8be --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/detach-plain.stdout @@ -0,0 +1 @@ +{"volumeID":"v1","cutLSN":1,"headGen":3,"headEpoch":1,"lastWrittenLSN":1} diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened.stdout new file mode 100644 index 0000000000..747b6e56dc --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened.stdout @@ -0,0 +1 @@ +{"volumeID":"v1","volume":{"origin":"create","numBlocks":65536,"blockSize":4096,"chunkBlocks":1024,"createdNs":1795337541307771858,"parent":null},"head":{"gen":4,"epoch":2,"holder":"s1/r1","remoteLSN":1,"state":"active","detachedBy":null,"chunkCount":1}} diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-sealed.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-sealed.stdout new file mode 100644 index 0000000000..af1de786d9 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-sealed.stdout @@ -0,0 +1 @@ +{"volumeID":"v1","volume":{"origin":"create","numBlocks":65536,"blockSize":4096,"chunkBlocks":1024,"createdNs":1795337541307771858,"parent":null},"head":{"gen":3,"epoch":1,"holder":"s1/r1","remoteLSN":1,"state":"detached","detachedBy":{"holder":"s1/r1","epoch":1,"gen":3},"chunkCount":1}} diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/logs.txt b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/logs.txt new file mode 100644 index 0000000000..3645c7a9f4 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/logs.txt @@ -0,0 +1,9 @@ +2026/11/22 00:52:20 blockmaster: lock acquired, reloaded=0, listen=127.0.0.1:44358 +2026/11/22 00:52:21 blockvolume: volume v1 adopted as PRIMARY at r1@1 (EV=1) +2026/11/22 00:52:21 durable: HEAD claim for volume=v1 starting: target epoch=1 holder="s1/r1" +2026/11/22 00:52:21 durable: HEAD claim for volume=v1 done in 2.250367ms: gen=2 epoch=1 holder="s1/r1" +2026/11/22 00:52:21 workspace lease: fenced volume=v1 replica=r1 epoch=1: revoked by the master +blockvolume: stopping: the workspace lease guard fenced and requested the drain +2026/11/22 00:52:22 blockvolume: volume v1 adopted as PRIMARY at r1@2 (EV=1) +2026/11/22 00:52:22 durable: HEAD claim for volume=v1 starting: target epoch=2 holder="s1/r1" +2026/11/22 00:52:22 durable: HEAD claim for volume=v1 done in 3.597902ms: gen=4 epoch=2 holder="s1/r1" diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean.stdout new file mode 100644 index 0000000000..94de184444 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean.stdout @@ -0,0 +1,2 @@ +clean move issued: volume v1 request move-v1-1: r1@1 -> r1@2 on s1 (sealed HEAD gen 3, remote LSN 1) +next: start volume v1 on s1 (this command moved authority only) diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/revoke.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/revoke.stdout new file mode 100644 index 0000000000..d8f6e00f41 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/revoke.stdout @@ -0,0 +1,2 @@ +revocation requested: volume v1 holder r1@1 expiry_ns 1795337571673280526 +operator-stated sealed HEAD generation: 3 (not verified); workspace show must report ACK at this generation before move --clean diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-acked.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-acked.stdout new file mode 100644 index 0000000000..8eae3b9488 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-acked.stdout @@ -0,0 +1,8 @@ +volume: v1 (query snapshot, not authority to serve) +replica: r1 +epoch: 1 +lease state: revoking +holder: r1@1 (logical replica) +lease expiry_ns: 1795337571673280526; host validity_ns at query: 19706858270 +recorded ACK: r1@1 HEAD generation 3 +host: unknown (not recorded by the master); issued moves and bindings below are separate facts diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-before-start.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-before-start.stdout new file mode 100644 index 0000000000..284ab8c607 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-before-start.stdout @@ -0,0 +1,7 @@ +volume: v1 (query snapshot, not authority to serve) +replica: none +epoch: none +lease state: none +holder: none +recorded ACK: none +host: unknown (not recorded by the master); issued moves and bindings below are separate facts diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-granted.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-granted.stdout new file mode 100644 index 0000000000..71488987f4 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-granted.stdout @@ -0,0 +1,8 @@ +volume: v1 (query snapshot, not authority to serve) +replica: r1 +epoch: 1 +lease state: granted +holder: r1@1 (logical replica) +lease expiry_ns: 1795337571294082097; host validity_ns at query: 19891253918 +recorded ACK: none +host: unknown (not recorded by the master); issued moves and bindings below are separate facts diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-moved.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-moved.stdout new file mode 100644 index 0000000000..40e1fe5ca0 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-moved.stdout @@ -0,0 +1,9 @@ +volume: v1 (query snapshot, not authority to serve) +replica: r1 +epoch: 2 +lease state: granted +holder: r1@2 (logical replica) +lease expiry_ns: 1795337572110285858; host validity_ns at query: 19885280122 +recorded ACK: none +host: unknown (not recorded by the master); issued moves and bindings below are separate facts +move: request=move-v1-1 kind=clean issued=true s1/r1@1 -> s1/r1@2 HEAD generation 3 remote LSN 1 diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/status-primary.json b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/status-primary.json new file mode 100644 index 0000000000..f33bc5ac9a --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/status-primary.json @@ -0,0 +1 @@ +{"VolumeID":"v1","ReplicaID":"r1","Epoch":2,"EndpointVersion":1,"Healthy":true,"Memory":{"HeapAllocBytes":1520736,"HeapInuseBytes":3547136,"HeapSysBytes":7503872,"HeapReleasedBytes":3194880,"SoftLimitBytes":268435456,"RSSBytes":21516288,"AnonymousRSSBytes":5230592},"FrontendPrimaryReady":true,"AuthorityRole":"primary","ReplicationRole":"none"} From d2525156cc89d6d6e3eb89a3bc2e417080b9e40a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:57:04 -0800 Subject: [PATCH 043/204] test: cover foreign-holder fencing and carried lease identity --- .../host/volume/assignment_holder_test.go | 49 +++++++++++++++++++ .../volume/workspace_holder_identity_test.go | 26 ++++++++++ seaweed-block/docs/releases/README.md | 2 + .../docs/releases/holder-identity.md | 17 +++++++ seaweed-block/docs/standalone-deployment.md | 8 +++ 5 files changed, 102 insertions(+) create mode 100644 seaweed-block/core/host/volume/workspace_holder_identity_test.go create mode 100644 seaweed-block/docs/releases/holder-identity.md diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index c13f4198d8..1359ea8ed5 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -73,3 +73,52 @@ func TestAssignmentHolderIdentityMatchingServerStillAdopts(t *testing.T) { t.Fatalf("matching holder did not become healthy: %+v", p) } } + +// The old process may already have been healthy before the forced move. The +// foreign line must withdraw that projection even though r1 is unchanged. +func TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + own := holderAssignment(t, "old-host") + own.Epoch = 1 + h.applyFact(own) + deadline := time.Now().Add(time.Second) + for !h.view.Projection().Healthy && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if !h.view.Projection().Healthy { + t.Fatal("old owner baseline not healthy") + } + h.applyFact(holderAssignment(t, "new-host")) + if h.realAdpt.Projection().Epoch != 1 { + t.Fatal("foreign epoch adopted") + } + if h.view.Projection().Healthy { + t.Fatal("same-r1 foreign holder left the old frontend healthy") + } +} + +func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) { + for _, endpoint := range []string{"data", "control"} { + t.Run(endpoint, func(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + f := holderAssignment(t, "new-host") + if endpoint == "data" { + f.DataAddr = "127.0.0.1:9991" + } else { + f.CtrlAddr = "127.0.0.1:9992" + } + h.applyFact(f) + if h.realAdpt.Projection().Epoch != 0 || h.LastOtherLine() == nil { + t.Fatal("mismatched endpoint was adopted or not recorded") + } + }) + } +} diff --git a/seaweed-block/core/host/volume/workspace_holder_identity_test.go b/seaweed-block/core/host/volume/workspace_holder_identity_test.go new file mode 100644 index 0000000000..e5c56263d8 --- /dev/null +++ b/seaweed-block/core/host/volume/workspace_holder_identity_test.go @@ -0,0 +1,26 @@ +package volume + +import ( + "context" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" + "testing" +) + +func TestWorkspaceLeaseGuardCarriesHolderServerIdentity(t *testing.T) { + seen := "" + client := funcLeaseClient(func(_ context.Context, id *control.WorkspaceIdentity, _ ...grpc.CallOption) (*control.WorkspaceLeaseFact, error) { + seen = id.ServerId + return &control.WorkspaceLeaseFact{VolumeId: "v", ReplicaId: "r", Epoch: 1, ValidForNs: 1000000000}, nil + }) + g, err := NewWorkspaceLeaseGuard(workspaceTestView{}, client, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1, ServerId: "node-a"}, func(context.Context) (uint64, error) { return 7, nil }, nil) + if err != nil { + t.Fatal(err) + } + if err = g.Refresh(context.Background()); err != nil { + t.Fatal(err) + } + if seen != "node-a" { + t.Fatalf("master saw holder server %q, want node-a", seen) + } +} diff --git a/seaweed-block/docs/releases/README.md b/seaweed-block/docs/releases/README.md index df3295b868..17c155376d 100644 --- a/seaweed-block/docs/releases/README.md +++ b/seaweed-block/docs/releases/README.md @@ -4,6 +4,7 @@ Seaweed Block release notes use narrow product claims. Each alpha version names what a user or reviewer can actually run, what QA evidence backs it, and what is still outside the supported boundary. +- [Holder identity and pre-release upgrades](holder-identity.md) - [v0.1 Alpha — Kubernetes Block Foundation](v0.1-alpha.md) - [v0.2 Alpha — Day-1 Activation And First Volume](v0.2-alpha.md) - [v0.3 Alpha — Helm Install And Observable First Volume](v0.3-alpha.md) @@ -93,3 +94,4 @@ The WAL multi-block record opt-in is documented separately because it is a backend/WAL-format optimization boundary, not a RoCE, NVMe/RDMA, or performance claim. It remains default-off and source-gated; a future published-image smoke is still required before any public release-image claim. + diff --git a/seaweed-block/docs/releases/holder-identity.md b/seaweed-block/docs/releases/holder-identity.md new file mode 100644 index 0000000000..cea2a0b6ea --- /dev/null +++ b/seaweed-block/docs/releases/holder-identity.md @@ -0,0 +1,17 @@ +# Holder identity and pre-release upgrades + +Assignments and workspace lease requests carry the holder's server id as well +as its replica id. Replica ids and loopback addresses may be reused on another +host, so they do not identify the holder by themselves. A volume refuses an +assignment with a missing or different server id, or different carried data or +control endpoints. The master refuses a workspace lease request whose server +id is missing or does not match the assigned holder. + +Upgrade the master first, then the volumes, using binaries from the same +release. A new volume connected to an older pre-release master stays not +serving until the master is upgraded. An old volume does not gain the new +assignment guard merely because its master has been upgraded. There is no +compatibility flag or endpoint-based fallback. + +This affects pre-release version mixing; it does not change the local volume +or remote HEAD format. diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index f3e46a6522..041aada217 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -13,6 +13,13 @@ For a first, read-only try without services, see [first volume (read-only check)](#first-volume-read-only-check). For a write test, see [write test (scratch host only)](#write-test-scratch-host-only). +## Upgrade order + +Upgrade `blockmaster` first, then `blockvolume`. Assignments and workspace +lease requests require the assigned server id. A new volume against an older +pre-release master stays not serving until the master is upgraded; an older +volume must also be upgraded to gain the assignment guard. Do not use endpoint +matching as a compatibility fallback. See [holder identity and upgrades](releases/holder-identity.md). ## Get the matching files The unit and settings files must come from the same commit as your @@ -556,3 +563,4 @@ A restore makes a new, independent volume from a snapshot. The source volume and - Follow it with `sw-block ops chunk restore --volume v2 --status-addr STATUS_OF_V2 --status`. - Until v2 is independent, a snapshot of v2 is refused (`restore_incomplete`). - While v2 still fetches chunks, its scheduled snapshots are skipped and counted as `restoring`. After that, until it is independent, they are refused like any snapshot and show as failed attempts with that code. + From 85139083d60fd0ba34ba7d37dc3f4681f8f1da1a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:58:15 -0800 Subject: [PATCH 044/204] test: schedule planned-drain expiry at provider outcome seam --- seaweed-block/cmd/blockvolume/process_exit.go | 8 ++++- .../process_exit_authority_test.go | 36 ++++++++----------- .../durable/provider_startup_outcome_test.go | 11 +++++- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 8a3ae07c37..7089128a81 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -171,7 +171,13 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e e.choose(workspaceExit{exitWorkspaceRetry, "revoke_ack_unconfirmed"}) } -func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p *durable.DurableProvider) bool { +// The provider publishes only a generation-bound outcome and an atomic choice. +type chunkStartupOutcomeProvider interface { + ChunkStartupOutcome(string) (uint64, bool) + ChooseChunkStartupExit(string, uint64, func()) bool +} + +func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p chunkStartupOutcomeProvider) bool { if !f.workspaceLease || f.durableImpl != "walstore-chunk" { return false } diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index 6ffe4db778..be80656ae4 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -3,8 +3,6 @@ package main import ( "context" "errors" - "github.com/seaweedfs/seaweed-block/core/frontend" - "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/host/volume" control "github.com/seaweedfs/seaweed-block/core/rpc/control" "github.com/seaweedfs/seaweed-block/core/storage" @@ -157,10 +155,17 @@ func TestWorkspaceUnconfirmedRevokeHasOwnReason(t *testing.T) { } } -type exitWaitingProjection struct{} +// Controlled provider outcome at its public generation/selection seam. The +// real provider deadline/retained-state boundary is tested in durable. +type exitStartupOutcome struct{ expired bool } -func (exitWaitingProjection) Projection() frontend.Projection { - return frontend.Projection{VolumeID: "v", ReplicaID: "r"} +func (s *exitStartupOutcome) ChunkStartupOutcome(string) (uint64, bool) { return 1, s.expired } +func (s *exitStartupOutcome) ChooseChunkStartupExit(_ string, gen uint64, choose func()) bool { + if gen != 1 || !s.expired { + return false + } + choose() + return true } func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { @@ -196,22 +201,9 @@ func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { if request == nil || !h.WorkspaceLeaseRevoking() { t.Fatal("real planned drain not acquired") } - p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: time.Nanosecond, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return storage.NewMemChunkRemote(), nil }}, exitWaitingProjection{}) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = p.Close() }) - if _, err = p.EnsureStorage("v"); err != nil { - t.Fatal(err) - } - if _, err = p.RecoverVolume(ctx, "v"); err != nil { - t.Fatal(err) - } - select { - case <-p.ChunkStartupUpdates(): - case <-time.After(3 * time.Second): - t.Fatal("controlled startup expiry absent") - } + // Deliver expiry only after the real guard's planned drain owns + // shutdown, while its resource-owner reply is deliberately held. + p := &exitStartupOutcome{expired: true} chooseChunkStartupExit(e, f, h, p) select { case out := <-e.decision: @@ -219,7 +211,7 @@ func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { default: } remote := storage.NewMemChunkRemote() - _, err = remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 1, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Epoch: 1, Holder: "s/r", Gen: 1}}) + _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 1, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Epoch: 1, Holder: "s/r", Gen: 1}}) if err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go index 03206667a6..d8741bd803 100644 --- a/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go +++ b/seaweed-block/core/frontend/durable/provider_startup_outcome_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "reflect" + "sync/atomic" "testing" "time" @@ -122,10 +123,15 @@ func TestChunkStartupRetainedDispositionWinsExpiredAttachContext(t *testing.T) { waiting.Epoch = 0 waiting.Healthy = false view.set(waiting) + var entered atomic.Bool p, err := durable.NewDurableProvider(durable.ProviderConfig{ Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkAssignmentTimeout: 250 * time.Millisecond, - ChunkAttachCheck: func(ctx context.Context, _ string, _ durable.ChunkGeometry) error { <-ctx.Done(); return tc.err }, + ChunkAttachCheck: func(ctx context.Context, _ string, _ durable.ChunkGeometry) error { + entered.Store(true) + <-ctx.Done() + return tc.err + }, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { t.Error("retained attach reached remote") return storage.NewMemChunkRemote(), nil @@ -143,6 +149,9 @@ func TestChunkStartupRetainedDispositionWinsExpiredAttachContext(t *testing.T) { } view.set(assigned) waitLog(t, logs, "chunk authority wait for volume=v1 ended") + if !entered.Load() { + t.Fatal("fixture deadline elapsed before attach check entered; not a retained-disposition witness") + } if _, failed := p.ChunkStartupOutcome("v1"); failed { t.Fatal("deadline defer replaced retained attach disposition with process retry") } From 58839e5c2d6a8f355abbec0c3a4dc14cd875f4c6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:58:47 -0800 Subject: [PATCH 045/204] fix: read committed holder identity without waiting for authority writes --- seaweed-block/core/authority/workspace_lease_view.go | 12 ++++++++++++ seaweed-block/core/host/master/workspace_binding.go | 5 +++++ seaweed-block/core/host/master/workspace_service.go | 8 ++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/authority/workspace_lease_view.go b/seaweed-block/core/authority/workspace_lease_view.go index f72ded0815..480eb10418 100644 --- a/seaweed-block/core/authority/workspace_lease_view.go +++ b/seaweed-block/core/authority/workspace_lease_view.go @@ -157,6 +157,18 @@ type PublishedLine struct { IssuedHost string } +// PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity +// checks on renewal must not wait for p.mu, which spans authority store I/O. +func (p *Publisher) PublishedAuthorityLine(volume string) (PublishedLine, bool) { + p.leaseMu.Lock() + defer p.leaseMu.Unlock() + lv := p.leaseViews[volume] + if lv == nil || !lv.d.bound { + return PublishedLine{}, false + } + return PublishedLine{ReplicaID: lv.d.replica, Epoch: lv.d.epoch, IssuedHost: lv.d.issuedHost}, true +} + // PublishedAuthorityLines returns the committed authority line of every // volume that has one. It reads the lease views under the leaf leaseMu only: // it never waits on p.mu, which writers hold across store writes, and it diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 5346b8935f..abfb9c4ebf 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -76,6 +76,11 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string } } } + return h.placementSourceHost(volume, replica) +} + +// placementSourceHost uses explicit membership, never endpoint inference. +func (h *Host) placementSourceHost(volume, replica string) string { if h.lifecycle != nil { if p, ok := h.lifecycle.Placements.GetPlacement(volume); ok { for _, slot := range p.Slots { diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index d33b5b5688..70eb91c0df 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -91,8 +91,12 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace return nil, err } // r2.34 AUTHORITY: a replica id can move between servers. - line, ok := s.host.Publisher().VolumeAuthorityLine(q.GetVolumeId()) - if !ok || line.ReplicaID != q.GetReplicaId() || line.Epoch != q.GetEpoch() || q.GetServerId() == "" || q.GetServerId() != s.host.workspaceSourceHost(q.GetVolumeId(), line.ReplicaID, line.Epoch) { + line, ok := s.host.Publisher().PublishedAuthorityLine(q.GetVolumeId()) + server := line.IssuedHost + if server == "" { + server = s.host.placementSourceHost(q.GetVolumeId(), line.ReplicaID) + } + if !ok || line.ReplicaID != q.GetReplicaId() || line.Epoch != q.GetEpoch() || q.GetServerId() == "" || q.GetServerId() != server { return nil, status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder") } l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch()) From 5d28c4350471435202b408b755d7fb2ab852d722 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:59:46 -0800 Subject: [PATCH 046/204] test: reject foreign server identity across expired lease regrant --- .../master/workspace_holder_identity_test.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go index eac051f7b2..6b919ddd36 100644 --- a/seaweed-block/core/host/master/workspace_holder_identity_test.go +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -1,11 +1,15 @@ package master import ( + "context" + "github.com/seaweedfs/seaweed-block/core/authority" control "github.com/seaweedfs/seaweed-block/core/rpc/control" "google.golang.org/protobuf/encoding/protowire" "google.golang.org/protobuf/proto" "reflect" + "sync/atomic" "testing" + "time" ) func leaseHolderIdentity(t *testing.T, epoch uint64, server string) *control.WorkspaceIdentity { @@ -26,7 +30,13 @@ func leaseHolderIdentity(t *testing.T, epoch uint64, server string) *control.Wor } func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) { - h, conn, ctx := reviewBindingHost(t) + var nowNS atomic.Int64 + nowNS.Store(time.Now().UnixNano()) + h, conn, ctx := reviewBindingHostBeforeStart(t, func(context.Context, string) (authority.WorkspaceHead, error) { + return authority.WorkspaceHead{Gen: 9, Epoch: 1, Holder: "node-a/r1", RemoteLSN: 42, Detached: true}, nil + }, func(h *Host) { + authority.WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return time.Unix(0, nowNS.Load()) })(h.Publisher()) + }) reviewCreate(t, conn, ctx, "v") ws := control.NewWorkspaceServiceClient(conn) b := &control.WorkspaceBinding{VolumeId: "v", ServerId: "node-a", DataAddr: "127.0.0.1:10000", CtrlAddr: "127.0.0.1:10001"} @@ -60,6 +70,11 @@ func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) t.Fatal("matching server grant", err) } refuse("renew", line.Epoch) + nowNS.Add(int64(2 * time.Minute)) // beyond both the old horizon and clock-skew barrier + refuse("expired re-grant", line.Epoch) + if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { + t.Fatal("matching server expired re-grant", err) + } if _, err := ws.RevokeWorkspace(ctx, id); err != nil { t.Fatal(err) } From e966deea38360bc7d60edede7ab685f97de3d054 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:01:17 -0800 Subject: [PATCH 047/204] fix: retain a newer foreign-holder fence across stale replay --- seaweed-block/core/host/volume/assignment_holder_test.go | 6 ++++++ seaweed-block/core/host/volume/host.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 1359ea8ed5..943c3b72a6 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -99,6 +99,12 @@ func TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica(t *testing.T if h.view.Projection().Healthy { t.Fatal("same-r1 foreign holder left the old frontend healthy") } + stale := holderAssignment(t, "new-host") + stale.Epoch = 0 + h.applyFact(stale) + if h.view.Projection().Healthy { + t.Fatal("stale foreign replay erased the newer fencing line") + } } func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) { diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 259e9eae14..1d1591b2c9 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -235,6 +235,11 @@ func (h *Host) recordOtherLine(f *control.AssignmentFact) { // is the canonical safe deep-copy for proto messages. cp := proto.Clone(f).(*control.AssignmentFact) h.otherMu.Lock() + // A stale replay must not erase the newer foreign-holder fence (r2.34). + if old := h.lastOther; old != nil && (cp.Epoch < old.Epoch || cp.Epoch == old.Epoch && cp.EndpointVersion < old.EndpointVersion) { + h.otherMu.Unlock() + return + } h.lastOther = cp h.otherMu.Unlock() } From 7600be4e818ed8a24f7acbec265a05f792a54cd6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:01:28 -0800 Subject: [PATCH 048/204] fix: preserve retained startup and planned-drain ownership --- seaweed-block/cmd/blockvolume/process_exit.go | 36 ++- .../startup_systemd_integration_test.go | 205 +++++++++++++----- .../workspace_weed_integration_test.go | 11 +- .../core/frontend/durable/provider_chunk.go | 5 +- .../docs/design/agent-workspace-design.md | 15 +- seaweed-block/docs/design/invariants.md | 4 +- 6 files changed, 214 insertions(+), 62 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 7089128a81..fe4a0e392e 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -28,15 +28,35 @@ type workspaceExit struct { // INV-WS-STARTUP-RETRY-001: the first outcome is immutable. The channel is a // single latched wakeup, not a queue of competing shutdown events. type processExit struct { - parent context.Context - once sync.Once - done chan struct{} - decision chan workspaceExit + parent context.Context + once sync.Once + done chan struct{} + decision chan workspaceExit + startupMu sync.Mutex + startupCtx context.Context + startupCancel context.CancelFunc } func newProcessExit(ctx context.Context) *processExit { - return &processExit{parent: ctx, done: make(chan struct{}), decision: make(chan workspaceExit, 1)} + startupCtx, cancel := context.WithCancel(ctx) + return &processExit{parent: ctx, done: make(chan struct{}), decision: make(chan workspaceExit, 1), startupCtx: startupCtx, startupCancel: cancel} } + +// INV-WS-STARTUP-RETRY-001: once the resource owner takes shutdown, startup +// outcomes cannot arbitrate it. ACK success is still selected only after ACK. +func (e *processExit) stopChunkStartup() { + e.startupMu.Lock() + defer e.startupMu.Unlock() + e.startupCancel() +} +func (e *processExit) chooseChunkStartup(out workspaceExit) { + e.startupMu.Lock() + defer e.startupMu.Unlock() + if e.startupCtx.Err() == nil { + e.choose(out) + } +} + func (e *processExit) choose(out workspaceExit) { e.once.Do(func() { if e.parent.Err() != nil { @@ -118,6 +138,8 @@ func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.H } select { + case <-e.startupCtx.Done(): + return case <-ctx.Done(): return case <-e.done: @@ -136,6 +158,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan case <-e.done: return nil, done case request := <-requests: + e.stopChunkStartup() out := workspaceExit{reason: "revoked"} if !h.WorkspaceLeaseRevoking() { out = workspaceRetryOutcome("lease_expired", h) @@ -145,6 +168,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan } return &request, done case err := <-done: + e.stopChunkStartup() fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) e.choose(workspaceRetryOutcome("lease_expired", h)) return nil, nil @@ -186,5 +210,5 @@ func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p chunkStar return false } out := workspaceRetryOutcome("assignment_timeout", h) - return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.choose(out) }) + return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.chooseChunkStartup(out) }) } diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 49db69ecf8..5827b55e85 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -21,6 +21,7 @@ import ( "github.com/seaweedfs/seaweed-block/core/frontend/durable" hostvolume "github.com/seaweedfs/seaweed-block/core/host/volume" control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "github.com/seaweedfs/seaweed-block/core/storage" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) @@ -37,24 +38,30 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if os.Getenv("CHUNKSTORE_WEED") == "" { t.Fatal("real CHUNKSTORE_WEED binary required") } - if out, err := exec.Command("systemctl", "show", "--property=Version").CombinedOutput(); err != nil { + probeCtx, probeCancel := context.WithTimeout(context.Background(), 5*time.Second) + defer probeCancel() + if out, err := exec.CommandContext(probeCtx, "systemctl", "show", "--property=Version").CombinedOutput(); err != nil { t.Fatalf("real systemd unavailable: %v %s", err, out) } - root := t.TempDir() + fixture := newGAP1Fixture(t) + root := fixture.root bin := filepath.Join(root, "bin") if err := os.Mkdir(bin, 0755); err != nil { t.Fatal(err) } for _, name := range []string{"blockvolume", "blockmaster"} { - cmd := exec.Command("go", "build", "-p", "4", "-o", filepath.Join(bin, name), "../"+name) - if out, err := cmd.CombinedOutput(); err != nil { + buildCtx, buildCancel := context.WithTimeout(context.Background(), 2*time.Minute) + cmd := exec.CommandContext(buildCtx, "go", "build", "-p", "4", "-o", filepath.Join(bin, name), "../"+name) + out, err := cmd.CombinedOutput() + buildCancel() + if err != nil { t.Fatalf("real binary build: %v %s", err, out) } } - cluster := startWorkspaceWeed(t) + cluster := startWorkspaceWeedAt(t, filepath.Join(root, "weed")) gap1PreserveFailure(t, root, cluster.dir) stem := fmt.Sprintf("codex03-gap1-%d", time.Now().UnixNano()) - gap1ProbeTerminalSuccess(t, stem+"-policy-probe") + gap1ProbeTerminalSuccess(t, fixture, stem+"-policy-probe") volume := stem base := "/" + stem masterAddr := leaseBinaryAddress(t) @@ -64,7 +71,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if err := os.WriteFile(spec, []byte(cfg), 0600); err != nil { t.Fatal(err) } - startGAP1Unit(t, stem+"-master", false, filepath.Join(bin, "blockmaster"), + fixture.start(t, stem+"-master", false, filepath.Join(bin, "blockmaster"), "--listen", masterAddr, "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), "--cluster-spec", spec, "--lifecycle-product-loop-interval", "200ms", "--expected-slots-per-volume", "1", "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+base) @@ -82,7 +89,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { "--nvme-listen", nvmeAddr, "--nvme-subsysnqn", "nqn.2026-11.test:" + stem} // Bootstrap is a different, non-restarting unit. Kill only this exact unit. bootstrap := stem + "-bootstrap" - startGAP1Unit(t, bootstrap, false, filepath.Join(bin, "blockvolume"), args...) + fixture.start(t, bootstrap, false, filepath.Join(bin, "blockvolume"), args...) waitGAP1(t, "bootstrap did not attach under a real lease", 60*time.Second, func() bool { return gap1Operational(t, statusAddr, volume) }) // Calibrate verdict parsing against actual binary responses BEFORE kill. status, payload, err := gap1Status(statusAddr, volume) @@ -102,7 +109,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { client.readExact(t, 8, want) client.close() remote := cluster.remote(t, base+"/"+volume) - before, err := remote.GetHead(context.Background()) + before, err := gap1ReadHead(t, remote) if err != nil || before.Gen == 0 { t.Fatalf("bootstrap HEAD: %+v %v", before, err) } @@ -123,7 +130,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { return s.Lease.ValidForNs <= 0 && time.Now().UnixNano() >= s.Lease.ExpiresAtNs }) unit := stem + "-returning" - startGAP1Unit(t, unit, true, filepath.Join(bin, "blockvolume"), args...) + fixture.start(t, unit, true, filepath.Join(bin, "blockvolume"), args...) first := gap1Unit(t, unit) t.Logf("captured effective restart policy: %+v", first) firstPID := first["MainPID"] @@ -156,7 +163,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { } return n >= 1 && s["MainPID"] != "0" && s["MainPID"] != firstPID && gap1Operational(t, statusAddr, volume) }) - after, err := remote.GetHead(context.Background()) + after, err := gap1ReadHead(t, remote) if err != nil || after.Gen <= before.Gen || after.Holder != before.Holder || after.Epoch != before.Epoch { t.Fatalf("return did not claim HEAD: before%+v after%+v err%v", before, after, err) } @@ -183,47 +190,140 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { t.Fatalf("systemd rate limit hit: %+v", s) } gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, "r1", s["NRestarts"], s["InvocationID"]) - gap1SupersededDoesNotRestart(t, stem, filepath.Join(bin, "blockvolume"), args, root, volume) + gap1SupersededDoesNotRestart(t, fixture, stem, filepath.Join(bin, "blockvolume"), args, root, volume) } -func startGAP1Unit(t *testing.T, unit string, restart bool, exe string, args ...string) { +// Roots are deliberately independent of testing.TempDir: unknown unit cleanup +// must never remove an executable or WAL beneath a possible surviving service. +type gap1Fixture struct { + root string + units []string +} + +func newGAP1Fixture(t *testing.T) *gap1Fixture { t.Helper() + root, err := os.MkdirTemp("", "codex03-gap1-runtime-") + if err != nil { + t.Fatal(err) + } + f := &gap1Fixture{root: root} + t.Cleanup(func() { + safe := true + for _, unit := range f.units { + state, err := gap1ReadUnit(unit) + if err != nil || !gap1UnitGone(state) { + t.Errorf("final unit absence unproved: %s state%v err%v", unit, state, err) + safe = false + } + } + if !safe || t.Failed() { + t.Logf("retained run root: %s (safe=%v failed=%v)", root, safe, t.Failed()) + return + } + if err := os.RemoveAll(root); err != nil { + t.Errorf("remove confirmed idle run root: %v", err) + } + }) + return f +} +func (f *gap1Fixture) start(t *testing.T, unit string, restart bool, exe string, args ...string) { + t.Helper() + f.units = append(f.units, unit) + // Persist ownership before the create, including an aggregate test crash. + ownership, err := os.OpenFile(filepath.Join(f.root, "owned-units.txt"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600) + if err != nil { + t.Fatal(err) + } + _, writeErr := fmt.Fprintln(ownership, unit) + closeErr := ownership.Close() + if writeErr != nil || closeErr != nil { + t.Fatalf("record unit ownership: %v %v", writeErr, closeErr) + } + // Register BEFORE submission: systemd may create the unit even when the + // command loses its answer or times out. Every uncertain create is owned. + t.Cleanup(func() { gap1CleanupUnit(t, unit) }) policy := "no" if restart { policy = "on-failure" } shipped := gap1ShippedPolicy(t) - cmdArgs := []string{"--unit=" + unit, "--property=Type=exec", "--property=Restart=" + policy, - "--property=RestartSec=" + shipped["RestartSec"], - "--property=RestartPreventExitStatus=" + shipped["RestartPreventExitStatus"], - "--property=TimeoutStopSec=" + shipped["TimeoutStopSec"], - "--property=StartLimitIntervalSec=10s", "--property=StartLimitBurst=5", "--", exe} + cmdArgs := []string{"--unit=" + unit, "--property=Type=exec", "--property=Restart=" + policy, "--property=RestartSec=" + shipped["RestartSec"], "--property=RestartPreventExitStatus=" + shipped["RestartPreventExitStatus"], "--property=TimeoutStopSec=" + shipped["TimeoutStopSec"], "--property=StartLimitIntervalSec=10s", "--property=StartLimitBurst=5", "--", exe} cmdArgs = append(cmdArgs, args...) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) defer cancel() - out, err := exec.CommandContext(ctx, "systemd-run", cmdArgs...).CombinedOutput() - if err != nil { - t.Fatalf("systemd-run %s: %v %s", unit, err, out) + if out, err := exec.CommandContext(ctx, "systemd-run", cmdArgs...).CombinedOutput(); err != nil { + t.Fatalf("systemd-run %s (creation outcome uncertain; registered cleanup owns it): %v %s", unit, err, out) } - t.Cleanup(func() { - // Capture before stopping; never remove a run root owned by another run. - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - log, _ := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=short-monotonic").CombinedOutput() - cancel() - t.Logf("real unit %s journal:\n%s", unit, log) - ctx, cancel = context.WithTimeout(context.Background(), 15*time.Second) - _, err := exec.CommandContext(ctx, "systemctl", "stop", unit).CombinedOutput() - cancel() - if err != nil && gap1Unit(t, unit)["LoadState"] != "not-found" { - ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) - _ = exec.CommandContext(ctx, "systemctl", "kill", "--signal=KILL", unit).Run() - cancel() - t.Errorf("unit stop required kill: %s", unit) +} +func gap1CleanupUnit(t *testing.T, unit string) { + t.Helper() + command := func(bound time.Duration, args ...string) error { + ctx, cancel := context.WithTimeout(context.Background(), bound) + defer cancel() + out, err := exec.CommandContext(ctx, "systemctl", args...).CombinedOutput() + if err != nil { + t.Logf("unit cleanup %s: %v %s", unit, err, out) } - ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) - _ = exec.CommandContext(ctx, "systemctl", "reset-failed", unit).Run() - cancel() - }) + return err + } + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + journal, _ := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=short-monotonic").CombinedOutput() + cancel() + t.Logf("real unit %s journal:\n%s", unit, journal) + _ = command(15*time.Second, "stop", unit) + state, err := gap1ReadUnit(unit) + if err != nil || !gap1UnitGone(state) { + _ = command(5*time.Second, "kill", "--kill-who=all", "--signal=KILL", unit) + _ = command(5*time.Second, "stop", unit) + } + _ = command(5*time.Second, "reset-failed", unit) + state, err = gap1ReadUnit(unit) + if err != nil || !gap1UnitGone(state) { + t.Errorf("owned unit/PID cleanup not confirmed; retain run root: %s state%v err%v", unit, state, err) + return + } + t.Logf("confirmed owned unit stopped: %s state%v", unit, state) +} +func gap1UnitGone(s map[string]string) bool { + job, hasJob := s["Job"] + return hasJob && job == "" && s["MainPID"] == "0" && s["ControlPID"] == "0" && + (s["LoadState"] == "not-found" || s["LoadState"] == "loaded") && s["ActiveState"] == "inactive" && s["SubState"] == "dead" +} + +// The absent-unit shape is captured from real systemd249. Refuse incomplete, +// contradictory, queued-job and live-process observations before removing WAL. +func TestGAP1AbsenceRequiresNoJobAndBothPIDsZero(t *testing.T) { + for _, tc := range []struct { + name, key, value string + want bool + }{ + {"collected", "LoadState", "not-found", true}, + {"loaded stopped", "LoadState", "loaded", true}, + {"main lives", "MainPID", "123", false}, + {"control lives", "ControlPID", "123", false}, + {"job queued", "Job", "123", false}, + {"restart pending", "SubState", "auto-restart", false}, + {"contradictory active", "ActiveState", "active", false}, + {"unknown load", "LoadState", "", false}, + } { + t.Run(tc.name, func(t *testing.T) { + s := map[string]string{"MainPID": "0", "ControlPID": "0", "LoadState": "not-found", "ActiveState": "inactive", "SubState": "dead", "Job": ""} + s[tc.key] = tc.value + if gap1UnitGone(s) != tc.want { + t.Fatalf("absence classification %+v want%v", s, tc.want) + } + delete(s, "Job") + if gap1UnitGone(s) { + t.Fatal("missing observation treated as absence") + } + }) + } +} +func gap1ReadHead(t *testing.T, remote storage.ChunkRemote) (storage.ChunkHead, error) { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + return remote.GetHead(ctx) } func gap1Systemctl(t *testing.T, args ...string) { t.Helper() @@ -235,11 +335,19 @@ func gap1Systemctl(t *testing.T, args ...string) { } func gap1Unit(t *testing.T, unit string) map[string]string { t.Helper() + m, err := gap1ReadUnit(unit) + if err != nil { + t.Fatal(err) + } + t.Logf("captured unit %s: %+v", unit, m) + return m +} +func gap1ReadUnit(unit string) (map[string]string, error) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=MainPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec,ActiveState,SubState,LoadState,InvocationID").CombinedOutput() + b, err := exec.CommandContext(ctx, "systemctl", "show", unit, "--property=Job,MainPID,ControlPID,NRestarts,ExecMainStatus,Result,ExecMainStartTimestampMonotonic,RestartUSec,RestartPreventExitStatus,StartLimitBurst,StartLimitIntervalUSec,ActiveState,SubState,LoadState,InvocationID").CombinedOutput() if err != nil { - t.Fatalf("unit show: %v %s", err, b) + return nil, fmt.Errorf("unit show %s: %w %s", unit, err, b) } m := map[string]string{} for _, l := range strings.Split(strings.TrimSpace(string(b)), "\n") { @@ -248,13 +356,12 @@ func gap1Unit(t *testing.T, unit string) map[string]string { m[k] = v } } - for _, key := range []string{"MainPID", "NRestarts", "ExecMainStatus", "Result", "ExecMainStartTimestampMonotonic"} { + for _, key := range []string{"Job", "MainPID", "ControlPID", "NRestarts", "ExecMainStatus", "Result", "ExecMainStartTimestampMonotonic", "LoadState", "ActiveState", "SubState"} { if _, ok := m[key]; !ok { - t.Fatalf("captured systemd response lacks %s: %s", key, b) + return nil, fmt.Errorf("captured systemd response lacks %s: %s", key, b) } } - t.Logf("captured unit %s: %s", unit, strings.TrimSpace(string(b))) - return m + return m, nil } func gap1Status(addr, volume string) (int, []byte, error) { r, e := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status/durable?volume=" + volume) @@ -395,7 +502,7 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie // assignment and names r-old, so only the observed different-replica fact may // permit 78. Run after the live holder has ACKed and exited, avoiding a node // registration change while that holder is serving. -func gap1SupersededDoesNotRestart(t *testing.T, stem, exe string, args []string, root, volume string) { +func gap1SupersededDoesNotRestart(t *testing.T, fixture *gap1Fixture, stem, exe string, args []string, root, volume string) { t.Helper() changed := append([]string(nil), args...) addr := leaseBinaryAddress(t) @@ -406,7 +513,7 @@ func gap1SupersededDoesNotRestart(t *testing.T, stem, exe string, args []string, } } unit := stem + "-superseded" - startGAP1Unit(t, unit, true, exe, changed...) + fixture.start(t, unit, true, exe, changed...) waitGAP1(t, "superseded process never observed the master's other-replica fact", 15*time.Second, func() bool { resp, err := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status?volume=" + volume) if err != nil { @@ -544,9 +651,9 @@ func gap1JournalTerminalSuccess(t *testing.T, unit, invocation string, expectedS // Calibrate the terminal parser against the real supervisor before any holder // is killed. Successful transient units can be collected; their journal is the // proof, never the default zeros returned for an unknown unit. -func gap1ProbeTerminalSuccess(t *testing.T, unit string) { +func gap1ProbeTerminalSuccess(t *testing.T, fixture *gap1Fixture, unit string) { t.Helper() - startGAP1Unit(t, unit, true, "/bin/true") + fixture.start(t, unit, true, "/bin/true") waitGAP1(t, "systemd terminal-success parser preflight failed", 5*time.Second, func() bool { return gap1JournalTerminalSuccess(t, unit, "", 1) }) diff --git a/seaweed-block/cmd/blockvolume/workspace_weed_integration_test.go b/seaweed-block/cmd/blockvolume/workspace_weed_integration_test.go index afa7e1f32f..5ca1cbde54 100644 --- a/seaweed-block/cmd/blockvolume/workspace_weed_integration_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_weed_integration_test.go @@ -62,12 +62,21 @@ func w4WaitTCP(t *testing.T, addr string, d time.Duration) { } func startWorkspaceWeed(t *testing.T) *w4WeedCluster { + t.Helper() + return startWorkspaceWeedAt(t, t.TempDir()) +} + +// A caller-owned root lets process qualification retain its filer evidence +// when external-service cleanup is uncertain. Existing tests keep TempDir. +func startWorkspaceWeedAt(t *testing.T, dir string) *w4WeedCluster { t.Helper() weed := os.Getenv("CHUNKSTORE_WEED") if weed == "" { t.Skip("CHUNKSTORE_WEED not set") } - dir := t.TempDir() + if err := os.MkdirAll(dir, 0700); err != nil { + t.Fatal(err) + } used := map[int]bool{} mp, vp, fp := w4FreePortPair(t, used), w4FreePortPair(t, used), w4FreePortPair(t, used) c := &w4WeedCluster{ diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 206d3e5616..7fd1e45a02 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -164,10 +164,11 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen defer func() { log.Printf("durable: chunk authority wait for volume=%s ended after %s: %s", volumeID, time.Since(start), ended) }() + retained := false // this generation already chose sealed replay or diagnostics waitCtx, endWait := context.WithTimeout(p.closeCtx, limit) defer endWait() defer func() { - if !errors.Is(waitCtx.Err(), context.DeadlineExceeded) { + if retained || !errors.Is(waitCtx.Err(), context.DeadlineExceeded) { return } // The old wait must not overwrite a newer recovery's readiness. @@ -235,6 +236,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen case errors.Is(err, storage.ErrChunkLayerDetached): // INV-WS-STARTUP-RETRY-001: an assigned sealed incarnation stays // non-serving for exact seal replay; restarting cannot unseal it. + retained = true ended = "sealed assignment, retained for replay" h.backend.SetOperational(false, "sealed assignment; replay only") return @@ -242,6 +244,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen ended = "fenced, not serving" log.Printf("durable: chunk layer for volume=%s: %v (not serving)", volumeID, err) if errors.Is(err, ErrChunkStaleLocalRoot) { + retained = true h.attachMu.Lock() if p.current(h, gen) && h.chunk == nil { h.backend.SetOperational(false, "chunk layer attach refused: "+err.Error()) diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index c8a8882f37..e1415f2e1d 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -485,7 +485,7 @@ Guest I/O never acquires a slot. An unavailable pool skips background cuts; urge A workspace chunk primary that exhausts its existing assignment wait, or whose lease fences while serving, exits 75 after fail-closed cleanup bounded by the existing five-second lease-drain limit. systemd restarts on failure with -RestartSec=5s. Only a master fact naming another replica permits exit 78; +RestartSec=5s. Only a newer master fact naming another replica permits exit 78; RestartPreventExitStatus=78 suppresses automatic restarts until an operator explicitly starts the unit. A higher epoch for the same replica retries. An ACKed planned revocation and a signal stop retain their normal exit status. @@ -500,14 +500,21 @@ stateDiagram-v2 AwaitingAssignment --> Serving: grant and HEAD claim AwaitingAssignment --> Exit75: assignment wait exhausted Serving --> Exit75: lease fence - AwaitingAssignment --> Exit78: master names another replica - Serving --> Exit78: lease fence and another-replica fact + AwaitingAssignment --> Exit78: newer master fact names another replica + Serving --> Exit78: lease fence and newer other-replica fact Exit75 --> AwaitingAssignment: supervisor starts new process Exit78 --> AwaitingAssignment: explicit operator start AwaitingAssignment --> SealedReplay: assigned same-epoch sealed HEAD SealedReplay --> Exit75: lease fence SealedReplay --> [*]: signal - Serving --> [*]: revoke ACK or signal + AwaitingAssignment --> Draining: planned revoke owns shutdown; retire startup watcher + Serving --> Draining: planned revoke owns shutdown + SealedReplay --> Draining: planned revoke owns shutdown + Draining --> [*]: stored detached proof and revoke ACK + Draining --> Exit75: ACK unconfirmed + Serving --> [*]: signal ``` GAP-1 exit classification compares a newer other-replica fact with the newest own assignment this process observed, including a locally blocked assignment; historical other facts do not suppress restart. The shared `Host.IsSuperseded` predicate is reused without changing frontend admission. An unconfirmed revocation ACK exits75 with `revoke_ack_unconfirmed`. Restart can retry ACK only while the original revoking lease remains valid; after expiry the revoking/recorded-ACK re-grant guards still refuse, so restart alone cannot resolve that case and operator recovery is required. + +Once the resource owner accepts a stop request, startup-monitor cancellation and startup exit choice serialize on the process owner's startup mutex. A delayed startup deadline cannot replace planned drain ownership; success remains unselected until the real guard confirms the stored detached proof's ACK. A wait that already chose sealed replay or stale-local-root diagnostics keeps that disposition even if its context expires at return. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index eac66bed24..b6ff593151 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -100,7 +100,7 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current holder/epoch, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001` | -| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a newer master fact naming another replica exits 78. Revocation ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a newer master fact naming another replica exits 78. Planned drain retires startup monitoring before cleanup; ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -674,6 +674,8 @@ Notes: | `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; only a newer master fact naming another replica permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is an optimisation, permitted only by a NEWER observed master fact for this volume naming another replica, compared with the latest own assignment observed by this process (zero before any). Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- 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 2 s RPC timeout. The existing 3 s closeout wait 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. Notes: From e76532be531a5b215a0a3edac7aee35b3fb77b96 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:02:02 -0800 Subject: [PATCH 049/204] docs: disclose both directions of pre-release identity skew --- seaweed-block/docs/releases/holder-identity.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/seaweed-block/docs/releases/holder-identity.md b/seaweed-block/docs/releases/holder-identity.md index cea2a0b6ea..16486d2832 100644 --- a/seaweed-block/docs/releases/holder-identity.md +++ b/seaweed-block/docs/releases/holder-identity.md @@ -10,8 +10,11 @@ id is missing or does not match the assigned holder. Upgrade the master first, then the volumes, using binaries from the same release. A new volume connected to an older pre-release master stays not serving until the master is upgraded. An old volume does not gain the new -assignment guard merely because its master has been upgraded. There is no +assignment guard merely because its master has been upgraded. The new master also +refuses lease calls from old volumes that omit the server id, so plan for a +service interruption while replacing pre-release components. There is no compatibility flag or endpoint-based fallback. This affects pre-release version mixing; it does not change the local volume or remote HEAD format. + From eb12ec4c68f73d5d90e1d4413f6e2b18aa944add Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:03:54 -0800 Subject: [PATCH 050/204] test: bound the multi-RPC holder scenario independently of fixture setup --- .../core/host/master/workspace_holder_identity_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go index 6b919ddd36..380ca16406 100644 --- a/seaweed-block/core/host/master/workspace_holder_identity_test.go +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -32,11 +32,13 @@ func leaseHolderIdentity(t *testing.T, epoch uint64, server string) *control.Wor func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) { var nowNS atomic.Int64 nowNS.Store(time.Now().UnixNano()) - h, conn, ctx := reviewBindingHostBeforeStart(t, func(context.Context, string) (authority.WorkspaceHead, error) { + h, conn, _ := reviewBindingHostBeforeStart(t, func(context.Context, string) (authority.WorkspaceHead, error) { return authority.WorkspaceHead{Gen: 9, Epoch: 1, Holder: "node-a/r1", RemoteLSN: 42, Detached: true}, nil }, func(h *Host) { authority.WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return time.Unix(0, nowNS.Load()) })(h.Publisher()) }) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + t.Cleanup(cancel) reviewCreate(t, conn, ctx, "v") ws := control.NewWorkspaceServiceClient(conn) b := &control.WorkspaceBinding{VolumeId: "v", ServerId: "node-a", DataAddr: "127.0.0.1:10000", CtrlAddr: "127.0.0.1:10001"} From 8815c82098e9c8a7898b866f29ec36bc27dd8ff3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:07:24 -0800 Subject: [PATCH 051/204] test: the old process exits within the 30 s lease; a clean move without the ACK is refused The planned hand-over waits 30 s for the old blockvolume's own exit, the lease bound the lifecycle chapter states. TestStandaloneCleanMoveWithoutTheACKIsRefused makes the chapter's negative check deterministic: the volume is sealed, its blockvolume is killed (a signal sends no ACK), the lease is revoked with the sealed generation, and the clean move exits 1 with the documented refusal while workspace show keeps no ACK. Its output is captured into the fixtures and read by the shared checks. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_checks_test.go | 19 +- .../planned_handoff_integration_test.go | 204 ++++++++++++------ .../planned-handoff/move-refused.stderr | 1 + .../planned-handoff/show-revoked.stdout | 8 + 4 files changed, 170 insertions(+), 62 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-refused.stderr create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-revoked.stdout diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go index 82b6dd78f3..dedf934a66 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go @@ -144,6 +144,15 @@ func checkHeadReopened(out string, e2, g, l uint64) error { return nil } +// checkCleanMoveRefused checks a clean move refused for a missing ACK: exit +// 1 (a failed precondition), nothing on stdout, the documented error. +func checkCleanMoveRefused(stdout, stderr string, code int) error { + if code != 1 || stdout != "" || !strings.Contains(stderr, "workspace clean move needs detached HEAD and matching revocation ACK") { + return fmt.Errorf("clean move without the ACK: exit %d, stdout %q, stderr %q; want exit 1 and the documented refusal", code, stdout, stderr) + } + return nil +} + // statusPrimary reports whether a /status?volume=v1 body shows a healthy // primary at epoch. func statusPrimary(body []byte, epoch uint64) bool { @@ -183,7 +192,9 @@ func matchUint(re *regexp.Regexp, s string) (uint64, error) { // TestPlannedHandoffChecksReadCapturedProductOutput runs every check on the // output the real binaries printed in one passing hand-over (E=1, G=3, L=1, -// E2=2), and each check on an output of another step, which it must refuse. +// E2=2) and in the refused clean move without an ACK (move-refused, +// show-revoked), and each check on an output of another step, which it must +// refuse. func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { read := func(name string) string { b, err := os.ReadFile(filepath.Join("testdata", "planned-handoff", name)) @@ -248,6 +259,12 @@ func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { refused("show moved", checkShowMoved(read("show-granted.stdout"), e, e2, g, l)) ok("HEAD reopened", checkHeadReopened(read("head-reopened.stdout"), e2, g, l)) refused("HEAD reopened", checkHeadReopened(read("head-sealed.stdout"), e2, g, l)) + ok("clean move refused", checkCleanMoveRefused("", read("move-refused.stderr"), 1)) + refused("clean move refused", checkCleanMoveRefused("", read("move-refused.stderr"), 0)) + refused("clean move refused", checkCleanMoveRefused(read("move-clean.stdout"), "", 0)) + if r := read("show-revoked.stdout"); showsAck(r, e, g) || !hasLine(r, "recorded ACK: none") { + t.Error("the revoked show without an ACK is read as acknowledged") + } if !statusPrimary([]byte(read("status-primary.json")), e2) || statusPrimary([]byte(read("status-primary.json")), e) { t.Error("status check does not read the epoch of a healthy primary") } diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index e7270fa060..c431049689 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -6,6 +6,7 @@ import ( "bytes" "context" "crypto/sha256" + "errors" "fmt" "io" "net" @@ -28,69 +29,18 @@ import ( // by itself, show the ACK, clean move to the same host, start again, and the // written block reads back unchanged. func TestStandalonePlannedHandoffToTheSameHost(t *testing.T) { - h := newPlannedHandoffHarness(t) - cluster := startWorkspaceWeed(t) - chunkPath := fmt.Sprintf("/handoff-%d", time.Now().UnixNano()) - const nqn = "nqn.2026-11.io.seaweedfs:handoff" - must := func(err error) { - t.Helper() - if err != nil { - t.Fatal(err) - } - } - mustU := func(v uint64, err error) uint64 { - t.Helper() - must(err) - return v - } - - // 1. The cluster spec. - spec := filepath.Join(h.dir, "cluster-spec.yaml") - must(os.WriteFile(spec, []byte(fmt.Sprintf(`nodes: - - server_id: s1 - data_addr: %s - ctrl_addr: %s -volumes: - - id: v1 - size_bytes: 268435456 - replication_factor: 1 - placements: - - server_id: s1 - replica_id: r1 -`, h.dataAddr, h.ctrlAddr)), 0o644)) - - // 2. blockmaster with the lifecycle store and the cluster spec. - mstate := filepath.Join(h.dir, "master") - master := h.start(t, "blockmaster", h.master, - "--authority-store", filepath.Join(mstate, "authority"), "--lifecycle-store", filepath.Join(mstate, "lifecycle"), - "--cluster-spec", spec, "--expected-slots-per-volume", "1", "--listen", h.masterAddr, - "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+chunkPath) - if l := master.waitLog(t, 30*time.Second, "blockmaster: lock acquired, reloaded="); !strings.Contains(l, "listen="+h.masterAddr) { - t.Fatalf("blockmaster start line %q does not name listen=%s", l, h.masterAddr) - } - if master.has("blockmaster: WARNING: --topology not supplied or empty") { - t.Fatal("blockmaster warned about a missing topology although the cluster spec gives it") - } - - // 3. The setup answers before any blockvolume runs. - show := []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} - out, _ := h.command(t, show...) - must(checkShowBeforeStart(out)) + h, cluster, chunkPath, show, volArgs := startPlannedHandoff(t) + must, mustU := fatalOn(t) + const nqn = plannedHandoffNQN // 4. blockvolume adopts the volume. - volArgs := []string{"--master", h.masterAddr, "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", - "--data-addr", h.dataAddr, "--ctrl-addr", h.ctrlAddr, "--status-addr", h.statusAddr, - "--durable-root", filepath.Join(h.dir, "vol"), "--durable-impl", "walstore-chunk", - "--durable-blocks", "65536", "--durable-blocksize", "4096", - "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath, "--chunk-control-endpoint", - "--workspace-lease", "--nvme-listen", h.nvmeAddr, "--nvme-subsysnqn", nqn} vol1 := h.start(t, "blockvolume-1", h.volume, volArgs...) e := mustU(adoptedEpoch(vol1.waitLog(t, 60*time.Second, "blockvolume: volume v1 adopted as PRIMARY at r1@"))) vol1.waitLog(t, 60*time.Second, "durable: HEAD claim for volume=v1 done in") h.waitPrimary(t, e) // 5. The lease. - out, _ = h.command(t, show...) + out, _ := h.command(t, show...) must(checkShowGranted(out, e)) // 6, 7. Write a known block and flush it, then disconnect the writer. @@ -116,8 +66,8 @@ volumes: must(checkRevoke(out, e, g)) // 11. The old blockvolume acknowledges and exits by itself (a signal - // would suppress the ACK). - if err := vol1.wait(45 * time.Second); err != nil { + // would suppress the ACK), within the 30 s lease. + if err := vol1.wait(30 * time.Second); err != nil { t.Fatalf("blockvolume after the revocation: %v; want a clean exit by itself", err) } if !vol1.has(fmt.Sprintf("workspace lease: fenced volume=v1 replica=r1 epoch=%d: revoked by the master", e)) || @@ -172,6 +122,109 @@ volumes: } } +// TestStandaloneCleanMoveWithoutTheACKIsRefused is the chapter's negative +// check N1 made deterministic: the volume is sealed, its blockvolume is +// killed (a signal sends no ACK), and the lease is revoked with the sealed +// generation while no blockvolume runs. No ACK can arrive, so the clean move +// is refused with the documented error, exit 1, and the master keeps no ACK. +func TestStandaloneCleanMoveWithoutTheACKIsRefused(t *testing.T) { + h, cluster, chunkPath, show, volArgs := startPlannedHandoff(t) + must, mustU := fatalOn(t) + + vol := h.start(t, "blockvolume", h.volume, volArgs...) + e := mustU(adoptedEpoch(vol.waitLog(t, 60*time.Second, "blockvolume: volume v1 adopted as PRIMARY at r1@"))) + h.waitPrimary(t, e) + c := dialNVMe(t, h.nvmeAddr, plannedHandoffNQN) + c.write(t, 0, bytes.Repeat([]byte{0xa5}, 4096)) + c.flush(t) + c.close() + out, errOut := h.command(t, "ops", "chunk", "detach", "--plain", "--volume", "v1", "--status-addr", h.statusAddr, "--timeout", "120s") + g := mustU(sealedGen(out, errOut, e)) + out, _ = h.command(t, "ops", "chunk", "show", "--volume", "v1", "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath) + mustU(sealedHeadLSN(out, e, g)) // HEAD is sealed: only the ACK is missing + vol.kill(t) + + out, _ = h.command(t, "ops", "workspace", "revoke", "--master", h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--sealed-gen", fmt.Sprint(g)) + must(checkRevoke(out, e, g)) + out, errOut, code := h.run(t, "ops", "workspace", "move", "--clean", "--master", h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--target-host", "s1", "--target-data", h.dataAddr, "--target-ctrl", h.ctrlAddr, + "--request-id", "move-v1-1") + must(checkCleanMoveRefused(out, errOut, code)) + out, _ = h.command(t, show...) + if showsAck(out, e, g) || !hasLine(out, "recorded ACK: none") { + t.Fatalf("workspace show after the refused move:\n%s\nwant recorded ACK: none", out) + } +} + +const plannedHandoffNQN = "nqn.2026-11.io.seaweedfs:handoff" + +// startPlannedHandoff runs the chapter's steps 1-3: a weed cluster, the +// cluster spec, blockmaster with the lifecycle store, and the setup check. +// It returns the blockvolume arguments of step 4 and the show command. +func startPlannedHandoff(t *testing.T) (h *plannedHandoffHarness, cluster *w4WeedCluster, chunkPath string, show, volArgs []string) { + t.Helper() + h = newPlannedHandoffHarness(t) + cluster = startWorkspaceWeed(t) + chunkPath = fmt.Sprintf("/handoff-%d", time.Now().UnixNano()) + must, _ := fatalOn(t) + + // 1. The cluster spec. + spec := filepath.Join(h.dir, "cluster-spec.yaml") + must(os.WriteFile(spec, []byte(fmt.Sprintf(`nodes: + - server_id: s1 + data_addr: %s + ctrl_addr: %s +volumes: + - id: v1 + size_bytes: 268435456 + replication_factor: 1 + placements: + - server_id: s1 + replica_id: r1 +`, h.dataAddr, h.ctrlAddr)), 0o644)) + + // 2. blockmaster with the lifecycle store and the cluster spec. + mstate := filepath.Join(h.dir, "master") + master := h.start(t, "blockmaster", h.master, + "--authority-store", filepath.Join(mstate, "authority"), "--lifecycle-store", filepath.Join(mstate, "lifecycle"), + "--cluster-spec", spec, "--expected-slots-per-volume", "1", "--listen", h.masterAddr, + "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+chunkPath) + if l := master.waitLog(t, 30*time.Second, "blockmaster: lock acquired, reloaded="); !strings.Contains(l, "listen="+h.masterAddr) { + t.Fatalf("blockmaster start line %q does not name listen=%s", l, h.masterAddr) + } + if master.has("blockmaster: WARNING: --topology not supplied or empty") { + t.Fatal("blockmaster warned about a missing topology although the cluster spec gives it") + } + + // 3. The setup answers before any blockvolume runs. + show = []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} + out, _ := h.command(t, show...) + must(checkShowBeforeStart(out)) + + volArgs = []string{"--master", h.masterAddr, "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", + "--data-addr", h.dataAddr, "--ctrl-addr", h.ctrlAddr, "--status-addr", h.statusAddr, + "--durable-root", filepath.Join(h.dir, "vol"), "--durable-impl", "walstore-chunk", + "--durable-blocks", "65536", "--durable-blocksize", "4096", + "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath, "--chunk-control-endpoint", + "--workspace-lease", "--nvme-listen", h.nvmeAddr, "--nvme-subsysnqn", plannedHandoffNQN} + return h, cluster, chunkPath, show, volArgs +} + +func fatalOn(t *testing.T) (func(error), func(uint64, error) uint64) { + must := func(err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } + } + return must, func(v uint64, err error) uint64 { + t.Helper() + must(err) + return v + } +} + // plannedHandoffHarness owns real binaries, loopback endpoints and process // lifetimes. type plannedHandoffHarness struct { @@ -219,6 +272,18 @@ type daemon struct { name, log string done chan struct{} err error + cancel context.CancelFunc +} + +// kill kills the child (no ACK is sent on a signal) and waits for it. +func (d *daemon) kill(t *testing.T) { + t.Helper() + d.cancel() + select { + case <-d.done: + case <-time.After(10 * time.Second): + t.Fatalf("%s did not exit after kill", d.name) + } } // start registers cancellation and a bounded join before starting a daemon. @@ -235,7 +300,7 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. cmd := exec.CommandContext(ctx, binary, args...) cmd.Dir, cmd.Stdout, cmd.Stderr = h.dir, log, log cmd.WaitDelay = 5 * time.Second - d := &daemon{name: name, log: log.Name(), done: make(chan struct{})} + d := &daemon{name: name, log: log.Name(), done: make(chan struct{}), cancel: cancel} started := false t.Cleanup(func() { cancel() @@ -315,6 +380,17 @@ func (d *daemon) waitLog(t *testing.T, timeout time.Duration, s string) string { // its sealed-generation line is read from stderr by the documented sequence. // The bound covers the detach's own --timeout 120s. func (h *plannedHandoffHarness) command(t *testing.T, args ...string) (string, string) { + t.Helper() + stdout, stderr, code := h.run(t, args...) + if code != 0 { + t.Fatalf("sw-block %q: exit %d\nstdout: %s\nstderr: %s", args, code, stdout, stderr) + } + return stdout, stderr +} + +// run runs sw-block and returns its output and exit status; only a failure +// to run it at all (or its timeout) fails the test. +func (h *plannedHandoffHarness) run(t *testing.T, args ...string) (string, string, int) { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 150*time.Second) defer cancel() @@ -323,10 +399,16 @@ func (h *plannedHandoffHarness) command(t *testing.T, args ...string) (string, s cmd.WaitDelay = 5 * time.Second var stdout, stderr strings.Builder cmd.Stdout, cmd.Stderr = &stdout, &stderr - if err := cmd.Run(); err != nil { - t.Fatalf("sw-block %q: %v\nstdout: %s\nstderr: %s", args, err, stdout.String(), stderr.String()) + err := cmd.Run() + var exit *exec.ExitError + switch { + case err == nil: + return stdout.String(), stderr.String(), 0 + case errors.As(err, &exit) && ctx.Err() == nil: + return stdout.String(), stderr.String(), exit.ExitCode() } - return stdout.String(), stderr.String() + t.Fatalf("sw-block %q: %v\nstdout: %s\nstderr: %s", args, err, stdout.String(), stderr.String()) + return "", "", -1 } // waitPrimary polls the status endpoint until the volume serves as a diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-refused.stderr b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-refused.stderr new file mode 100644 index 0000000000..984df2b1ca --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-refused.stderr @@ -0,0 +1 @@ +workspace move: clean move: workspace clean move needs detached HEAD and matching revocation ACK diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-revoked.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-revoked.stdout new file mode 100644 index 0000000000..3f0ca8c3c0 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/show-revoked.stdout @@ -0,0 +1,8 @@ +volume: v1 (query snapshot, not authority to serve) +replica: r1 +epoch: 1 +lease state: revoking +holder: r1@1 (logical replica) +lease expiry_ns: 1795338384724043516; host validity_ns at query: 19727540908 +recorded ACK: none +host: unknown (not recorded by the master); issued moves and bindings below are separate facts From 4bc8ba094a35bdd645dc928dc9bb17e1fc30c985 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:03:01 -0800 Subject: [PATCH 052/204] ci: run the planned hand-over tests against a pinned SeaweedFS release A step after the default pass runs the documented standalone planned hand-over and its refused clean move without the ACK (cmd/blockvolume TestStandalone*, build tags subprocess and chunkstore_integration) with weed 4.53 linux_amd64 from the SeaweedFS release, checked against its sha256 before every use, also from the runner's tool cache. A mismatch fails the step. It follows the job's rules: pushes, train PRs and non-Draft PRs. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/.github/workflows/test.yml | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/seaweed-block/.github/workflows/test.yml b/seaweed-block/.github/workflows/test.yml index 4b32f0a04b..917fb011f1 100644 --- a/seaweed-block/.github/workflows/test.yml +++ b/seaweed-block/.github/workflows/test.yml @@ -83,3 +83,30 @@ jobs: done fi go test -p=1 -short -count=1 -timeout 10m $pkgs + + - name: Test planned hand-over (real binaries) + # The documented standalone planned hand-over and its refused clean + # move without the ACK (cmd/blockvolume TestStandalone*, build tags + # subprocess and chunkstore_integration, so the default pass above is + # unchanged) run real blockmaster, blockvolume and sw-block against a + # pinned SeaweedFS release. The release archive is checked against its sha256 before + # every use, also when taken from the runner's cache; a mismatch fails + # the step. Nothing else is fetched. + env: + WEED_VERSION: "4.53" + WEED_SHA256: d1a7dec9f48d8b33895a0ea8951971defc2dc5312906dcc76fa5a5f74a6ee90d + run: | + set -euo pipefail + cache="${RUNNER_TOOL_CACHE:-$RUNNER_TEMP}/seaweedfs-weed/$WEED_VERSION" + tgz="$cache/linux_amd64.tar.gz" + mkdir -p "$cache" + if ! echo "$WEED_SHA256 $tgz" | sha256sum -c --status - 2>/dev/null; then + part="$tgz.$$.part" + curl -fsSL --retry 3 -o "$part" "https://github.com/seaweedfs/seaweedfs/releases/download/$WEED_VERSION/linux_amd64.tar.gz" + echo "$WEED_SHA256 $part" | sha256sum -c - || { rm -f "$part"; exit 1; } + mv -f "$part" "$tgz" + fi + bin="$RUNNER_TEMP/weed-$WEED_VERSION" + mkdir -p "$bin" + tar -xzf "$tgz" -C "$bin" weed + CHUNKSTORE_WEED="$bin/weed" go test -tags 'subprocess chunkstore_integration' -count=1 -timeout 10m -run '^TestStandalone(PlannedHandoffToTheSameHost|CleanMoveWithoutTheACKIsRefused)$' ./cmd/blockvolume/ From d21304dc4f65a31a5a18a3a739fe0acba129e9d9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:10:06 -0800 Subject: [PATCH 053/204] fix: expose foreign-holder refusal in the existing fenced journal --- seaweed-block/core/host/volume/host.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 1d1591b2c9..ef1ea7ba4a 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -519,12 +519,9 @@ func (h *Host) getReplication() replicaSetUpdater { return h.replication } -// IsSuperseded satisfies SupersedeProbe: returns true when this -// host's lastOther record names a DIFFERENT replica at a strictly -// newer (Epoch, EndpointVersion) than the caller's self-lineage. -// Same-replica updates (our own Epoch advance) are NOT supersede -// events; the bridge handles those naturally through adapter -// projection. +// IsSuperseded gates a newer foreign replica line, or a same-replica foreign +// server/endpoint identity at or above the local lineage. An explicitly +// matching self identity remains an ordinary adapter update. func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool { h.otherMu.Lock() defer h.otherMu.Unlock() @@ -818,7 +815,7 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { if err := h.fenceSelfWithPeers(selfRolePrimary, fact.Epoch, false); err != nil { h.log.Printf("blockvolume: foreign holder ingress fence: %v", err) } - h.log.Printf("blockvolume: volume %s assignment server=%q replica=%q is not this process server=%q; fenced, never adopted", h.cfg.VolumeID, fact.ServerId, fact.ReplicaId, h.cfg.ServerID) + h.log.Printf("blockvolume: volume %s assignment server=%q replica=%q is not this process server=%q; fenced, not serving; never adopted", h.cfg.VolumeID, fact.ServerId, fact.ReplicaId, h.cfg.ServerID) return } if fact.ReplicaId != h.cfg.ReplicaID { From 55226e0f9ee14f5b1512a4e0968e84e5ababaef4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:18:16 -0800 Subject: [PATCH 054/204] docs: pin the approved assignment and lease holder identity invariant --- seaweed-block/docs/design/invariants.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..6861de5697 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -410,7 +410,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -303 rows: 217 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. +304 rows: 218 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 289 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -574,6 +574,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| +| `INV-ASSIGNMENT-HOLDER-IDENTITY-001` | A volume adopts an assignment only when it names this process's server id and replica id (and, when carried, its own data and control endpoints); any other primary fact is another holder's line: recorded, fenced, never adopted. The master refuses workspace lease first grants, renewals and re-grants with a missing server id or one that differs from the assigned holder. | AUTHORITY: primary assignment and workspace lease identity | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease` | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`) | — (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 476b5fceb9480d16a7a120da5ef8fb2d8b832db4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:21:01 -0800 Subject: [PATCH 055/204] fix: keep holder membership lookup off placement writer locks --- .../core/host/master/workspace_binding.go | 2 +- .../core/lifecycle/placement_intent.go | 25 ++++++-- .../core/lifecycle/placement_snapshot_test.go | 62 +++++++++++++++++++ 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 seaweed-block/core/lifecycle/placement_snapshot_test.go diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index abfb9c4ebf..109fe132c9 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -82,7 +82,7 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string // placementSourceHost uses explicit membership, never endpoint inference. func (h *Host) placementSourceHost(volume, replica string) string { if h.lifecycle != nil { - if p, ok := h.lifecycle.Placements.GetPlacement(volume); ok { + if p, ok := h.lifecycle.Placements.GetPlacementSnapshot(volume); ok { for _, slot := range p.Slots { if slot.ReplicaID == replica { return slot.ServerID diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index 7ea8868830..7d4a58ef8a 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -35,9 +35,10 @@ type PlacementIntent struct { // PlacementIntentStore persists one placement intent per volume. type PlacementIntentStore struct { - mu sync.Mutex - dir string - records map[string]PlacementIntent + mu sync.Mutex + dir string + records map[string]PlacementIntent + published sync.Map // committed immutable PlacementIntent values; renewal never takes mu } // OpenPlacementIntentStore opens or creates a placement intent store. @@ -55,6 +56,9 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) { if err := s.load(); err != nil { return nil, err } + for volume, rec := range s.records { + s.published.Store(volume, copyPlacementIntent(rec)) + } return s, nil } @@ -90,6 +94,7 @@ func (s *PlacementIntentStore) ApplyPlan(plan PlacementPlan) (PlacementIntent, e return PlacementIntent{}, err } s.records[intent.VolumeID] = intent + s.published.Store(intent.VolumeID, copyPlacementIntent(intent)) return copyPlacementIntent(intent), nil } @@ -101,10 +106,11 @@ func (s *PlacementIntentStore) DeletePlacement(volumeID string) error { } s.mu.Lock() defer s.mu.Unlock() - delete(s.records, volumeID) if err := os.Remove(s.path(volumeID)); err != nil && !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("lifecycle: remove placement intent %s: %w", volumeID, err) } + delete(s.records, volumeID) + s.published.Delete(volumeID) return nil } @@ -116,6 +122,17 @@ func (s *PlacementIntentStore) GetPlacement(volumeID string) (PlacementIntent, b return copyPlacementIntent(rec), ok } +// GetPlacementSnapshot reads only committed placement, without waiting for a +// writer's filesystem I/O (INV-WS-RENEW-NONBLOCKING-001). The returned slice +// is a copy: a caller cannot change the published holder membership. +func (s *PlacementIntentStore) GetPlacementSnapshot(volumeID string) (PlacementIntent, bool) { + value, ok := s.published.Load(volumeID) + if !ok { + return PlacementIntent{}, false + } + return copyPlacementIntent(value.(PlacementIntent)), true +} + // ListPlacements returns intents ordered by VolumeID. func (s *PlacementIntentStore) ListPlacements() []PlacementIntent { s.mu.Lock() diff --git a/seaweed-block/core/lifecycle/placement_snapshot_test.go b/seaweed-block/core/lifecycle/placement_snapshot_test.go new file mode 100644 index 0000000000..90327d7e1b --- /dev/null +++ b/seaweed-block/core/lifecycle/placement_snapshot_test.go @@ -0,0 +1,62 @@ +package lifecycle + +import ( + "sync" + "testing" + "time" +) + +// INV-WS-RENEW-NONBLOCKING-001: holder lookup cannot wait behind placement +// store I/O. A committed snapshot is also isolated from caller mutation. +func TestPlacementSnapshotDoesNotWaitForWriter(t *testing.T) { + dir := t.TempDir() + s, err := OpenPlacementIntentStore(dir) + if err != nil { + t.Fatal(err) + } + if _, err = s.ApplyPlan(PlacementPlan{VolumeID: "v", DesiredRF: 1, Candidates: []PlacementCandidate{{VolumeID: "v", ServerID: "node-a", ReplicaID: "r1", Source: PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + s.mu.Lock() // the mutex a writer owns across filesystem I/O + var once sync.Once + release := func() { once.Do(s.mu.Unlock) } + result := make(chan PlacementIntent, 1) + joined := make(chan struct{}) + t.Cleanup(func() { + release() + select { + case <-joined: + case <-time.After(5 * time.Second): + t.Error("snapshot reader did not join") + } + }) + go func() { defer close(joined); r, _ := s.GetPlacementSnapshot("v"); result <- r }() + var got PlacementIntent + select { + case got = <-result: + case <-time.After(time.Second): + t.Fatal("holder snapshot waited for placement writer") + } + release() + if len(got.Slots) != 1 || got.Slots[0].ServerID != "node-a" { + t.Fatalf("wrong committed holder: %+v", got) + } + got.Slots[0].ServerID = "changed-by-reader" + again, _ := s.GetPlacementSnapshot("v") + if again.Slots[0].ServerID != "node-a" { + t.Fatal("caller mutated published holder") + } + reopened, err := OpenPlacementIntentStore(dir) + if err != nil { + t.Fatal(err) + } + if got, ok := reopened.GetPlacementSnapshot("v"); !ok || got.Slots[0].ServerID != "node-a" { + t.Fatal("reopened snapshot lost holder") + } + if err = s.DeletePlacement("v"); err != nil { + t.Fatal(err) + } + if _, ok := s.GetPlacementSnapshot("v"); ok { + t.Fatal("deleted placement remained published") + } +} From a86f07d71ac0c8935429d7fa09d09b0318a5b106 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:22:26 -0800 Subject: [PATCH 056/204] docs: trace holder checks and nonblocking lookup to their invariants --- seaweed-block/core/authority/workspace_lease_view.go | 3 ++- seaweed-block/core/host/master/workspace_binding.go | 5 ++++- seaweed-block/core/host/master/workspace_service.go | 2 +- seaweed-block/core/host/volume/assignment_holder.go | 2 +- seaweed-block/core/host/volume/host.go | 4 ++-- seaweed-block/docs/design/invariants.md | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/authority/workspace_lease_view.go b/seaweed-block/core/authority/workspace_lease_view.go index 480eb10418..49a0885727 100644 --- a/seaweed-block/core/authority/workspace_lease_view.go +++ b/seaweed-block/core/authority/workspace_lease_view.go @@ -158,7 +158,8 @@ type PublishedLine struct { } // PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity -// checks on renewal must not wait for p.mu, which spans authority store I/O. +// checks on renewal must not wait for p.mu, which spans authority store I/O +// (INV-LEASE-VIEW-001, INV-WS-RENEW-NONBLOCKING-001). func (p *Publisher) PublishedAuthorityLine(volume string) (PublishedLine, bool) { p.leaseMu.Lock() defer p.leaseMu.Unlock() diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 109fe132c9..f465e160d2 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -65,6 +65,8 @@ func (h *Host) workspaceEndpointsAvailable(b lifecycle.WorkspaceBinding) error { return nil } +// workspaceSourceHost resolves explicit holder membership for +// INV-ASSIGNMENT-HOLDER-IDENTITY-001; endpoints never select a server. func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string { if state := h.Publisher().WorkspaceState(volume); state != nil { for _, r := range state.Moves { @@ -79,7 +81,8 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string return h.placementSourceHost(volume, replica) } -// placementSourceHost uses explicit membership, never endpoint inference. +// placementSourceHost uses committed membership, never endpoint inference +// (INV-ASSIGNMENT-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001). func (h *Host) placementSourceHost(volume, replica string) string { if h.lifecycle != nil { if p, ok := h.lifecycle.Placements.GetPlacementSnapshot(volume); ok { diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 70eb91c0df..8412157dad 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -90,7 +90,7 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil { return nil, err } - // r2.34 AUTHORITY: a replica id can move between servers. + // INV-ASSIGNMENT-HOLDER-IDENTITY-001: a replica id can move between servers. line, ok := s.host.Publisher().PublishedAuthorityLine(q.GetVolumeId()) server := line.IssuedHost if server == "" { diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index f1961de2c6..dcc63b37ae 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -2,7 +2,7 @@ package volume import control "github.com/seaweedfs/seaweed-block/core/rpc/control" -// assignmentNamesSelf implements r2.34 AUTHORITY. Missing server identity is +// assignmentNamesSelf implements INV-ASSIGNMENT-HOLDER-IDENTITY-001. Missing server identity is // refused; endpoints qualify identity only when the master carries them. func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { return f.GetServerId() != "" && f.GetServerId() == h.cfg.ServerID && diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index ef1ea7ba4a..8494eba878 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -235,7 +235,7 @@ func (h *Host) recordOtherLine(f *control.AssignmentFact) { // is the canonical safe deep-copy for proto messages. cp := proto.Clone(f).(*control.AssignmentFact) h.otherMu.Lock() - // A stale replay must not erase the newer foreign-holder fence (r2.34). + // A stale replay must not erase the newer foreign-holder fence (INV-ASSIGNMENT-HOLDER-IDENTITY-001). if old := h.lastOther; old != nil && (cp.Epoch < old.Epoch || cp.Epoch == old.Epoch && cp.EndpointVersion < old.EndpointVersion) { h.otherMu.Unlock() return @@ -808,7 +808,7 @@ func (h *Host) streamOnce(ctx context.Context) error { // OnAssignment could flip the projection Healthy before peers were // installed, admitting local-only writes with zero fan-out. func (h *Host) applyFact(fact *control.AssignmentFact) { - // r2.34 AUTHORITY: matching r1 and loopback endpoints do not identify a host. + // INV-ASSIGNMENT-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host. if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) { h.wd.notPrimary() h.recordOtherLine(fact) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6861de5697..146d58d341 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -583,7 +583,7 @@ Notes: | `INV-LEASE-VIEW-OWNED-001` | The granted deadline and the extender flag exist only in the lease view; refreshing the view from its derive inputs never changes either of them. | M2 every workspace transition | `core/authority/workspace_lease_view.go` `refreshLeaseViewLocked`, `setLeaseDeadlineLocked`, `extendWorkspaceLease` | — | — | STUB | | `INV-WS-LEASE-HORIZON-001` | For the active lease of the current authority epoch, the `Lease.ExpiresAtNS` persisted in the authority store is at least the published horizon, and the published horizon is at least every grant issued since the last reload. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`, `newWorkspaceLease`, `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked`, `issueWorkspaceMove` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardFencesByHorizonUnderStalledStore` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) | — | ACTIVE | +| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter` (`core/lifecycle/placement_snapshot_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | From 6f3aa6090b158d1d1718ff6b2b7158c6eaf3e0ec Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:24:06 -0800 Subject: [PATCH 057/204] test: foreign HEAD claim must select no-retry exit --- .../process_exit_authority_test.go | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index be80656ae4..ac6ca918c9 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -3,6 +3,8 @@ package main import ( "context" "errors" + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/host/volume" control "github.com/seaweedfs/seaweed-block/core/rpc/control" "github.com/seaweedfs/seaweed-block/core/storage" @@ -235,3 +237,68 @@ func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { }) } } + +// The real provider must carry the claim's filer proof to the process owner, +// even when the master stream has never reported another replica. +type claimExitView struct{} + +func (claimExitView) Projection() frontend.Projection { + return frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true} +} +func TestWorkspaceForeignHeadClaimChoosesNoRetry(t *testing.T) { + for _, tc := range []struct { + name, holder string + want int + }{ + {"foreign holder", "other", 78}, {"same holder higher epoch", "r", 75}, + } { + t.Run(tc.name, func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + h, _ := exitAuthorityHost(t) + remote := storage.NewMemChunkRemote() + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 2, Holder: tc.holder, State: storage.ChunkHeadActive}); err != nil { + t.Fatal(err) + } + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, claimExitView{}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := p.Close(); err != nil { + t.Error(err) + } + }) + if _, err = p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + if _, err = p.RecoverVolume(ctx, "v"); !errors.Is(err, storage.ErrChunkLayerFenced) { + t.Fatalf("claim refusal=%v", err) + } + if h.LastOtherLine() != nil { + t.Fatal("fixture unexpectedly supplied master supersede evidence") + } + e := newProcessExit(ctx) + if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, p) { + t.Fatal("claim refusal did not select an exit") + } + select { + case out := <-e.decision: + if out.code != tc.want { + t.Fatalf("claim exit=%+v want %d", out, tc.want) + } + case <-ctx.Done(): + t.Fatal(ctx.Err()) + } + head, err := remote.GetHead(ctx) + if err != nil || head.Gen != 1 || head.Holder != tc.holder || remote.Puts() != 0 { + t.Fatalf("refused claim mutated remote: %+v puts=%d err=%v", head, remote.Puts(), err) + } + for _, status := range p.DurableStatuses() { + if status.Operational { + t.Fatal("refused claim became operational") + } + } + }) + } +} From c2edb7305c69109182052d036547af895031a3a1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:26:01 -0800 Subject: [PATCH 058/204] fix: carry foreign HEAD claim proof to startup exit classification --- seaweed-block/cmd/blockvolume/process_exit.go | 6 + .../process_exit_authority_test.go | 129 ++++++++++-------- .../core/frontend/durable/provider.go | 12 +- .../core/frontend/durable/provider_chunk.go | 16 ++- .../core/frontend/durable/provider_startup.go | 14 +- .../durable/provider_startup_internal_test.go | 25 +++- seaweed-block/core/storage/chunk_restore.go | 6 +- .../docs/design/agent-workspace-design.md | 12 +- seaweed-block/docs/design/invariants.md | 4 +- 9 files changed, 148 insertions(+), 76 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index fe4a0e392e..f19b2c6b71 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -198,6 +198,7 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e // The provider publishes only a generation-bound outcome and an atomic choice. type chunkStartupOutcomeProvider interface { ChunkStartupOutcome(string) (uint64, bool) + ChunkStartupSuperseded(string, uint64) bool ChooseChunkStartupExit(string, uint64, func()) bool } @@ -210,5 +211,10 @@ func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p chunkStar return false } out := workspaceRetryOutcome("assignment_timeout", h) + // INV-WS-STARTUP-RETRY-001: a claim's foreign-holder proof is + // independent of the master stream; generation is rechecked below. + if p.ChunkStartupSuperseded(f.volumeID, gen) { + out = workspaceExit{exitWorkspaceSuperseded, "superseded"} + } return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.chooseChunkStartup(out) }) } diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index ac6ca918c9..ba49d3bf7f 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -161,7 +161,8 @@ func TestWorkspaceUnconfirmedRevokeHasOwnReason(t *testing.T) { // real provider deadline/retained-state boundary is tested in durable. type exitStartupOutcome struct{ expired bool } -func (s *exitStartupOutcome) ChunkStartupOutcome(string) (uint64, bool) { return 1, s.expired } +func (s *exitStartupOutcome) ChunkStartupSuperseded(string, uint64) bool { return false } +func (s *exitStartupOutcome) ChunkStartupOutcome(string) (uint64, bool) { return 1, s.expired } func (s *exitStartupOutcome) ChooseChunkStartupExit(_ string, gen uint64, choose func()) bool { if gen != 1 || !s.expired { return false @@ -240,65 +241,83 @@ func TestWorkspacePlannedDrainOwnsStartupExpiryUntilAck(t *testing.T) { // The real provider must carry the claim's filer proof to the process owner, // even when the master stream has never reported another replica. -type claimExitView struct{} +type claimExitView struct{ assigned atomic.Bool } -func (claimExitView) Projection() frontend.Projection { +func (v *claimExitView) Projection() frontend.Projection { + if !v.assigned.Load() { + return frontend.Projection{VolumeID: "v"} + } return frontend.Projection{VolumeID: "v", ReplicaID: "r", Epoch: 1, Healthy: true} } func TestWorkspaceForeignHeadClaimChoosesNoRetry(t *testing.T) { - for _, tc := range []struct { - name, holder string - want int - }{ - {"foreign holder", "other", 78}, {"same holder higher epoch", "r", 75}, - } { - t.Run(tc.name, func(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) - defer cancel() - h, _ := exitAuthorityHost(t) - remote := storage.NewMemChunkRemote() - if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 2, Holder: tc.holder, State: storage.ChunkHeadActive}); err != nil { - t.Fatal(err) - } - p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, claimExitView{}) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { - if err := p.Close(); err != nil { - t.Error(err) + for _, deferred := range []bool{false, true} { + for _, tc := range []struct { + name, holder string + want int + }{ + {"foreign holder", "other", 78}, {"same holder higher epoch", "r", 75}, + } { + t.Run(tc.name+map[bool]string{false: "/immediate", true: "/waiting"}[deferred], func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + h, _ := exitAuthorityHost(t) + remote := storage.NewMemChunkRemote() + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 2, Holder: tc.holder, State: storage.ChunkHeadActive}); err != nil { + t.Fatal(err) + } + view := &claimExitView{} + view.assigned.Store(!deferred) + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, view) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := p.Close(); err != nil { + t.Error(err) + } + }) + if _, err = p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + _, err = p.RecoverVolume(ctx, "v") + if deferred { + if err != nil { + t.Fatal(err) + } + view.assigned.Store(true) + } else if !errors.Is(err, storage.ErrChunkLayerFenced) { + t.Fatalf("claim refusal=%v", err) + } + select { + case <-p.ChunkStartupUpdates(): + case <-ctx.Done(): + t.Fatal(ctx.Err()) + } + if h.LastOtherLine() != nil { + t.Fatal("fixture unexpectedly supplied master supersede evidence") + } + e := newProcessExit(ctx) + if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, p) { + t.Fatal("claim refusal did not select an exit") + } + select { + case out := <-e.decision: + if out.code != tc.want { + t.Fatalf("claim exit=%+v want %d", out, tc.want) + } + case <-ctx.Done(): + t.Fatal(ctx.Err()) + } + head, err := remote.GetHead(ctx) + if err != nil || head.Gen != 1 || head.Holder != tc.holder || remote.Puts() != 0 { + t.Fatalf("refused claim mutated remote: %+v puts=%d err=%v", head, remote.Puts(), err) + } + for _, status := range p.DurableStatuses() { + if status.Operational { + t.Fatal("refused claim became operational") + } } }) - if _, err = p.EnsureStorage("v"); err != nil { - t.Fatal(err) - } - if _, err = p.RecoverVolume(ctx, "v"); !errors.Is(err, storage.ErrChunkLayerFenced) { - t.Fatalf("claim refusal=%v", err) - } - if h.LastOtherLine() != nil { - t.Fatal("fixture unexpectedly supplied master supersede evidence") - } - e := newProcessExit(ctx) - if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, p) { - t.Fatal("claim refusal did not select an exit") - } - select { - case out := <-e.decision: - if out.code != tc.want { - t.Fatalf("claim exit=%+v want %d", out, tc.want) - } - case <-ctx.Done(): - t.Fatal(ctx.Err()) - } - head, err := remote.GetHead(ctx) - if err != nil || head.Gen != 1 || head.Holder != tc.holder || remote.Puts() != 0 { - t.Fatalf("refused claim mutated remote: %+v puts=%d err=%v", head, remote.Puts(), err) - } - for _, status := range p.DurableStatuses() { - if status.Operational { - t.Fatal("refused claim became operational") - } - } - }) + } } } diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index d5b282877c..19ffa5acc5 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -285,11 +285,12 @@ type volHandle struct { // wait, 0 if none: a recovered volume whose layer waits for master // authority. A wait only acts while its generation is still the // latest recovery's. - recoverGen uint64 - waitGen uint64 - startupEnded uint64 // recovery generation with a terminal startup outcome; guarded by p.mu - chunk storage.ChunkLayer // after RecoverVolume - chunkLineage chunkLineage // immutable authority captured by this attachment + recoverGen uint64 + waitGen uint64 + startupSuperseded bool // exact foreign-holder claim proof for startupEnded; guarded by p.mu + startupEnded uint64 // recovery generation with a terminal startup outcome; guarded by p.mu + chunk storage.ChunkLayer // after RecoverVolume + chunkLineage chunkLineage // immutable authority captured by this attachment // Private until the owner commit succeeds; retained for attach retry. chunkPending storage.ChunkLayer // chunkDetach is set (under attachMu) when DetachVolume starts and @@ -951,6 +952,7 @@ func (p *DurableProvider) RecoverVolume(ctx context.Context, volumeID string) (R h.recoverGen++ // any earlier recovery's authority wait is now stale gen = h.recoverGen h.startupEnded = 0 + h.startupSuperseded = false p.mu.Unlock() } report := Recover(h.storage, volumeID) diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 7fd1e45a02..42742de6fd 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -56,8 +56,9 @@ var ( var ErrChunkStaleLocalRoot = errors.New("durable: local volume predates a HEAD published by another holder") var ( - errProviderClosed = errors.New("durable: provider closed") - errChunkNoAuthority = errors.New("durable: projection carries no master authority for the chunk layer") + errProviderClosed = errors.New("durable: provider closed") + errChunkForeignClaim = errors.New("durable: HEAD claim refused by another holder") + errChunkNoAuthority = errors.New("durable: projection carries no master authority for the chunk layer") ) const ( @@ -125,7 +126,7 @@ func (p *DurableProvider) recoverChunk(ctx context.Context, volumeID string, h * return false, nil } if errors.Is(err, storage.ErrChunkLayerFenced) && !errors.Is(err, ErrChunkStaleLocalRoot) { - p.endChunkStartup(h, gen) + p.endChunkStartup(h, gen, err) } return err == nil, err } @@ -177,7 +178,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen if p.current(h, gen) && h.chunk == nil { ended = fmt.Sprintf("assignment unavailable, not serving (projection lacks %s)", chunkAuthorityGap(p.view.Projection(), volumeID)) h.backend.SetOperational(false, "chunk assignment unavailable: "+waitCtx.Err().Error()) - p.endChunkStartup(h, gen) + p.endChunkStartup(h, gen, nil) } }() defer func() { @@ -251,7 +252,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen } h.attachMu.Unlock() } else { - p.endChunkStartup(h, gen) + p.endChunkStartup(h, gen, err) } return case errors.Is(err, errChunkNoAuthority): @@ -500,6 +501,11 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h log.Printf("durable: HEAD claim for volume=%s starting: target epoch=%d holder=%q", volumeID, cfg.Epoch, cfg.Holder) head, err := storage.ClaimChunkHead(ctx, remote, cfg) if err != nil { + // INV-WS-STARTUP-RETRY-001: only the claim's exact foreign-holder + // proof permits no-retry; a higher epoch of our own holder retries. + if errors.Is(err, storage.ErrChunkLayerFenced) && head.Gen != 0 && head.Holder != "" && head.Holder != cfg.Holder { + err = errors.Join(err, errChunkForeignClaim) + } log.Printf("durable: HEAD claim for volume=%s failed after %s: %v", volumeID, time.Since(claimStart), err) return nil, fmt.Errorf("durable: restore HEAD claim: %w", err) } diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go index ff61f0978d..1d10da2aaf 100644 --- a/seaweed-block/core/frontend/durable/provider_startup.go +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -1,5 +1,7 @@ package durable +import "errors" + // ChunkStartupUpdates wakes the process owner when a startup wait ends. It is // not an event queue: the owner must read ChunkStartupOutcome for its volume. // INV-WS-STARTUP-RETRY-001 keeps stale recoveries from terminating a newer one. @@ -18,13 +20,23 @@ func (p *DurableProvider) ChunkStartupOutcome(volumeID string) (uint64, bool) { return h.startupEnded, true } -func (p *DurableProvider) endChunkStartup(h *volHandle, gen uint64) { +// ChunkStartupSuperseded reports only a proven foreign-holder claim refusal +// for this exact recovery. Selection still rechecks gen under the provider lock. +func (p *DurableProvider) ChunkStartupSuperseded(volumeID string, gen uint64) bool { + p.mu.Lock() + defer p.mu.Unlock() + h := p.volumes[volumeID] + return !p.closed && h != nil && gen != 0 && h.recoverGen == gen && h.startupEnded == gen && h.startupSuperseded +} + +func (p *DurableProvider) endChunkStartup(h *volHandle, gen uint64, cause error) { p.mu.Lock() defer p.mu.Unlock() if p.closed || gen != h.recoverGen || h.startupEnded != 0 { return } h.startupEnded = gen + h.startupSuperseded = errors.Is(cause, errChunkForeignClaim) select { case p.startupUpdates <- struct{}{}: default: diff --git a/seaweed-block/core/frontend/durable/provider_startup_internal_test.go b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go index 61fff6fdb6..3d5848f289 100644 --- a/seaweed-block/core/frontend/durable/provider_startup_internal_test.go +++ b/seaweed-block/core/frontend/durable/provider_startup_internal_test.go @@ -5,19 +5,19 @@ import "testing" func TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake(t *testing.T) { h := &volHandle{recoverGen: 1} p := &DurableProvider{volumes: map[string]*volHandle{"v": h}, startupUpdates: make(chan struct{}, 1)} - p.endChunkStartup(h, 1) + p.endChunkStartup(h, 1, nil) h.recoverGen = 2 h.startupEnded = 0 // RecoverVolume invalidates the old generation under p.mu. - p.endChunkStartup(h, 1) + p.endChunkStartup(h, 1, nil) if _, ok := p.ChunkStartupOutcome("v"); ok { t.Fatal("stale wait ended the new recovery") } - p.endChunkStartup(h, 2) // full wake channel must not discard the current latched result + p.endChunkStartup(h, 2, nil) // full wake channel must not discard the current latched result <-p.ChunkStartupUpdates() if gen, ok := p.ChunkStartupOutcome("v"); !ok || gen != 2 { t.Fatalf("current result lost: %d %v", gen, ok) } - p.endChunkStartup(h, 1) + p.endChunkStartup(h, 1, nil) if gen, ok := p.ChunkStartupOutcome("v"); !ok || gen != 2 { t.Fatal("late old completion overwrote the current result") } @@ -38,3 +38,20 @@ func TestChunkStartupExitRechecksGenerationBeforeChoice(t *testing.T) { t.Fatal("closed provider selected exit") } } + +func TestChunkStartupForeignProofIsGenerationBound(t *testing.T) { + h := &volHandle{recoverGen: 1} + p := &DurableProvider{volumes: map[string]*volHandle{"v": h}, startupUpdates: make(chan struct{}, 1)} + p.endChunkStartup(h, 1, errChunkForeignClaim) + if !p.ChunkStartupSuperseded("v", 1) || p.ChunkStartupSuperseded("other", 1) || p.ChunkStartupSuperseded("v", 2) { + t.Fatal("foreign proof escaped volume or generation") + } + h.recoverGen = 2 + h.startupEnded = 0 + h.startupSuperseded = false + p.endChunkStartup(h, 1, errChunkForeignClaim) + p.endChunkStartup(h, 2, nil) + if p.ChunkStartupSuperseded("v", 2) { + t.Fatal("old foreign proof poisoned current retry") + } +} diff --git a/seaweed-block/core/storage/chunk_restore.go b/seaweed-block/core/storage/chunk_restore.go index 5b39bdfef0..fb83e12467 100644 --- a/seaweed-block/core/storage/chunk_restore.go +++ b/seaweed-block/core/storage/chunk_restore.go @@ -11,6 +11,8 @@ import ( // persist lazy-read absence before exposing the local volume for I/O. // No WALStore, layer-state or provider-map lock is held across remote calls; // the provider may hold its per-volume attach serialization lock. +// On a proven owner fence, the returned HEAD is the exact observed proof; +// it is not an installed claim and must never be used to serve I/O. func ClaimChunkHead(ctx context.Context, remote ChunkRemote, cfg ChunkLayerConfig) (ChunkHead, error) { if remote == nil || cfg.Epoch == 0 || cfg.Holder == "" { return ChunkHead{}, errors.New("storage: HEAD claim needs master epoch and holder") @@ -35,7 +37,7 @@ func ClaimChunkHead(ctx context.Context, remote ChunkRemote, cfg ChunkLayerConfi return ChunkHead{}, err } if head.Epoch > cfg.Epoch || (head.Gen != 0 && head.Epoch == cfg.Epoch && head.Holder != cfg.Holder) { - return ChunkHead{}, ErrChunkLayerFenced + return copyHead(head), ErrChunkLayerFenced } // INV-WS-SEALED-REOPEN-001: the sealing incarnation cannot reopen its // committed handoff proof. A higher-epoch takeover remains a separate claim. @@ -113,7 +115,7 @@ func ClaimChunkHead(ctx context.Context, remote ChunkRemote, cfg ChunkLayerConfi } // A foreign publication is a fence, not permission to clean our roots. if current.Gen != 0 && (current.Epoch != head.Epoch || current.Holder != head.Holder) { - return ChunkHead{}, fmt.Errorf("storage: HEAD claim displaced: %w", ErrChunkLayerFenced) + return copyHead(current), fmt.Errorf("storage: HEAD claim displaced: %w", ErrChunkLayerFenced) } settled = errors.Is(casErr, ErrChunkHeadPrecondition) || current.Gen > head.Gen return ChunkHead{}, fmt.Errorf("storage: HEAD claim not installed: %w", casErr) diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index e1415f2e1d..1e8bd22477 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -485,7 +485,8 @@ Guest I/O never acquires a slot. An unavailable pool skips background cuts; urge A workspace chunk primary that exhausts its existing assignment wait, or whose lease fences while serving, exits 75 after fail-closed cleanup bounded by the existing five-second lease-drain limit. systemd restarts on failure with -RestartSec=5s. Only a newer master fact naming another replica permits exit 78; +RestartSec=5s. A newer master fact naming another replica or a refused claim proving another +HEAD holder permits exit 78; RestartPreventExitStatus=78 suppresses automatic restarts until an operator explicitly starts the unit. A higher epoch for the same replica retries. An ACKed planned revocation and a signal stop retain their normal exit status. @@ -500,7 +501,7 @@ stateDiagram-v2 AwaitingAssignment --> Serving: grant and HEAD claim AwaitingAssignment --> Exit75: assignment wait exhausted Serving --> Exit75: lease fence - AwaitingAssignment --> Exit78: newer master fact names another replica + AwaitingAssignment --> Exit78: newer other-replica fact or exact foreign-holder HEAD claim proof Serving --> Exit78: lease fence and newer other-replica fact Exit75 --> AwaitingAssignment: supervisor starts new process Exit78 --> AwaitingAssignment: explicit operator start @@ -518,3 +519,10 @@ stateDiagram-v2 GAP-1 exit classification compares a newer other-replica fact with the newest own assignment this process observed, including a locally blocked assignment; historical other facts do not suppress restart. The shared `Host.IsSuperseded` predicate is reused without changing frontend admission. An unconfirmed revocation ACK exits75 with `revoke_ack_unconfirmed`. Restart can retry ACK only while the original revoking lease remains valid; after expiry the revoking/recorded-ACK re-grant guards still refuse, so restart alone cannot resolve that case and operator recovery is required. Once the resource owner accepts a stop request, startup-monitor cancellation and startup exit choice serialize on the process owner's startup mutex. A delayed startup deadline cannot replace planned drain ownership; success remains unselected until the real guard confirms the stored detached proof's ACK. A wait that already chose sealed replay or stale-local-root diagnostics keeps that disposition even if its context expires at return. + +A refused HEAD claim returns its exact observed image as failure evidence, never +an installed claim. Only a nonempty foreign holder in that fenced image permits +no-retry independently of the assignment stream. Higher epochs of the same +holder and fences without that proof retain retry75. Provider generation checks +and planned-stop arbitration still apply; no readiness or listen gate changes +belong to this classification fix. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index b6ff593151..40dcedce77 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -671,9 +671,9 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; only a newer master fact naming another replica permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; a newer master fact naming another replica or a claim proving another HEAD holder permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | -- `INV-WS-STARTUP-RETRY-001`: exit 78 is an optimisation, permitted only by a NEWER observed master fact for this volume naming another replica, compared with the latest own assignment observed by this process (zero before any). Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder. The provider binds the latter proof to its recovery generation; stale-local-root diagnostics do not become no-retry. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. - 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 2 s RPC timeout. The existing 3 s closeout wait 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. From 3d2081756fdac27b1ffc213d78dd9330729bebe3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:26:33 -0800 Subject: [PATCH 059/204] docs: keep startup retry statement within ledger limit --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 40dcedce77..4e1f960a57 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -671,7 +671,7 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary whose assignment wait ends or lease expires exits 75 after bounded fail-closed cleanup; a newer master fact naming another replica or a claim proving another HEAD holder permits exit 78 without restart. Revocation ACK and signal keep normal exit. The lease and HEAD-claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or a refused claim proving another HEAD holder permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder. The provider binds the latter proof to its recovery generation; stale-local-root diagnostics do not become no-retry. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. - 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. From b1e973761a2dfb7f439aa2660ceac31c94ca99f1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:26:45 -0800 Subject: [PATCH 060/204] test: resolve an unknown revocation ACK by its exact recorded witness --- .../host/master/workspace_service_test.go | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/seaweed-block/core/host/master/workspace_service_test.go b/seaweed-block/core/host/master/workspace_service_test.go index cd0159093e..8c4763d82b 100644 --- a/seaweed-block/core/host/master/workspace_service_test.go +++ b/seaweed-block/core/host/master/workspace_service_test.go @@ -15,13 +15,27 @@ import ( "github.com/seaweedfs/seaweed-block/core/lifecycle" control "github.com/seaweedfs/seaweed-block/core/rpc/control" "google.golang.org/grpc" + "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/status" ) type workspaceRPCView struct{ p frontend.Projection } func (v workspaceRPCView) Projection() frontend.Projection { return v.p } +// lostAckReply returns an unknown outcome only after the real master has +// committed the ACK. The caller must resolve it from a recorded witness. +type lostAckReply struct{ control.WorkspaceServiceClient } + +func (c lostAckReply) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck, opts ...grpc.CallOption) (*control.WorkspaceEmpty, error) { + reply, err := c.WorkspaceServiceClient.AckWorkspaceRevoked(ctx, q, opts...) + if err != nil { + return reply, err + } + return nil, status.Error(codes.DeadlineExceeded, "injected ACK reply loss after commit") +} + func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { var detached atomic.Bool server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -70,11 +84,11 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { } defer conn.Close() client := control.NewWorkspaceServiceClient(conn) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: "r2", Epoch: 1} stops := 0 - g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "vol-a", ReplicaID: "r2", Epoch: 1, Healthy: true}}, client, id, + g, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "vol-a", ReplicaID: "r2", Epoch: 1, Healthy: true}}, lostAckReply{client}, id, func(context.Context) (uint64, error) { stops++; return 9, nil }, nil) if err != nil { t.Fatal(err) @@ -90,8 +104,18 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { if _, err := client.RevokeWorkspace(ctx, id); err != nil { t.Fatal(err) } - if err := g.Refresh(ctx); err != nil { - t.Fatal(err) + // The stop/ACK path keeps its production timeout. Resolve a lost reply + // from the master's exact ACK, never from elapsed time or the stop alone. + if err := g.Refresh(ctx); status.Code(err) != codes.DeadlineExceeded { + t.Fatalf("expected unknown ACK reply, got %v", err) + } + recorded, err := client.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: "vol-a"}) + if err != nil { + t.Fatal("ACK witness unreadable", err) + } + ack := recorded.GetRevocationAck() + if ack.GetIdentity().GetVolumeId() != "vol-a" || ack.GetIdentity().GetReplicaId() != "r2" || ack.GetIdentity().GetEpoch() != 1 || ack.GetHeadGen() != 9 { + t.Fatalf("unknown ACK has no exact recorded witness: %+v", ack) } if g.Projection().Healthy || stops != 1 { t.Fatal("revoked frontend remained admitted") From 4a3a66597ac53be3293d39dd848073dca93f4da1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:28:44 -0800 Subject: [PATCH 061/204] test: superseded existing local holder must exit without retry --- .../process_exit_authority_test.go | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index ba49d3bf7f..0c6c7d121c 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -1,6 +1,7 @@ package main import ( + "bytes" "context" "errors" "github.com/seaweedfs/seaweed-block/core/frontend" @@ -321,3 +322,66 @@ func TestWorkspaceForeignHeadClaimChoosesNoRetry(t *testing.T) { } } } + +// Unlike a move BACK to an older foreign publication, this local root's +// assignment is older than the foreign HEAD: another holder has superseded it. +func TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + h, _ := exitAuthorityHost(t) + root := t.TempDir() + remote := storage.NewMemChunkRemote() + view := &claimExitView{} + view.assigned.Store(true) + open := func() *durable.DurableProvider { + t.Helper() + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: root, NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, view) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = p.Close() }) + if _, err := p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + return p + } + first := open() + if _, err := first.RecoverVolume(ctx, "v"); err != nil { + t.Fatal(err) + } + want := bytes.Repeat([]byte{0x73}, 4096) + if _, err := first.LogicalStorage("v").Write(0, want); err != nil { + t.Fatal(err) + } + if _, err := first.LogicalStorage("v").Sync(); err != nil { + t.Fatal(err) + } + if err := first.Close(); err != nil { + t.Fatal(err) + } + before, err := remote.GetHead(ctx) + if err != nil { + t.Fatal(err) + } + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{Gen: before.Gen, Epoch: before.Epoch}, storage.ChunkHead{Epoch: 2, Holder: "other", State: storage.ChunkHeadActive}); err != nil { + t.Fatal(err) + } + second := open() + if _, err := second.RecoverVolume(ctx, "v"); !errors.Is(err, storage.ErrChunkLayerFenced) { + t.Fatalf("old root refusal=%v", err) + } + e := newProcessExit(ctx) + if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, second) { + t.Fatal("foreign HEAD attach refusal retained the superseded process") + } + if out := <-e.decision; out.code != 78 { + t.Fatalf("old holder exit=%+v", out) + } + if got, err := second.LogicalStorage("v").Read(0); err != nil || !bytes.Equal(got, want) { + t.Fatalf("refusal lost local acknowledged bytes: %v", err) + } + after, err := remote.GetHead(ctx) + if err != nil || after.Gen != before.Gen+1 || after.Holder != "other" || remote.Puts() != 0 { + t.Fatalf("refusal mutated HEAD/payload: %+v puts=%d err=%v", after, remote.Puts(), err) + } +} From 4814ce613c7bc8ce593dabe684843c43a330e957 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:29:40 -0800 Subject: [PATCH 062/204] fix: terminate superseded local roots while retaining move-back diagnostics --- .../process_exit_authority_test.go | 131 ++++++++++-------- .../core/frontend/durable/provider_chunk.go | 10 +- .../docs/design/agent-workspace-design.md | 5 + seaweed-block/docs/design/invariants.md | 4 +- 4 files changed, 89 insertions(+), 61 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index 0c6c7d121c..829e8e5e18 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -326,62 +326,79 @@ func TestWorkspaceForeignHeadClaimChoosesNoRetry(t *testing.T) { // Unlike a move BACK to an older foreign publication, this local root's // assignment is older than the foreign HEAD: another holder has superseded it. func TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) - defer cancel() - h, _ := exitAuthorityHost(t) - root := t.TempDir() - remote := storage.NewMemChunkRemote() - view := &claimExitView{} - view.assigned.Store(true) - open := func() *durable.DurableProvider { - t.Helper() - p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: root, NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, view) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = p.Close() }) - if _, err := p.EnsureStorage("v"); err != nil { - t.Fatal(err) - } - return p - } - first := open() - if _, err := first.RecoverVolume(ctx, "v"); err != nil { - t.Fatal(err) - } - want := bytes.Repeat([]byte{0x73}, 4096) - if _, err := first.LogicalStorage("v").Write(0, want); err != nil { - t.Fatal(err) - } - if _, err := first.LogicalStorage("v").Sync(); err != nil { - t.Fatal(err) - } - if err := first.Close(); err != nil { - t.Fatal(err) - } - before, err := remote.GetHead(ctx) - if err != nil { - t.Fatal(err) - } - if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{Gen: before.Gen, Epoch: before.Epoch}, storage.ChunkHead{Epoch: 2, Holder: "other", State: storage.ChunkHeadActive}); err != nil { - t.Fatal(err) - } - second := open() - if _, err := second.RecoverVolume(ctx, "v"); !errors.Is(err, storage.ErrChunkLayerFenced) { - t.Fatalf("old root refusal=%v", err) - } - e := newProcessExit(ctx) - if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, second) { - t.Fatal("foreign HEAD attach refusal retained the superseded process") - } - if out := <-e.decision; out.code != 78 { - t.Fatalf("old holder exit=%+v", out) - } - if got, err := second.LogicalStorage("v").Read(0); err != nil || !bytes.Equal(got, want) { - t.Fatalf("refusal lost local acknowledged bytes: %v", err) - } - after, err := remote.GetHead(ctx) - if err != nil || after.Gen != before.Gen+1 || after.Holder != "other" || remote.Puts() != 0 { - t.Fatalf("refusal mutated HEAD/payload: %+v puts=%d err=%v", after, remote.Puts(), err) + for _, deferred := range []bool{false, true} { + t.Run(map[bool]string{false: "immediate", true: "waiting"}[deferred], func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + h, _ := exitAuthorityHost(t) + root := t.TempDir() + remote := storage.NewMemChunkRemote() + view := &claimExitView{} + view.assigned.Store(true) + open := func() *durable.DurableProvider { + t.Helper() + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: root, NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, view) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = p.Close() }) + if _, err := p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + return p + } + first := open() + if _, err := first.RecoverVolume(ctx, "v"); err != nil { + t.Fatal(err) + } + want := bytes.Repeat([]byte{0x73}, 4096) + if _, err := first.LogicalStorage("v").Write(0, want); err != nil { + t.Fatal(err) + } + if _, err := first.LogicalStorage("v").Sync(); err != nil { + t.Fatal(err) + } + if err := first.Close(); err != nil { + t.Fatal(err) + } + before, err := remote.GetHead(ctx) + if err != nil { + t.Fatal(err) + } + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{Gen: before.Gen, Epoch: before.Epoch}, storage.ChunkHead{Epoch: 2, Holder: "other", State: storage.ChunkHeadActive}); err != nil { + t.Fatal(err) + } + view.assigned.Store(!deferred) + second := open() + _, err = second.RecoverVolume(ctx, "v") + if deferred { + if err != nil { + t.Fatal(err) + } + view.assigned.Store(true) + select { + case <-second.ChunkStartupUpdates(): + case <-ctx.Done(): + t.Fatal(ctx.Err()) + } + } else if !errors.Is(err, storage.ErrChunkLayerFenced) { + t.Fatalf("old root refusal=%v", err) + } + e := newProcessExit(ctx) + if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, second) { + t.Fatal("foreign HEAD attach refusal retained the superseded process") + } + if out := <-e.decision; out.code != 78 { + t.Fatalf("old holder exit=%+v", out) + } + if got, err := second.LogicalStorage("v").Read(0); err != nil || !bytes.Equal(got, want) { + t.Fatalf("refusal lost local acknowledged bytes: %v", err) + } + after, err := remote.GetHead(ctx) + if err != nil || after.Gen != before.Gen+1 || after.Holder != "other" || remote.Puts() != 0 { + t.Fatalf("refusal mutated HEAD/payload: %+v puts=%d err=%v", after, remote.Puts(), err) + } + + }) } } diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 42742de6fd..91f5e9e1fe 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -125,7 +125,7 @@ func (p *DurableProvider) recoverChunk(ctx context.Context, volumeID string, h * p.startChunkAuthorityWait(volumeID, h, gen) return false, nil } - if errors.Is(err, storage.ErrChunkLayerFenced) && !errors.Is(err, ErrChunkStaleLocalRoot) { + if errors.Is(err, storage.ErrChunkLayerFenced) && (!errors.Is(err, ErrChunkStaleLocalRoot) || errors.Is(err, errChunkForeignClaim)) { p.endChunkStartup(h, gen, err) } return err == nil, err @@ -244,7 +244,7 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen case errors.Is(err, storage.ErrChunkLayerFenced): ended = "fenced, not serving" log.Printf("durable: chunk layer for volume=%s: %v (not serving)", volumeID, err) - if errors.Is(err, ErrChunkStaleLocalRoot) { + if errors.Is(err, ErrChunkStaleLocalRoot) && !errors.Is(err, errChunkForeignClaim) { retained = true h.attachMu.Lock() if p.current(h, gen) && h.chunk == nil { @@ -450,6 +450,12 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h if head.Gen != 0 && head.Holder != holder { err := fmt.Errorf("%w: %w: volume %s local root %s, HEAD holder %q gen %d epoch %d, local holder %q; remove or quarantine the local root to attach fresh from HEAD", ErrChunkStaleLocalRoot, storage.ErrChunkLayerFenced, volumeID, h.path, head.Holder, head.Gen, head.Epoch, holder) + // INV-WS-STARTUP-RETRY-001: at or above this assignment, + // the foreign holder is a supersede proof. A lower epoch is + // the existing move-back/stale-root diagnostic, never 78. + if head.Epoch >= cfg.Epoch { + err = fmt.Errorf("%w: %w", err, errChunkForeignClaim) + } log.Printf("durable: refusing to attach volume=%s root=%s: HEAD holder=%q gen=%d epoch=%d is not this holder %q (remove or quarantine the local root)", volumeID, h.path, head.Holder, head.Gen, head.Epoch, holder) return err diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 1e8bd22477..833168a6a4 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -526,3 +526,8 @@ no-retry independently of the assignment stream. Higher epochs of the same holder and fences without that proof retain retry75. Provider generation checks and planned-stop arbitration still apply; no readiness or listen gate changes belong to this classification fix. + +The existing-local-root precheck uses the same distinction: another holder at +or above the assigned epoch is positive supersede evidence; an older foreign +publication remains the existing move-back diagnostic. Neither path serves or +publishes the local WAL, which remains on disk for diagnosis. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 4e1f960a57..d9807cda7e 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -671,9 +671,9 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or a refused claim proving another HEAD holder permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or a refused claim proving another HEAD holder permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | -- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder. The provider binds the latter proof to its recovery generation; stale-local-root diagnostics do not become no-retry. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder. The provider binds the latter proof to its recovery generation. On an existing root, a foreign HEAD at or above the assigned epoch proves supersede; a lower-epoch foreign HEAD retains the move-back diagnostic. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. - 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 2 s RPC timeout. The existing 3 s closeout wait 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. From d38f8167005f3aad20d3da5a1a24fdb1ceb007d7 Mon Sep 17 00:00:00 2001 From: Ping Qiu Date: Sun, 22 Nov 2026 01:32:19 -0800 Subject: [PATCH 063/204] ci: give a touched heavy package 20 minutes core/storage alone took 602 s under -short on the shared runner on main, past the 10 minute per-package limit, so a PR that touches it fails on the limit, not on a test. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/.github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/seaweed-block/.github/workflows/test.yml b/seaweed-block/.github/workflows/test.yml index 4b32f0a04b..59fecc1a36 100644 --- a/seaweed-block/.github/workflows/test.yml +++ b/seaweed-block/.github/workflows/test.yml @@ -82,4 +82,6 @@ jobs: fi done fi - go test -p=1 -short -count=1 -timeout 10m $pkgs + # 20m per package: core/storage alone took 602 s on tp04 on main + # (2026-11-22), past the old 10m, so any PR touching it failed. + go test -p=1 -short -count=1 -timeout 20m $pkgs From 62d7f31912ce1e792865e90acbcb892e876a80f7 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:38:40 -0800 Subject: [PATCH 064/204] docs: align holder identity sites with AUTHORITY ruling --- seaweed-block/core/host/master/workspace_binding.go | 4 ++-- seaweed-block/core/host/master/workspace_service.go | 2 +- seaweed-block/core/host/volume/assignment_holder.go | 2 +- seaweed-block/core/host/volume/host.go | 4 ++-- seaweed-block/docs/design/invariants.md | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index f465e160d2..5ef7f5356d 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -66,7 +66,7 @@ func (h *Host) workspaceEndpointsAvailable(b lifecycle.WorkspaceBinding) error { } // workspaceSourceHost resolves explicit holder membership for -// INV-ASSIGNMENT-HOLDER-IDENTITY-001; endpoints never select a server. +// INV-AUTH-HOLDER-IDENTITY-001; endpoints never select a server. func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string { if state := h.Publisher().WorkspaceState(volume); state != nil { for _, r := range state.Moves { @@ -82,7 +82,7 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string } // placementSourceHost uses committed membership, never endpoint inference -// (INV-ASSIGNMENT-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001). +// (INV-AUTH-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001). func (h *Host) placementSourceHost(volume, replica string) string { if h.lifecycle != nil { if p, ok := h.lifecycle.Placements.GetPlacementSnapshot(volume); ok { diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 8412157dad..4bbd429abd 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -90,7 +90,7 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil { return nil, err } - // INV-ASSIGNMENT-HOLDER-IDENTITY-001: a replica id can move between servers. + // INV-AUTH-HOLDER-IDENTITY-001: a replica id can move between servers. line, ok := s.host.Publisher().PublishedAuthorityLine(q.GetVolumeId()) server := line.IssuedHost if server == "" { diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index dcc63b37ae..c2f6928268 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -2,7 +2,7 @@ package volume import control "github.com/seaweedfs/seaweed-block/core/rpc/control" -// assignmentNamesSelf implements INV-ASSIGNMENT-HOLDER-IDENTITY-001. Missing server identity is +// assignmentNamesSelf implements INV-AUTH-HOLDER-IDENTITY-001. Missing server identity is // refused; endpoints qualify identity only when the master carries them. func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { return f.GetServerId() != "" && f.GetServerId() == h.cfg.ServerID && diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 8494eba878..042c731eba 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -235,7 +235,7 @@ func (h *Host) recordOtherLine(f *control.AssignmentFact) { // is the canonical safe deep-copy for proto messages. cp := proto.Clone(f).(*control.AssignmentFact) h.otherMu.Lock() - // A stale replay must not erase the newer foreign-holder fence (INV-ASSIGNMENT-HOLDER-IDENTITY-001). + // A stale replay must not erase the newer foreign-holder fence (INV-AUTH-HOLDER-IDENTITY-001). if old := h.lastOther; old != nil && (cp.Epoch < old.Epoch || cp.Epoch == old.Epoch && cp.EndpointVersion < old.EndpointVersion) { h.otherMu.Unlock() return @@ -808,7 +808,7 @@ func (h *Host) streamOnce(ctx context.Context) error { // OnAssignment could flip the projection Healthy before peers were // installed, admitting local-only writes with zero fan-out. func (h *Host) applyFact(fact *control.AssignmentFact) { - // INV-ASSIGNMENT-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host. + // INV-AUTH-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host. if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) { h.wd.notPrimary() h.recordOtherLine(fact) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 146d58d341..1aa2d5c6ed 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -574,7 +574,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-ASSIGNMENT-HOLDER-IDENTITY-001` | A volume adopts an assignment only when it names this process's server id and replica id (and, when carried, its own data and control endpoints); any other primary fact is another holder's line: recorded, fenced, never adopted. The master refuses workspace lease first grants, renewals and re-grants with a missing server id or one that differs from the assigned holder. | AUTHORITY: primary assignment and workspace lease identity | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease` | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`) | — (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: holder identity | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone) | — (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 447d0b1a3a11c29bab377dbb0190c962973415a9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:41:44 -0800 Subject: [PATCH 065/204] docs: clarify primary holdership invariant scope --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 1aa2d5c6ed..1fa9b89554 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -574,7 +574,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: holder identity | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone) | — (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 7fed83180d8883d73f25843d05dd904c83221880 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:41:58 -0800 Subject: [PATCH 066/204] docs: apply final primary holder invariant wording --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 1fa9b89554..13969b1145 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -574,7 +574,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 6e148b696a7851376a908dae0f4aadcf37855c32 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:43:49 -0800 Subject: [PATCH 067/204] test: reject revocation ACK from a different holder server --- .../master/workspace_holder_identity_test.go | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/seaweed-block/core/host/master/workspace_holder_identity_test.go b/seaweed-block/core/host/master/workspace_holder_identity_test.go index 380ca16406..4d9066b690 100644 --- a/seaweed-block/core/host/master/workspace_holder_identity_test.go +++ b/seaweed-block/core/host/master/workspace_holder_identity_test.go @@ -95,3 +95,51 @@ func TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant(t *testing.T) t.Fatal("matching server re-grant", err) } } + +// INV-AUTH-HOLDER-IDENTITY-001: an ACK licenses a clean move, so only the +// primary server/replica pair may record it, not another host of the same r1. +func TestWorkspaceRevocationACKRequiresHolderServer(t *testing.T) { + for _, server := range []string{"", "node-b"} { + t.Run("server="+server, func(t *testing.T) { + h, conn, ctx := reviewBindingHost(t) + reviewCreate(t, conn, ctx, "v") + ws := control.NewWorkspaceServiceClient(conn) + b := &control.WorkspaceBinding{VolumeId: "v", ServerId: "node-a", DataAddr: "127.0.0.1:10000", CtrlAddr: "127.0.0.1:10001"} + if _, err := ws.RegisterWorkspaceBinding(ctx, b); err != nil { + t.Fatal(err) + } + if _, err := ws.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "v", ServerId: "node-a", ReplicaId: "r1"}); err != nil { + t.Fatal(err) + } + reviewHeartbeat(t, conn, ctx, "v", "node-a", b.DataAddr, b.CtrlAddr) + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + line := waitAuthorityLine(t, h.Publisher(), "v") + own := leaseHolderIdentity(t, line.Epoch, "node-a") + if _, err := ws.RenewWorkspaceLease(ctx, own); err != nil { + t.Fatal(err) + } + if _, err := ws.RevokeWorkspace(ctx, own); err != nil { + t.Fatal(err) + } + if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: leaseHolderIdentity(t, line.Epoch, server), HeadGen: 9}); err == nil { + t.Errorf("ACK accepted server %q with the right replica/epoch", server) + } + recorded, err := ws.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: "v"}) + if err != nil { + t.Fatal(err) + } + if recorded.GetRevocationAck() != nil { + t.Errorf("foreign ACK recorded: %v", recorded.GetRevocationAck()) + } + if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: own, HeadGen: 9}); err != nil { + t.Fatal("own ACK refused", err) + } + recorded, err = ws.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: "v"}) + if err != nil || recorded.GetRevocationAck().GetHeadGen() != 9 { + t.Fatal("own ACK not recorded", recorded, err) + } + }) + } +} From 90e25b939c22dbe6efac49c78226353e1eeeeac4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:46:21 -0800 Subject: [PATCH 068/204] fix: validate revocation ACK with the shared holder predicate --- .../core/host/master/workspace_service.go | 25 +++++++++++++------ seaweed-block/docs/design/invariants.md | 2 +- .../docs/releases/holder-identity.md | 5 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 4bbd429abd..7c3cbc5ccc 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -86,17 +86,25 @@ func leaseFact(volume string, l authority.WorkspaceLease) *control.WorkspaceLeas return &control.WorkspaceLeaseFact{VolumeId: volume, ReplicaId: l.ReplicaID, Epoch: l.Epoch, ExpiresAtNs: l.ExpiresAtNS, ValidForNs: int64(remaining), Revoking: l.Revoking} } +// holderMatches implements INV-AUTH-HOLDER-IDENTITY-001 for both holder RPCs. +// The committed line and placement snapshot avoid store I/O on renewal. +func (s *services) holderMatches(volume, replica, server string, epoch uint64) bool { + line, ok := s.host.Publisher().PublishedAuthorityLine(volume) + if !ok || server == "" || line.ReplicaID != replica || line.Epoch != epoch { + return false + } + owner := line.IssuedHost + if owner == "" { + owner = s.host.placementSourceHost(volume, line.ReplicaID) + } + return server == owner +} + func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) { if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil { return nil, err } - // INV-AUTH-HOLDER-IDENTITY-001: a replica id can move between servers. - line, ok := s.host.Publisher().PublishedAuthorityLine(q.GetVolumeId()) - server := line.IssuedHost - if server == "" { - server = s.host.placementSourceHost(q.GetVolumeId(), line.ReplicaID) - } - if !ok || line.ReplicaID != q.GetReplicaId() || line.Epoch != q.GetEpoch() || q.GetServerId() == "" || q.GetServerId() != server { + if !s.holderMatches(q.GetVolumeId(), q.GetReplicaId(), q.GetServerId(), q.GetEpoch()) { return nil, status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder") } l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch()) @@ -128,6 +136,9 @@ func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.Workspace if err := s.workspaceVolume(id.GetVolumeId()); err != nil { return nil, err } + if !s.holderMatches(id.GetVolumeId(), id.GetReplicaId(), id.GetServerId(), id.GetEpoch()) { + return nil, status.Error(codes.FailedPrecondition, "workspace ACK: server identity does not match the current holder") + } if err := s.host.Publisher().AckWorkspaceRevocation(ctx, id.GetVolumeId(), authority.WorkspaceRevokeAck{ReplicaID: id.GetReplicaId(), Epoch: id.GetEpoch(), HeadGen: q.GetHeadGen()}); err != nil { return nil, workspaceError(err) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 13969b1145..1eec783a56 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -574,7 +574,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `RenewWorkspaceLease`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | diff --git a/seaweed-block/docs/releases/holder-identity.md b/seaweed-block/docs/releases/holder-identity.md index 16486d2832..ebc4ee7332 100644 --- a/seaweed-block/docs/releases/holder-identity.md +++ b/seaweed-block/docs/releases/holder-identity.md @@ -4,8 +4,9 @@ Assignments and workspace lease requests carry the holder's server id as well as its replica id. Replica ids and loopback addresses may be reused on another host, so they do not identify the holder by themselves. A volume refuses an assignment with a missing or different server id, or different carried data or -control endpoints. The master refuses a workspace lease request whose server -id is missing or does not match the assigned holder. +control endpoints. The master refuses workspace lease requests and revocation ACKs whose server +id is missing or does not match the assigned primary holder. A refused ACK is +not recorded and cannot license a clean move. Upgrade the master first, then the volumes, using binaries from the same release. A new volume connected to an older pre-release master stays not From e907fbdd553996de8ffcbd45472ac5ebf7de9996 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:42:51 -0800 Subject: [PATCH 069/204] test: the lifecycle page's procedures on two hosts with distinct server ids Five tagged binary tests run the procedures of the volume lifecycle page as written, on two blockvolume processes with server ids s1 and s2 that share one blockmaster and one SeaweedFS: the planned hand-over to another host, a same-host restart inside the lease, a return after a lapsed lease started 65 s after the stop, a forced move with the old host returning, and a revoke without an ACK followed by a forced move. The harness takes N hosts (cluster spec nodes s1..sN); the checks that read each step's output take the host and stay in the default-build check file with the existing ones. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_checks_test.go | 58 ++- .../planned_handoff_integration_test.go | 85 +++-- .../procedure_gate_integration_test.go | 331 ++++++++++++++++++ 3 files changed, 443 insertions(+), 31 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go index dedf934a66..af534928eb 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go @@ -106,9 +106,12 @@ func showsAck(out string, e, g uint64) bool { return hasLine(out, fmt.Sprintf("recorded ACK: r1@%d HEAD generation %d", e, g)) } -// movedEpoch reads E2 from the clean move's answer. -func movedEpoch(out string, e, g, l uint64) (uint64, error) { - issued := regexp.MustCompile(fmt.Sprintf(`^clean move issued: volume v1 request move-v1-1: r1@%d -> r1@(\d+) on s1 \(sealed HEAD gen %d, remote LSN %d\)$`, e, g, l)) +// movedEpoch reads E2 from the clean move's answer to s1. +func movedEpoch(out string, e, g, l uint64) (uint64, error) { return movedEpochTo(out, e, g, l, "s1") } + +// movedEpochTo reads E2 from the clean move's answer to the target host. +func movedEpochTo(out string, e, g, l uint64, target string) (uint64, error) { + issued := regexp.MustCompile(fmt.Sprintf(`^clean move issued: volume v1 request move-v1-1: r1@%d -> r1@(\d+) on %s \(sealed HEAD gen %d, remote LSN %d\)$`, e, regexp.QuoteMeta(target), g, l)) first, _, _ := strings.Cut(out, "\n") e2, err := matchUint(issued, strings.TrimRight(first, "\r")) if err != nil { @@ -117,12 +120,14 @@ func movedEpoch(out string, e, g, l uint64) (uint64, error) { if e2 <= e { return 0, fmt.Errorf("clean move issued epoch %d; want above %d", e2, e) } - return e2, wantLines(out, "next: start volume v1 on s1 (this command moved authority only)") + return e2, wantLines(out, fmt.Sprintf("next: start volume v1 on %s (this command moved authority only)", target)) } -func checkClaimDone(line string, e2 uint64) error { - if !strings.Contains(line, "durable: HEAD claim for volume=v1 done in") || !strings.Contains(line, fmt.Sprintf(`epoch=%d holder="s1/r1"`, e2)) { - return fmt.Errorf("HEAD claim %q; want done at epoch %d holder s1/r1", line, e2) +func checkClaimDone(line string, e2 uint64) error { return checkClaimDoneBy(line, e2, "s1") } + +func checkClaimDoneBy(line string, e2 uint64, host string) error { + if !strings.Contains(line, "durable: HEAD claim for volume=v1 done in") || !strings.Contains(line, fmt.Sprintf(`epoch=%d holder="%s/r1"`, e2, host)) { + return fmt.Errorf("HEAD claim %q; want done at epoch %d holder %s/r1", line, e2, host) } return nil } @@ -134,16 +139,48 @@ func checkShowMoved(out string, e, e2, g, l uint64) error { } func checkHeadReopened(out string, e2, g, l uint64) error { + return checkHeadReopenedBy(out, e2, g, l, "s1") +} + +func checkHeadReopenedBy(out string, e2, g, l uint64, host string) error { h, err := parseHead(out) if err != nil { return err } - if h.State != "active" || h.Epoch != e2 || h.Holder != "s1/r1" || h.Gen <= g || h.RemoteLSN != l || h.DetachedBy != nil { - return fmt.Errorf("HEAD after the reopen %+v; want active, epoch %d, holder s1/r1, gen above %d, remote LSN %d, not detached", h, e2, g, l) + if h.State != "active" || h.Epoch != e2 || h.Holder != host+"/r1" || h.Gen <= g || h.RemoteLSN != l || h.DetachedBy != nil { + return fmt.Errorf("HEAD after the reopen %+v; want active, epoch %d, holder %s/r1, gen above %d, remote LSN %d, not detached", h, e2, host, g, l) } return nil } +// forcedEpoch reads E2 from a forced move's answer (`forced move issued: +// ... r1@E on FROM -> r1@E2 on TO (kept HEAD gen N, remote LSN L)`). +func forcedEpoch(out string, e uint64, from, to string) (uint64, error) { + re := regexp.MustCompile(fmt.Sprintf(`(?m)^forced move issued: volume v1 request \S+: r1@%d on %s -> r1@(\d+) on %s \(kept HEAD gen \d+, remote LSN \d+\)$`, e, regexp.QuoteMeta(from), regexp.QuoteMeta(to))) + e2, err := matchUint(re, out) + if err == nil && e2 <= e { + err = fmt.Errorf("forced move issued epoch %d; want above %d", e2, e) + } + return e2, err +} + +// forcedKeptLSN reads the remote LSN a forced move kept. +func forcedKeptLSN(out string) (uint64, error) { + return matchUint(regexp.MustCompile(`(?m)^forced move issued: .*\(kept HEAD gen \d+, remote LSN (\d+)\)$`), out) +} + +// previewAdmitted reports whether a force-move --dry-run says admitted. +func previewAdmitted(out string) bool { + return regexp.MustCompile(`(?m)^forced move admitted(: .*)?$`).MatchString(out) +} + +// frontendReady reports whether a /status?volume=v1 body says the frontend +// is ready to serve as primary. +func frontendReady(body []byte) bool { + var st struct{ FrontendPrimaryReady bool } + return json.Unmarshal(body, &st) == nil && st.FrontendPrimaryReady +} + // checkCleanMoveRefused checks a clean move refused for a missing ACK: exit // 1 (a failed precondition), nothing on stdout, the documented error. func checkCleanMoveRefused(stdout, stderr string, code int) error { @@ -265,6 +302,9 @@ func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { if r := read("show-revoked.stdout"); showsAck(r, e, g) || !hasLine(r, "recorded ACK: none") { t.Error("the revoked show without an ACK is read as acknowledged") } + if !frontendReady([]byte(read("status-primary.json"))) || frontendReady([]byte(`{"FrontendPrimaryReady":false,"Healthy":true}`)) { + t.Error("the frontend-ready check does not read FrontendPrimaryReady") + } if !statusPrimary([]byte(read("status-primary.json")), e2) || statusPrimary([]byte(read("status-primary.json")), e) { t.Error("status check does not read the epoch of a healthy primary") } diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index c431049689..320fee1872 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -159,30 +159,60 @@ func TestStandaloneCleanMoveWithoutTheACKIsRefused(t *testing.T) { const plannedHandoffNQN = "nqn.2026-11.io.seaweedfs:handoff" -// startPlannedHandoff runs the chapter's steps 1-3: a weed cluster, the -// cluster spec, blockmaster with the lifecycle store, and the setup check. -// It returns the blockvolume arguments of step 4 and the show command. +// startPlannedHandoff runs the chapter's steps 1-3 for one host, s1, and +// returns the blockvolume arguments of step 4 and the show command. func startPlannedHandoff(t *testing.T) (h *plannedHandoffHarness, cluster *w4WeedCluster, chunkPath string, show, volArgs []string) { t.Helper() - h = newPlannedHandoffHarness(t) - cluster = startWorkspaceWeed(t) - chunkPath = fmt.Sprintf("/handoff-%d", time.Now().UnixNano()) + env := startHandoffEnv(t, 1) + return env.h, env.cluster, env.chunkPath, env.show, env.volArgs("s1") +} + +// handoffEnv is a running setup: weed, blockmaster with the cluster spec +// naming every host, and the hosts' blockvolume endpoints. The volume starts +// on s1. +type handoffEnv struct { + h *plannedHandoffHarness + cluster *w4WeedCluster + chunkPath string + show []string + hosts map[string]bvHost +} + +// bvHost is one host's blockvolume: its server id, endpoints and local root. +type bvHost struct { + id, data, ctrl, status, nvme, root string +} + +// startHandoffEnv runs the chapter's steps 1-3: a weed cluster, the cluster +// spec with hosts s1..sN, blockmaster with the lifecycle store, and the setup +// check. +func startHandoffEnv(t *testing.T, n int) *handoffEnv { + t.Helper() + h := newPlannedHandoffHarness(t) + env := &handoffEnv{h: h, cluster: startWorkspaceWeed(t), chunkPath: fmt.Sprintf("/handoff-%d", time.Now().UnixNano()), hosts: map[string]bvHost{}} must, _ := fatalOn(t) + env.hosts["s1"] = bvHost{id: "s1", data: h.dataAddr, ctrl: h.ctrlAddr, status: h.statusAddr, nvme: h.nvmeAddr, root: filepath.Join(h.dir, "vol")} + for i := 2; i <= n; i++ { + id := fmt.Sprintf("s%d", i) + env.hosts[id] = bvHost{id: id, data: leaseBinaryAddress(t), ctrl: leaseBinaryAddress(t), status: leaseBinaryAddress(t), nvme: leaseBinaryAddress(t), root: filepath.Join(h.dir, "vol-"+id)} + } + cluster, chunkPath := env.cluster, env.chunkPath // 1. The cluster spec. + var nodes strings.Builder + for i := 1; i <= n; i++ { + b := env.hosts[fmt.Sprintf("s%d", i)] + fmt.Fprintf(&nodes, " - server_id: %s\n data_addr: %s\n ctrl_addr: %s\n", b.id, b.data, b.ctrl) + } spec := filepath.Join(h.dir, "cluster-spec.yaml") - must(os.WriteFile(spec, []byte(fmt.Sprintf(`nodes: - - server_id: s1 - data_addr: %s - ctrl_addr: %s -volumes: + must(os.WriteFile(spec, []byte("nodes:\n"+nodes.String()+`volumes: - id: v1 size_bytes: 268435456 replication_factor: 1 placements: - server_id: s1 replica_id: r1 -`, h.dataAddr, h.ctrlAddr)), 0o644)) +`), 0o644)) // 2. blockmaster with the lifecycle store and the cluster spec. mstate := filepath.Join(h.dir, "master") @@ -198,17 +228,21 @@ volumes: } // 3. The setup answers before any blockvolume runs. - show = []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} - out, _ := h.command(t, show...) + env.show = []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} + out, _ := h.command(t, env.show...) must(checkShowBeforeStart(out)) + return env +} - volArgs = []string{"--master", h.masterAddr, "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", - "--data-addr", h.dataAddr, "--ctrl-addr", h.ctrlAddr, "--status-addr", h.statusAddr, - "--durable-root", filepath.Join(h.dir, "vol"), "--durable-impl", "walstore-chunk", +// volArgs is the chapter's blockvolume command for one host. +func (env *handoffEnv) volArgs(id string) []string { + b := env.hosts[id] + return []string{"--master", env.h.masterAddr, "--server-id", b.id, "--volume-id", "v1", "--replica-id", "r1", + "--data-addr", b.data, "--ctrl-addr", b.ctrl, "--status-addr", b.status, + "--durable-root", b.root, "--durable-impl", "walstore-chunk", "--durable-blocks", "65536", "--durable-blocksize", "4096", - "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath, "--chunk-control-endpoint", - "--workspace-lease", "--nvme-listen", h.nvmeAddr, "--nvme-subsysnqn", plannedHandoffNQN} - return h, cluster, chunkPath, show, volArgs + "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath, "--chunk-control-endpoint", + "--workspace-lease", "--nvme-listen", b.nvme, "--nvme-subsysnqn", plannedHandoffNQN} } func fatalOn(t *testing.T) (func(error), func(uint64, error) uint64) { @@ -414,10 +448,17 @@ func (h *plannedHandoffHarness) run(t *testing.T, args ...string) (string, strin // waitPrimary polls the status endpoint until the volume serves as a // healthy primary at epoch. func (h *plannedHandoffHarness) waitPrimary(t *testing.T, epoch uint64) { + t.Helper() + h.waitPrimaryAt(t, h.statusAddr, epoch) +} + +// waitPrimaryAt polls one host's status endpoint until the volume serves +// there as a healthy primary at epoch. +func (h *plannedHandoffHarness) waitPrimaryAt(t *testing.T, statusAddr string, epoch uint64) { t.Helper() c := &http.Client{Timeout: 5 * time.Second} - poll(t, 60*time.Second, fmt.Sprintf("status never showed a healthy primary at epoch %d", epoch), func() bool { - resp, err := c.Get("http://" + h.statusAddr + "/status?volume=v1") + poll(t, 60*time.Second, fmt.Sprintf("status at %s never showed a healthy primary at epoch %d", statusAddr, epoch), func() bool { + resp, err := c.Get("http://" + statusAddr + "/status?volume=v1") if err != nil { return false } diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go new file mode 100644 index 0000000000..62c3d521ab --- /dev/null +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -0,0 +1,331 @@ +//go:build subprocess && chunkstore_integration + +package main_test + +import ( + "bytes" + "fmt" + "io" + "net" + "net/http" + "strings" + "testing" + "time" +) + +// The procedure gate: every operator procedure of docs/volume-lifecycle.md +// runs as written, with real binaries, on two blockvolume processes with +// distinct server ids (s1 and s2) sharing one blockmaster and one SeaweedFS. +// The planned return to the same host is TestStandalonePlannedHandoffToTheSameHost. + +// TestProcedurePlannedHandoffToAnotherHost: the planned hand-over from s1 to +// s2. The new holder starts with no local copy, claims the sealed HEAD at the +// new epoch and serves the written block. +func TestProcedurePlannedHandoffToAnotherHost(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + block := pattern("to-another-host!") + env.writeBlock(t, "s1", 0, block) + + g := env.seal(t, "s1", e) + l := env.sealedLSN(t, e, g) + env.revoke(t, e, g) + if err := old.wait(30 * time.Second); err != nil { + t.Fatalf("s1 after the revocation: %v; want a clean exit by itself", err) + } + env.waitAck(t, e, g) + + moved, _ := h.command(t, env.moveClean(e, "s2", "move-v1-1")...) + e2 := mustU(movedEpochTo(moved, e, g, l, "s2")) + nw := env.start(t, "blockvolume-s2", "s2") + must(checkClaimDoneBy(nw.waitLog(t, 60*time.Second, "durable: HEAD claim for volume=v1 done in"), e2, "s2")) + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + out, _ := h.command(t, env.show...) + must(wantLines(out, fmt.Sprintf("holder: r1@%d (logical replica)", e2), + fmt.Sprintf("move: request=move-v1-1 kind=clean issued=true s1/r1@%d -> s2/r1@%d HEAD generation %d remote LSN %d", e, e2, g, l))) + out, _ = h.command(t, env.chunkShow()...) + must(checkHeadReopenedBy(out, e2, g, l, "s2")) + if !bytes.Equal(env.readBlock(t, "s2", 0), block) { + t.Fatal("the block written on s1 does not read back on s2") + } +} + +// TestProcedureSameHostRestartInsideTheLease: the holder's process dies and is +// started again on its host within the 30 s lease. It keeps holder and epoch +// and serves again at once from its local WAL. +func TestProcedureSameHostRestartInsideTheLease(t *testing.T) { + env := startHandoffEnv(t, 2) + must, _ := fatalOn(t) + + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("restart-in-lease") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + + again := env.start(t, "blockvolume-s1-again", "s1") + if got := env.adopt(t, again, "s1"); got != e { + t.Fatalf("the restarted holder adopted epoch %d; want the same epoch %d", got, e) + } + out, _ := env.h.command(t, env.show...) + must(checkShowGranted(out, e)) + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the restart does not read back") + } +} + +// TestProcedureReturnAfterALapsedLease: the holder's process dies and stays +// down past its lease. Started again 65 s after it stopped (the page's +// bound with default flags), it is granted again at the same epoch, reclaims +// HEAD and serves its local WAL. +func TestProcedureReturnAfterALapsedLease(t *testing.T) { + env := startHandoffEnv(t, 2) + must, _ := fatalOn(t) + + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("after-lapsed-ttl") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + stopped := time.Now() + + time.Sleep(time.Until(stopped.Add(65 * time.Second))) + back := env.start(t, "blockvolume-s1-back", "s1") + if got := env.adopt(t, back, "s1"); got != e { + t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) + } + if back.has("assignment unavailable, not serving") { + t.Fatal("started 65 s after the stop, the holder still logged the not-serving line") + } + out, _ := env.h.command(t, env.show...) + must(checkShowGranted(out, e)) + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the lapse does not read back") + } +} + +// TestProcedureForcedMoveWithTheOldHostReturning: the holder on s1 dies and +// never comes back in time. A forced move to s2, admitted after the barrier, +// restores the last HEAD: a block cut before the crash is kept, one written +// after the cut is lost, as the lost range says. The old s1 process then +// returns with its old local root and must not serve; s2 keeps serving. +func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + kept, lost := pattern("cut-before-crash"), pattern("after-the-cut!!!") + env.writeBlock(t, "s1", 0, kept) + h.command(t, "ops", "chunk", "cut", "--volume", "v1", "--status-addr", env.hosts["s1"].status) + env.writeBlock(t, "s1", 8, lost) + old.kill(t) + + out := env.forceMove(t, e, "s2", "force-v1-1") + e2, keptLSN := mustU(forcedEpoch(out, e, "s1", "s2")), mustU(forcedKeptLSN(out)) + must(wantLines(out, "next: start volume v1 on s2 (this command moved authority only)")) + if !strings.Contains(out, fmt.Sprintf("writes with LSN <= %d are preserved", keptLSN)) { + t.Fatalf("the forced move printed no lost range at LSN %d:\n%s", keptLSN, out) + } + ranges, _ := h.command(t, "ops", "workspace", "lost-range", "--master", h.masterAddr, "--volume", "v1") + if !strings.Contains(ranges, "range 1 of 1: request force-v1-1, r1@") { + t.Fatalf("lost-range does not show the forced move:\n%s", ranges) + } + + nw := env.start(t, "blockvolume-s2", "s2") + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + if !bytes.Equal(env.readBlock(t, "s2", 0), kept) { + t.Fatal("the block cut before the crash is not on s2") + } + if got := env.readBlock(t, "s2", 8); !bytes.Equal(got, make([]byte, 4096)) { + t.Fatal("the block written after the last cut reads back on s2; the page says it is lost") + } + + // The old host returns with its old local root. It must not take s2's + // line as its own (a holder is server and replica), report its frontend + // ready, or listen for I/O; the page says it does not serve. + back := env.start(t, "blockvolume-s1-back", "s1") + var failures []string + end := time.Now().Add(40 * time.Second) + for time.Now().Before(end) && len(failures) == 0 { + if l := back.line(fmt.Sprintf("adopted as PRIMARY at r1@%d", e2)); l != "" { + failures = append(failures, "it adopted s2's line: "+l) + } + if env.frontendReadyAt("s1") { + failures = append(failures, "its status reports FrontendPrimaryReady") + } + if listening(env.hosts["s1"].nvme) { + failures = append(failures, "its NVMe/TCP target listens") + } + time.Sleep(time.Second) + } + if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") { + failures = append(failures, "it logged neither the stale-root refusal nor stale authority") + } + if len(failures) > 0 { + t.Errorf("the returning old host after the forced move: %s", strings.Join(failures, "; ")) + } + env.h.waitPrimaryAt(t, env.hosts["s2"].status, e2) + if !bytes.Equal(env.readBlock(t, "s2", 0), kept) { + t.Fatal("s2 no longer serves the kept block after the old host returned") + } +} + +// TestProcedureRevokeWithoutACKThenForcedMove: the volume is sealed and +// revoked, but its process dies before it sends the ACK. The clean move is +// refused; only a forced move to another node remains, and since HEAD is +// sealed, nothing acknowledged is lost. +func TestProcedureRevokeWithoutACKThenForcedMove(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + block := pattern("sealed-no-ack!!!") + env.writeBlock(t, "s1", 0, block) + g := env.seal(t, "s1", e) + l := env.sealedLSN(t, e, g) + old.kill(t) + env.revoke(t, e, g) + o, eo, code := h.run(t, env.moveClean(e, "s2", "move-v1-1")...) + must(checkCleanMoveRefused(o, eo, code)) + + out := env.forceMove(t, e, "s2", "force-v1-1") + e2 := mustU(forcedEpoch(out, e, "s1", "s2")) + if got := mustU(forcedKeptLSN(out)); got != l { + t.Fatalf("the forced move kept LSN %d; want the sealed HEAD's %d", got, l) + } + nw := env.start(t, "blockvolume-s2", "s2") + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + if !bytes.Equal(env.readBlock(t, "s2", 0), block) { + t.Fatal("the sealed block does not read back on s2") + } +} + +func pattern(s string) []byte { return bytes.Repeat([]byte(s), 4096/len(s)) } + +func (env *handoffEnv) start(t *testing.T, name, id string) *daemon { + t.Helper() + return env.h.start(t, name, env.h.volume, env.volArgs(id)...) +} + +// adopt waits for the process to adopt v1 as primary and its host to report +// it healthy, and returns the epoch. +func (env *handoffEnv) adopt(t *testing.T, d *daemon, id string) uint64 { + t.Helper() + _, mustU := fatalOn(t) + e := mustU(adoptedEpoch(d.waitLog(t, 60*time.Second, "blockvolume: volume v1 adopted as PRIMARY at r1@"))) + env.h.waitPrimaryAt(t, env.hosts[id].status, e) + return e +} + +// frontendReadyAt reports whether the host's status shows v1's frontend +// ready to serve. +func (env *handoffEnv) frontendReadyAt(id string) bool { + c := &http.Client{Timeout: 2 * time.Second} + resp, err := c.Get("http://" + env.hosts[id].status + "/status?volume=v1") + if err != nil { + return false + } + defer resp.Body.Close() + b, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) + return frontendReady(b) +} + +// listening reports whether something accepts TCP connections at addr. +func listening(addr string) bool { + c, err := net.DialTimeout("tcp", addr, time.Second) + if err != nil { + return false + } + c.Close() + return true +} + +func (env *handoffEnv) writeBlock(t *testing.T, id string, lba uint64, data []byte) { + t.Helper() + c := dialNVMe(t, env.hosts[id].nvme, plannedHandoffNQN) + defer c.close() + c.write(t, lba, data) + c.flush(t) +} + +func (env *handoffEnv) readBlock(t *testing.T, id string, lba uint64) []byte { + t.Helper() + c := dialNVMe(t, env.hosts[id].nvme, plannedHandoffNQN) + defer c.close() + return c.read(t, lba, 4096) +} + +func (env *handoffEnv) seal(t *testing.T, id string, e uint64) uint64 { + t.Helper() + _, mustU := fatalOn(t) + out, errOut := env.h.command(t, "ops", "chunk", "detach", "--plain", "--volume", "v1", "--status-addr", env.hosts[id].status, "--timeout", "120s") + return mustU(sealedGen(out, errOut, e)) +} + +func (env *handoffEnv) chunkShow() []string { + return []string{"ops", "chunk", "show", "--volume", "v1", "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath} +} + +func (env *handoffEnv) sealedLSN(t *testing.T, e, g uint64) uint64 { + t.Helper() + _, mustU := fatalOn(t) + out, _ := env.h.command(t, env.chunkShow()...) + return mustU(sealedHeadLSN(out, e, g)) +} + +func (env *handoffEnv) revoke(t *testing.T, e, g uint64) { + t.Helper() + must, _ := fatalOn(t) + out, _ := env.h.command(t, "ops", "workspace", "revoke", "--master", env.h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--sealed-gen", fmt.Sprint(g)) + must(checkRevoke(out, e, g)) +} + +func (env *handoffEnv) waitAck(t *testing.T, e, g uint64) { + t.Helper() + poll(t, 30*time.Second, fmt.Sprintf("workspace show never reported the ACK of r1@%d at generation %d", e, g), func() bool { + out, _ := env.h.command(t, env.show...) + return showsAck(out, e, g) + }) +} + +func (env *handoffEnv) moveClean(e uint64, target, request string) []string { + b := env.hosts[target] + return []string{"ops", "workspace", "move", "--clean", "--master", env.h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--target-host", b.id, "--target-data", b.data, "--target-ctrl", b.ctrl, "--request-id", request} +} + +// forceMove runs the page's forced move: --dry-run until it says admitted +// (the barrier: at most 65 s after the holder stopped, with defaults, plus a +// margin), then the move itself, whose stdout it returns. +func (env *handoffEnv) forceMove(t *testing.T, e uint64, target, request string) string { + t.Helper() + b := env.hosts[target] + args := []string{"ops", "workspace", "force-move", "--master", env.h.masterAddr, "--volume", "v1", + "--target-host", b.id, "--target-data", b.data, "--target-ctrl", b.ctrl, + "--request-id", request, "--confirm-forced", fmt.Sprintf("v1@%d", e)} + first, _ := env.h.command(t, append(args, "--dry-run")...) + if !previewAdmitted(first) && !strings.Contains(first, "admissible at ") { + t.Fatalf("a refused preview does not say when the move is admissible:\n%s", first) + } + poll(t, 90*time.Second, "the forced move was never admitted", func() bool { + out, _ := env.h.command(t, append(args, "--dry-run")...) + return previewAdmitted(out) + }) + out, _ := env.h.command(t, args...) + return out +} From 95a3a892637b7cbb67fb8ee5c70e85c173bb9e34 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:50:54 -0800 Subject: [PATCH 070/204] test: pin backend retry classes across iSCSI and NVMe --- .../iscsi/backend_error_class_test.go | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 seaweed-block/core/frontend/iscsi/backend_error_class_test.go diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go new file mode 100644 index 0000000000..3e85ac5f5c --- /dev/null +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -0,0 +1,94 @@ +package iscsi_test + +import ( + "context" + "errors" + "fmt" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/iscsi" + "github.com/seaweedfs/seaweed-block/core/frontend/nvme" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" +) + +type classifiedErrorBackend struct { + frontend.Backend + err error +} + +func (b classifiedErrorBackend) Read(context.Context, int64, []byte) (int, error) { return 0, b.err } +func (b classifiedErrorBackend) Write(context.Context, int64, []byte) (int, error) { return 0, b.err } +func (b classifiedErrorBackend) Sync(context.Context) error { return b.err } + +// r2.36: transient backend errors must never become a media failure. Both +// protocol handlers consume the same backend condition; neither returns data. +func TestBackendErrorClassesAcrossFrontends(t *testing.T) { + for _, tc := range []struct { + name string + err error + status, key, asc, ascq, sct, sc uint8 + deadline bool + }{ + {name: "not-ready", err: frontend.ErrNotReady, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, + {name: "busy", err: frontend.ErrBackendBusy, status: 0x08, sct: 0, sc: 0x82}, + {name: "stale", err: frontend.ErrStalePrimary, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x0a, sct: 3, sc: 3}, + {name: "closed", err: frontend.ErrBackendClosed, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x03, sct: 3, sc: 2}, + {name: "permanent", err: errors.New("media read failure"), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "deadline", err: context.DeadlineExceeded, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82, deadline: true}, + {name: "deadline-and-physical", err: errors.Join(context.DeadlineExceeded, errors.New("media sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + } { + for _, op := range []string{"read", "write", "sync"} { + t.Run(tc.name+"/"+op, func(t *testing.T) { + ctx := context.Background() + if tc.deadline { + var cancel context.CancelFunc + ctx, cancel = context.WithDeadline(ctx, time.Now().Add(-time.Second)) + defer cancel() + } + b := classifiedErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: fmt.Errorf("backend: %w", tc.err)} + sh := iscsi.NewSCSIHandler(iscsi.HandlerConfig{Backend: b}) + nh := nvme.NewIOHandler(nvme.HandlerConfig{Backend: b}) + var cdb [16]byte + var payload []byte + nc := nvme.IOCommand{NSID: 1, NLB: 1} + switch op { + case "read": + cdb[0] = iscsi.ScsiRead10 + cdb[8] = 1 + nc.Opcode = 2 + case "write": + cdb[0] = iscsi.ScsiWrite10 + cdb[8] = 1 + payload = make([]byte, 512) + nc.Opcode = 1 + nc.Data = payload + case "sync": + cdb[0] = iscsi.ScsiSyncCache10 + nc.Opcode = 0 + } + got := sh.HandleCommand(ctx, cdb, payload) + ng := nh.Handle(ctx, nc) + asc := tc.asc + if op == "sync" && tc.key == 0x03 { + asc = 0x0c + } + if got.Status != tc.status || got.SenseKey != tc.key || got.ASC != asc || got.ASCQ != tc.ascq { + t.Errorf("SCSI got status/key/ASC/ASCQ %02x/%02x/%02x/%02x want %02x/%02x/%02x/%02x", got.Status, got.SenseKey, got.ASC, got.ASCQ, tc.status, tc.key, asc, tc.ascq) + } + if ng.SCT != tc.sct || ng.SC != tc.sc { + t.Errorf("NVMe got %x/%x want %x/%x", ng.SCT, ng.SC, tc.sct, tc.sc) + } + if len(got.Data) != 0 || len(ng.Data) != 0 { + t.Fatal("error returned data") + } + if tc.name == "not-ready" || tc.name == "busy" { + if got.SenseKey == iscsi.SenseMediumError || ng.SCT != nvme.SCTGeneric || ng.SC != nvme.SCNamespaceNotReady { + t.Fatal("transient condition is not retryable on both protocols") + } + } + }) + } + } +} From a46a355f0728f5362d8415f35743d627b29cc9fc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:52:10 -0800 Subject: [PATCH 071/204] fix: share backend retry classification across frontends --- seaweed-block/core/frontend/error_class.go | 37 +++++++++++ seaweed-block/core/frontend/iscsi/scsi.go | 63 ++++++------------- .../frontend/nvme/backend_error_class_test.go | 41 ++++++++++++ seaweed-block/core/frontend/nvme/io.go | 60 +++++------------- 4 files changed, 113 insertions(+), 88 deletions(-) create mode 100644 seaweed-block/core/frontend/error_class.go create mode 100644 seaweed-block/core/frontend/nvme/backend_error_class_test.go diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go new file mode 100644 index 0000000000..4cddefa34a --- /dev/null +++ b/seaweed-block/core/frontend/error_class.go @@ -0,0 +1,37 @@ +package frontend + +import ( + "context" + "errors" +) + +// BackendErrorClass is independent of the transport's status codes. +type BackendErrorClass uint8 + +const ( + BackendErrorPermanent BackendErrorClass = iota + BackendErrorNotReady + BackendErrorBusy + BackendErrorStale + BackendErrorClosed +) + +// ClassifyBackendError implements the approved r2.36 frontend retry-class rule. +// Call only for a non-nil backend error. A pure expired command deadline is +// transient; a joined physical cause keeps its permanent classification. +func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { + switch { + case IsWriteDeadline(ctx, err): + return BackendErrorNotReady + case errors.Is(err, ErrBackendBusy): + return BackendErrorBusy + case errors.Is(err, ErrStalePrimary): + return BackendErrorStale + case errors.Is(err, ErrBackendClosed): + return BackendErrorClosed + case errors.Is(err, ErrNotReady): + return BackendErrorNotReady + default: + return BackendErrorPermanent + } +} diff --git a/seaweed-block/core/frontend/iscsi/scsi.go b/seaweed-block/core/frontend/iscsi/scsi.go index 216bf4dfdb..0335e784e7 100644 --- a/seaweed-block/core/frontend/iscsi/scsi.go +++ b/seaweed-block/core/frontend/iscsi/scsi.go @@ -5,7 +5,6 @@ import ( "crypto/sha256" "encoding/binary" "encoding/hex" - "errors" "fmt" "log" @@ -215,13 +214,7 @@ func (h *SCSIHandler) HandleCommand(ctx context.Context, cdb [16]byte, dataOut [ log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE handler entry opcode=0x%02x", cdb[0]) if err := h.backend.Sync(ctx); err != nil { log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE backend.Sync FAILED: %v", err) - return SCSIResult{ - Status: StatusCheckCondition, - SenseKey: SenseMediumError, - ASC: ASCWriteError, - ASCQ: 0x00, - Reason: fmt.Sprintf("SYNC_CACHE: backend sync: %v", err), - } + return mapBackendError(ctx, err, "sync") } log.Printf("iscsi: SCSI SYNCHRONIZE_CACHE backend.Sync ok") return SCSIResult{Status: StatusGood} @@ -278,7 +271,7 @@ func (h *SCSIHandler) doRead(ctx context.Context, lba uint64, transferLen uint32 buf := make([]byte, byteLen) _, err := h.backend.Read(ctx, int64(lba)*int64(h.blockSize), buf) if err != nil { - return mapBackendError(err, "read") + return mapBackendError(ctx, err, "read") } return SCSIResult{Status: StatusGood, Data: buf} } @@ -307,7 +300,7 @@ func (h *SCSIHandler) doWrite(ctx context.Context, lba uint64, transferLen uint3 _, err := h.backend.Write(ctx, int64(lba)*int64(h.blockSize), dataOut[:expectedBytes]) if err != nil { log.Printf("iscsi: SCSI WRITE backend.Write FAILED lba=%d: %v", lba, err) - return mapBackendError(err, "write") + return mapBackendError(ctx, err, "write") } log.Printf("iscsi: SCSI WRITE backend.Write ok lba=%d", lba) return SCSIResult{Status: StatusGood} @@ -688,41 +681,25 @@ func (h *SCSIHandler) reportLuns(cdb [16]byte) SCSIResult { // --- helpers --- -// mapBackendError translates a frontend.Backend error into the -// SCSI status/sense tuple. ErrStalePrimary is the load-bearing -// case (test-spec §4 T2.L0.i2/i3): stale WRITE must not -// acknowledge success, stale READ must not return stale bytes. -// Both map to CHECK CONDITION + NOT READY + stale-lineage ASC. -// -// Other backend errors surface as CHECK CONDITION / MEDIUM -// ERROR — conservative fail-closed; real-backend-specific -// mapping lands with T3. -func mapBackendError(err error, op string) SCSIResult { - if errors.Is(err, frontend.ErrStalePrimary) { - return SCSIResult{ - Status: StatusCheckCondition, - SenseKey: SenseNotReady, - ASC: ASCStaleLineage, - ASCQ: ASCQStaleLineage, - Reason: "stale primary lineage on " + op, +// mapBackendError only maps the shared retry class to SCSI status/sense. +func mapBackendError(ctx context.Context, err error, op string) SCSIResult { + result := SCSIResult{Status: StatusCheckCondition, SenseKey: SenseNotReady, ASC: ASCNotReady, Reason: "backend error on " + op + ": " + err.Error()} + switch frontend.ClassifyBackendError(ctx, err) { + case frontend.BackendErrorBusy: + return SCSIResult{Status: StatusBusy, Reason: result.Reason} + case frontend.BackendErrorNotReady: + result.ASCQ = 0x01 // LOGICAL UNIT IS IN PROCESS OF BECOMING READY (T10 ASC list). + case frontend.BackendErrorStale: + result.ASC, result.ASCQ = ASCStaleLineage, ASCQStaleLineage + case frontend.BackendErrorClosed: + result.ASCQ = ASCNotReadyManualIntv + default: + result.SenseKey, result.ASC = SenseMediumError, 0x11 + if op == "sync" { + result.ASC = ASCWriteError } } - if errors.Is(err, frontend.ErrBackendClosed) { - return SCSIResult{ - Status: StatusCheckCondition, - SenseKey: SenseNotReady, - ASC: ASCNotReady, - ASCQ: ASCNotReadyManualIntv, - Reason: "backend closed on " + op, - } - } - return SCSIResult{ - Status: StatusCheckCondition, - SenseKey: SenseMediumError, - ASC: 0x11, // Unrecovered read error (or generic medium error) - ASCQ: 0x00, - Reason: "backend error on " + op + ": " + err.Error(), - } + return result } func illegalRequest(asc, ascq uint8, reason string) SCSIResult { diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go new file mode 100644 index 0000000000..7c90c24706 --- /dev/null +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -0,0 +1,41 @@ +package nvme + +import ( + "context" + "errors" + "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "testing" +) + +type retryClassBackend struct { + frontend.Backend + err error +} + +func (b retryClassBackend) Read(context.Context, int64, []byte) (int, error) { return 0, b.err } +func (b retryClassBackend) Write(context.Context, int64, []byte) (int, error) { return 0, b.err } +func (b retryClassBackend) Sync(context.Context) error { return b.err } + +// r2.36: validate the completion encoding, not only the handler's status code. +func TestBackendRetryClassClearsWireDNR(t *testing.T) { + for _, tc := range []struct { + name string + err error + dnr bool + }{ + {"not-ready", frontend.ErrNotReady, false}, + {"busy", frontend.ErrBackendBusy, false}, + {"permanent", errors.New("physical media fault"), true}, + } { + for _, op := range []uint8{ioRead, ioWrite, ioFlush} { + t.Run(tc.name+string(rune('0'+op)), func(t *testing.T) { + h := NewIOHandler(HandlerConfig{Backend: retryClassBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: tc.err}}) + result := h.Handle(context.Background(), IOCommand{Opcode: op, NSID: 1, NLB: 1, Data: make([]byte, 512)}) + if dnr := result.completionStatus()&(1<<15) != 0; dnr != tc.dnr { + t.Fatalf("DNR=%t want %t, result=%+v", dnr, tc.dnr, result) + } + }) + } + } +} diff --git a/seaweed-block/core/frontend/nvme/io.go b/seaweed-block/core/frontend/nvme/io.go index 437737aa49..17ec3f8159 100644 --- a/seaweed-block/core/frontend/nvme/io.go +++ b/seaweed-block/core/frontend/nvme/io.go @@ -17,7 +17,6 @@ package nvme import ( "context" - "errors" "fmt" "time" @@ -214,7 +213,7 @@ func (h *IOHandler) Handle(ctx context.Context, cmd IOCommand) (result IOResult) // SC=0x06) — stop rule §3.6 (error-faithful) forbids // swallowing to Success. if err := h.backend.Sync(ctx); err != nil { - return mapBackendError(err, "flush") + return mapBackendError(ctx, err, "flush") } return IOResult{SCT: SCTGeneric, SC: SCSuccess} default: @@ -257,7 +256,7 @@ func (h *IOHandler) read(ctx context.Context, cmd IOCommand) IOResult { buf := make([]byte, byteLen) _, err := h.backend.Read(ctx, int64(cmd.SLBA)*int64(h.blockSize), buf) if err != nil { - return mapBackendError(err, "read") + return mapBackendError(ctx, err, "read") } return IOResult{SCT: SCTGeneric, SC: SCSuccess, Data: buf} } @@ -283,58 +282,29 @@ func (h *IOHandler) write(ctx context.Context, cmd IOCommand) IOResult { start := time.Now() n, err := h.backend.Write(ctx, int64(cmd.SLBA)*int64(h.blockSize), cmd.Data[:expectedBytes]) if err != nil { - return mapWriteBudgetError(ctx, err, "write") + return mapBackendError(ctx, err, "write") } if rec, ok := h.backend.(targetWriteRecorder); ok { rec.RecordTargetWrite(n, time.Since(start)) } if cmd.FUA { if err := h.backend.Sync(ctx); err != nil { - return mapWriteBudgetError(ctx, err, "FUA sync") + return mapBackendError(ctx, err, "FUA sync") } } return IOResult{SCT: SCTGeneric, SC: SCSuccess} } -// Only a pure command-deadline cause is transient. A joined physical error -// must retain its terminal mapping even when the command deadline also passed. -func mapWriteBudgetError(ctx context.Context, err error, op string) IOResult { - if frontend.IsWriteDeadline(ctx, err) { - return IOResult{SCT: SCTGeneric, SC: SCNamespaceNotReady, retryable: true, Reason: "command deadline on " + op + ": " + err.Error()} - } - return mapBackendError(err, op) -} - -// mapBackendError translates frontend errors into NVMe CQE -// status tuples. ErrStalePrimary → ANA Transition; -// ErrBackendClosed → ANA Inaccessible; ErrNotReady → retryable Namespace -// Not Ready; anything else → Internal -// Error (fail-closed; real-backend-specific mapping lands with -// T3). -func mapBackendError(err error, op string) IOResult { - if errors.Is(err, frontend.ErrBackendBusy) { - return IOResult{SCT: SCTGeneric, SC: SCNamespaceNotReady, Reason: "local admission pressure on " + op + ": " + err.Error(), retryable: true} - } - if errors.Is(err, frontend.ErrStalePrimary) { - return IOResult{ - SCT: SCTPathRelated, - SC: SCPathAsymAccessTransition, - Reason: "stale primary lineage on " + op, - } - } - if errors.Is(err, frontend.ErrBackendClosed) { - return IOResult{ - SCT: SCTPathRelated, - SC: SCPathAsymAccessInaccessible, - Reason: "backend closed on " + op, - } - } - if errors.Is(err, frontend.ErrNotReady) { - return IOResult{SCT: SCTGeneric, SC: SCNamespaceNotReady, Reason: "backend not ready on " + op + ": " + err.Error(), retryable: true} - } - return IOResult{ - SCT: SCTGeneric, - SC: SCInternalError, - Reason: "backend error on " + op + ": " + err.Error(), +// mapBackendError only maps the shared retry class to NVMe protocol status. +func mapBackendError(ctx context.Context, err error, op string) IOResult { + switch frontend.ClassifyBackendError(ctx, err) { + case frontend.BackendErrorBusy, frontend.BackendErrorNotReady: + return IOResult{SCT: SCTGeneric, SC: SCNamespaceNotReady, retryable: true, Reason: "backend temporarily unavailable on " + op + ": " + err.Error()} + case frontend.BackendErrorStale: + return IOResult{SCT: SCTPathRelated, SC: SCPathAsymAccessTransition, Reason: "stale primary lineage on " + op} + case frontend.BackendErrorClosed: + return IOResult{SCT: SCTPathRelated, SC: SCPathAsymAccessInaccessible, Reason: "backend closed on " + op} + default: + return IOResult{SCT: SCTGeneric, SC: SCInternalError, Reason: "backend error on " + op + ": " + err.Error()} } } From 53618e5d5b3254858d25075f2c5b11a578928593 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:55:57 -0800 Subject: [PATCH 072/204] test: a holder started inside the barrier wait, and one started too early Two procedure tests for a holder that returns after its lease ended but before the re-grant barrier. Started 35 s after the stop (default flags), the barrier passes within its 30 s authority wait: it must not serve while its renewals are still refused for the barrier, then serves at the same epoch. With --workspace-max-clock-skew 50s and a start 31 s after the stop, its wait ends first: it does not serve and exits 75, and a supervised restart that waits past the barrier serves at the same epoch. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_integration_test.go | 10 +- .../procedure_gate_integration_test.go | 125 ++++++++++++++++++ 2 files changed, 130 insertions(+), 5 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 320fee1872..9e03afddb4 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -184,9 +184,9 @@ type bvHost struct { } // startHandoffEnv runs the chapter's steps 1-3: a weed cluster, the cluster -// spec with hosts s1..sN, blockmaster with the lifecycle store, and the setup -// check. -func startHandoffEnv(t *testing.T, n int) *handoffEnv { +// spec with hosts s1..sN, blockmaster with the lifecycle store (and +// masterArgs), and the setup check. +func startHandoffEnv(t *testing.T, n int, masterArgs ...string) *handoffEnv { t.Helper() h := newPlannedHandoffHarness(t) env := &handoffEnv{h: h, cluster: startWorkspaceWeed(t), chunkPath: fmt.Sprintf("/handoff-%d", time.Now().UnixNano()), hosts: map[string]bvHost{}} @@ -216,10 +216,10 @@ func startHandoffEnv(t *testing.T, n int) *handoffEnv { // 2. blockmaster with the lifecycle store and the cluster spec. mstate := filepath.Join(h.dir, "master") - master := h.start(t, "blockmaster", h.master, + master := h.start(t, "blockmaster", h.master, append([]string{ "--authority-store", filepath.Join(mstate, "authority"), "--lifecycle-store", filepath.Join(mstate, "lifecycle"), "--cluster-spec", spec, "--expected-slots-per-volume", "1", "--listen", h.masterAddr, - "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+chunkPath) + "--workspace-rpc", "--workspace-head-base-url", "http://" + cluster.filerHTTP + chunkPath}, masterArgs...)...) if l := master.waitLog(t, 30*time.Second, "blockmaster: lock acquired, reloaded="); !strings.Contains(l, "listen="+h.masterAddr) { t.Fatalf("blockmaster start line %q does not name listen=%s", l, h.masterAddr) } diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 62c3d521ab..24861cdebf 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -4,10 +4,13 @@ package main_test import ( "bytes" + "errors" "fmt" "io" "net" "net/http" + "os" + "os/exec" "strings" "testing" "time" @@ -214,6 +217,128 @@ func TestProcedureRevokeWithoutACKThenForcedMove(t *testing.T) { } } +// TestProcedureStartInsideTheBarrierWaitIsReGranted: the holder's process +// dies and is started again 35 s later: its lease has ended, the re-grant +// barrier (at most 65 s after the stop, default flags) has not passed, and +// the barrier passes within the process's 30 s authority wait. It must not +// serve while its renewals are still refused for the barrier; once +// re-granted it serves its local WAL at the same epoch. +func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { + env := startHandoffEnv(t, 1) + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("inside-the-wait!") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + time.Sleep(35 * time.Second) + + back := env.start(t, "blockvolume-s1-back", "s1") + var ready []time.Time + end := time.Now().Add(90 * time.Second) + for time.Now().Before(end) { + if env.frontendReadyAt("s1") || listening(env.hosts["s1"].nvme) { + ready = append(ready, time.Now()) + if len(ready) >= 5 { + break + } + } + time.Sleep(200 * time.Millisecond) + } + if len(ready) == 0 { + t.Fatal("the returning holder never served within 90 s") + } + if last := lastLogTime(back, "clock-skew margin has not elapsed"); !last.IsZero() && ready[0].Before(last) { + t.Errorf("the returning holder served at %s, before its renewal was still refused for the barrier at %s: it served without a lease", + ready[0].Format("15:04:05.000"), last.Format("15:04:05")) + } + if got := env.adopt(t, back, "s1"); got != e { + t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) + } + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the stop does not read back") + } +} + +// TestProcedureStartTooEarlyExitsAndARestartServes: with +// --workspace-max-clock-skew 50s the barrier is at most 95 s after the stop. +// A holder started 31 s after the stop ends its 30 s authority wait before +// the barrier: it does not serve and exits with status 75, so a supervisor +// (Restart=on-failure, RestartSec=5s) starts it again; a start that waits +// past the barrier is re-granted and serves at the same epoch. +func TestProcedureStartTooEarlyExitsAndARestartServes(t *testing.T) { + env := startHandoffEnv(t, 1, "--workspace-max-clock-skew", "50s") + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("start-too-early!") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + time.Sleep(31 * time.Second) + + for attempt := 1; ; attempt++ { + d := env.start(t, fmt.Sprintf("blockvolume-s1-try%d", attempt), "s1") + served := false + end := time.Now().Add(45 * time.Second) + for time.Now().Before(end) { + if env.frontendReadyAt("s1") { + served = true + break + } + select { + case <-d.done: + end = time.Now() + default: + time.Sleep(200 * time.Millisecond) + } + } + if served { + if attempt == 1 { + t.Fatal("started before the barrier with its wait ending first, the holder served") + } + if got := env.adopt(t, d, "s1"); got != e { + t.Fatalf("attempt %d adopted epoch %d; want the same epoch %d", attempt, got, e) + } + break + } + if err := d.wait(5 * time.Second); exitCode(err) != 75 { + t.Fatalf("attempt %d did not serve and did not exit 75: %v", attempt, err) + } + if attempt == 4 { + t.Fatal("four supervised starts never served") + } + time.Sleep(5 * time.Second) + } + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the stop does not read back") + } +} + +// lastLogTime is the time of the last log line containing s (second +// resolution, the log's local time), or zero. +func lastLogTime(d *daemon, s string) time.Time { + data, _ := os.ReadFile(d.log) + var last time.Time + for _, l := range strings.Split(string(data), "\n") { + if strings.Contains(l, s) && len(l) >= 19 { + if ts, err := time.ParseInLocation("2006/01/02 15:04:05", l[:19], time.Local); err == nil { + last = ts + } + } + } + return last +} + +// exitCode is a child's exit status (-1 when it did not exit with one). +func exitCode(err error) int { + var exit *exec.ExitError + if err == nil { + return 0 + } + if errors.As(err, &exit) { + return exit.ExitCode() + } + return -1 +} + func pattern(s string) []byte { return bytes.Repeat([]byte(s), 4096/len(s)) } func (env *handoffEnv) start(t *testing.T, name, id string) *daemon { From 6154b7299e340e497501512f48eb8b7e03f73668 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:56:11 -0800 Subject: [PATCH 073/204] test: cover failed placement commits and trace holder guards --- .../core/lifecycle/placement_snapshot_test.go | 85 +++++++++++++++++++ seaweed-block/docs/design/invariants.md | 17 ++-- 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/seaweed-block/core/lifecycle/placement_snapshot_test.go b/seaweed-block/core/lifecycle/placement_snapshot_test.go index 90327d7e1b..e74baa86aa 100644 --- a/seaweed-block/core/lifecycle/placement_snapshot_test.go +++ b/seaweed-block/core/lifecycle/placement_snapshot_test.go @@ -1,6 +1,9 @@ package lifecycle import ( + "os" + "path/filepath" + "reflect" "sync" "testing" "time" @@ -60,3 +63,85 @@ func TestPlacementSnapshotDoesNotWaitForWriter(t *testing.T) { t.Fatal("deleted placement remained published") } } + +// INV-WS-RENEW-NONBLOCKING-001: publication is a committed view, not a +// speculative plan. Force a real replace/remove failure, without a hook. +func TestPlacementSnapshotFailedCommitStaysCommitted(t *testing.T) { + for _, op := range []string{"create", "replace", "delete"} { + t.Run(op, func(t *testing.T) { + dir := t.TempDir() + s, err := OpenPlacementIntentStore(dir) + if err != nil { + t.Fatal(err) + } + plan := PlacementPlan{VolumeID: "v", DesiredRF: 1, Candidates: []PlacementCandidate{{VolumeID: "v", ServerID: "node-a", ReplicaID: "r1", Source: PlacementSourceExistingReplica}}} + path := filepath.Join(dir, "v.json") + var saved []byte + if op != "create" { + if _, err = s.ApplyPlan(plan); err != nil { + t.Fatal(err) + } + saved, err = os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + if err = os.Remove(path); err != nil { + t.Fatal(err) + } + } + before, existed := s.GetPlacementSnapshot("v") + // A nonempty directory at the record path makes both replace and delete + // fail after validation, on Windows and Linux, even when run as root. + if err = os.Mkdir(path, 0755); err != nil { + t.Fatal(err) + } + blocker := filepath.Join(path, "blocker") + if err = os.WriteFile(blocker, []byte("owned test fixture"), 0600); err != nil { + t.Fatal(err) + } + plan.Candidates[0].ServerID = "node-b" + if op == "delete" { + err = s.DeletePlacement("v") + } else { + _, err = s.ApplyPlan(plan) + } + if err == nil { + t.Fatal("fixture did not fail commit") + } + got, ok := s.GetPlacementSnapshot("v") + if ok != existed || !reflect.DeepEqual(got, before) { + t.Fatalf("failed %s published %+v/%t instead of %+v/%t", op, got, ok, before, existed) + } + current, present := s.GetPlacement("v") + if present != existed || !reflect.DeepEqual(current, before) { + t.Fatal("failed commit changed the store's current placement") + } + if err = os.Remove(blocker); err != nil { + t.Fatal(err) + } + if err = os.Remove(path); err != nil { + t.Fatal(err) + } + if saved != nil { + if err = os.WriteFile(path, saved, 0600); err != nil { + t.Fatal(err) + } + } + reopened, err := OpenPlacementIntentStore(dir) + if err != nil { + t.Fatal(err) + } + got, ok = reopened.GetPlacementSnapshot("v") + if ok != existed || !reflect.DeepEqual(got, before) { + t.Fatal("reopen did not retain the committed placement") + } + if _, err = s.ApplyPlan(plan); err != nil { + t.Fatal("unblocked commit", err) + } + got, ok = s.GetPlacementSnapshot("v") + if !ok || len(got.Slots) != 1 || got.Slots[0].ServerID != "node-b" { + t.Fatal("committed replacement not published", got, ok) + } + }) + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 1eec783a56..e8321996d2 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -92,14 +92,14 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | From | To | Event and guard | Enforced in | Protects | |---|---|---|---|---| -| none | Granted | `RenewWorkspaceLease` from the current holder at the current epoch; no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001` | -| Granted | Granted | renew from memory (the lease view, leaf lock only) before the durable horizon and the granted deadline; the grant is min(now + TTL, horizon), refused with an error when it would leave no host validity (grant − skew/2 ≤ now); an extender, an ordinary writer under the publisher lock, raises the horizon to trigger + 1.5·TTL | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LEASE-HORIZON-MONO-001`, `INV-WS-RENEW-NONBLOCKING-001`, `INV-LEASE-VIEW-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001` | +| none | Granted | `RenewWorkspaceLease` from the current primary (server id, replica id) at the current epoch; a missing/foreign server is refused by RPC holderMatches; no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Granted | Granted | current primary server/replica/epoch required by RPC holderMatches (missing server refused); renew from memory (the lease view, leaf lock only) before the durable horizon and the granted deadline; the grant is min(now + TTL, horizon), refused with an error when it would leave no host validity (grant − skew/2 ≤ now); an extender, an ordinary writer under the publisher lock, raises the horizon to trigger + 1.5·TTL | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LEASE-HORIZON-MONO-001`, `INV-WS-RENEW-NONBLOCKING-001`, `INV-LEASE-VIEW-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Granted | Revoking | `BeginWorkspaceRevocation` for the matching lease; a renew now returns the revoking lease with the granted expiry, min(horizon, deadline), without extending it | `core/authority/workspace.go` `BeginWorkspaceRevocation`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `WorkspaceLeaseReply` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001` | -| Revoking | Acked | `AckWorkspaceRevocation` from the holder at the current epoch, a nonzero HEAD generation, the lease still valid; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001` | +| Revoking | Acked | `AckWorkspaceRevocation` from the primary server/replica at the current epoch, validated by the same RPC holderMatches (missing/foreign server refused), a nonzero HEAD generation, the lease still valid; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Acked | Moved (clean) | HEAD detached by the expected holder at the expected epoch, and the acknowledgement names that HEAD generation; the target may be the same host, with a newly issued epoch and every binding/collision/isolation check retained | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `validateWorkspaceMoveRequest`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-SAME-HOST-CLEAN-MOVE-001` | | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | -| Expired | Granted | Same current holder/epoch, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001` | +| Expired | Granted | Same current primary server/replica/epoch, validated by RPC holderMatches with missing server refused, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -132,9 +132,10 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the fact names this replica; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | -| Primary, Supporting | Excluded | the fact names another primary and does not list this replica; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001` | +| Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | | any | role admission failed | the listener cannot be fenced or its floor cannot be persisted; the role is not adopted and the projection is not healthy | `core/host/volume/host.go` `latchRoleAdmission` | `INV-FENCE-FLOOR-DURABLE-001` | | (every inbound frame) | — | a mutating frame is refused on a primary, below the floor, or before a role is known; the rebuild port applies the same rules; a failed apply closes the connection | `core/transport/replica.go` `acceptMutationLineage`, `admitMutation`, `EnterDualLane`, `handleConn` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-REPL-REBUILD-PORT-FENCE-001`, `INV-REPL-APPLY-FAIL-001` | | Supporting | promotion candidate | no active recovery session; member, reachable, caught up, fenced at the current epoch, post-rebuild durable acknowledgement delivered; for RF=3 also a fresh probe and coverage of the required frontier: known, or proven by at least N_peers-K+1 fresh ready peers when it is unknown | `core/engine/promotion_ready.go` `BuildPromotionReadyFact`; `core/host/master/product_loop.go` `applyPromotionEvidenceGate` | `INV-REPL-PROMOTION-READY-001`, `INV-PROMOTE-FRONTIER-001`, `INV-PROMOTE-FRONTIER-PROBE-001`, `INV-PROMOTE-FRONTIER-UNKNOWN-001` | @@ -574,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | @@ -583,7 +584,7 @@ Notes: | `INV-LEASE-VIEW-OWNED-001` | The granted deadline and the extender flag exist only in the lease view; refreshing the view from its derive inputs never changes either of them. | M2 every workspace transition | `core/authority/workspace_lease_view.go` `refreshLeaseViewLocked`, `setLeaseDeadlineLocked`, `extendWorkspaceLease` | — | — | STUB | | `INV-WS-LEASE-HORIZON-001` | For the active lease of the current authority epoch, the `Lease.ExpiresAtNS` persisted in the authority store is at least the published horizon, and the published horizon is at least every grant issued since the last reload. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`, `newWorkspaceLease`, `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked`, `issueWorkspaceMove` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardFencesByHorizonUnderStalledStore` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter` (`core/lifecycle/placement_snapshot_test.go`) | — | ACTIVE | +| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | From 5508d581b536a717a2ec41d3210ec7b511cdad63 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:00:11 -0800 Subject: [PATCH 074/204] docs: bind frontend retry mapping to its approved invariant --- seaweed-block/core/frontend/error_class.go | 4 ++-- .../core/frontend/iscsi/backend_error_class_test.go | 2 +- .../core/frontend/nvme/backend_error_class_test.go | 2 +- seaweed-block/docs/design/invariants.md | 11 ++++++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go index 4cddefa34a..fe1062c6e8 100644 --- a/seaweed-block/core/frontend/error_class.go +++ b/seaweed-block/core/frontend/error_class.go @@ -5,7 +5,7 @@ import ( "errors" ) -// BackendErrorClass is independent of the transport's status codes. +// BackendErrorClass is independent of transport status (INV-FE-ERROR-RETRY-CLASS-001). type BackendErrorClass uint8 const ( @@ -16,7 +16,7 @@ const ( BackendErrorClosed ) -// ClassifyBackendError implements the approved r2.36 frontend retry-class rule. +// ClassifyBackendError implements INV-FE-ERROR-RETRY-CLASS-001. // Call only for a non-nil backend error. A pure expired command deadline is // transient; a joined physical cause keeps its permanent classification. func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go index 3e85ac5f5c..1df2506638 100644 --- a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -22,7 +22,7 @@ func (b classifiedErrorBackend) Read(context.Context, int64, []byte) (int, error func (b classifiedErrorBackend) Write(context.Context, int64, []byte) (int, error) { return 0, b.err } func (b classifiedErrorBackend) Sync(context.Context) error { return b.err } -// r2.36: transient backend errors must never become a media failure. Both +// INV-FE-ERROR-RETRY-CLASS-001: transient backend errors must never become a media failure. Both // protocol handlers consume the same backend condition; neither returns data. func TestBackendErrorClassesAcrossFrontends(t *testing.T) { for _, tc := range []struct { diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go index 7c90c24706..c1102796b7 100644 --- a/seaweed-block/core/frontend/nvme/backend_error_class_test.go +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -17,7 +17,7 @@ func (b retryClassBackend) Read(context.Context, int64, []byte) (int, error) { func (b retryClassBackend) Write(context.Context, int64, []byte) (int, error) { return 0, b.err } func (b retryClassBackend) Sync(context.Context) error { return b.err } -// r2.36: validate the completion encoding, not only the handler's status code. +// INV-FE-ERROR-RETRY-CLASS-001: validate the completion encoding, not only the handler's status code. func TestBackendRetryClassClearsWireDNR(t *testing.T) { for _, tc := range []struct { name string diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..724b2f1566 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -376,6 +376,14 @@ snapshot lifetime; local persistence does not bypass it. Generic/Namespace Not Ready (SC0x82), DNR=0. Sticky faults retain their original non-retryable mapping. This is a local pressure outcome, not a whole-I/O deadline; the broader budget gap is tracked separately in issue221. +- Every frontend I/O error completion uses one shared retry class + (`INV-FE-ERROR-RETRY-CLASS-001`): not-ready and pure expired-command + deadlines map to SCSI NOT READY04/01 or NVMe NamespaceNotReady/DNR0; + local busy maps to SCSI BUSY or NVMe NamespaceNotReady/DNR0. Stale + lineage and closed preserve their distinct path-status meanings. + Permanent errors retain terminal protocol mapping, including a deadline + joined with a physical error. Read, write and sync use the same classifier; + no storage/authority state changes on this mapping. - A flusher cycle sorts native snapshot entries by record offset and reuses at most one fully validated record (bounded by WALSize). Every block still checks its LBA/data offset/LSN/nonce; the cache is local to the snapshot recovery @@ -410,7 +418,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -303 rows: 217 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 288 new. +304 rows: 218 ACTIVE, 83 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 289 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -455,6 +463,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-ADMISSION-EXPIRY-STATE-001` | A v3 write refused for an expired deadline before its append leaves the WAL bytes, nextLSN and the dirty map unchanged. | M1 Serving (write admission) | `core/storage/walstore.go` `WALStore.WriteContext`, `WALStore.WriteBatchContext` | `TestStorageBackendExpiredWriteDoesNotAppend` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-PREFIX-ERR-001` | A write batch that returns a committed prefix with a storage error keeps that error in the error set the frontend classifies. | M1 Serving (write admission) | `core/frontend/durable/storage_adapter.go` `writeFullBlockBatch`, `withStorageCause`, `observeWriteCause` | `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-RETRYABLE-001` | A write that fails only because the caller's deadline expired is reported retryable, also through a required write observer and on NVMe; a write whose error carries a physical cause is reported terminal. | M1 Serving (write admission) | `core/frontend/write_budget.go` `IsWriteDeadline`; `core/frontend/durable/storage_adapter.go` `StorageBackend.Write`, `replicationWriteError`; `core/frontend/nvme/io.go` `mapBackendError`; `core/frontend/nvme/session.go` `Session.handleWrite` | `TestStorageBackendRequiredObserverDeadlineStaysRetryable`, `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline`; `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | — | ACTIVE | +| `INV-FE-ERROR-RETRY-CLASS-001` | A backend error's retry class is decided once and every frontend reports it with its protocol's retryable form; only permanent errors become medium errors. | M1 I/O error completion (shared frontend classifier) | `core/frontend/error_class.go` `ClassifyBackendError`; `core/frontend/iscsi/scsi.go`, `core/frontend/nvme/io.go` `mapBackendError` | `TestBackendErrorClassesAcrossFrontends` (`core/frontend/iscsi/backend_error_class_test.go`); `TestBackendRetryClassClearsWireDNR` (`core/frontend/nvme/backend_error_class_test.go`); `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | Protocol output only; existing backend states, no new automaton state | ACTIVE | | `INV-WAL-V3-RECLAIM-001` | A mapped v3 checkpoint at cp moves retainedTail only to the end of a complete validated record whose last LSN is at most cp minus the retention window, and, while a BASE is installing, never past BaseCursor. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/wal_io_v3.go` `walWriterV3.reclaimThroughV3` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | Existing dual-slot retirement and nonce/cursor contract; concrete index/recovery/caller wiring is a code-test obligation | STUB | | `INV-WAL-V3-RECLAIM-INDEX-001` | A physical v3 recovery rebuilds the writer's volatile record-boundary index only from trusted write records of the kept scan; an installing reopen indexes them without moving the writer's cursor. | M1 checkpoint / existing two-slot retirement | `core/storage/wal_io_v3.go` `walWriterV3.restoreScanV3`, `walWriterV3.rememberReclaimScanV3`, `walWriterV3.indexReclaimScanLockedV3`; `core/storage/walstore_v3.go` `WALStore.recoverV3` | `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | — | STUB | | `INV-WAL-V3-RECLAIM-PUBLISH-001` | A mapped v3 checkpoint publishes retainedTail, retainedHead, the map root, CheckpointLSN and W in one slot publication, followed by a metadata-only rollover when the fallback slot still pins a lower tail. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.rolloverIfPinned` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | — | STUB | From 9d6b978d8347518273507b5e4629138a9b9ac0c0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:02:31 -0800 Subject: [PATCH 075/204] test: carry holder server in CLI master fixtures --- seaweed-block/cmd/sw-block/workspace_master_test.go | 2 +- seaweed-block/cmd/sw-block/workspace_planned_master_test.go | 2 +- seaweed-block/docs/design/invariants.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seaweed-block/cmd/sw-block/workspace_master_test.go b/seaweed-block/cmd/sw-block/workspace_master_test.go index d7c594913b..227153ab2b 100644 --- a/seaweed-block/cmd/sw-block/workspace_master_test.go +++ b/seaweed-block/cmd/sw-block/workspace_master_test.go @@ -64,7 +64,7 @@ func seedForcedVolume(t *testing.T, h *master.Host) { t.Fatal("no authority line for vol-f") } } - if _, err := ws.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1}); err != nil { + if _, err := ws.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1}); err != nil { t.Fatal(err) } } diff --git a/seaweed-block/cmd/sw-block/workspace_planned_master_test.go b/seaweed-block/cmd/sw-block/workspace_planned_master_test.go index b003feeb66..91396ad8e5 100644 --- a/seaweed-block/cmd/sw-block/workspace_planned_master_test.go +++ b/seaweed-block/cmd/sw-block/workspace_planned_master_test.go @@ -45,7 +45,7 @@ func TestWorkspacePlannedHandoffAgainstRealMaster(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() // This is the separate host event, never synthesized by the CLI. - _, err = control.NewWorkspaceServiceClient(conn).AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: &control.WorkspaceIdentity{VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1}, HeadGen: 9}) + _, err = control.NewWorkspaceServiceClient(conn).AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1}, HeadGen: 9}) if err != nil { t.Fatal(err) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index e8321996d2..cd3380a110 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | — (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From c89e38f5c4e837e05de3d89d83f43a54b7959ab5 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:04:11 -0800 Subject: [PATCH 076/204] test: empty replica fact cannot suppress workspace restart --- .../cmd/blockvolume/process_exit_authority_test.go | 4 ++++ seaweed-block/core/host/volume/workspace_startup_test.go | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index 829e8e5e18..eb3dc01743 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -127,6 +127,10 @@ func TestWorkspaceRetryUsesNewestOwnAssignment(t *testing.T) { replica string epoch uint64 }{{"other", 6}}, 78}, + {"empty replica newer epoch", []struct { + replica string + epoch uint64 + }{{"r", 5}, {"", 7}}, 75}, {"same replica higher epoch", []struct { replica string epoch uint64 diff --git a/seaweed-block/core/host/volume/workspace_startup_test.go b/seaweed-block/core/host/volume/workspace_startup_test.go index 28330e77f5..ca8e39af63 100644 --- a/seaweed-block/core/host/volume/workspace_startup_test.go +++ b/seaweed-block/core/host/volume/workspace_startup_test.go @@ -29,3 +29,12 @@ func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { t.Fatal("another volume produced a no-retry outcome") } } + +func TestWorkspaceEmptyOtherReplicaNeverSelectsNoRetry(t *testing.T) { + h, _, _ := newStubbedHost(t, "v", "r", &orderingRecorder{}) + h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 5, EndpointVersion: 1}) + h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "", Epoch: 7, EndpointVersion: 1}) + if h.IsCurrentReplicaSuperseded() { + t.Fatal("empty replica id is not another holder; must retry") + } +} From f36710e5b576b228e0ef8e357f7829a8424b6dc8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:05:54 -0800 Subject: [PATCH 077/204] fix: reject empty supersede identity and bound build pipe cleanup --- .../cmd/blockvolume/startup_systemd_integration_test.go | 1 + seaweed-block/core/host/volume/workspace_startup.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 5827b55e85..fa869e29b3 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -52,6 +52,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { for _, name := range []string{"blockvolume", "blockmaster"} { buildCtx, buildCancel := context.WithTimeout(context.Background(), 2*time.Minute) cmd := exec.CommandContext(buildCtx, "go", "build", "-p", "4", "-o", filepath.Join(bin, name), "../"+name) + cmd.WaitDelay = time.Second // bound inherited child pipes after cancellation out, err := cmd.CombinedOutput() buildCancel() if err != nil { diff --git a/seaweed-block/core/host/volume/workspace_startup.go b/seaweed-block/core/host/volume/workspace_startup.go index 3de4ee4516..e3942fa611 100644 --- a/seaweed-block/core/host/volume/workspace_startup.go +++ b/seaweed-block/core/host/volume/workspace_startup.go @@ -23,7 +23,7 @@ func (h *Host) IsCurrentReplicaSuperseded() bool { h.ownAssignmentMu.RLock() defer h.ownAssignmentMu.RUnlock() other := h.LastOtherLine() - if other == nil || other.VolumeId != h.cfg.VolumeID { + if other == nil || other.ReplicaId == "" || other.VolumeId != h.cfg.VolumeID { return false } return h.IsSuperseded(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) From 3fcbde02a83291efa391812ac2cc85c92857ed41 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:24:47 -0800 Subject: [PATCH 078/204] test: displaced lower-epoch claim must retry startup --- .../process_exit_authority_test.go | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index eb3dc01743..80d8296aaa 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -406,3 +406,87 @@ func TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry(t *testing.T) { }) } } + +// The real claim reads E1/A; a late E2/C wins before E3/B's CAS. +// The displaced HEAD is a fence for this attempt, not proof E3 was superseded. +type displacedClaimExitRemote struct { + storage.ChunkRemote + epoch uint64 + raced bool +} + +func (r *displacedClaimExitRemote) CASHead(ctx context.Context, prev storage.ChunkHeadVersion, next storage.ChunkHead) (uint64, error) { + if !r.raced { + r.raced = true + late := storage.ChunkHead{Epoch: r.epoch, Holder: "C", State: storage.ChunkHeadActive} + if _, err := r.ChunkRemote.CASHead(ctx, prev, late); err != nil { + return 0, err + } + } + return r.ChunkRemote.CASHead(ctx, prev, next) +} + +type displacedClaimExitView struct{} + +func (displacedClaimExitView) Projection() frontend.Projection { + return frontend.Projection{VolumeID: "v", ReplicaID: "B", Epoch: 3, Healthy: true} +} +func TestWorkspaceDisplacedClaimUsesAssignedEpoch(t *testing.T) { + for _, tc := range []struct { + name string + epoch uint64 + want int + }{ + {"late lower epoch", 2, 75}, {"equal epoch foreign holder", 3, 78}, {"higher epoch foreign holder", 4, 78}, + } { + t.Run(tc.name, func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + h, _ := exitAuthorityHost(t) + base := storage.NewMemChunkRemote() + if _, err := base.CASHead(ctx, storage.ChunkHeadVersion{}, storage.ChunkHead{Epoch: 1, Holder: "A", State: storage.ChunkHeadActive}); err != nil { + t.Fatal(err) + } + remote := &displacedClaimExitRemote{ChunkRemote: base, epoch: tc.epoch} + p, err := durable.NewDurableProvider(durable.ProviderConfig{Impl: durable.ImplWALStoreChunk, StorageRoot: t.TempDir(), NumBlocks: 64, BlockSize: 4096, ChunkBlocks: 4, ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }}, displacedClaimExitView{}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { + if err := p.Close(); err != nil { + t.Error(err) + } + }) + if _, err = p.EnsureStorage("v"); err != nil { + t.Fatal(err) + } + if _, err = p.RecoverVolume(ctx, "v"); !errors.Is(err, storage.ErrChunkLayerFenced) { + t.Fatalf("claim error=%v", err) + } + if !remote.raced { + t.Fatal("controlled CAS did not run") + } + e := newProcessExit(ctx) + if !chooseChunkStartupExit(e, flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v"}, h, p) { + t.Fatal("fenced claim did not choose an exit") + } + select { + case out := <-e.decision: + if out.code != tc.want { + t.Fatalf("displaced E%d/C at assigned E3/B chose %+v, want %d", tc.epoch, out, tc.want) + } + case <-ctx.Done(): + t.Fatal(ctx.Err()) + } + head, err := base.GetHead(ctx) + if err != nil || head.Gen != 2 || head.Epoch != tc.epoch || head.Holder != "C" || base.Puts() != 0 { + t.Fatalf("refused claim mutated HEAD/payload: %+v puts=%d err=%v", head, base.Puts(), err) + } + for _, status := range p.DurableStatuses() { + if status.Operational { + t.Fatal("displaced claim served I/O") + } + } + }) + } +} From 7dfa3127c1b7330b5e243c284f5e9fc03238e0e9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:25:28 -0800 Subject: [PATCH 079/204] fix: require assigned epoch for foreign claim no-retry proof --- seaweed-block/core/frontend/durable/provider_chunk.go | 10 ++++++++-- seaweed-block/docs/design/invariants.md | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 91f5e9e1fe..17e438f558 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -453,7 +453,7 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h // INV-WS-STARTUP-RETRY-001: at or above this assignment, // the foreign holder is a supersede proof. A lower epoch is // the existing move-back/stale-root diagnostic, never 78. - if head.Epoch >= cfg.Epoch { + if claimHeadSupersedes(head, cfg) { err = fmt.Errorf("%w: %w", err, errChunkForeignClaim) } log.Printf("durable: refusing to attach volume=%s root=%s: HEAD holder=%q gen=%d epoch=%d is not this holder %q (remove or quarantine the local root)", @@ -509,7 +509,7 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h if err != nil { // INV-WS-STARTUP-RETRY-001: only the claim's exact foreign-holder // proof permits no-retry; a higher epoch of our own holder retries. - if errors.Is(err, storage.ErrChunkLayerFenced) && head.Gen != 0 && head.Holder != "" && head.Holder != cfg.Holder { + if errors.Is(err, storage.ErrChunkLayerFenced) && claimHeadSupersedes(head, cfg) { err = errors.Join(err, errChunkForeignClaim) } log.Printf("durable: HEAD claim for volume=%s failed after %s: %v", volumeID, time.Since(claimStart), err) @@ -1500,3 +1500,9 @@ func (w *cutWaitSlot) status(cutSeq uint64) CutScheduleStatus { } return st } + +// INV-WS-STARTUP-RETRY-001: a displaced lower-epoch claim fences this +// attempt, but cannot prove the assigned holder was superseded. +func claimHeadSupersedes(head storage.ChunkHead, cfg storage.ChunkLayerConfig) bool { + return head.Gen != 0 && head.Holder != "" && head.Holder != cfg.Holder && head.Epoch >= cfg.Epoch +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index d9807cda7e..52f9338efc 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -100,7 +100,7 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current holder/epoch, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001` | -| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; only a newer master fact naming another replica exits 78. Planned drain retires startup monitoring before cleanup; ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; a newer other-replica master fact or exact foreign HEAD at or above the assigned epoch permits 78. Planned drain retires startup monitoring before cleanup; ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -671,9 +671,9 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or a refused claim proving another HEAD holder permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | -- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder. The provider binds the latter proof to its recovery generation. On an existing root, a foreign HEAD at or above the assigned epoch proves supersede; a lower-epoch foreign HEAD retains the move-back diagnostic. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. - 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 2 s RPC timeout. The existing 3 s closeout wait 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. From 2e2d7adf763cd4b9eb04514de91867b1f59639ed Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:35:56 -0800 Subject: [PATCH 080/204] docs: map displaced claim regression to startup retry invariant --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 52f9338efc..908d0c79de 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -671,7 +671,7 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. - 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. From e5e316bf9fd90d96fd80062955c401dbced992f8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:40:11 -0800 Subject: [PATCH 081/204] docs: explain startup and runtime supersede evidence scope --- seaweed-block/docs/design/invariants.md | 1 + 1 file changed, 1 insertion(+) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 908d0c79de..8cdc67b999 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -674,6 +674,7 @@ Notes: | `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- Part T evidence scope: startup `chooseChunkStartupExit` ORs the newer other-replica master line with the recovery-generation-bound refused-claim HEAD proof. Runtime lease-end `workspaceRetryOutcome` has no new claim attempt supplying such a proof, so it uses only the master line and otherwise retries 75; absence of a HEAD proof never implies 78. - 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 2 s RPC timeout. The existing 3 s closeout wait 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. From 652013444601b1c88f0a67f08c8607e6a620d481 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:09:23 -0800 Subject: [PATCH 082/204] docs: Part T binds shared terms to one deciding function each Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c566e3b11..c17b6f0c74 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -30,6 +30,7 @@ The design is described in three documents, and this one collects their machines - [Part C. Change rules](#part-c-change-rules) - [Part D. Wait ownership](#part-d-wait-ownership) - [Part E. Quantities](#part-e-quantities) +- [Part T. Terms bound to code](#part-t-terms-bound-to-code) --- @@ -956,3 +957,35 @@ Frozen estimate reporting: a tail above the existing 60 s estimator ceiling repo | Quantity | Unit | Cap | Enforced at (producer) | Drained | Outcome at the cap | |---|---|---|---|---|---| | COW side-file spill per cut | bytes | min(`COWSpillLimit` (default 1 GiB, or the host limit's COW bytes), free space on `--durable-root` / 2 - 1 GiB), at least 0; the free space is read once per cut and that cap bounds both staging and the copy window; off Linux, the configured cap. Shown per cut in the layer stats (`COWSpillCap`, `COWSpillCapReason`: `no_room_to_cut` when the free space is within the reserve, `free_space_unreadable` when the read fails) | the saver: `core/storage/chunk_cut_cow.go` `readCutSpill`, the save's cap check | at the cut's end (the side file is removed on publish, abort or close) | that cut aborts (retryable), counted as `cow_capacity`, or as `no_room_to_cut` / `free_space_unreadable` when the free space made the cap 0; the guest write completes and nothing partial is published | + +## Part T. Terms bound to code + +Some facts are read by many parts of the code: who the holder is, whether the lease is valid, whether the volume may serve. Each such fact is a term. For each term this part lists the fields that carry it, the one function that decides it on each side, and the role that owns it. **A second derivation of a term is a defect.** Code that needs a term calls its deciding function, or a function that only wraps that call. It never compares the term's fields again itself. Known second derivations are listed in each row together with the pull request that removes them, or "open". + +A reviewer applies the rule to every pull request: + +1. If the diff reads or compares a field listed in a row anywhere other than that row's deciding function, it must call the deciding function instead. Otherwise it changes the row in the same pull request, and the description says why. +2. A pull request that removes a listed second derivation also deletes it from the row. A pull request that adds a new one is refused, unless it adds the new derivation to the row as open, with a reason. +3. Renaming, moving or splitting a deciding function updates its row in the same pull request. + +A row that names a function existing only on an open pull request says so ("on #N"). The qualifier is dropped when that pull request merges. Code references name a file and a function, as in the rest of this document. A checker will later verify that every deciding function named here exists on `main`. + +10 rows for 5 terms. They name 13 deciding functions: 10 on `main` and 3 only on open pull requests (2 on #411, 1 on #409). One row (`TERM-STOP-STALE-ROOT-001`) has no named function yet. + +| Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | +|---|---|---|---|---|---| +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computes the line's owner server twice: `holderMatches` reads `PublishedLine.IssuedHost` and falls back to `placementSourceHost`, while the fact's `server_id` and the move source come from `Host.workspaceSourceHost` (the move journal first, then `placementSourceHost`): open. `workspaceHeadAdmits` compares the HEAD holder, built from the volume's `--server-id` flag, with the registry server id, and nothing checks that the two are the same string: open. `DurableProvider.chunkHolder` (`core/frontend/durable/provider_seal_replay.go`) falls back to the replica id alone when no holder is configured: open. | authority (master side); volume host (volume side) | +| `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | +| `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. `StorageBackend.gate` is the per-I/O AND of the two sides. | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410's `backendAdmitsIO` reads only `VolumeStatus.Operational`, once, and not the guarded projection: open (it should read the one AND). A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | +| `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | +| `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | +| `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup leaves the lease renewing and the process running: open. Only a refused startup claim exits, with 78, on #409. | chunk layer | +| `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host | +| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | +| `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | +| `TERM-ONE-PROCESS-001` One live process per holder | At most one blockvolume process serves a holder at a time. Today a second process is refused only when it opens the same store file. A local-root nonce in the holder identity is to close the other cases (pending). | The store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); its exclusive OS file lock; the HEAD `Holder` | Volume: `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the lock's limit: it covers one file. A second process is not refused when it uses another `--durable-root`, runs on another host with the same server id, or runs on a copied root. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open, pending the local-root nonce. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | + +Notes: + +- `TERM-SERVING-001` and `TERM-STOP-*`: in this release a workspace primary that can no longer serve should stop, not linger. Today `TERM-STOP-HEAD-FENCED-001` and `TERM-STOP-STALE-ROOT-001` leave the process up and its lease renewing. A forced move then waits for that lease. The open entries in those rows track this. +- `TERM-HOLDER-001`: supporting replicas (RF greater than 1) are not holders, and their replica-keyed checks (`AdapterProjectionView.supportingReplicaReady`) are outside this row. From 7cf8c8c961710737d17475af47aa4fcae4bdd56a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:11:03 -0800 Subject: [PATCH 083/204] docs: Part T, the HEAD fence after startup exits on #410 Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index c17b6f0c74..9501fb6555 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -979,7 +979,7 @@ A row that names a function existing only on an open pull request says so ("on # | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. `StorageBackend.gate` is the per-I/O AND of the two sides. | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410's `backendAdmitsIO` reads only `VolumeStatus.Operational`, once, and not the guarded projection: open (it should read the one AND). A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | -| `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup leaves the lease renewing and the process running: open. Only a refused startup claim exits, with 78, on #409. | chunk layer | +| `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | | `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host | | `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | From 329c42bc9cd5fe02fd2c7802c211a297a0d058f6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:20:59 -0800 Subject: [PATCH 084/204] test: host shutdown fence must record the guard terminal cause --- .../host/volume/workspace_terminal_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/seaweed-block/core/host/volume/workspace_terminal_test.go b/seaweed-block/core/host/volume/workspace_terminal_test.go index 8c12c94994..dcfc11e467 100644 --- a/seaweed-block/core/host/volume/workspace_terminal_test.go +++ b/seaweed-block/core/host/volume/workspace_terminal_test.go @@ -76,3 +76,41 @@ func TestWorkspaceCanceledReplyCannotPublishGrant(t *testing.T) { t.Error("canceled reply published a serving grant") } } + +// A synchronous host fence must use the guard's first-cause latch even +// before runtime publication; installation must carry that terminal cause. +func TestWorkspaceHostFencePublishesOneTerminalCause(t *testing.T) { + h := workspaceRuntimeHost(t, runtimeWire(t, &runtimeLeaseServer{ttl: time.Second}), true) + h.FenceWorkspaceLease() + g := h.view.workspaceGuard.Load() + if g == nil { + t.Fatal("host fence has no guard-owned terminal cause") + } + first := g.FenceCause() + if first == "" { + t.Fatal("host fence bypassed the guard first-cause latch") + } + h.FenceWorkspaceLease() + if g.FenceCause() != first || h.ProjectionView().Projection().Healthy { + t.Fatal("repeated fence changed cause or reopened admission") + } +} +func TestWorkspaceInstalledHostFenceRecordsCause(t *testing.T) { + wire := &runtimeLeaseServer{ttl: time.Second} + h := workspaceRuntimeHost(t, runtimeWire(t, wire), true) + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan error, 1) + t.Cleanup(func() { cancel(); _ = runtimeDone(t, done) }) + go func() { + done <- h.RunWorkspaceLease(ctx, func(context.Context, *control.WorkspaceIdentity) (uint64, error) { return 7, nil }) + }() + runtimeAwait(t, "installed serving lease", func() bool { return h.ProjectionView().Projection().Healthy }) + g := h.view.workspaceGuard.Load() + h.FenceWorkspaceLease() + if g.FenceCause() == "" { + t.Error("installed host fence bypassed fenceLocked") + } + if h.ProjectionView().Projection().Healthy { + t.Error("host fence still admits I/O") + } +} From 1da0c2905dbbb1e1033cbf64ed26b296c82ddfc6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:22:28 -0800 Subject: [PATCH 085/204] fix: use guard fence ownership and one workspace exit decision --- seaweed-block/cmd/blockvolume/process_exit.go | 21 ++++++++--------- seaweed-block/core/host/volume/host.go | 3 +-- .../core/host/volume/workspace_runtime.go | 23 ++++++++++++++----- .../host/volume/workspace_terminal_test.go | 3 +++ .../docs/design/agent-workspace-design.md | 2 ++ seaweed-block/docs/design/invariants.md | 5 ++-- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index f19b2c6b71..f1f5925e3b 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -118,10 +118,10 @@ func reportWorkspaceExit(out workspaceExit) int { return out.code } -// INV-WS-STARTUP-RETRY-001: only a newer other-replica authority fact -// permits no-retry. Host owns the lineage observation and shared predicate. -func workspaceRetryOutcome(reason string, h *volume.Host) workspaceExit { - if h.IsCurrentReplicaSuperseded() { +// INV-WS-STARTUP-RETRY-001: one decision combines a newer other-replica +// authority fact and the provider's generation-bound foreign-HEAD proof. +func workspaceRetryOutcome(reason string, h *volume.Host, claimSuperseded bool) workspaceExit { + if claimSuperseded || h.IsCurrentReplicaSuperseded() { return workspaceExit{exitWorkspaceSuperseded, "superseded"} } return workspaceExit{exitWorkspaceRetry, reason} @@ -161,7 +161,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan e.stopChunkStartup() out := workspaceExit{reason: "revoked"} if !h.WorkspaceLeaseRevoking() { - out = workspaceRetryOutcome("lease_expired", h) + out = workspaceRetryOutcome("lease_expired", h, false) } if out.code != 0 { e.choose(out) @@ -170,7 +170,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan case err := <-done: e.stopChunkStartup() fmt.Fprintln(os.Stderr, "blockvolume: workspace lease stopped:", err) - e.choose(workspaceRetryOutcome("lease_expired", h)) + e.choose(workspaceRetryOutcome("lease_expired", h, false)) return nil, nil } } @@ -210,11 +210,8 @@ func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p chunkStar if !failed { return false } - out := workspaceRetryOutcome("assignment_timeout", h) - // INV-WS-STARTUP-RETRY-001: a claim's foreign-holder proof is - // independent of the master stream; generation is rechecked below. - if p.ChunkStartupSuperseded(f.volumeID, gen) { - out = workspaceExit{exitWorkspaceSuperseded, "superseded"} - } + // INV-WS-STARTUP-RETRY-001: one exit decision consumes both proof + // sources; the provider rechecks the claim generation below. + out := workspaceRetryOutcome("assignment_timeout", h, p.ChunkStartupSuperseded(f.volumeID, gen)) return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.chooseChunkStartup(out) }) } diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index b7591515d8..9466b02ded 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -176,8 +176,7 @@ type Host struct { workspaceLeaseStarted atomic.Bool // Guard installation and terminal host fencing share this lock. Order: // workspaceLeaseMu -> guard.mu; never hold either across RPC or drain. - workspaceLeaseMu sync.Mutex - workspaceLeaseFenced bool + workspaceLeaseMu sync.Mutex // workspaceStopPending is the guard's stop-pending mode, kept here for a // guard installed later; workspaceStopAttempt numbers detach attempts so // only the latest one's resume clears it. diff --git a/seaweed-block/core/host/volume/workspace_runtime.go b/seaweed-block/core/host/volume/workspace_runtime.go index d6fad91ccf..775810b746 100644 --- a/seaweed-block/core/host/volume/workspace_runtime.go +++ b/seaweed-block/core/host/volume/workspace_runtime.go @@ -43,7 +43,14 @@ func (h *Host) runWorkspaceLease(ctx context.Context, stop func(context.Context, h.workspaceLeaseMu.Lock() // The guard is not yet shared: publish it already fenced if a // synchronous shutdown won the race with this installer. - guard.fenced = h.workspaceLeaseFenced || ctx.Err() != nil + if prior := h.view.workspaceGuard.Load(); prior != nil { + // Before this one-shot install, only FenceWorkspaceLease can + // publish a guard: its terminal cause must survive installation. + guard.fenceLocked(prior.FenceCause()) + } + if ctx.Err() != nil { + guard.fenceLocked("shutdown requested (context cancelled)") + } guard.stopPending = h.workspaceStopPending h.view.workspaceGuard.Store(guard) h.workspaceLeaseMu.Unlock() @@ -103,12 +110,16 @@ func (h *Host) WorkspaceStopResumed(volumeID string, attempt uint64) { func (h *Host) FenceWorkspaceLease() { h.workspaceLeaseMu.Lock() defer h.workspaceLeaseMu.Unlock() - h.workspaceLeaseFenced = true - if g := h.view.workspaceGuard.Load(); g != nil { - g.mu.Lock() - g.fenced = true - g.mu.Unlock() + // INV-WS-STARTUP-RETRY-001: the guard owns the only terminal latch, + // including shutdown before its runtime installation. + g := h.view.workspaceGuard.Load() + if g == nil { + g = &WorkspaceLeaseGuard{} } + g.mu.Lock() + g.fenceLocked("host shutdown requested") + g.mu.Unlock() + h.view.workspaceGuard.Store(g) } // WorkspaceLeaseRevoking distinguishes the ACK-owning planned drain from a diff --git a/seaweed-block/core/host/volume/workspace_terminal_test.go b/seaweed-block/core/host/volume/workspace_terminal_test.go index dcfc11e467..6bc031f272 100644 --- a/seaweed-block/core/host/volume/workspace_terminal_test.go +++ b/seaweed-block/core/host/volume/workspace_terminal_test.go @@ -42,6 +42,9 @@ func TestWorkspaceFenceBeforeHeldInstallIsTerminal(t *testing.T) { _ = runtimeDone(t, done) t.Fatal("fenced installer did not settle") } + if g := h.view.workspaceGuard.Load(); g == nil || g.FenceCause() != "host shutdown requested" { + t.Fatal("installation lost the synchronous fence cause") + } if stops.Load() != 1 || h.ProjectionView().Projection().Healthy { t.Fatal("fence failed to stop installed guard", stops.Load()) } diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 833168a6a4..9601926f6b 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -531,3 +531,5 @@ The existing-local-root precheck uses the same distinction: another holder at or above the assigned epoch is positive supersede evidence; an older foreign publication remains the existing move-back diagnostic. Neither path serves or publishes the local WAL, which remains on disk for diagnosis. + +Part T ownership: the lease guard alone holds the terminal fence and its first cause. A host shutdown before runtime installation publishes only a fenced, zero-validity guard; installation carries that cause into the valid-identity guard and never renews it. Startup and runtime exit callers both use workspaceRetryOutcome; only startup can supply a generation-bound refused-claim HEAD proof. diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 8cdc67b999..927a61773d 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -189,7 +189,7 @@ stateDiagram-v2 | From | To | Guard | Enforced in | Protects | |---|---|---|---|---| | NoLease, Valid | Valid | the reply names this `{volume, replica, epoch}`, its validity is positive and at most 30 s, and it arrives before the old deadline; the new deadline is anchored to the request start | `core/host/volume/workspace_lease.go` `Refresh` | `INV-WS-LEASE-001`, `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001` | -| Valid, StopPending | Fenced | the local deadline passes (checked on every projection read), the reply is invalid, or the lease is revoking; a fenced guard never reopens | `core/host/volume/workspace_lease.go` `permits`, `Refresh` | `INV-WS-LEASE-001` | +| NoLease, Valid, StopPending | Fenced | the local deadline passes (checked on every projection read), the reply is invalid, the lease is revoking, or synchronous host shutdown fences through the guard; first cause is kept and a fenced guard never reopens | `core/host/volume/workspace_lease.go` `permits`, `Refresh`, `fenceLocked`; `core/host/volume/workspace_runtime.go` `FenceWorkspaceLease` | `INV-WS-LEASE-001` | | 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` | @@ -674,7 +674,8 @@ Notes: | `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. -- Part T evidence scope: startup `chooseChunkStartupExit` ORs the newer other-replica master line with the recovery-generation-bound refused-claim HEAD proof. Runtime lease-end `workspaceRetryOutcome` has no new claim attempt supplying such a proof, so it uses only the master line and otherwise retries 75; absence of a HEAD proof never implies 78. +- Part T evidence scope: `workspaceRetryOutcome` is the one retry/no-retry decision. Startup `chooseChunkStartupExit` supplies the recovery-generation-bound refused-claim HEAD proof; runtime lease-end supplies none. Both combine that input with the newer other-replica master line; absent proof means retry 75. +- 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 2 s RPC timeout. The existing 3 s closeout wait 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. From 9efdea867d4fe23527542f376c9a41b84bee1f38 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:25:15 -0800 Subject: [PATCH 086/204] docs: Part T, serving is decided by StorageBackend.AdmitsIO (on #410) Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 9501fb6555..f2f95ba8e9 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -976,7 +976,7 @@ A row that names a function existing only on an open pull request says so ("on # |---|---|---|---|---|---| | `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computes the line's owner server twice: `holderMatches` reads `PublishedLine.IssuedHost` and falls back to `placementSourceHost`, while the fact's `server_id` and the move source come from `Host.workspaceSourceHost` (the move journal first, then `placementSourceHost`): open. `workspaceHeadAdmits` compares the HEAD holder, built from the volume's `--server-id` flag, with the registry server id, and nothing checks that the two are the same string: open. `DurableProvider.chunkHolder` (`core/frontend/durable/provider_seal_replay.go`) falls back to the replica id alone when no holder is configured: open. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | -| `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. `StorageBackend.gate` is the per-I/O AND of the two sides. | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410's `backendAdmitsIO` reads only `VolumeStatus.Operational`, once, and not the guarded projection: open (it should read the one AND). A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | +| `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | | `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | From b2ddf6206aa85dd517b298b52a6cb3adfa28ecd5 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:32:08 -0800 Subject: [PATCH 087/204] test: the barrier-wait start at 40 s; the refusal of another server's assignment counts Co-Authored-By: Claude Opus 5.5 --- .../blockvolume/procedure_gate_integration_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 24861cdebf..34e8ac3668 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -171,8 +171,8 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { } time.Sleep(time.Second) } - if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") { - failures = append(failures, "it logged neither the stale-root refusal nor stale authority") + if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") && !back.has("is not this process") { + failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") } if len(failures) > 0 { t.Errorf("the returning old host after the forced move: %s", strings.Join(failures, "; ")) @@ -218,9 +218,9 @@ func TestProcedureRevokeWithoutACKThenForcedMove(t *testing.T) { } // TestProcedureStartInsideTheBarrierWaitIsReGranted: the holder's process -// dies and is started again 35 s later: its lease has ended, the re-grant -// barrier (at most 65 s after the stop, default flags) has not passed, and -// the barrier passes within the process's 30 s authority wait. It must not +// dies and is started again 40 s later: its lease has ended, the re-grant +// barrier (at least 50 s and at most 65 s after the stop, default flags) has +// not passed, and it passes within the process's 30 s authority wait. It must not // serve while its renewals are still refused for the barrier; once // re-granted it serves its local WAL at the same epoch. func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { @@ -230,7 +230,7 @@ func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { block := pattern("inside-the-wait!") env.writeBlock(t, "s1", 0, block) first.kill(t) - time.Sleep(35 * time.Second) + time.Sleep(40 * time.Second) back := env.start(t, "blockvolume-s1-back", "s1") var ready []time.Time From e31d2fb8a9ae7a83d8c60605b6d9e1adf05131b8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:32:38 -0800 Subject: [PATCH 088/204] docs: Part T, the line owner is decided by Host.workspaceLineOwner (on #423) Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index f2f95ba8e9..53efd94cdd 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -974,7 +974,7 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| -| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computes the line's owner server twice: `holderMatches` reads `PublishedLine.IssuedHost` and falls back to `placementSourceHost`, while the fact's `server_id` and the move source come from `Host.workspaceSourceHost` (the move journal first, then `placementSourceHost`): open. `workspaceHeadAdmits` compares the HEAD holder, built from the volume's `--server-id` flag, with the registry server id, and nothing checks that the two are the same string: open. `DurableProvider.chunkHolder` (`core/frontend/durable/provider_seal_replay.go`) falls back to the replica id alone when no holder is configured: open. | authority (master side); volume host (volume side) | +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | From d5c8d761458a9da27d25c3e4ad4a8fcd1dbee90d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:34:59 -0800 Subject: [PATCH 089/204] test: reproduce own handoff poisoned before readiness replay --- .../host/volume/assignment_holder_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 943c3b72a6..cbbcb39412 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -128,3 +128,33 @@ func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) { }) } } + +// INV-AUTH-HOLDER-IDENTITY-001 / M3 Unassigned -> Primary: recovery replay +// of a valid new holder must not inherit a foreign-holder fence from an +// endpoint-mismatched delivery naming that same server and replica. +func TestAssignmentHolderIdentityPlannedHandoffBeforeReadiness(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + h.BlockLocalReadiness("awaiting durable recovery") + own := holderAssignment(t, "new-host") + h.applyFact(own) + mismatch := holderAssignment(t, "new-host") + mismatch.DataAddr = "127.0.0.1:9991" + h.applyFact(mismatch) + if h.realAdpt.Projection().Epoch != 0 { + t.Fatal("assignment entered adapter before readiness") + } + h.ClearLocalReadinessBlock() + h.SetReplicationVolume(nil) + h.replayLocalReadinessFactIfReady() + deadline := time.Now().Add(time.Second) + for !h.view.Projection().Healthy && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if p := h.view.Projection(); !p.Healthy || p.Epoch != 2 { + t.Fatalf("own clean-move assignment stayed fenced after readiness replay: %+v; other=%+v", p, h.LastOtherLine()) + } +} From da9d92c691d399921d7225df992f9e1b00fca349 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:35:52 -0800 Subject: [PATCH 090/204] fix: recover own endpoint refusal on valid readiness replay --- .../core/host/volume/assignment_holder.go | 14 +++++++++ .../host/volume/assignment_holder_test.go | 30 +++++++++++++++++++ seaweed-block/core/host/volume/host.go | 2 ++ seaweed-block/docs/design/invariants.md | 4 +-- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index c2f6928268..dedbc7ec0c 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -10,3 +10,17 @@ func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { (f.GetDataAddr() == "" || f.GetDataAddr() == h.cfg.DataAddr) && (f.GetCtrlAddr() == "" || f.GetCtrlAddr() == h.cfg.CtrlAddr) } + +// clearOwnEndpointRefusal implements M3's successful self-primary admission +// under INV-AUTH-HOLDER-IDENTITY-001. A rejected endpoint is not a different +// holder: a subsequent valid fact may supersede it, but never a foreign-server +// fence or a newer lineage. Caller has validated assignmentNamesSelf. +func (h *Host) clearOwnEndpointRefusal(f *control.AssignmentFact) { + h.otherMu.Lock() + defer h.otherMu.Unlock() + old := h.lastOther + if old != nil && old.GetServerId() == h.cfg.ServerID && old.GetReplicaId() == h.cfg.ReplicaID && + (f.Epoch > old.Epoch || f.Epoch == old.Epoch && f.EndpointVersion >= old.EndpointVersion) { + h.lastOther = nil + } +} diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index cbbcb39412..12d76bbf41 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -1,6 +1,7 @@ package volume import ( + "fmt" "strings" "testing" "time" @@ -158,3 +159,32 @@ func TestAssignmentHolderIdentityPlannedHandoffBeforeReadiness(t *testing.T) { t.Fatalf("own clean-move assignment stayed fenced after readiness replay: %+v; other=%+v", p, h.LastOtherLine()) } } + +// A same-holder endpoint refusal can be superseded only by a valid current +// fact; neither a true foreign holder nor a newer refusal is erased. +func TestAssignmentHolderIdentityReplayCannotClearForeignOrNewerFence(t *testing.T) { + for _, foreign := range []bool{false, true} { + t.Run(fmt.Sprint("foreign=", foreign), func(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + h.BlockLocalReadiness("awaiting durable recovery") + h.applyFact(holderAssignment(t, "new-host")) + refused := holderAssignment(t, "new-host") + if foreign { + refused.ServerId = "another-host" + } else { + refused.DataAddr = "127.0.0.1:9991" + refused.EndpointVersion = 2 + } + h.applyFact(refused) + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + if h.LastOtherLine() == nil || !h.IsSuperseded("r1", 2, 1) || h.view.Projection().Healthy { + t.Fatal("replay erased a foreign or newer fence") + } + }) + } +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 042c731eba..a642dae41c 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -862,6 +862,8 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { return } + h.clearOwnEndpointRefusal(fact) + // The recovery watchdog runs from the primary assignment, before any // admission step can fail (#128 rule 6). h.wd.primaryAssigned(fact.Epoch) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index cd3380a110..808d417cb2 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; a valid equal/newer self fact clears only a prior same-holder endpoint refusal (never a foreign holder or newer line); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `clearOwnEndpointRefusal`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch`, `TestAssignmentHolderIdentityPlannedHandoffBeforeReadiness`, `TestAssignmentHolderIdentityReplayCannotClearForeignOrNewerFence` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 66e0dae7ffcf560a97c3fc5f6f3bbeeda90e0097 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:38:52 -0800 Subject: [PATCH 091/204] test: withdraw endpoint special case and pin foreign stream ordering --- .../core/host/volume/assignment_holder.go | 14 --- .../host/volume/assignment_holder_test.go | 107 ++++++++++-------- seaweed-block/core/host/volume/host.go | 2 - seaweed-block/docs/design/invariants.md | 4 +- 4 files changed, 61 insertions(+), 66 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index dedbc7ec0c..c2f6928268 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -10,17 +10,3 @@ func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { (f.GetDataAddr() == "" || f.GetDataAddr() == h.cfg.DataAddr) && (f.GetCtrlAddr() == "" || f.GetCtrlAddr() == h.cfg.CtrlAddr) } - -// clearOwnEndpointRefusal implements M3's successful self-primary admission -// under INV-AUTH-HOLDER-IDENTITY-001. A rejected endpoint is not a different -// holder: a subsequent valid fact may supersede it, but never a foreign-server -// fence or a newer lineage. Caller has validated assignmentNamesSelf. -func (h *Host) clearOwnEndpointRefusal(f *control.AssignmentFact) { - h.otherMu.Lock() - defer h.otherMu.Unlock() - old := h.lastOther - if old != nil && old.GetServerId() == h.cfg.ServerID && old.GetReplicaId() == h.cfg.ReplicaID && - (f.Epoch > old.Epoch || f.Epoch == old.Epoch && f.EndpointVersion >= old.EndpointVersion) { - h.lastOther = nil - } -} diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 12d76bbf41..c91b7bde44 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -1,8 +1,8 @@ package volume import ( - "fmt" "strings" + "sync/atomic" "testing" "time" @@ -130,60 +130,71 @@ func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) { } } -// INV-AUTH-HOLDER-IDENTITY-001 / M3 Unassigned -> Primary: recovery replay -// of a valid new holder must not inherit a foreign-holder fence from an -// endpoint-mismatched delivery naming that same server and replica. -func TestAssignmentHolderIdentityPlannedHandoffBeforeReadiness(t *testing.T) { - h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) - if err != nil { - t.Fatal(err) - } - t.Cleanup(func() { _ = h.Close() }) - h.BlockLocalReadiness("awaiting durable recovery") - own := holderAssignment(t, "new-host") - h.applyFact(own) - mismatch := holderAssignment(t, "new-host") - mismatch.DataAddr = "127.0.0.1:9991" - h.applyFact(mismatch) - if h.realAdpt.Projection().Epoch != 0 { - t.Fatal("assignment entered adapter before readiness") - } - h.ClearLocalReadinessBlock() - h.SetReplicationVolume(nil) - h.replayLocalReadinessFactIfReady() - deadline := time.Now().Add(time.Second) - for !h.view.Projection().Healthy && time.Now().Before(deadline) { - time.Sleep(time.Millisecond) - } - if p := h.view.Projection(); !p.Healthy || p.Epoch != 2 { - t.Fatalf("own clean-move assignment stayed fenced after readiness replay: %+v; other=%+v", p, h.LastOtherLine()) - } -} +type holderFenceCounter struct{ calls atomic.Uint32 } -// A same-holder endpoint refusal can be superseded only by a valid current -// fact; neither a true foreign holder nor a newer refusal is erased. -func TestAssignmentHolderIdentityReplayCannotClearForeignOrNewerFence(t *testing.T) { - for _, foreign := range []bool{false, true} { - t.Run(fmt.Sprint("foreign=", foreign), func(t *testing.T) { +func (f *holderFenceCounter) FenceAsPrimary(uint64) error { f.calls.Add(1); return nil } +func (f *holderFenceCounter) AdmitAsReplica(uint64) error { f.calls.Add(1); return nil } + +// INV-AUTH-HOLDER-IDENTITY-001 / M3: a recorded foreign fact supersedes +// only an adopted own lineage and only when it is strictly newer. +func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { + for _, mode := range []string{"target-old-first", "served-newer-foreign", "served-old-replay", "never-assigned"} { + t.Run(mode, func(t *testing.T) { h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) if err != nil { t.Fatal(err) } t.Cleanup(func() { _ = h.Close() }) - h.BlockLocalReadiness("awaiting durable recovery") - h.applyFact(holderAssignment(t, "new-host")) - refused := holderAssignment(t, "new-host") - if foreign { - refused.ServerId = "another-host" - } else { - refused.DataAddr = "127.0.0.1:9991" - refused.EndpointVersion = 2 + fencer := &holderFenceCounter{} + if err := h.SetSelfFence(fencer); err != nil { + t.Fatal(err) } - h.applyFact(refused) - h.ClearLocalReadinessBlock() - h.replayLocalReadinessFactIfReady() - if h.LastOtherLine() == nil || !h.IsSuperseded("r1", 2, 1) || h.view.Projection().Healthy { - t.Fatal("replay erased a foreign or newer fence") + own := holderAssignment(t, "new-host") + foreign := holderAssignment(t, "old-host") + foreign.Epoch = 1 + waitHealthy := func() { + t.Helper() + deadline := time.Now().Add(time.Second) + for !h.view.Projection().Healthy && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if p := h.view.Projection(); !p.Healthy || p.Epoch != 2 { + t.Fatalf("rightful target did not serve: %+v", p) + } + } + switch mode { + case "target-old-first": + h.BlockLocalReadiness("awaiting durable recovery") + h.applyFact(foreign) + if fencer.calls.Load() != 0 || h.IsSuperseded("r1", 0, 0) { + t.Fatal("unassigned target was fenced by the current old line") + } + h.applyFact(own) + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + waitHealthy() + case "never-assigned": + h.applyFact(foreign) + foreign.Epoch = 2 + h.applyFact(foreign) + if fencer.calls.Load() != 0 || h.realAdpt.Projection().Epoch != 0 || h.view.Projection().Healthy || h.IsSuperseded("r1", 0, 0) || h.LastOtherLine() == nil { + t.Fatal("never-assigned process must record, wait, neither adopt nor fence") + } + default: + h.applyFact(own) + waitHealthy() + before := fencer.calls.Load() + if mode == "served-newer-foreign" { + foreign.Epoch = 3 + } + h.applyFact(foreign) + if mode == "served-newer-foreign" { + if fencer.calls.Load() <= before || h.view.Projection().Healthy { + t.Fatal("served holder was not fenced by newer foreign line") + } + } else if fencer.calls.Load() != before || !h.view.Projection().Healthy { + t.Fatal("old foreign replay fenced a serving holder") + } } }) } diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index a642dae41c..042c731eba 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -862,8 +862,6 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { return } - h.clearOwnEndpointRefusal(fact) - // The recovery watchdog runs from the primary assignment, before any // admission step can fail (#128 rule 6). h.wd.primaryAssigned(fact.Epoch) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 808d417cb2..cd3380a110 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; a valid equal/newer self fact clears only a prior same-holder endpoint refusal (never a foreign holder or newer line); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `clearOwnEndpointRefusal`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch`, `TestAssignmentHolderIdentityPlannedHandoffBeforeReadiness`, `TestAssignmentHolderIdentityReplayCannotClearForeignOrNewerFence` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 1d4e29a07a6b4d25e9e47eb95a00a2f90a99cc5d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:39:13 -0800 Subject: [PATCH 092/204] fix: fence foreign facts only after adopted lineage is superseded --- .../core/host/volume/assignment_holder.go | 20 +++++++++++++++++++ seaweed-block/core/host/volume/host.go | 13 ++++-------- seaweed-block/docs/design/invariants.md | 4 ++-- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index c2f6928268..ddac223cec 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -10,3 +10,23 @@ func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { (f.GetDataAddr() == "" || f.GetDataAddr() == h.cfg.DataAddr) && (f.GetCtrlAddr() == "" || f.GetCtrlAddr() == h.cfg.CtrlAddr) } + +// observeForeignHolder implements M3 / INV-AUTH-HOLDER-IDENTITY-001. +// Delivery before a move is not supersession: record every refused fact, +// and use the one supersession decision against the adopted engine lineage. +func (h *Host) observeForeignHolder(f *control.AssignmentFact) { + h.recordOtherLine(f) + if h.view == nil { + return + } + own := h.view.EngineProjection() + if !h.IsSuperseded(h.cfg.ReplicaID, own.Epoch, own.EndpointVersion) { + h.log.Printf("blockvolume: volume %s foreign assignment server=%q replica=%q recorded, not adopted; waiting for own current line", h.cfg.VolumeID, f.ServerId, f.ReplicaId) + return + } + h.wd.notPrimary() + if err := h.fenceSelfWithPeers(selfRolePrimary, f.Epoch, false); err != nil { + h.log.Printf("blockvolume: foreign holder ingress fence: %v", err) + } + h.log.Printf("blockvolume: volume %s superseded by assignment server=%q replica=%q; fenced, not serving", h.cfg.VolumeID, f.ServerId, f.ReplicaId) +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 042c731eba..5704165606 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -520,12 +520,12 @@ func (h *Host) getReplication() replicaSetUpdater { } // IsSuperseded gates a newer foreign replica line, or a same-replica foreign -// server/endpoint identity at or above the local lineage. An explicitly +// server/endpoint identity strictly newer than an adopted local lineage. An explicitly // matching self identity remains an ordinary adapter update. func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool { h.otherMu.Lock() defer h.otherMu.Unlock() - if h.lastOther == nil { + if h.lastOther == nil || selfEpoch == 0 { return false } other := h.lastOther @@ -533,7 +533,7 @@ func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool if h.assignmentNamesSelf(other) { return false } - return other.Epoch > selfEpoch || other.Epoch == selfEpoch && other.EndpointVersion >= selfEV + return other.Epoch > selfEpoch || other.Epoch == selfEpoch && other.EndpointVersion > selfEV } if other.Epoch > selfEpoch { return true @@ -810,12 +810,7 @@ func (h *Host) streamOnce(ctx context.Context) error { func (h *Host) applyFact(fact *control.AssignmentFact) { // INV-AUTH-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host. if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) { - h.wd.notPrimary() - h.recordOtherLine(fact) - if err := h.fenceSelfWithPeers(selfRolePrimary, fact.Epoch, false); err != nil { - h.log.Printf("blockvolume: foreign holder ingress fence: %v", err) - } - h.log.Printf("blockvolume: volume %s assignment server=%q replica=%q is not this process server=%q; fenced, not serving; never adopted", h.cfg.VolumeID, fact.ServerId, fact.ReplicaId, h.cfg.ServerID) + h.observeForeignHolder(fact) return } if fact.ReplicaId != h.cfg.ReplicaID { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index cd3380a110..c7543d8665 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From e803a8269b81e9ec23d15bdabffd2d9dafead19a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:40:08 -0800 Subject: [PATCH 093/204] test: retain early endpoint and same-epoch supersession controls --- .../host/volume/assignment_holder_test.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index c91b7bde44..7ce74eb935 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -138,7 +138,7 @@ func (f *holderFenceCounter) AdmitAsReplica(uint64) error { f.calls.Add(1); retu // INV-AUTH-HOLDER-IDENTITY-001 / M3: a recorded foreign fact supersedes // only an adopted own lineage and only when it is strictly newer. func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { - for _, mode := range []string{"target-old-first", "served-newer-foreign", "served-old-replay", "never-assigned"} { + for _, mode := range []string{"target-old-first", "target-own-endpoint-first", "served-newer-foreign", "served-newer-endpoint-version", "served-old-replay", "never-assigned"} { t.Run(mode, func(t *testing.T) { h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) if err != nil { @@ -173,6 +173,18 @@ func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { h.ClearLocalReadinessBlock() h.replayLocalReadinessFactIfReady() waitHealthy() + case "target-own-endpoint-first": + h.BlockLocalReadiness("awaiting durable recovery") + h.applyFact(own) + mismatch := holderAssignment(t, "new-host") + mismatch.DataAddr = "127.0.0.1:9991" + h.applyFact(mismatch) + if fencer.calls.Load() != 0 { + t.Fatal("early endpoint refusal fenced unassigned target") + } + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + waitHealthy() case "never-assigned": h.applyFact(foreign) foreign.Epoch = 2 @@ -187,8 +199,12 @@ func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { if mode == "served-newer-foreign" { foreign.Epoch = 3 } + if mode == "served-newer-endpoint-version" { + foreign.Epoch = 2 + foreign.EndpointVersion = 2 + } h.applyFact(foreign) - if mode == "served-newer-foreign" { + if mode == "served-newer-foreign" || mode == "served-newer-endpoint-version" { if fencer.calls.Load() <= before || h.view.Projection().Healthy { t.Fatal("served holder was not fenced by newer foreign line") } From 951c0f020c46147bdd8d8989f331d9d84d1891d4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:45:11 -0800 Subject: [PATCH 094/204] diagnostics: show assignment endpoint and lineage refusal inputs --- seaweed-block/core/host/volume/assignment_holder.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index ddac223cec..fef06d7af6 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -15,6 +15,10 @@ func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { // Delivery before a move is not supersession: record every refused fact, // and use the one supersession decision against the adopted engine lineage. func (h *Host) observeForeignHolder(f *control.AssignmentFact) { + h.log.Printf("blockvolume: assignment identity refusal volume=%q replica=%q server=%q epoch=%d ev=%d data=%q ctrl=%q "+ + "expected_volume=%q expected_replica=%q expected_server=%q expected_data=%q expected_ctrl=%q", + f.VolumeId, f.ReplicaId, f.ServerId, f.Epoch, f.EndpointVersion, f.DataAddr, f.CtrlAddr, + h.cfg.VolumeID, h.cfg.ReplicaID, h.cfg.ServerID, h.cfg.DataAddr, h.cfg.CtrlAddr) h.recordOtherLine(f) if h.view == nil { return From 0a0eeb72ccccbd6f7b5a00c7f81607ca06c21dae Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:50:15 -0800 Subject: [PATCH 095/204] test: own holder adopts endpoint aliases and reports warning --- .../host/volume/assignment_holder_test.go | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 7ce74eb935..31f640ede7 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -1,6 +1,7 @@ package volume import ( + "log" "strings" "sync/atomic" "testing" @@ -108,23 +109,46 @@ func TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica(t *testing.T } } -func TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch(t *testing.T) { +// Endpoints are routing data, not the holder identity (claude06 ruling). +func TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch(t *testing.T) { for _, endpoint := range []string{"data", "control"} { t.Run(endpoint, func(t *testing.T) { - h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + logs := &lockedBuffer{} + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true, Logger: log.New(logs, "", 0)}) if err != nil { t.Fatal(err) } t.Cleanup(func() { _ = h.Close() }) f := holderAssignment(t, "new-host") if endpoint == "data" { - f.DataAddr = "127.0.0.1:9991" + f.DataAddr = "0.0.0.0:19303" } else { - f.CtrlAddr = "127.0.0.1:9992" + f.CtrlAddr = "localhost:19304" + } + h.BlockLocalReadiness("awaiting durable recovery") + h.applyFact(f) + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + deadline := time.Now().Add(time.Second) + for !h.view.Projection().Healthy && time.Now().Before(deadline) { + time.Sleep(time.Millisecond) + } + if p := h.view.Projection(); !p.Healthy || p.Epoch != 2 || h.LastOtherLine() != nil { + t.Fatalf("own endpoint spelling fenced holder: %+v", p) + } + st := NewStatusServer(h.ProjectionView()).statusProjection() + if len(st.Warnings) != 1 || !strings.Contains(st.Warnings[0], "master advertises data=") || !strings.Contains(st.Warnings[0], "this process listens on") { + t.Fatalf("status warning missing: %+v", st.Warnings) } h.applyFact(f) - if h.realAdpt.Projection().Epoch != 0 || h.LastOtherLine() == nil { - t.Fatal("mismatched endpoint was adopted or not recorded") + if n := strings.Count(logs.String(), "master advertises data="); n != 1 { + t.Fatalf("warning logged %d times, want once", n) + } + corrected := holderAssignment(t, "new-host") + corrected.EndpointVersion = 2 + h.applyFact(corrected) + if got := NewStatusServer(h.ProjectionView()).statusProjection().Warnings; len(got) != 0 { + t.Fatalf("corrected endpoints retained warning: %v", got) } }) } From e6a996cca104a6953adcd8c09a42f08f9411647e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:51:13 -0800 Subject: [PATCH 096/204] fix: treat advertised endpoints as routing data not holder identity --- .../core/host/volume/assignment_holder.go | 30 +++++++++++++++---- seaweed-block/core/host/volume/host.go | 9 ++++-- .../core/host/volume/projection_bridge.go | 8 +++++ .../core/host/volume/status_server.go | 5 +++- seaweed-block/docs/design/invariants.md | 4 +-- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index fef06d7af6..cebfcc286f 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -1,14 +1,15 @@ package volume -import control "github.com/seaweedfs/seaweed-block/core/rpc/control" +import ( + "fmt" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" +) // assignmentNamesSelf implements INV-AUTH-HOLDER-IDENTITY-001. Missing server identity is -// refused; endpoints qualify identity only when the master carries them. +// refused. Endpoints are routing data and never qualify holder identity. func (h *Host) assignmentNamesSelf(f *control.AssignmentFact) bool { return f.GetServerId() != "" && f.GetServerId() == h.cfg.ServerID && - f.GetVolumeId() == h.cfg.VolumeID && f.GetReplicaId() == h.cfg.ReplicaID && - (f.GetDataAddr() == "" || f.GetDataAddr() == h.cfg.DataAddr) && - (f.GetCtrlAddr() == "" || f.GetCtrlAddr() == h.cfg.CtrlAddr) + f.GetVolumeId() == h.cfg.VolumeID && f.GetReplicaId() == h.cfg.ReplicaID } // observeForeignHolder implements M3 / INV-AUTH-HOLDER-IDENTITY-001. @@ -34,3 +35,22 @@ func (h *Host) observeForeignHolder(f *control.AssignmentFact) { } h.log.Printf("blockvolume: volume %s superseded by assignment server=%q replica=%q; fenced, not serving", h.cfg.VolumeID, f.ServerId, f.ReplicaId) } + +// reportAssignmentEndpoints is diagnostic only under INV-AUTH-HOLDER-IDENTITY-001: +// the master's published routing values need not spell this process's listeners. +func (h *Host) reportAssignmentEndpoints(f *control.AssignmentFact) { + warning := "" + if (f.DataAddr != "" && f.DataAddr != h.cfg.DataAddr) || (f.CtrlAddr != "" && f.CtrlAddr != h.cfg.CtrlAddr) { + warning = fmt.Sprintf("master advertises data=%s ctrl=%s for this holder; this process listens on %s, %s", f.DataAddr, f.CtrlAddr, h.cfg.DataAddr, h.cfg.CtrlAddr) + } + previous := h.assignmentEndpointWarning.Swap(warning) + if warning != "" && previous != warning { + h.log.Printf("blockvolume: %s", warning) + } +} + +// AssignmentEndpointWarning is visible on status without changing readiness. +func (h *Host) AssignmentEndpointWarning() string { + warning, _ := h.assignmentEndpointWarning.Load().(string) + return warning +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 5704165606..788a292e24 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -187,8 +187,9 @@ type Host struct { readyMarkerMu sync.Mutex supportingReadyMarks map[string]struct{} - localReadinessBlocked atomic.Bool - localReadinessReason atomic.Value // string + assignmentEndpointWarning atomic.Value // diagnostic string; never an admission guard + localReadinessBlocked atomic.Bool + localReadinessReason atomic.Value // string // localRecoveryReason is the typed reason local durable recovery // failed (#133); empty when none or unclassified. localRecoveryReason atomic.Value // string @@ -520,7 +521,7 @@ func (h *Host) getReplication() replicaSetUpdater { } // IsSuperseded gates a newer foreign replica line, or a same-replica foreign -// server/endpoint identity strictly newer than an adopted local lineage. An explicitly +// server identity strictly newer than an adopted local lineage. An explicitly // matching self identity remains an ordinary adapter update. func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool { h.otherMu.Lock() @@ -857,6 +858,8 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { return } + h.reportAssignmentEndpoints(fact) + // The recovery watchdog runs from the primary assignment, before any // admission step can fail (#128 rule 6). h.wd.primaryAssigned(fact.Epoch) diff --git a/seaweed-block/core/host/volume/projection_bridge.go b/seaweed-block/core/host/volume/projection_bridge.go index 2d2f1a6fb3..36e89ad268 100644 --- a/seaweed-block/core/host/volume/projection_bridge.go +++ b/seaweed-block/core/host/volume/projection_bridge.go @@ -227,3 +227,11 @@ func (v *AdapterProjectionView) PromotionReadyFact() engine.PromotionReadyFact { func (v *AdapterProjectionView) EngineProjection() engine.ReplicaProjection { return v.projector.Projection() } + +// assignmentEndpointWarning exposes routing disagreement without gating I/O. +func (v *AdapterProjectionView) assignmentEndpointWarning() string { + if p, ok := v.probe.(interface{ AssignmentEndpointWarning() string }); ok { + return p.AssignmentEndpointWarning() + } + return "" +} diff --git a/seaweed-block/core/host/volume/status_server.go b/seaweed-block/core/host/volume/status_server.go index eda1faaa63..cea8a7c79d 100644 --- a/seaweed-block/core/host/volume/status_server.go +++ b/seaweed-block/core/host/volume/status_server.go @@ -203,7 +203,7 @@ type StatusProjection struct { // CatchUp shows a supporting replica's catch-up progress while it is // not yet replica_ready; it is visible without being an alert. CatchUp *CatchUpStatus `json:",omitempty"` - // Warnings are the durable store's typed recovery warnings (e.g. + // Warnings include routing disagreements and typed recovery warnings (e.g. // wal_hole_suspected, issue #51). Visible, not an alert: they do not // change Healthy or the frontend's readiness. Warnings []string `json:",omitempty"` @@ -531,6 +531,9 @@ func (s *StatusServer) authorityProjection() StatusProjection { RoleAdmissionFailure: s.view.roleAdmissionReason(), UnhealthyReason: s.view.unhealthyReason(), } + if warning := s.view.assignmentEndpointWarning(); warning != "" { + out.Warnings = append(out.Warnings, warning) + } if since := s.view.catchUpSince(); !since.IsZero() && replicationRole != ReplicationRoleReady { cu := &CatchUpStatus{ElapsedMs: time.Since(since).Milliseconds()} if ep.H > ep.R { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index c7543d8665..0f29eb64af 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, with matching data/control endpoints when carried; missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityRefusesCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 1ad3218fa986bcade94b2ec48f7c19926d7e669b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:52:16 -0800 Subject: [PATCH 097/204] test: a recorded foreign assignment counts as the old host's refusal Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/procedure_gate_integration_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 34e8ac3668..eec3f8d1bf 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -171,7 +171,7 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { } time.Sleep(time.Second) } - if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") && !back.has("is not this process") { + if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") && !back.has("is not this process") && !back.has("foreign assignment") { failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") } if len(failures) > 0 { From 9f54c4f155ff112549918b602dfa2333660a6ba4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:52:43 -0800 Subject: [PATCH 098/204] test: equal foreign replay does not supersede an adopted holder --- seaweed-block/core/host/volume/assignment_holder_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 31f640ede7..611dd2d596 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -162,7 +162,7 @@ func (f *holderFenceCounter) AdmitAsReplica(uint64) error { f.calls.Add(1); retu // INV-AUTH-HOLDER-IDENTITY-001 / M3: a recorded foreign fact supersedes // only an adopted own lineage and only when it is strictly newer. func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { - for _, mode := range []string{"target-old-first", "target-own-endpoint-first", "served-newer-foreign", "served-newer-endpoint-version", "served-old-replay", "never-assigned"} { + for _, mode := range []string{"target-old-first", "target-own-endpoint-first", "served-newer-foreign", "served-newer-endpoint-version", "served-old-replay", "served-equal-replay", "never-assigned"} { t.Run(mode, func(t *testing.T) { h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "new-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) if err != nil { @@ -223,6 +223,9 @@ func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { if mode == "served-newer-foreign" { foreign.Epoch = 3 } + if mode == "served-equal-replay" { + foreign.Epoch = 2 + } if mode == "served-newer-endpoint-version" { foreign.Epoch = 2 foreign.EndpointVersion = 2 From 0d4a511954d941d922b8e2220ef1df5e2bbfc7ff Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:55:00 -0800 Subject: [PATCH 099/204] docs: Part T, the line owner is carried in the published line Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 53efd94cdd..24dfe3b7d1 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -974,7 +974,7 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| -| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | From 22037e1ce568b6eaec0aaec5c4ebc1a88eb61f16 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:59:20 -0800 Subject: [PATCH 100/204] test: trace forced-move deliveries and reject stale self replay --- .../host/volume/assignment_holder_test.go | 36 +++++++++++++++++++ seaweed-block/core/host/volume/host.go | 9 +++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index 611dd2d596..b33c80f0d5 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -242,3 +242,39 @@ func TestAssignmentHolderIdentityForeignStreamOrdering(t *testing.T) { }) } } + +// INV-AUTH-HOLDER-IDENTITY-001: an old process cannot adopt a stale +// self-labelled EV1 after it has observed the forced move's foreign EV2. +func TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + h.BlockLocalReadiness("awaiting durable recovery") + for _, ev := range []uint64{1, 2, 1, 3} { + foreign := holderAssignment(t, "new-host") + foreign.EndpointVersion = ev + h.applyFact(foreign) + if h.realAdpt.Projection().Epoch != 0 { + t.Fatalf("old server adopted foreign EV%d", ev) + } + } + // Covers the safety boundary even if an older delivery incorrectly + // names the source: a known newer foreign line still takes precedence. + staleSelf := holderAssignment(t, "old-host") + h.applyFact(staleSelf) + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + if p := h.realAdpt.Projection(); p.Epoch != 0 { + t.Fatalf("old server adopted stale EV1 after foreign newer line: %+v", p) + } + for _, cmd := range h.t1exec.Commands() { + if strings.HasPrefix(cmd, "PublishHealthy:") { + t.Fatalf("old server published healthy: %s", cmd) + } + } + if h.view.Projection().Healthy { + t.Fatal("old server served after forced move") + } +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 788a292e24..c7a3488370 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -396,7 +396,8 @@ func (h *Host) replayLocalReadinessFactIfReady() { if fact == nil { return } - h.log.Printf("blockvolume: volume %s replaying assignment after local readiness cleared", h.cfg.VolumeID) + h.log.Printf("blockvolume: volume %s replaying assignment after local readiness cleared server=%q epoch=%d ev=%d data=%q ctrl=%q", + h.cfg.VolumeID, fact.ServerId, fact.Epoch, fact.EndpointVersion, fact.DataAddr, fact.CtrlAddr) h.applyFact(fact) } @@ -779,6 +780,8 @@ func (h *Host) streamOnce(ctx context.Context) error { if err != nil { return err } + h.log.Printf("blockvolume: assignment stream delivery process=%q server=%q volume=%q replica=%q epoch=%d ev=%d data=%q ctrl=%q", + h.cfg.ServerID, fact.ServerId, fact.VolumeId, fact.ReplicaId, fact.Epoch, fact.EndpointVersion, fact.DataAddr, fact.CtrlAddr) h.applyFact(fact) } } @@ -931,8 +934,8 @@ func (h *Host) applyFact(fact *control.AssignmentFact) { return } h.adpt.OnAssignment(info) - h.log.Printf("blockvolume: volume %s adopted as PRIMARY at %s@%d (EV=%d)", - h.cfg.VolumeID, info.ReplicaID, info.Epoch, info.EndpointVersion) + h.log.Printf("blockvolume: volume %s adopted as PRIMARY at %s@%d (EV=%d) process=%q server=%q data=%q ctrl=%q", + h.cfg.VolumeID, info.ReplicaID, info.Epoch, info.EndpointVersion, h.cfg.ServerID, fact.ServerId, fact.DataAddr, fact.CtrlAddr) if h.cfg.ReadyMarker != nil && info.Epoch > 0 && h.readyOnce.CompareAndSwap(false, true) { select { case h.cfg.ReadyMarker <- info: From f951c0102c23553b7227c0b05da655ffac3f7912 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:00:11 -0800 Subject: [PATCH 101/204] fix: refuse stale self assignment behind observed foreign lineage --- .../core/host/volume/assignment_holder.go | 19 +++++++++++++++++++ seaweed-block/core/host/volume/host.go | 3 +-- seaweed-block/docs/design/invariants.md | 4 ++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index cebfcc286f..fdb86962de 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -54,3 +54,22 @@ func (h *Host) AssignmentEndpointWarning() string { warning, _ := h.assignmentEndpointWarning.Load().(string) return warning } + +// refusePrimaryAssignment implements M3 / INV-AUTH-HOLDER-IDENTITY-001: +// a candidate cannot enter the adapter behind an already observed foreign line. +// Identity and ordering each use their existing single deciding function. +func (h *Host) refusePrimaryAssignment(f *control.AssignmentFact) bool { + if f.ReplicaId != h.cfg.ReplicaID { + return false + } + if !h.assignmentNamesSelf(f) { + h.observeForeignHolder(f) + return true + } + if h.IsSuperseded(h.cfg.ReplicaID, f.Epoch, f.EndpointVersion) { + h.log.Printf("blockvolume: volume %s refuses stale self-labelled assignment server=%q epoch=%d ev=%d behind recorded foreign line", + h.cfg.VolumeID, f.ServerId, f.Epoch, f.EndpointVersion) + return true + } + return false +} diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index c7a3488370..068acdc0d0 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -813,8 +813,7 @@ func (h *Host) streamOnce(ctx context.Context) error { // installed, admitting local-only writes with zero fan-out. func (h *Host) applyFact(fact *control.AssignmentFact) { // INV-AUTH-HOLDER-IDENTITY-001: matching r1 and loopback endpoints do not identify a host. - if fact.ReplicaId == h.cfg.ReplicaID && !h.assignmentNamesSelf(fact) { - h.observeForeignHolder(fact) + if h.refusePrimaryAssignment(fact) { return } if fact.ReplicaId != h.cfg.ReplicaID { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0f29eb64af..a8a88cae51 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); a self-labelled candidate behind a recorded newer foreign line is refused by IsSuperseded before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From c8522ed198199853b30d533f4ca9e9913688d9d7 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:01:34 -0800 Subject: [PATCH 102/204] test: retain stale assignment before foreign delivery then replay --- seaweed-block/core/host/volume/assignment_holder_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index b33c80f0d5..f430ff19cd 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -252,6 +252,8 @@ func TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion(t *testi } t.Cleanup(func() { _ = h.Close() }) h.BlockLocalReadiness("awaiting durable recovery") + staleSelf := holderAssignment(t, "old-host") + h.applyFact(staleSelf) // retained before the newer foreign delivery for _, ev := range []uint64{1, 2, 1, 3} { foreign := holderAssignment(t, "new-host") foreign.EndpointVersion = ev @@ -262,8 +264,6 @@ func TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion(t *testi } // Covers the safety boundary even if an older delivery incorrectly // names the source: a known newer foreign line still takes precedence. - staleSelf := holderAssignment(t, "old-host") - h.applyFact(staleSelf) h.ClearLocalReadinessBlock() h.replayLocalReadinessFactIfReady() if p := h.realAdpt.Projection(); p.Epoch != 0 { From 501d68ea0642011e70742ab125a666a621234249 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:01:47 -0800 Subject: [PATCH 103/204] test: harness ports below the kernel's ephemeral range Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_integration_test.go | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 9e03afddb4..24efa719f2 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -9,12 +9,14 @@ import ( "errors" "fmt" "io" + "math/rand" "net" "net/http" "os" "os/exec" "path/filepath" "strings" + "sync" "testing" "time" @@ -194,7 +196,7 @@ func startHandoffEnv(t *testing.T, n int, masterArgs ...string) *handoffEnv { env.hosts["s1"] = bvHost{id: "s1", data: h.dataAddr, ctrl: h.ctrlAddr, status: h.statusAddr, nvme: h.nvmeAddr, root: filepath.Join(h.dir, "vol")} for i := 2; i <= n; i++ { id := fmt.Sprintf("s%d", i) - env.hosts[id] = bvHost{id: id, data: leaseBinaryAddress(t), ctrl: leaseBinaryAddress(t), status: leaseBinaryAddress(t), nvme: leaseBinaryAddress(t), root: filepath.Join(h.dir, "vol-"+id)} + env.hosts[id] = bvHost{id: id, data: handoffAddress(t), ctrl: handoffAddress(t), status: handoffAddress(t), nvme: handoffAddress(t), root: filepath.Join(h.dir, "vol-"+id)} } cluster, chunkPath := env.cluster, env.chunkPath @@ -293,14 +295,46 @@ func newPlannedHandoffHarness(t *testing.T) *plannedHandoffHarness { t.Fatalf("build %s: %v\n%s", b.name, err, out) } } - h.masterAddr = leaseBinaryAddress(t) - h.dataAddr = leaseBinaryAddress(t) - h.ctrlAddr = leaseBinaryAddress(t) - h.statusAddr = leaseBinaryAddress(t) - h.nvmeAddr = leaseBinaryAddress(t) + h.masterAddr = handoffAddress(t) + h.dataAddr = handoffAddress(t) + h.ctrlAddr = handoffAddress(t) + h.statusAddr = handoffAddress(t) + h.nvmeAddr = handoffAddress(t) return h } +var handoffPorts struct { + sync.Mutex + used map[int]bool +} + +// handoffAddress returns a free loopback address below the kernel's +// ephemeral range (32768 and up on Linux). A daemon restarted minutes later +// binds it again, and an outgoing connection may take any ephemeral port in +// between; ports below the range are never handed out that way. +func handoffAddress(t *testing.T) string { + t.Helper() + handoffPorts.Lock() + defer handoffPorts.Unlock() + if handoffPorts.used == nil { + handoffPorts.used = map[int]bool{} + } + for i := 0; i < 500; i++ { + p := 21000 + rand.Intn(11000) + if handoffPorts.used[p] { + continue + } + addr := fmt.Sprintf("127.0.0.1:%d", p) + if ln, err := net.Listen("tcp", addr); err == nil { + ln.Close() + handoffPorts.used[p] = true + return addr + } + } + t.Fatal("no free loopback port below the ephemeral range") + return "" +} + // daemon is one started child: its log file and its exit. type daemon struct { name, log string From 56cd0275db25c5f2e0f5cc50820cd23b1495ef9a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:10:04 -0800 Subject: [PATCH 104/204] test(volume): reject same-epoch changes of recorded owner --- .../host/volume/assignment_holder_test.go | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index f430ff19cd..bb6ad8d4ad 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -1,6 +1,7 @@ package volume import ( + "fmt" "log" "strings" "sync/atomic" @@ -278,3 +279,26 @@ func TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion(t *testi t.Fatal("old server served after forced move") } } + +// INV-AUTH-HOLDER-IDENTITY-001: a recorded foreign owner at this epoch +// cannot be overwritten by a self-labelled delivery, even at a higher EV. +func TestAssignmentHolderIdentitySameEpochCannotChangeServer(t *testing.T) { + for _, ev := range []uint64{1, 2, 3} { + t.Run(fmt.Sprint(ev), func(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "old-host", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304", EnableT1Readiness: true}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + foreign := holderAssignment(t, "new-host") + foreign.EndpointVersion = 2 + h.applyFact(foreign) + self := holderAssignment(t, "old-host") + self.EndpointVersion = ev + h.applyFact(self) + if p := h.realAdpt.Projection(); p.Epoch != 0 { + t.Fatalf("same epoch changed from recorded new-host to old-host at EV%d: %+v", ev, p) + } + }) + } +} From ef3d1d03f6a26a5372132482753134d1716cb661 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:10:28 -0800 Subject: [PATCH 105/204] docs: Part T, the refusal to adopt is the holder safety rule Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 24dfe3b7d1..f4e7af2348 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -974,7 +974,7 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| -| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | From 2ff0e765d92ac45625b57931587fdb7b57805da3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:10:34 -0800 Subject: [PATCH 106/204] fix(volume): retain recorded owner for an assignment epoch --- seaweed-block/core/host/volume/assignment_holder.go | 7 ++++++- seaweed-block/docs/design/invariants.md | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/volume/assignment_holder.go b/seaweed-block/core/host/volume/assignment_holder.go index fdb86962de..6f99e734da 100644 --- a/seaweed-block/core/host/volume/assignment_holder.go +++ b/seaweed-block/core/host/volume/assignment_holder.go @@ -66,7 +66,12 @@ func (h *Host) refusePrimaryAssignment(f *control.AssignmentFact) bool { h.observeForeignHolder(f) return true } - if h.IsSuperseded(h.cfg.ReplicaID, f.Epoch, f.EndpointVersion) { + other := h.LastOtherLine() + // A candidate's owner cannot change within one epoch, even when its EV + // advances. This is an admission refusal, not a supersession fence on + // an already-adopted lineage (whose strict-newer rule is unchanged). + sameEpochForeign := other != nil && other.Epoch == f.Epoch && other.ReplicaId == f.ReplicaId && other.ServerId != "" && other.ServerId != f.ServerId + if sameEpochForeign || h.IsSuperseded(h.cfg.ReplicaID, f.Epoch, f.EndpointVersion) { h.log.Printf("blockvolume: volume %s refuses stale self-labelled assignment server=%q epoch=%d ev=%d behind recorded foreign line", h.cfg.VolumeID, f.ServerId, f.Epoch, f.EndpointVersion) return true diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index a8a88cae51..501a93e1eb 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 165c6b0330574e2086f8ffe7437bef1189314f1b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:10:56 -0800 Subject: [PATCH 107/204] docs(authority): trace same-epoch candidate admission refusal --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 501a93e1eb..f3de8eb41a 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); a self-labelled candidate behind a recorded newer foreign line is refused by IsSuperseded before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); refusePrimaryAssignment rejects a candidate behind a newer foreign line or naming a different server at the same epoch before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | From f388f2c3571c310040dba997e42a35abef47292d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:25:22 -0800 Subject: [PATCH 108/204] docs(authority): reconcile exclusion guard and repair invariant status --- seaweed-block/docs/design/invariants.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index f3de8eb41a..6506e3446d 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -134,7 +134,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | | Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); refusePrimaryAssignment rejects a candidate behind a newer foreign line or naming a different server at the same epoch before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | -| Primary, Supporting | Excluded | the fact names another primary and does not list this replica, or names this replica on a missing/foreign server or mismatched carried endpoints; a same-replica foreign line at or above local epoch/endpoint-version gates the projection; ingress is closed, the other line is recorded and the frontend is unhealthy | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Primary, Supporting | Excluded | another primary excludes this replica, or IsSuperseded finds a foreign-server fact strictly newer than an adopted own lineage; record the foreign line, close ingress and gate the frontend; unassigned and older/equal foreign replay do not fence; endpoints are not identity; refusePrimaryAssignment rejects any candidate changing a recorded server within the same epoch, regardless of endpoint version | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | | any | role admission failed | the listener cannot be fenced or its floor cannot be persisted; the role is not adopted and the projection is not healthy | `core/host/volume/host.go` `latchRoleAdmission` | `INV-FENCE-FLOOR-DURABLE-001` | | (every inbound frame) | — | a mutating frame is refused on a primary, below the floor, or before a role is known; the rebuild port applies the same rules; a failed apply closes the connection | `core/transport/replica.go` `acceptMutationLineage`, `admitMutation`, `EnterDualLane`, `handleConn` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-REPL-REBUILD-PORT-FENCE-001`, `INV-REPL-APPLY-FAIL-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE, `INV-AUTH-HOLDER-IDENTITY-001` | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From c4720afa3ad6113ddefdbfb909eeb6a86d69d32b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:43:09 -0800 Subject: [PATCH 109/204] docs(status): regenerate warning schema for routing diagnostics --- seaweed-block/docs/status-schema.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/status-schema.md b/seaweed-block/docs/status-schema.md index 1d5a4b5ee1..f6243d2c8d 100644 --- a/seaweed-block/docs/status-schema.md +++ b/seaweed-block/docs/status-schema.md @@ -35,7 +35,7 @@ The volume's authority and health projection. Go type `volume.StatusProjection`. | `CatchUp` | object | CatchUp shows a supporting replica's catch-up progress while it is not yet replica_ready; it is visible without being an alert. (omitted when empty) | | `CatchUp.ElapsedMs` | int64 | ElapsedMs is the time since this replica was admitted as a supporting replica at its current epoch. | | `CatchUp.LagLSN` | uint64 | LagLSN is the engine's H-R (primary head minus this replica's durable frontier) as last observed; 0 when unknown or caught up. | -| `Warnings[]` | string | Warnings are the durable store's typed recovery warnings (e.g. wal_hole_suspected, issue #51). Visible, not an alert: they do not change Healthy or the frontend's readiness. (omitted when empty) | +| `Warnings[]` | string | Warnings include routing disagreements and typed recovery warnings (e.g. wal_hole_suspected, issue #51). Visible, not an alert: they do not change Healthy or the frontend's readiness. (omitted when empty) | ### `GET /status/peers` From 6ff7a6a2b7d3c122e33bcde065d979d777fe329c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:42:13 -0800 Subject: [PATCH 110/204] test: red: a server id from a second host; portal and primary from the line server INV-ASSIGNMENT-HOLDER-IDENTITY-001: the same --server-id reported from a host other than its registered one must be refused, and the CSI portal and displayed primary must come from the server on the authority line, not the freshest heartbeat. Co-Authored-By: Claude Opus 5.5 --- .../host/master/server_host_identity_test.go | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 seaweed-block/core/host/master/server_host_identity_test.go diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go new file mode 100644 index 0000000000..db3d1265e6 --- /dev/null +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -0,0 +1,88 @@ +package master + +import ( + "context" + "strings" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +// heartbeatFrom sends a heartbeat for server whose slot addresses are on host. +func (r *isolationRig) heartbeatFrom(server, host string) error { + _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true, + Slots: []*control.HeartbeatSlot{{VolumeId: "hb-" + server, ReplicaId: "r-" + server, DataAddr: host + ":19611", CtrlAddr: host + ":19612"}}}) + return err +} + +// INV-ASSIGNMENT-HOLDER-IDENTITY-001: OSS has no host authentication, so a server id names a host only if the master +// refuses that id from any host other than the one registered for it. Two processes started with the same --server-id +// on different hosts: the one on the registered host is accepted, the other is refused, and it never enters the +// observations (a copied config cannot borrow the registered host's holder identity). +func TestServerIDRefusedFromAHostOtherThanItsRegisteredOne(t *testing.T) { + r := newIsolationRig(t, false, t.TempDir(), t.TempDir()) // node-a is registered on 127.0.0.1 + if err := r.heartbeatFrom("node-a", "127.0.0.1"); err != nil { + t.Fatalf("heartbeat from node-a's registered host refused: %v", err) + } + err := r.heartbeatFrom("node-a", "127.0.0.2") + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1") { + t.Fatalf("same --server-id from a second host: %v, want FailedPrecondition naming the registered host", err) + } + if slot, ok := r.m.ObservationHost().Store().SlotFactOnServer("node-a", "hb-node-a", "r-node-a"); !ok || !strings.HasPrefix(slot.DataAddr, "127.0.0.1:") { + t.Fatalf("refused heartbeat reached the observations: %+v ok=%v", slot, ok) + } +} + +// INV-ASSIGNMENT-HOLDER-IDENTITY-001: the CSI portal (QueryVolumeStatus frontends) and the displayed primary +// (ClusterStatus primary node and publish target) come from the server on the volume's authority line, never from +// whichever host sent the freshest heartbeat for the same replica id. A stale old host that still reports the +// primary's replica, even more recently, changes neither. +func TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat(t *testing.T) { + h := newTestMasterWithControllerConfig(t, t.TempDir(), authority.TopologyControllerConfig{ExpectedSlotsPerVolume: 3}) + defer closeTestMaster(t, h) + seedObservationSnapshotVolume(t, h) + seedRF3PlacementForServers(t, h, "pvc-a", "m01", "m02", "tp01") + ingestObservationSnapshotRF3(t, h, true, true, true) + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatalf("product tick: %v", err) + } + line := waitAuthorityLine(t, h.Publisher(), "pvc-a") + holder := h.workspaceSourceHost("pvc-a", line.ReplicaID, line.Epoch) + holderAddr := map[string]string{"m01": "192.168.1.181:3260", "m02": "192.168.1.184:3260", "tp01": "192.168.1.188:3260"}[holder] + if holderAddr == "" { + t.Fatalf("line %+v names holder %q", line, holder) + } + stale := "m02" + if holder == stale { + stale = "tp01" + } + // the stale host reports the primary's replica id with a newer observation than the holder's + if err := h.ObservationHost().Ingest(authority.Observation{ServerID: stale, ObservedAt: time.Now().UTC().Add(time.Second), + Server: authority.ServerFact{Reachable: true, Eligible: true}, + Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "10.9.9.9:19101", CtrlAddr: "10.9.9.9:19102", + Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 99, + Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: "10.9.9.9:3260", IQN: "iqn.2026-05.io.seaweedfs:pvc-a", LUN: 1}}}}}); err != nil { + t.Fatalf("ingest stale host: %v", err) + } + resp, err := newServices(h).QueryVolumeStatus(context.Background(), &control.StatusRequest{VolumeId: "pvc-a"}) + if err != nil { + t.Fatalf("status: %v", err) + } + if len(resp.Frontends) == 0 || resp.Frontends[0].Addr != holderAddr { + t.Fatalf("CSI portal: frontends=%v, want the line server %s's %s first (stale host %s must not win)", resp.Frontends, holder, holderAddr, stale) + } + for _, ft := range resp.Frontends { + if ft.Addr == "10.9.9.9:3260" { + t.Fatalf("CSI portal lists the stale host's frontend: %v", resp.Frontends) + } + } + vol := h.ObservationSnapshot(time.Now().UTC()).Volumes[0] + if vol.PrimaryNode != holder || vol.PublishTarget != holderAddr { + t.Fatalf("displayed primary node=%q target=%q, want %q %q (line server, not the stale host %s)", vol.PrimaryNode, vol.PublishTarget, holder, holderAddr, stale) + } +} From 5c912694b1a3a32c4dbfa9e55e4d2bee1aae6c35 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:43:21 -0800 Subject: [PATCH 111/204] fix: one server id names one host; portal and primary from the line server INV-ASSIGNMENT-HOLDER-IDENTITY-001. - ReportHeartbeat refuses (FailedPrecondition) a heartbeat whose slot addresses are on a host other than the one registered for its server id. Only the host part is compared; several server ids on one host stay allowed; an unregistered id has nothing to contradict. - QueryVolumeStatus lists the primary's frontends from the server on the authority line (workspaceSourceHost), never a fresher same-replica claim from another server. - ClusterStatus primary node is the line's server (issued holder), not placement, and the primary replica's evidence and publish target come only from that server. Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/observation_snapshot.go | 10 ++- .../core/host/master/server_host_identity.go | 67 +++++++++++++++++++ seaweed-block/core/host/master/services.go | 25 ++++++- 3 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 seaweed-block/core/host/master/server_host_identity.go diff --git a/seaweed-block/core/host/master/observation_snapshot.go b/seaweed-block/core/host/master/observation_snapshot.go index 8e154b80c7..f3790e0bea 100644 --- a/seaweed-block/core/host/master/observation_snapshot.go +++ b/seaweed-block/core/host/master/observation_snapshot.go @@ -122,7 +122,8 @@ func (h *Host) observationVolume(volumeID string, rec lifecycle.VolumeRecord, pl volume.Replicas = replicas volume.ObservedReplicas = countObservedReplicas(replicas) if volume.PrimaryReplica != "" { - volume.PrimaryNode = serverForReplica(placement, volume.PrimaryReplica) + // the server on the authority line (issued holder), not placement (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + volume.PrimaryNode = h.workspaceSourceHost(volumeID, line.ReplicaID, line.Epoch) volume.PublishTarget = publishTargetForReplica(replicas, volume.PrimaryReplica) } @@ -230,7 +231,12 @@ func (h *Host) observationReplicas(volumeID string, placement lifecycle.Placemen replica.Role = "primary" replica.ReplicationRole = "primary" } - if fact, ok := h.ObservationHost().Store().SlotFact(volumeID, replicaID); ok { + fact, ok := h.ObservationHost().Store().SlotFact(volumeID, replicaID) + if hasLine && line.Assigned && replicaID == line.ReplicaID { + // the primary's evidence comes only from the line's server (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + _, fact, ok = h.holderSlotFact(volumeID, replicaID, line.Epoch) + } + if ok { replica.Observed = true replica.CandidateReady = fact.ReadyForPrimary replica.CandidateReadyReason = candidateReason(fact.ReadyForPrimary) diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go new file mode 100644 index 0000000000..0516a1693d --- /dev/null +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -0,0 +1,67 @@ +package master + +import ( + "fmt" + "net" + "strings" + + "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/rpc/control" +) + +// addrHost is the host part of a host:port (or bare host) address. +func addrHost(addr string) string { + if h, _, err := net.SplitHostPort(addr); err == nil { + return h + } + return strings.TrimSpace(addr) +} + +// refuseServerIDFromOtherHost implements the host half of INV-ASSIGNMENT-HOLDER-IDENTITY-001. OSS has no host +// authentication, so a server id names a host only if every address a heartbeat reports under that id is on the host +// registered for it. A second process started with the same --server-id elsewhere (a copied config) is refused before +// its slots reach the observations. Only the host part is compared (each volume process listens on its own ports); +// several server ids on one host stay allowed; an id with no registry record has nothing to contradict. +func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { + if h.lifecycle == nil || h.lifecycle.Nodes == nil { + return nil + } + reg, ok := h.lifecycle.Nodes.GetNode(r.ServerId) + if !ok { + return nil + } + hosts := map[string]bool{} + for _, a := range []string{reg.DataAddr, reg.CtrlAddr, reg.Addr} { + if a != "" { + hosts[addrHost(a)] = true + } + } + if len(hosts) == 0 { + return nil + } + registered := addrHost(reg.DataAddr) + if registered == "" { + registered = addrHost(reg.Addr) + } + for _, s := range r.Slots { + for _, a := range []string{s.DataAddr, s.CtrlAddr} { + if a != "" && !hosts[addrHost(a)] { + return fmt.Errorf("heartbeat: server id %s is registered on host %s; refused from %s (volume %s replica %s): one server id names one host", + r.ServerId, registered, addrHost(a), s.VolumeId, s.ReplicaId) + } + } + } + return nil +} + +// holderSlotFact is the slot fact of replica on the server the authority line names (workspaceSourceHost); a +// same-replica claim from any other server, however fresh, is never used (INV-ASSIGNMENT-HOLDER-IDENTITY-001). +// No resolvable holder: no fact (fail closed). +func (h *Host) holderSlotFact(volumeID, replicaID string, epoch uint64) (string, authority.SlotFact, bool) { + holder := h.workspaceSourceHost(volumeID, replicaID, epoch) + if holder == "" || h.obs == nil { + return holder, authority.SlotFact{}, false + } + fact, ok := h.obs.Store().SlotFactOnServer(holder, volumeID, replicaID) + return holder, fact, ok +} diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 5fab9c3ebc..d53dc72de0 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -292,6 +292,10 @@ func (s *services) ReportHeartbeat(ctx context.Context, r *control.HeartbeatRepo if err := s.host.refuseColocatedHeartbeat(r.ServerId, storeident.Identity{MachineID: r.GetMachineId(), Dev: r.GetDurableRootDev(), FSID: r.GetDurableRootFsid()}); err != nil { return nil, status.Error(codes.FailedPrecondition, err.Error()) } + // INV-ASSIGNMENT-HOLDER-IDENTITY-001: one server id names one host. + if err := s.host.refuseServerIDFromOtherHost(r); err != nil { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } msg := heartbeatFromWire(r) if err := s.host.ingestHeartbeatRecordingHealth(msg); err != nil { return nil, fmt.Errorf("ingest: %w", err) @@ -509,7 +513,15 @@ func (s *services) QueryVolumeStatus(ctx context.Context, req *control.StatusReq replicaIDs = []string{line.ReplicaID} } replicaIDs = primaryFirstReplicaIDs(replicaIDs, line.ReplicaID) - resp.Frontends = statusFrontendsForAssignedVolume(s.host.obs, req.VolumeId, replicaIDs, line.Assigned) + // the primary's portal comes from the server on the line, never a fresher same-replica claim elsewhere + // (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + resp.Frontends = statusFrontendsFor(s.host.obs, req.VolumeId, replicaIDs, line.Assigned, func(replicaID string) (authority.SlotFact, bool) { + if replicaID == line.ReplicaID { + _, fact, ok := s.host.holderSlotFact(req.VolumeId, replicaID, line.Epoch) + return fact, ok + } + return s.host.obs.Store().SlotFact(req.VolumeId, replicaID) + }) resp.UnhealthyReplicas = statusUnhealthyReplicas(s.host.obs, req.VolumeId, replicaIDs) } if ev, ok := ctrl.LastUnsupported(req.VolumeId); ok { @@ -553,16 +565,25 @@ func primaryFirstReplicaIDs(replicaIDs []string, primaryReplicaID string) []stri } func statusFrontendsForAssignedVolume(obs *authority.ObservationHost, volumeID string, replicaIDs []string, assigned bool) []*control.FrontendTarget { + return statusFrontendsFor(obs, volumeID, replicaIDs, assigned, nil) +} + +// statusFrontendsFor lists the frontends of replicaIDs in order; slotOf selects each replica's slot fact (nil: the +// freshest claim for that replica). +func statusFrontendsFor(obs *authority.ObservationHost, volumeID string, replicaIDs []string, assigned bool, slotOf func(replicaID string) (authority.SlotFact, bool)) []*control.FrontendTarget { if !assigned || obs == nil { return nil } + if slotOf == nil { + slotOf = func(replicaID string) (authority.SlotFact, bool) { return obs.Store().SlotFact(volumeID, replicaID) } + } out := make([]*control.FrontendTarget, 0, len(replicaIDs)) seen := map[string]struct{}{} for _, replicaID := range replicaIDs { if replicaID == "" { continue } - slot, ok := obs.Store().SlotFact(volumeID, replicaID) + slot, ok := slotOf(replicaID) if !ok { continue } From 9db53255ff1831bbc7a6c329ef54ab8d59fbd626 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:53:38 -0800 Subject: [PATCH 112/204] test: derive the holder's portal from the fixture; documentation-range address for the stale claim Co-Authored-By: Claude Opus 5.5 --- .../host/master/server_host_identity_test.go | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index db3d1265e6..b76e95062d 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -53,20 +53,24 @@ func TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat(t *testing } line := waitAuthorityLine(t, h.Publisher(), "pvc-a") holder := h.workspaceSourceHost("pvc-a", line.ReplicaID, line.Epoch) - holderAddr := map[string]string{"m01": "192.168.1.181:3260", "m02": "192.168.1.184:3260", "tp01": "192.168.1.188:3260"}[holder] - if holderAddr == "" { - t.Fatalf("line %+v names holder %q", line, holder) + own, ok := h.ObservationHost().Store().SlotFactOnServer(holder, "pvc-a", line.ReplicaID) + if holder == "" || !ok || len(own.Frontends) == 0 { + t.Fatalf("line %+v names holder %q with no observed frontend", line, holder) } - stale := "m02" - if holder == stale { - stale = "tp01" + holderAddr := own.Frontends[0].Addr + stale := "" + for _, server := range []string{"m01", "m02", "tp01"} { // the fixture's placement servers + if server != holder { + stale = server + break + } } // the stale host reports the primary's replica id with a newer observation than the holder's if err := h.ObservationHost().Ingest(authority.Observation{ServerID: stale, ObservedAt: time.Now().UTC().Add(time.Second), Server: authority.ServerFact{Reachable: true, Eligible: true}, - Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "10.9.9.9:19101", CtrlAddr: "10.9.9.9:19102", + Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "192.0.2.9:19101", CtrlAddr: "192.0.2.9:19102", Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 99, - Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: "10.9.9.9:3260", IQN: "iqn.2026-05.io.seaweedfs:pvc-a", LUN: 1}}}}}); err != nil { + Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: "192.0.2.9:3260", IQN: "iqn.2026-05.io.seaweedfs:pvc-a", LUN: 1}}}}}); err != nil { t.Fatalf("ingest stale host: %v", err) } resp, err := newServices(h).QueryVolumeStatus(context.Background(), &control.StatusRequest{VolumeId: "pvc-a"}) @@ -77,7 +81,7 @@ func TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat(t *testing t.Fatalf("CSI portal: frontends=%v, want the line server %s's %s first (stale host %s must not win)", resp.Frontends, holder, holderAddr, stale) } for _, ft := range resp.Frontends { - if ft.Addr == "10.9.9.9:3260" { + if ft.Addr == "192.0.2.9:3260" { t.Fatalf("CSI portal lists the stale host's frontend: %v", resp.Frontends) } } From f53bddf24e4ab2d7921d2187f536e7505638160c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:56:36 -0800 Subject: [PATCH 113/204] test: displayed primary is the issued holder, not the placement slot; id renamed to INV-AUTH-HOLDER-IDENTITY-001 Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/observation_snapshot.go | 4 +- .../core/host/master/server_host_identity.go | 4 +- .../host/master/server_host_identity_test.go | 97 ++++++++++++++++++- seaweed-block/core/host/master/services.go | 4 +- 4 files changed, 101 insertions(+), 8 deletions(-) diff --git a/seaweed-block/core/host/master/observation_snapshot.go b/seaweed-block/core/host/master/observation_snapshot.go index f3790e0bea..279f368d4a 100644 --- a/seaweed-block/core/host/master/observation_snapshot.go +++ b/seaweed-block/core/host/master/observation_snapshot.go @@ -122,7 +122,7 @@ func (h *Host) observationVolume(volumeID string, rec lifecycle.VolumeRecord, pl volume.Replicas = replicas volume.ObservedReplicas = countObservedReplicas(replicas) if volume.PrimaryReplica != "" { - // the server on the authority line (issued holder), not placement (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + // the server on the authority line (issued holder), not placement (INV-AUTH-HOLDER-IDENTITY-001) volume.PrimaryNode = h.workspaceSourceHost(volumeID, line.ReplicaID, line.Epoch) volume.PublishTarget = publishTargetForReplica(replicas, volume.PrimaryReplica) } @@ -233,7 +233,7 @@ func (h *Host) observationReplicas(volumeID string, placement lifecycle.Placemen } fact, ok := h.ObservationHost().Store().SlotFact(volumeID, replicaID) if hasLine && line.Assigned && replicaID == line.ReplicaID { - // the primary's evidence comes only from the line's server (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + // the primary's evidence comes only from the line's server (INV-AUTH-HOLDER-IDENTITY-001) _, fact, ok = h.holderSlotFact(volumeID, replicaID, line.Epoch) } if ok { diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index 0516a1693d..8855fa8f70 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -17,7 +17,7 @@ func addrHost(addr string) string { return strings.TrimSpace(addr) } -// refuseServerIDFromOtherHost implements the host half of INV-ASSIGNMENT-HOLDER-IDENTITY-001. OSS has no host +// refuseServerIDFromOtherHost implements the host half of INV-AUTH-HOLDER-IDENTITY-001. OSS has no host // authentication, so a server id names a host only if every address a heartbeat reports under that id is on the host // registered for it. A second process started with the same --server-id elsewhere (a copied config) is refused before // its slots reach the observations. Only the host part is compared (each volume process listens on its own ports); @@ -55,7 +55,7 @@ func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { } // holderSlotFact is the slot fact of replica on the server the authority line names (workspaceSourceHost); a -// same-replica claim from any other server, however fresh, is never used (INV-ASSIGNMENT-HOLDER-IDENTITY-001). +// same-replica claim from any other server, however fresh, is never used (INV-AUTH-HOLDER-IDENTITY-001). // No resolvable holder: no fact (fail closed). func (h *Host) holderSlotFact(volumeID, replicaID string, epoch uint64) (string, authority.SlotFact, bool) { holder := h.workspaceSourceHost(volumeID, replicaID, epoch) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index b76e95062d..e715455684 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -7,12 +7,105 @@ import ( "time" "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/lifecycle" "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc" "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" ) +// INV-AUTH-HOLDER-IDENTITY-001: after an issued workspace move the authority line is on the new host while the placement +// slot may still name the old one. The displayed primary node, its publish target and the CSI portal follow the ISSUED +// holder; the old host, still reporting the replica id with a newer observation, wins none of them. +func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) { + heads := map[string]authority.WorkspaceHead{"a2": {Gen: 9, Epoch: 1, Holder: "node-b/r1", RemoteLSN: 42, Detached: true}} + m, err := New(Config{Listen: "127.0.0.1:0", AuthorityStoreDir: t.TempDir(), LifecycleStoreDir: t.TempDir(), WorkspaceRPC: true, + WorkspaceHeadReader: func(_ context.Context, v string) (authority.WorkspaceHead, error) { return heads[v], nil }}) + if err != nil { + t.Fatal(err) + } + m.Start() + defer closeTestMaster(t, m) + conn, err := grpc.NewClient(m.Addr(), grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + t.Fatal(err) + } + defer conn.Close() + ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + defer cancel() + ws, lc, obs := control.NewWorkspaceServiceClient(conn), control.NewLifecycleServiceClient(conn), control.NewObservationServiceClient(conn) + for _, n := range []struct{ id, d, c string }{{"node-a", "127.0.0.1:19101", "127.0.0.1:19102"}, {"node-b", "127.0.0.1:19301", "127.0.0.1:19302"}} { + if _, err := m.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: n.id, DataAddr: n.d, CtrlAddr: n.c}); err != nil { + t.Fatal(err) + } + } + if _, err := lc.CreateVolume(ctx, &control.CreateVolumeRequest{VolumeId: "a2", SizeBytes: 1 << 20, ReplicationFactor: 1}); err != nil { + t.Fatal(err) + } + if _, err := m.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "a2", DesiredRF: 1, + Candidates: []lifecycle.PlacementCandidate{{VolumeID: "a2", ServerID: "node-b", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + if _, err := obs.ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-b", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, + Slots: []*control.HeartbeatSlot{{VolumeId: "a2", ReplicaId: "r1", DataAddr: "127.0.0.1:19301", CtrlAddr: "127.0.0.1:19302"}}}); err != nil { + t.Fatal(err) + } + if _, err := m.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + a2 := waitAuthorityLine(t, m.Publisher(), "a2") + id := &control.WorkspaceIdentity{ServerId: "node-b", VolumeId: "a2", ReplicaId: "r1", Epoch: a2.Epoch} + if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { + t.Fatal(err) + } + if _, err := ws.RevokeWorkspace(ctx, id); err != nil { + t.Fatal(err) + } + if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil { + t.Fatal(err) + } + g, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "to-a", VolumeId: "a2", ExpectedReplicaId: "r1", ExpectedEpoch: a2.Epoch, + TargetReplicaId: "r1", TargetServerId: "node-a", TargetDataAddr: "127.0.0.1:19111", TargetCtrlAddr: "127.0.0.1:19112", Kind: "clean"}) + if err != nil || !g.Issued || g.NewHost != "node-a" { + t.Fatalf("move to node-a: %+v %v", g, err) + } + line, _ := m.Publisher().VolumeAuthorityLine("a2") + if p, ok := m.Lifecycle().Placements.GetPlacementSnapshot("a2"); ok { + t.Logf("placement after the move: %+v (the displayed primary must not depend on it)", p.Slots) + } + fact := func(server, host string, at time.Time) authority.Observation { + return authority.Observation{ServerID: server, ObservedAt: at, Server: authority.ServerFact{Reachable: true, Eligible: true}, + Slots: []authority.SlotFact{{VolumeID: "a2", ReplicaID: "r1", DataAddr: host + ":19111", CtrlAddr: host + ":19112", + Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 10, + Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: host + ":3260", IQN: "iqn.2026-05.io.seaweedfs:a2", LUN: 1}}}}} + } + now := time.Now().UTC() + if err := m.ObservationHost().Ingest(fact("node-a", "127.0.0.1", now)); err != nil { + t.Fatal(err) + } + if err := m.ObservationHost().Ingest(fact("node-b", "192.0.2.9", now.Add(time.Second))); err != nil { // the old host, newer + t.Fatal(err) + } + if holder := m.workspaceSourceHost("a2", line.ReplicaID, line.Epoch); holder != "node-a" { + t.Fatalf("issued holder %q, want node-a (line %+v)", holder, line) + } + var vol *struct{ node, target string } + for _, v := range m.ObservationSnapshot(time.Now().UTC()).Volumes { + if v.VolumeID == "a2" { + vol = &struct{ node, target string }{v.PrimaryNode, v.PublishTarget} + } + } + if vol == nil || vol.node != "node-a" || vol.target != "127.0.0.1:3260" { + t.Fatalf("displayed primary %+v, want node-a at 127.0.0.1:3260 (the issued holder, not the placement slot or the old host)", vol) + } + resp, err := newServices(m).QueryVolumeStatus(ctx, &control.StatusRequest{VolumeId: "a2"}) + if err != nil || len(resp.Frontends) == 0 || resp.Frontends[0].Addr != "127.0.0.1:3260" { + t.Fatalf("CSI portal %v %v, want the issued holder's 127.0.0.1:3260", resp.GetFrontends(), err) + } +} + // heartbeatFrom sends a heartbeat for server whose slot addresses are on host. func (r *isolationRig) heartbeatFrom(server, host string) error { _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true, @@ -20,7 +113,7 @@ func (r *isolationRig) heartbeatFrom(server, host string) error { return err } -// INV-ASSIGNMENT-HOLDER-IDENTITY-001: OSS has no host authentication, so a server id names a host only if the master +// INV-AUTH-HOLDER-IDENTITY-001: OSS has no host authentication, so a server id names a host only if the master // refuses that id from any host other than the one registered for it. Two processes started with the same --server-id // on different hosts: the one on the registered host is accepted, the other is refused, and it never enters the // observations (a copied config cannot borrow the registered host's holder identity). @@ -38,7 +131,7 @@ func TestServerIDRefusedFromAHostOtherThanItsRegisteredOne(t *testing.T) { } } -// INV-ASSIGNMENT-HOLDER-IDENTITY-001: the CSI portal (QueryVolumeStatus frontends) and the displayed primary +// INV-AUTH-HOLDER-IDENTITY-001: the CSI portal (QueryVolumeStatus frontends) and the displayed primary // (ClusterStatus primary node and publish target) come from the server on the volume's authority line, never from // whichever host sent the freshest heartbeat for the same replica id. A stale old host that still reports the // primary's replica, even more recently, changes neither. diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index d53dc72de0..446d6b08b3 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -292,7 +292,7 @@ func (s *services) ReportHeartbeat(ctx context.Context, r *control.HeartbeatRepo if err := s.host.refuseColocatedHeartbeat(r.ServerId, storeident.Identity{MachineID: r.GetMachineId(), Dev: r.GetDurableRootDev(), FSID: r.GetDurableRootFsid()}); err != nil { return nil, status.Error(codes.FailedPrecondition, err.Error()) } - // INV-ASSIGNMENT-HOLDER-IDENTITY-001: one server id names one host. + // INV-AUTH-HOLDER-IDENTITY-001: one server id names one host. if err := s.host.refuseServerIDFromOtherHost(r); err != nil { return nil, status.Error(codes.FailedPrecondition, err.Error()) } @@ -514,7 +514,7 @@ func (s *services) QueryVolumeStatus(ctx context.Context, req *control.StatusReq } replicaIDs = primaryFirstReplicaIDs(replicaIDs, line.ReplicaID) // the primary's portal comes from the server on the line, never a fresher same-replica claim elsewhere - // (INV-ASSIGNMENT-HOLDER-IDENTITY-001) + // (INV-AUTH-HOLDER-IDENTITY-001) resp.Frontends = statusFrontendsFor(s.host.obs, req.VolumeId, replicaIDs, line.Assigned, func(replicaID string) (authority.SlotFact, bool) { if replicaID == line.ReplicaID { _, fact, ok := s.host.holderSlotFact(req.VolumeId, replicaID, line.Epoch) From b38462d01a47477afdb423fb6941788e642c9db7 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:07:44 -0800 Subject: [PATCH 114/204] fix: workspace holder RPCs refuse a server id from a host other than its registered one INV-AUTH-HOLDER-IDENTITY-001 (claude06 review of #416; claude01 decisions): - holderMatches (lease renew and revocation ACK) refuses an unregistered server id and a call whose gRPC network peer is not on the host registered for its server id. - SubscribeAssignments refuses the same for a workspace volume, so the line is never delivered to a second host with a copied --server-id; SubscribeRequest carries the subscriber's server_id (field 4), sent by the volume. - Refusals are logged. The heartbeat check stays (observations). - Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication. Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/server_host_identity.go | 73 +- .../host/master/server_host_identity_test.go | 81 ++ seaweed-block/core/host/master/services.go | 7 + .../core/host/master/workspace_service.go | 19 +- seaweed-block/core/host/volume/host.go | 1 + seaweed-block/core/rpc/control/control.pb.go | 1096 +++++++++-------- seaweed-block/core/rpc/proto/control.proto | 3 + 7 files changed, 716 insertions(+), 564 deletions(-) diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index 8855fa8f70..0a6a363913 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -1,12 +1,14 @@ package master import ( + "context" "fmt" "net" "strings" "github.com/seaweedfs/seaweed-block/core/authority" "github.com/seaweedfs/seaweed-block/core/rpc/control" + "google.golang.org/grpc/peer" ) // addrHost is the host part of a host:port (or bare host) address. @@ -17,43 +19,80 @@ func addrHost(addr string) string { return strings.TrimSpace(addr) } -// refuseServerIDFromOtherHost implements the host half of INV-AUTH-HOLDER-IDENTITY-001. OSS has no host -// authentication, so a server id names a host only if every address a heartbeat reports under that id is on the host -// registered for it. A second process started with the same --server-id elsewhere (a copied config) is refused before -// its slots reach the observations. Only the host part is compared (each volume process listens on its own ports); -// several server ids on one host stay allowed; an id with no registry record has nothing to contradict. -func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { - if h.lifecycle == nil || h.lifecycle.Nodes == nil { - return nil +// registryHosts is the host set the node registry records for serverID (data, ctrl and plain addresses) and the host +// named in refusals; ok is false when serverID has no registry record. +func (h *Host) registryHosts(serverID string) (hosts map[string]bool, named string, ok bool) { + if h.lifecycle == nil || h.lifecycle.Nodes == nil || serverID == "" { + return nil, "", false } - reg, ok := h.lifecycle.Nodes.GetNode(r.ServerId) + reg, ok := h.lifecycle.Nodes.GetNode(serverID) if !ok { - return nil + return nil, "", false } - hosts := map[string]bool{} + hosts = map[string]bool{} for _, a := range []string{reg.DataAddr, reg.CtrlAddr, reg.Addr} { if a != "" { hosts[addrHost(a)] = true } } - if len(hosts) == 0 { - return nil + named = addrHost(reg.DataAddr) + if named == "" { + named = addrHost(reg.Addr) } - registered := addrHost(reg.DataAddr) - if registered == "" { - registered = addrHost(reg.Addr) + return hosts, named, true +} + +// refuseServerIDFromOtherHost is the observation half of INV-AUTH-HOLDER-IDENTITY-001: a heartbeat whose slot addresses +// are on a host other than the one registered for its server id is refused before its slots reach the observations. +// Only the host part is compared (each volume process listens on its own ports); several server ids on one host stay +// allowed; an id with no registry record is not checked here (no first-seen binding in v1.0: host addresses change). +func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { + hosts, named, ok := h.registryHosts(r.ServerId) + if !ok || len(hosts) == 0 { + return nil } for _, s := range r.Slots { for _, a := range []string{s.DataAddr, s.CtrlAddr} { if a != "" && !hosts[addrHost(a)] { return fmt.Errorf("heartbeat: server id %s is registered on host %s; refused from %s (volume %s replica %s): one server id names one host", - r.ServerId, registered, addrHost(a), s.VolumeId, s.ReplicaId) + r.ServerId, named, addrHost(a), s.VolumeId, s.ReplicaId) } } } return nil } +// peerHost is the host part of a gRPC call's network peer; "" when the call carries none. +func peerHost(ctx context.Context) string { + p, ok := peer.FromContext(ctx) + if !ok || p.Addr == nil { + return "" + } + return addrHost(p.Addr.String()) +} + +// refuseWorkspaceHolderHost is the holder half of INV-AUTH-HOLDER-IDENTITY-001 for workspace volumes (lease renew, ACK, +// assignment stream): the server id must be registered (no first-seen binding), and the call's network peer must be on +// the host the registry records for it. Limits: it trusts the network peer address (no NAT or proxy between volume and +// master in OSS), and it is not authentication. Every refusal is logged. +func (h *Host) refuseWorkspaceHolderHost(ctx context.Context, rpc, server string) error { + hosts, named, ok := h.registryHosts(server) + var err error + switch ph := peerHost(ctx); { + case !ok: + err = fmt.Errorf("%s: server id %q is not registered; a workspace holder's server id must be", rpc, server) + case ph == "" || !hosts[ph]: + if ph == "" { + ph = "an unknown peer" + } + err = fmt.Errorf("%s: server id %s is registered on host %s; refused from %s: one server id names one host", rpc, server, named, ph) + } + if err != nil { + h.log.Print(err) + } + return err +} + // holderSlotFact is the slot fact of replica on the server the authority line names (workspaceSourceHost); a // same-replica claim from any other server, however fresh, is never used (INV-AUTH-HOLDER-IDENTITY-001). // No resolvable holder: no fact (fail closed). diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index e715455684..ca63b4266f 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -2,6 +2,7 @@ package master import ( "context" + "net" "strings" "testing" "time" @@ -183,3 +184,83 @@ func TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat(t *testing t.Fatalf("displayed primary node=%q target=%q, want %q %q (line server, not the stale host %s)", vol.PrimaryNode, vol.PublishTarget, holder, holderAddr, stale) } } + +// dialFrom opens a client connection to the rig's master whose source address is host (a real loopback address). +func (r *isolationRig) dialFrom(t *testing.T, host string) *grpc.ClientConn { + t.Helper() + d := net.Dialer{LocalAddr: &net.TCPAddr{IP: net.ParseIP(host)}} + conn, err := grpc.NewClient(r.m.Addr(), grpc.WithTransportCredentials(insecure.NewCredentials()), + grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) { return d.DialContext(ctx, "tcp", addr) })) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = conn.Close() }) + return conn +} + +// INV-AUTH-HOLDER-IDENTITY-001, workspace path: two processes with the same --server-id on two real loopback hosts. The +// one not on the registered host (127.0.0.2) is refused at lease renew, at the revocation ACK and at the assignment +// stream (so it never receives the line to adopt), and each refusal is logged; an unregistered server id is refused at +// its first renew; the registered host is unaffected. The check trusts the network peer address (no NAT or proxy +// between volume and master in OSS); it is not authentication. +func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T) { + r := newIsolationRig(t, false, t.TempDir(), t.TempDir()) // node-a registered on 127.0.0.1 + r.createVolume(t, "w1") + if _, err := r.m.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "w1", DesiredRF: 1, + Candidates: []lifecycle.PlacementCandidate{{VolumeID: "w1", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, + Slots: []*control.HeartbeatSlot{{VolumeId: "w1", ReplicaId: "r1", DataAddr: "127.0.0.1:19121", CtrlAddr: "127.0.0.1:19122"}}}); err != nil { + t.Fatal(err) + } + if _, err := r.m.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + line := waitAuthorityLine(t, r.m.Publisher(), "w1") + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "w1", ReplicaId: "r1", Epoch: line.Epoch} + other := r.dialFrom(t, "127.0.0.2") + wsOther, asnOther := control.NewWorkspaceServiceClient(other), control.NewAssignmentServiceClient(other) + refusedFrom2 := func(what string, err error) { + t.Helper() + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1; refused from 127.0.0.2") { + t.Fatalf("%s from 127.0.0.2 as node-a: %v, want the host refusal", what, err) + } + } + _, err := wsOther.RenewWorkspaceLease(r.ctx, id) + refusedFrom2("renew", err) + _, err = wsOther.AckWorkspaceRevoked(r.ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}) + refusedFrom2("ACK", err) + stream, err := asnOther.SubscribeAssignments(r.ctx, &control.SubscribeRequest{VolumeId: "w1", ReplicaId: "r1", ServerId: "node-a"}) + if err == nil { + _, err = stream.Recv() + } + refusedFrom2("assignment stream", err) + if n := strings.Count(r.logs.String(), "refused from 127.0.0.2"); n < 3 { + t.Fatalf("refusals logged %d times, want 3:\n%s", n, r.logs.String()) + } + // the registered host is unaffected: it renews and receives the line + if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err != nil { + t.Fatalf("renew from the registered host: %v", err) + } + own, err := control.NewAssignmentServiceClient(r.dialFrom(t, "127.0.0.1")).SubscribeAssignments(r.ctx, &control.SubscribeRequest{VolumeId: "w1", ReplicaId: "r1", ServerId: "node-a"}) + if err != nil { + t.Fatal(err) + } + if fact, err := own.Recv(); err != nil || fact.GetEpoch() != line.Epoch { + t.Fatalf("assignment stream from the registered host: %+v %v", fact, err) + } + // an unregistered server id is refused at its first renew; a stream naming no server id is refused too + _, err = r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{ServerId: "node-z", VolumeId: "w1", ReplicaId: "r1", Epoch: line.Epoch}) + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), `server id "node-z" is not registered`) { + t.Fatalf("renew by an unregistered server id: %v, want the not-registered refusal", err) + } + anon := r.dialFrom(t, "127.0.0.1") + s2, err := control.NewAssignmentServiceClient(anon).SubscribeAssignments(r.ctx, &control.SubscribeRequest{VolumeId: "w1", ReplicaId: "r1"}) + if err == nil { + _, err = s2.Recv() + } + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), `server id "" is not registered`) { + t.Fatalf("assignment stream with no server id: %v, want the not-registered refusal", err) + } +} diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 446d6b08b3..91b16ce507 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -391,6 +391,13 @@ func (s *services) SubscribeAssignments(req *control.SubscribeRequest, stream co if len(slots) == 0 { return fmt.Errorf("subscribe: volume %q not in accepted topology", req.VolumeId) } + // INV-AUTH-HOLDER-IDENTITY-001: a workspace volume's line is delivered only to a registered server id streaming + // from its registered host, so a second host with a copied --server-id never receives (never adopts) it. + if s.workspaceVolumeForRenewal(req.VolumeId) == nil { + if err := s.host.refuseWorkspaceHolderHost(ctx, "assignment stream", req.GetServerId()); err != nil { + return status.Error(codes.FailedPrecondition, err.Error()) + } + } type recv struct { ch <-chan adapter.AssignmentInfo diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 7c3cbc5ccc..8922ffdfb8 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -88,23 +88,30 @@ func leaseFact(volume string, l authority.WorkspaceLease) *control.WorkspaceLeas // holderMatches implements INV-AUTH-HOLDER-IDENTITY-001 for both holder RPCs. // The committed line and placement snapshot avoid store I/O on renewal. -func (s *services) holderMatches(volume, replica, server string, epoch uint64) bool { +// A non-nil error is the host refusal: the server id is unregistered, or the +// call's network peer is not on its registered host (refuseWorkspaceHolderHost). +func (s *services) holderMatches(ctx context.Context, volume, replica, server string, epoch uint64) (bool, error) { + if err := s.host.refuseWorkspaceHolderHost(ctx, "workspace lease", server); err != nil { + return false, err + } line, ok := s.host.Publisher().PublishedAuthorityLine(volume) if !ok || server == "" || line.ReplicaID != replica || line.Epoch != epoch { - return false + return false, nil } owner := line.IssuedHost if owner == "" { owner = s.host.placementSourceHost(volume, line.ReplicaID) } - return server == owner + return server == owner, nil } func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) { if err := s.workspaceVolumeForRenewal(q.GetVolumeId()); err != nil { return nil, err } - if !s.holderMatches(q.GetVolumeId(), q.GetReplicaId(), q.GetServerId(), q.GetEpoch()) { + if ok, err := s.holderMatches(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetServerId(), q.GetEpoch()); err != nil { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } else if !ok { return nil, status.Error(codes.FailedPrecondition, "workspace lease: server identity does not match the current holder") } l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch()) @@ -136,7 +143,9 @@ func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.Workspace if err := s.workspaceVolume(id.GetVolumeId()); err != nil { return nil, err } - if !s.holderMatches(id.GetVolumeId(), id.GetReplicaId(), id.GetServerId(), id.GetEpoch()) { + if ok, err := s.holderMatches(ctx, id.GetVolumeId(), id.GetReplicaId(), id.GetServerId(), id.GetEpoch()); err != nil { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } else if !ok { return nil, status.Error(codes.FailedPrecondition, "workspace ACK: server identity does not match the current holder") } if err := s.host.Publisher().AckWorkspaceRevocation(ctx, id.GetVolumeId(), authority.WorkspaceRevokeAck{ReplicaID: id.GetReplicaId(), Epoch: id.GetEpoch(), HeadGen: q.GetHeadGen()}); err != nil { diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 068acdc0d0..48d70a707b 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -768,6 +768,7 @@ func (h *Host) streamOnce(ctx context.Context) error { stream, err := h.asnCli.SubscribeAssignments(ctx, &control.SubscribeRequest{ VolumeId: h.cfg.VolumeID, ReplicaId: h.cfg.ReplicaID, + ServerId: h.cfg.ServerID, // INV-AUTH-HOLDER-IDENTITY-001: the master checks it against the stream's host }) if err != nil { return err diff --git a/seaweed-block/core/rpc/control/control.pb.go b/seaweed-block/core/rpc/control/control.pb.go index e5b3bf4ecc..e4e74aafe8 100644 --- a/seaweed-block/core/rpc/control/control.pb.go +++ b/seaweed-block/core/rpc/control/control.pb.go @@ -525,6 +525,9 @@ type SubscribeRequest struct { VolumeId string `protobuf:"bytes,1,opt,name=volume_id,json=volumeId,proto3" json:"volume_id,omitempty"` ReplicaId string `protobuf:"bytes,2,opt,name=replica_id,json=replicaId,proto3" json:"replica_id,omitempty"` ResumeEpoch uint64 `protobuf:"varint,3,opt,name=resume_epoch,json=resumeEpoch,proto3" json:"resume_epoch,omitempty"` // delivery hint only; does NOT influence authority + // the subscriber's --server-id: for a workspace volume the master delivers the line only to a registered server + // id whose stream comes from its registered host (INV-AUTH-HOLDER-IDENTITY-001) + ServerId string `protobuf:"bytes,4,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` } func (x *SubscribeRequest) Reset() { @@ -580,6 +583,13 @@ func (x *SubscribeRequest) GetResumeEpoch() uint64 { return 0 } +func (x *SubscribeRequest) GetServerId() string { + if x != nil { + return x.ServerId + } + return "" +} + // ReplicaDescriptor — one entry in an AssignmentFact.peers list. // Carries the authoritative lineage + addressing for a single peer // replica. Used by primary to configure its replication fan-out @@ -2994,569 +3004,571 @@ var file_control_proto_rawDesc = []byte{ 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x71, 0x0a, 0x10, - 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x8e, 0x01, 0x0a, + 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, + 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x21, 0x0a, + 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, + 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0xad, 0x01, + 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, + 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x22, 0xd6, 0x02, + 0x0a, 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, - 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x22, - 0xad, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, - 0x69, 0x70, 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, - 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, - 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x22, - 0xd6, 0x02, 0x0a, 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, - 0x63, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, - 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, - 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x40, 0x0a, 0x05, 0x70, 0x65, 0x65, - 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x6f, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x70, - 0x65, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x70, 0x65, 0x65, 0x72, 0x53, 0x65, - 0x74, 0x47, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, - 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, - 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, - 0x65, 0x64, 0x12, 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x70, - 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x19, 0x6c, 0x61, - 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x73, - 0x74, 0x75, 0x63, 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x6c, - 0x61, 0x73, 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x74, - 0x75, 0x63, 0x6b, 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, - 0x74, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x12, - 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, - 0x74, 0x68, 0x79, 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, - 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, - 0x6e, 0x22, 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, - 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x22, 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, 0x47, 0x65, 0x74, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x49, 0x64, 0x22, 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x24, 0x0a, 0x0e, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, - 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, - 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x5f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, 0x6e, 0x6f, 0x64, - 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, - 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x52, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, - 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, - 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, - 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, - 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, - 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x6e, - 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x45, - 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, - 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, - 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, - 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, - 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, - 0x6c, 0x49, 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, - 0x6c, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, - 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6c, - 0x61, 0x73, 0x74, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x61, 0x74, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, - 0x74, 0x41, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, - 0x69, 0x72, 0x65, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, - 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6d, 0x61, - 0x67, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6e, 0x67, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, - 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x72, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6c, 0x61, - 0x73, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x64, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x98, - 0x06, 0x0a, 0x0e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, - 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, - 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, - 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, - 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0f, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, - 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6f, 0x62, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, - 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x27, 0x0a, - 0x0f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x52, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, - 0x79, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, - 0x69, 0x6d, 0x61, 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, - 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x44, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x11, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, - 0x78, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, - 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, - 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, - 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, 0x0f, 0x52, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, - 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, - 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, - 0x6f, 0x73, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, - 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, - 0x6c, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6c, 0x61, - 0x74, 0x63, 0x68, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x64, 0x75, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x64, - 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x64, 0x75, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, 0x6e, 0x6f, 0x77, - 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, - 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x12, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, - 0x4c, 0x73, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x34, 0x0a, 0x16, - 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x5f, - 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, - 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, - 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, - 0x41, 0x64, 0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x41, 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x5f, 0x70, - 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x10, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, - 0x79, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, - 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x12, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, - 0x6c, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x64, 0x5f, 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, 0x64, 0x12, 0x2d, - 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xf8, 0x03, - 0x0a, 0x0c, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, - 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, - 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, - 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, - 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, - 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, - 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, - 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, - 0x65, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, - 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, + 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, + 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, + 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, + 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x40, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, + 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x65, 0x65, + 0x72, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x70, 0x65, 0x65, 0x72, 0x53, 0x65, 0x74, 0x47, + 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, + 0x12, 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, + 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x19, 0x6c, 0x61, 0x73, 0x74, + 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x75, + 0x63, 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x6c, 0x61, 0x73, + 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x75, 0x63, + 0x6b, 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, + 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x12, 0x75, 0x6e, + 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, + 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x79, 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, + 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, + 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, + 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x56, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, + 0x22, 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, + 0x0e, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, + 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x65, 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, + 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, + 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x6e, + 0x6f, 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, + 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, - 0x74, 0x75, 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, - 0x75, 0x72, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x49, 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x73, 0x22, 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, - 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, - 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, - 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, - 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, - 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x22, 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, - 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, - 0x7a, 0x65, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, - 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, - 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x17, 0x0a, 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, - 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x4e, 0x0a, 0x19, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, - 0x48, 0x0a, 0x1a, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, 0x0f, 0x46, 0x61, - 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, - 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x41, - 0x64, 0x64, 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x74, - 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3d, 0x0a, - 0x1b, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, - 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x65, 0x78, - 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, - 0x63, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, 0x67, 0x69, 0x62, - 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, 0x45, 0x6c, 0x69, - 0x67, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, - 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x42, 0x65, - 0x66, 0x6f, 0x72, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x38, 0x0a, 0x18, - 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, - 0x5f, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, - 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x43, - 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, - 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, - 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x0b, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, - 0x73, 0x22, 0xa7, 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, - 0x64, 0x12, 0x38, 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x70, - 0x6f, 0x63, 0x68, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, 0x0a, 0x1d, 0x73, - 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x61, 0x66, - 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, - 0x79, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x50, - 0x0a, 0x25, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x5f, 0x73, 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, - 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x21, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x77, 0x61, 0x70, - 0x70, 0x65, 0x64, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, - 0x12, 0x2e, 0x0a, 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, - 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6e, - 0x6f, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, - 0x6e, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, - 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, - 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x12, - 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, - 0x74, 0x62, 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, - 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, - 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, - 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, - 0x65, 0x6e, 0x74, 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81, 0x01, - 0x0a, 0x11, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, - 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73, 0x65, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x30, - 0x01, 0x32, 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x16, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, - 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x73, 0x65, 0x61, + 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, 0x6c, 0x61, + 0x69, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x6e, 0x43, 0x6c, + 0x61, 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, + 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, + 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, + 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, + 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x70, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, + 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, 0x6c, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, + 0x62, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6c, 0x61, 0x73, + 0x74, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x61, 0x74, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, + 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, + 0x65, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, + 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, + 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, + 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x72, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, + 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x98, 0x06, 0x0a, + 0x0e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, + 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, + 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2d, + 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, + 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1f, 0x0a, + 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x72, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x64, + 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x2b, + 0x0a, 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6f, 0x62, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x70, + 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, + 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6d, + 0x61, 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x14, + 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, + 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, + 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, + 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x44, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, + 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x14, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, + 0x64, 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, + 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, + 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, + 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6c, 0x61, 0x74, 0x63, + 0x68, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x64, 0x75, 0x72, 0x61, 0x62, + 0x6c, 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x64, 0x75, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, + 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x12, + 0x30, 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, + 0x69, 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x64, + 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4c, 0x73, + 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, + 0x65, 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x61, + 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x5f, 0x72, 0x65, + 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x61, 0x6e, 0x64, + 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x72, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x23, 0x0a, + 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x41, 0x64, + 0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x61, 0x64, 0x64, + 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x41, + 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, + 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x46, + 0x65, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, + 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x5f, + 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x12, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, + 0x50, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, + 0x5f, 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x12, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xf8, 0x03, 0x0a, 0x0c, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, + 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, + 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, + 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, + 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, + 0x72, 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x76, 0x69, 0x64, 0x65, + 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, + 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, + 0x41, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, + 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, + 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, + 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, + 0x22, 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x42, + 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, + 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, + 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, + 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, + 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x22, 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, + 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, + 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, + 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, + 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, + 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4e, 0x0a, + 0x19, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x48, 0x0a, + 0x1a, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6b, + 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6b, 0x6e, 0x6f, 0x77, + 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, + 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x74, 0x72, 0x6c, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3d, 0x0a, 0x1b, 0x65, + 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, + 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, + 0x70, 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x65, 0x78, 0x70, 0x65, + 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, + 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, 0x67, 0x69, 0x62, 0x6c, 0x65, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, 0x45, 0x6c, 0x69, 0x67, 0x69, + 0x62, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, + 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, 0x66, 0x61, + 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x66, 0x72, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, + 0x72, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x75, + 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x63, + 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x75, + 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x43, 0x6f, 0x76, + 0x65, 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, + 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, + 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, + 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, + 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, + 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x22, + 0xa7, 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, + 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x12, + 0x38, 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x70, 0x6f, 0x63, + 0x68, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, 0x0a, 0x1d, 0x73, 0x69, 0x6e, + 0x67, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x61, 0x66, 0x74, 0x65, + 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x41, + 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x50, 0x0a, 0x25, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x73, + 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x21, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x77, 0x61, 0x70, 0x70, 0x65, + 0x64, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2e, + 0x0a, 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x75, 0x74, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6e, 0x6f, 0x53, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x44, + 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, + 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, + 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x12, 0x4f, 0x62, + 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, + 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, + 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x25, 0x2e, + 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x61, + 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81, 0x01, 0x0a, 0x11, + 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x41, 0x73, + 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, + 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x30, 0x01, 0x32, + 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x16, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, 0x69, 0x73, + 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x12, 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, - 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, - 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x12, 0x57, - 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x73, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x74, 0x63, - 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x6f, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xec, - 0x04, 0x0a, 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, + 0x12, 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x12, 0x57, 0x61, 0x74, + 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, + 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xec, 0x04, 0x0a, + 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x6b, 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, + 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, + 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, - 0x12, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, - 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7e, 0x0a, 0x13, - 0x41, 0x62, 0x6f, 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, - 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7f, 0x0a, 0x14, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x69, 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, + 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, 0x12, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, - 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x66, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, - 0x61, 0x63, 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, - 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7e, 0x0a, 0x13, 0x41, 0x62, + 0x6f, 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, + 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7f, 0x0a, 0x14, 0x43, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, + 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, 0x0f, 0x46, + 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x66, + 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2f, 0x73, + 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, 0x63, 0x6f, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/seaweed-block/core/rpc/proto/control.proto b/seaweed-block/core/rpc/proto/control.proto index 650a8008fb..2d7eb8e29b 100644 --- a/seaweed-block/core/rpc/proto/control.proto +++ b/seaweed-block/core/rpc/proto/control.proto @@ -186,6 +186,9 @@ message SubscribeRequest { string volume_id = 1; string replica_id = 2; uint64 resume_epoch = 3; // delivery hint only; does NOT influence authority + // the subscriber's --server-id: for a workspace volume the master delivers the line only to a registered server + // id whose stream comes from its registered host (INV-AUTH-HOLDER-IDENTITY-001) + string server_id = 4; } // ReplicaDescriptor — one entry in an AssignmentFact.peers list. From cf40f8a5b5e100cbed32c774da26dc57085469be Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:14:35 -0800 Subject: [PATCH 115/204] test: in-process workspace RPCs carry a loopback peer; workspace holders are registered The holder host check (INV-AUTH-HOLDER-IDENTITY-001) reads the gRPC network peer and requires a registered server id; tests that call the service in-process now arrive as from 127.0.0.1, and tests that renew as node-a register it. Co-Authored-By: Claude Opus 5.5 --- .../host/master/journal_isolation_fold_test.go | 4 ++-- .../core/host/master/server_host_identity_test.go | 14 ++++++++++++++ .../host/master/workspace_lease_horizon_test.go | 8 ++++---- .../master/workspace_renewal_slowstore_test.go | 4 ++-- .../core/host/master/workspace_service_test.go | 1 + .../core/host/master/workspace_skew_test.go | 3 ++- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/seaweed-block/core/host/master/journal_isolation_fold_test.go b/seaweed-block/core/host/master/journal_isolation_fold_test.go index 220c0f5034..9eb5ce8ab3 100644 --- a/seaweed-block/core/host/master/journal_isolation_fold_test.go +++ b/seaweed-block/core/host/master/journal_isolation_fold_test.go @@ -312,7 +312,7 @@ func TestStatusReportsExtensionWriteLatency(t *testing.T) { line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} - if _, err := svc.RenewWorkspaceLease(ctx, id); err != nil { + if _, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id); err != nil { t.Fatal(err) // first grant: not an extension } get := func() map[string]any { @@ -329,7 +329,7 @@ func TestStatusReportsExtensionWriteLatency(t *testing.T) { t.Fatalf("before any extension: %v", b) } time.Sleep(8 * time.Second) - if _, err := svc.RenewWorkspaceLease(ctx, id); err != nil { + if _, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id); err != nil { t.Fatal(err) } for deadline := time.Now().Add(5 * time.Second); ; time.Sleep(20 * time.Millisecond) { diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index ca63b4266f..5b31e69525 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -13,6 +13,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/peer" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/timestamppb" ) @@ -264,3 +265,16 @@ func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T) t.Fatalf("assignment stream with no server id: %v, want the not-registered refusal", err) } } + +// loopbackPeer is ctx as an RPC from 127.0.0.1 arrives at the master (in-process service calls carry no peer). +func loopbackPeer(ctx context.Context) context.Context { + return peer.NewContext(ctx, &peer.Peer{Addr: &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 40000}}) +} + +// registerWorkspaceHolder registers server on 127.0.0.1 (a workspace holder must be registered). +func registerWorkspaceHolder(t *testing.T, h *Host, server string) { + t.Helper() + if _, err := h.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: server, DataAddr: "127.0.0.1:19901", CtrlAddr: "127.0.0.1:19902"}); err != nil { + t.Fatal(err) + } +} diff --git a/seaweed-block/core/host/master/workspace_lease_horizon_test.go b/seaweed-block/core/host/master/workspace_lease_horizon_test.go index 2acca42067..4882279711 100644 --- a/seaweed-block/core/host/master/workspace_lease_horizon_test.go +++ b/seaweed-block/core/host/master/workspace_lease_horizon_test.go @@ -113,7 +113,7 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} - first, err := svc.RenewWorkspaceLease(ctx, id) + first, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id) if err != nil { t.Fatal(err) } @@ -129,7 +129,7 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { if err != nil || !rv.Revoking || rv.ExpiresAtNs != first.ExpiresAtNs { t.Fatalf("RevokeWorkspace must report the grant %d, got %+v %v", first.ExpiresAtNs, rv, err) } - if _, err := svc.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil { + if _, err := svc.AckWorkspaceRevoked(loopbackPeer(ctx), &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil { t.Fatal(err) } deletions := h.Lifecycle().Deletions @@ -177,7 +177,7 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { } renewStarted = true go func() { - f, err := svc.RenewWorkspaceLease(ctx, id) + f, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id) renewed <- f renewErr <- err }() @@ -201,7 +201,7 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { case <-time.After(5 * time.Second): t.Fatal("mark deleting did not finish") } - if _, err := svc.RenewWorkspaceLease(ctx, id); err == nil || !strings.Contains(err.Error(), "being deleted") { + if _, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id); err == nil || !strings.Contains(err.Error(), "being deleted") { t.Fatalf("renewal after the reservation was published: %v; want refused as being deleted", err) } } diff --git a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go index 1ca711fc9f..a9c488dbcb 100644 --- a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go +++ b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go @@ -216,7 +216,7 @@ func TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite(t *testing.T) { line := waitAuthorityLine(t, h.Publisher(), "vol-b") svc := &services{host: h} id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-b", ReplicaId: line.ReplicaID, Epoch: line.Epoch} - if _, err := svc.RenewWorkspaceLease(ctx, id); err != nil { + if _, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id); err != nil { t.Fatal(err) // first grant } deletions := h.Lifecycle().Deletions @@ -266,7 +266,7 @@ func TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite(t *testing.T) { } start := time.Now() renewStarted = true - go func() { _, err := svc.RenewWorkspaceLease(ctx, id); renewed <- err }() + go func() { _, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id); renewed <- err }() select { case err := <-renewed: renewed <- err // keep it for the cleanup join diff --git a/seaweed-block/core/host/master/workspace_service_test.go b/seaweed-block/core/host/master/workspace_service_test.go index 8c4763d82b..38c13d73e0 100644 --- a/seaweed-block/core/host/master/workspace_service_test.go +++ b/seaweed-block/core/host/master/workspace_service_test.go @@ -70,6 +70,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { if _, err := h.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: "node-b", DataAddr: "127.0.0.1:9201", CtrlAddr: "127.0.0.1:9101"}); err != nil { t.Fatal(err) } + registerWorkspaceHolder(t, h, "node-a") // a workspace holder's server id must be registered (INV-AUTH-HOLDER-IDENTITY-001) seedVerifiedExistingReplicaPlacement(t, h) if _, err := h.RunLifecycleProductTick(); err != nil { t.Fatal(err) diff --git a/seaweed-block/core/host/master/workspace_skew_test.go b/seaweed-block/core/host/master/workspace_skew_test.go index 2b52a2b8ef..a2db589ec8 100644 --- a/seaweed-block/core/host/master/workspace_skew_test.go +++ b/seaweed-block/core/host/master/workspace_skew_test.go @@ -130,12 +130,13 @@ func TestWorkspaceClockSkewConfigReachesLeaseReply(t *testing.T) { if _, err := h.Lifecycle().Volumes.CreateVolume(lifecycle.VolumeSpec{VolumeID: "vol-a", SizeBytes: 1 << 20, ReplicationFactor: 1}); err != nil { t.Fatal(err) } + registerWorkspaceHolder(t, h, "node-a") // a workspace holder's server id must be registered (INV-AUTH-HOLDER-IDENTITY-001) seedVerifiedExistingReplicaPlacement(t, h) if _, err := h.RunLifecycleProductTick(); err != nil { t.Fatal(err) } line := waitAuthorityLine(t, h.Publisher(), "vol-a") - reply, err := (&services{host: h}).RenewWorkspaceLease(context.Background(), &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch}) + reply, err := (&services{host: h}).RenewWorkspaceLease(loopbackPeer(context.Background()), &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-a", ReplicaId: line.ReplicaID, Epoch: line.Epoch}) if err != nil { t.Fatal(err) } From 772cdef3ae2500c0a9bbe949711bbfd624c8c63b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:24:46 -0800 Subject: [PATCH 116/204] test: the workspace assignment stream names its server id Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/host/master/workspace_service_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/workspace_service_test.go b/seaweed-block/core/host/master/workspace_service_test.go index 38c13d73e0..6261450cf5 100644 --- a/seaweed-block/core/host/master/workspace_service_test.go +++ b/seaweed-block/core/host/master/workspace_service_test.go @@ -127,7 +127,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) { detached.Store(true) streamCtx, cancelStream := context.WithCancel(ctx) defer cancelStream() - stream, err := control.NewAssignmentServiceClient(conn).SubscribeAssignments(streamCtx, &control.SubscribeRequest{VolumeId: "vol-a", ReplicaId: "r2"}) + stream, err := control.NewAssignmentServiceClient(conn).SubscribeAssignments(streamCtx, &control.SubscribeRequest{VolumeId: "vol-a", ReplicaId: "r2", ServerId: "node-a"}) if err != nil { t.Fatal(err) } From fc6365232b79025e9939327182264505d988fec2 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:32:55 -0800 Subject: [PATCH 117/204] fix: no portal without the primary's holder evidence; the primary row is the issued holder codex01 review of #416 (INV-AUTH-HOLDER-IDENTITY-001): - P1: when the line's server has no evidence for the primary, QueryVolumeStatus lists no frontend, so CSI never publishes a supporting replica's frontend under the primary. Real CSI ControlStatusLookup negative (old host only: not found) and positive cases. - P2: the primary replica row (server id, node, frontend) is the issued holder as a whole. - Row: guard trace (Enforced in), tests, host scope and limits. Co-Authored-By: Claude Opus 5.5 --- .../core/host/master/observation_snapshot.go | 7 ++- .../host/master/server_host_identity_test.go | 63 ++++++++++++++++--- seaweed-block/core/host/master/services.go | 15 +++-- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/seaweed-block/core/host/master/observation_snapshot.go b/seaweed-block/core/host/master/observation_snapshot.go index 279f368d4a..b7cf9bb88b 100644 --- a/seaweed-block/core/host/master/observation_snapshot.go +++ b/seaweed-block/core/host/master/observation_snapshot.go @@ -233,8 +233,11 @@ func (h *Host) observationReplicas(volumeID string, placement lifecycle.Placemen } fact, ok := h.ObservationHost().Store().SlotFact(volumeID, replicaID) if hasLine && line.Assigned && replicaID == line.ReplicaID { - // the primary's evidence comes only from the line's server (INV-AUTH-HOLDER-IDENTITY-001) - _, fact, ok = h.holderSlotFact(volumeID, replicaID, line.Epoch) + // the whole primary row is the line's server: its identity, evidence and frontend + // (INV-AUTH-HOLDER-IDENTITY-001); never placement's server carrying the holder's frontend + var holder string + holder, fact, ok = h.holderSlotFact(volumeID, replicaID, line.Epoch) + replica.ServerID, replica.KubernetesNode = holder, holder } if ok { replica.Observed = true diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 5b31e69525..409fa71363 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -2,12 +2,15 @@ package master import ( "context" + "errors" + "fmt" "net" "strings" "testing" "time" "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/csi" "github.com/seaweedfs/seaweed-block/core/lifecycle" "github.com/seaweedfs/seaweed-block/core/rpc/control" "google.golang.org/grpc" @@ -84,23 +87,37 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) { Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: host + ":3260", IQN: "iqn.2026-05.io.seaweedfs:a2", LUN: 1}}}}} } now := time.Now().UTC() - if err := m.ObservationHost().Ingest(fact("node-a", "127.0.0.1", now)); err != nil { - t.Fatal(err) - } - if err := m.ObservationHost().Ingest(fact("node-b", "192.0.2.9", now.Add(time.Second))); err != nil { // the old host, newer - t.Fatal(err) - } if holder := m.workspaceSourceHost("a2", line.ReplicaID, line.Epoch); holder != "node-a" { t.Fatalf("issued holder %q, want node-a (line %+v)", holder, line) } - var vol *struct{ node, target string } + lookup := csi.NewControlStatusLookup(control.NewEvidenceServiceClient(conn)) + // only the old host reports the replica: no primary evidence from the issued holder, so no portal at all + if err := m.ObservationHost().Ingest(fact("node-b", "192.0.2.9", now.Add(time.Second))); err != nil { + t.Fatal(err) + } + if target, err := lookup.LookupPublishTarget(ctx, "a2", ""); !errors.Is(err, csi.ErrPublishTargetNotFound) { + t.Fatalf("CSI lookup with only the old host's claim: target %+v err %v, want ErrPublishTargetNotFound", target, err) + } + if err := m.ObservationHost().Ingest(fact("node-a", "127.0.0.1", now)); err != nil { + t.Fatal(err) + } + if target, err := lookup.LookupPublishTarget(ctx, "a2", ""); err != nil || !strings.Contains(fmt.Sprintf("%+v", target), "127.0.0.1:3260") || strings.Contains(fmt.Sprintf("%+v", target), "192.0.2.9") { + t.Fatalf("CSI lookup: target %+v err %v, want the issued holder's 127.0.0.1:3260", target, err) + } + var vol *struct{ node, target, rowServer, rowNode, rowFrontend string } for _, v := range m.ObservationSnapshot(time.Now().UTC()).Volumes { if v.VolumeID == "a2" { - vol = &struct{ node, target string }{v.PrimaryNode, v.PublishTarget} + vol = &struct{ node, target, rowServer, rowNode, rowFrontend string }{node: v.PrimaryNode, target: v.PublishTarget} + for _, r := range v.Replicas { + if r.ReplicaID == line.ReplicaID { + vol.rowServer, vol.rowNode, vol.rowFrontend = r.ServerID, r.KubernetesNode, r.FrontendAddr + } + } } } - if vol == nil || vol.node != "node-a" || vol.target != "127.0.0.1:3260" { - t.Fatalf("displayed primary %+v, want node-a at 127.0.0.1:3260 (the issued holder, not the placement slot or the old host)", vol) + // the whole primary row is the issued holder (codex01 P2): never placement's node-b carrying node-a's frontend + if vol == nil || vol.node != "node-a" || vol.target != "127.0.0.1:3260" || vol.rowServer != "node-a" || vol.rowNode != "node-a" || vol.rowFrontend != "127.0.0.1:3260" { + t.Fatalf("displayed primary %+v, want node-a at 127.0.0.1:3260 in the volume and its primary row (the issued holder, not the placement slot or the old host)", vol) } resp, err := newServices(m).QueryVolumeStatus(ctx, &control.StatusRequest{VolumeId: "a2"}) if err != nil || len(resp.Frontends) == 0 || resp.Frontends[0].Addr != "127.0.0.1:3260" { @@ -278,3 +295,29 @@ func registerWorkspaceHolder(t *testing.T, h *Host, server string) { t.Fatal(err) } } + +// codex01 P1: a CSI client takes the first frontend as the primary. When the primary's evidence (from the line's server) +// is missing, the status lists NO frontend, even though supporting replicas report theirs; without the rule a +// supporting replica's frontend would be published under the primary identity. +func TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing(t *testing.T) { + obs := authority.NewObservationHost(authority.ObservationHostConfig{}) + for _, r := range []struct{ server, replica, host string }{{"node-b", "r2", "127.0.0.2"}, {"node-c", "r3", "127.0.0.3"}} { + if err := obs.IngestHeartbeat(authority.HeartbeatMessage{ServerID: r.server, SentAt: time.Now().UTC(), Reachable: true, Eligible: true, + Slots: []authority.HeartbeatSlot{{VolumeID: "v1", ReplicaID: r.replica, DataAddr: r.host + ":9201", CtrlAddr: r.host + ":9101", + Frontends: []authority.FrontendTargetFact{{Protocol: "iscsi", Addr: r.host + ":3260", IQN: "iqn.2026-05.example:v1"}}}}}); err != nil { + t.Fatal(err) + } + } + noPrimary := func(replicaID string) (authority.SlotFact, bool) { + if replicaID == "r1" { + return authority.SlotFact{}, false // the line's server has no evidence for the primary + } + return obs.Store().SlotFact("v1", replicaID) + } + if got := statusFrontendsFor(obs, "v1", []string{"r1", "r2", "r3"}, true, "r1", noPrimary); len(got) != 0 { + t.Fatalf("primary evidence missing: frontends %v, want none (a supporting replica must not stand in for the primary)", got) + } + if got := statusFrontendsFor(obs, "v1", []string{"r1", "r2", "r3"}, true, "", noPrimary); len(got) != 2 { + t.Fatalf("control: without the primary rule the supporting frontends are listed (%v): the hazard this test pins", got) + } +} diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 91b16ce507..9a3733135c 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -522,7 +522,7 @@ func (s *services) QueryVolumeStatus(ctx context.Context, req *control.StatusReq replicaIDs = primaryFirstReplicaIDs(replicaIDs, line.ReplicaID) // the primary's portal comes from the server on the line, never a fresher same-replica claim elsewhere // (INV-AUTH-HOLDER-IDENTITY-001) - resp.Frontends = statusFrontendsFor(s.host.obs, req.VolumeId, replicaIDs, line.Assigned, func(replicaID string) (authority.SlotFact, bool) { + resp.Frontends = statusFrontendsFor(s.host.obs, req.VolumeId, replicaIDs, line.Assigned, line.ReplicaID, func(replicaID string) (authority.SlotFact, bool) { if replicaID == line.ReplicaID { _, fact, ok := s.host.holderSlotFact(req.VolumeId, replicaID, line.Epoch) return fact, ok @@ -572,18 +572,25 @@ func primaryFirstReplicaIDs(replicaIDs []string, primaryReplicaID string) []stri } func statusFrontendsForAssignedVolume(obs *authority.ObservationHost, volumeID string, replicaIDs []string, assigned bool) []*control.FrontendTarget { - return statusFrontendsFor(obs, volumeID, replicaIDs, assigned, nil) + return statusFrontendsFor(obs, volumeID, replicaIDs, assigned, "", nil) } // statusFrontendsFor lists the frontends of replicaIDs in order; slotOf selects each replica's slot fact (nil: the -// freshest claim for that replica). -func statusFrontendsFor(obs *authority.ObservationHost, volumeID string, replicaIDs []string, assigned bool, slotOf func(replicaID string) (authority.SlotFact, bool)) []*control.FrontendTarget { +// freshest claim for that replica). When primary is set and its slot fact is missing, nothing is listed: a CSI client +// takes the first frontend as the primary, so a supporting replica's frontend must never stand in for it +// (INV-AUTH-HOLDER-IDENTITY-001, fail closed). +func statusFrontendsFor(obs *authority.ObservationHost, volumeID string, replicaIDs []string, assigned bool, primary string, slotOf func(replicaID string) (authority.SlotFact, bool)) []*control.FrontendTarget { if !assigned || obs == nil { return nil } if slotOf == nil { slotOf = func(replicaID string) (authority.SlotFact, bool) { return obs.Store().SlotFact(volumeID, replicaID) } } + if primary != "" { + if _, ok := slotOf(primary); !ok { + return nil + } + } out := make([]*control.FrontendTarget, 0, len(replicaIDs)) seen := map[string]struct{}{} for _, replicaID := range replicaIDs { From abc57ceb6178adbc77def6778dfd7bd6ca0f6cb8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:51:44 -0800 Subject: [PATCH 118/204] fix: registry read from a committed snapshot; CSI publishes only a primary-owned target; deletion keeps the stream check codex01 review of #416 e56f1de1 (INV-AUTH-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001): - P1-1: the holder host check reads NodeInventoryStore.GetNodeSnapshot (published after each committed write), never the store mutex RegisterNode holds across file I/O. Held-registration-write control in core/lifecycle. - P1-2: a primary slot with no frontend lists nothing; status frontends carry their replica (FrontendTarget.replica_id = 8); CSI publishes a target only when the primary has a usable frontend, another replica's frontend joining only as an extra path to the same target. Real CSI lookup negatives (no primary frontend; rejected loopback primary). - P2: a deletion-reserved workspace volume keeps the assignment stream host check. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/csi/master_backend.go | 53 + .../core/csi/primary_owned_frontend_test.go | 45 + .../core/host/master/server_host_identity.go | 2 +- .../host/master/server_host_identity_test.go | 76 ++ seaweed-block/core/host/master/services.go | 7 +- .../core/host/master/workspace_service.go | 11 + .../core/lifecycle/node_inventory.go | 23 +- .../core/lifecycle/node_snapshot_test.go | 71 ++ seaweed-block/core/rpc/control/control.pb.go | 1103 +++++++++-------- seaweed-block/core/rpc/proto/control.proto | 4 + 10 files changed, 843 insertions(+), 552 deletions(-) create mode 100644 seaweed-block/core/csi/primary_owned_frontend_test.go create mode 100644 seaweed-block/core/lifecycle/node_snapshot_test.go diff --git a/seaweed-block/core/csi/master_backend.go b/seaweed-block/core/csi/master_backend.go index b18eec1888..6f84d42f9d 100644 --- a/seaweed-block/core/csi/master_backend.go +++ b/seaweed-block/core/csi/master_backend.go @@ -145,6 +145,13 @@ func publishTargetFromStatus(resp *control.StatusResponse, enableMultipath bool, if resp == nil { return PublishTarget{}, false } + if fronts, tagged := primaryOwnedFrontends(resp, rejectLoopback); tagged { + if len(fronts) == 0 { + return PublishTarget{}, false + } + resp = &control.StatusResponse{VolumeId: resp.GetVolumeId(), ReplicaId: resp.GetReplicaId(), Epoch: resp.GetEpoch(), + EndpointVersion: resp.GetEndpointVersion(), Assigned: resp.GetAssigned(), Frontends: fronts} + } base := PublishTarget{ VolumeID: resp.GetVolumeId(), ReplicaID: resp.GetReplicaId(), @@ -247,6 +254,52 @@ func publishTargetFromStatus(resp *control.StatusResponse, enableMultipath bool, return PublishTarget{}, false } +// primaryOwnedFrontends applies INV-AUTH-HOLDER-IDENTITY-001 when the master tags each frontend with its replica: the +// usable frontends of the primary replica come first, and another replica's frontend is kept only as an extra path to a +// target the primary itself serves (same IQN, or same NQN/NSID/transport). No usable primary frontend: none at all, so +// a supporting replica is never published under the primary identity. An untagged (older) response is returned as is. +func primaryOwnedFrontends(resp *control.StatusResponse, rejectLoopback bool) ([]*control.FrontendTarget, bool) { + tagged := false + for _, ft := range resp.GetFrontends() { + if ft != nil && ft.GetReplicaId() != "" { + tagged = true + } + } + if !tagged { + return nil, false + } + key := func(ft *control.FrontendTarget) (string, bool) { + switch { + case ft.GetAddr() == "" || rejectFrontendAddr(ft.GetAddr(), rejectLoopback): + return "", false + case ft.GetProtocol() == string(ProtocolISCSI) && ft.GetIqn() != "": + return "iscsi\x00" + ft.GetIqn(), true + case ft.GetProtocol() == string(ProtocolNVMe) && ft.GetNqn() != "": + return "nvme\x00" + ft.GetNqn() + "\x00" + strconv.FormatUint(uint64(ft.GetNsid()), 10) + "\x00" + + string(normalizeFrontendTransport(ProtocolNVMe, FrontendTransport(ft.GetTransport()))), true + } + return "", false + } + var out []*control.FrontendTarget + served := map[string]bool{} + for _, ft := range resp.GetFrontends() { + if ft != nil && ft.GetReplicaId() == resp.GetReplicaId() { + if k, ok := key(ft); ok { + served[k] = true + out = append(out, ft) + } + } + } + for _, ft := range resp.GetFrontends() { + if ft != nil && ft.GetReplicaId() != resp.GetReplicaId() { + if k, ok := key(ft); ok && served[k] { + out = append(out, ft) + } + } + } + return out, true +} + func rejectFrontendAddr(addr string, rejectLoopback bool) bool { if !rejectLoopback { return false diff --git a/seaweed-block/core/csi/primary_owned_frontend_test.go b/seaweed-block/core/csi/primary_owned_frontend_test.go new file mode 100644 index 0000000000..a276b139bd --- /dev/null +++ b/seaweed-block/core/csi/primary_owned_frontend_test.go @@ -0,0 +1,45 @@ +package csi + +import ( + "testing" + + "github.com/seaweedfs/seaweed-block/core/rpc/control" +) + +// INV-AUTH-HOLDER-IDENTITY-001: with replica-tagged frontends, a target is published only when the primary replica has a +// usable frontend; another replica's frontend is at most an extra path to the primary's own target. Untagged responses +// (an older master) keep the previous first-usable behaviour. +func TestPublishTargetIsPrimaryOwned(t *testing.T) { + ft := func(replica, addr, iqn string) *control.FrontendTarget { + return &control.FrontendTarget{Protocol: string(ProtocolISCSI), Addr: addr, Iqn: iqn, ReplicaId: replica} + } + status := func(fronts ...*control.FrontendTarget) *control.StatusResponse { + return &control.StatusResponse{VolumeId: "v1", Assigned: true, ReplicaId: "r1", Epoch: 3, Frontends: fronts} + } + // the primary's only frontend is one CSI rejects (loopback): the supporting replica's must not stand in + if got, ok := publishTargetFromStatus(status(ft("r1", "127.0.0.1:3260", "iqn.v1"), ft("r2", "192.0.2.2:3260", "iqn.v1")), false, true); ok { + t.Fatalf("rejected primary frontend: published %+v, want no target", got) + } + if got, ok := publishTargetFromStatus(status(ft("r1", "127.0.0.1:3260", "iqn.v1"), ft("r2", "192.0.2.2:3260", "iqn.v1")), true, true); ok { + t.Fatalf("rejected primary frontend (multipath): published %+v, want no target", got) + } + // primary first; a supporting path to the SAME target joins only as a multipath path + got, ok := publishTargetFromStatus(status(ft("r2", "192.0.2.2:3260", "iqn.v1"), ft("r1", "192.0.2.1:3260", "iqn.v1")), true, false) + if !ok || got.ISCSIAddr != "192.0.2.1:3260" || !got.Multipath || len(got.ISCSIAddrs) != 2 || got.ISCSIAddrs[0] != "192.0.2.1:3260" { + t.Fatalf("multipath: %+v ok=%v, want the primary first with the supporting path", got, ok) + } + // a supporting frontend of ANOTHER target never joins + got, ok = publishTargetFromStatus(status(ft("r1", "192.0.2.1:3260", "iqn.v1"), ft("r2", "192.0.2.2:3260", "iqn.other")), true, false) + if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.Multipath || got.IQN != "iqn.v1" { + t.Fatalf("foreign target: %+v ok=%v, want only the primary's", got, ok) + } + // no primary frontend at all, supporting present: no target + if got, ok := publishTargetFromStatus(status(ft("r2", "192.0.2.2:3260", "iqn.v1")), false, false); ok { + t.Fatalf("no primary frontend: published %+v, want no target", got) + } + // untagged (older master): unchanged first-usable selection + got, ok = publishTargetFromStatus(status(ft("", "192.0.2.2:3260", "iqn.v1")), false, false) + if !ok || got.ISCSIAddr != "192.0.2.2:3260" { + t.Fatalf("untagged: %+v ok=%v, want the first usable frontend", got, ok) + } +} diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index 0a6a363913..0ed05e436e 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -25,7 +25,7 @@ func (h *Host) registryHosts(serverID string) (hosts map[string]bool, named stri if h.lifecycle == nil || h.lifecycle.Nodes == nil || serverID == "" { return nil, "", false } - reg, ok := h.lifecycle.Nodes.GetNode(serverID) + reg, ok := h.lifecycle.Nodes.GetNodeSnapshot(serverID) // committed snapshot: never the store mutex (INV-WS-RENEW-NONBLOCKING-001) if !ok { return nil, "", false } diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 409fa71363..fff0ea9f4a 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -321,3 +321,79 @@ func TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing(t *testing.T) { t.Fatalf("control: without the primary rule the supporting frontends are listed (%v): the hazard this test pins", got) } } + +// inProcEvidence is the CSI lookup's EvidenceService client wired straight to the master's QueryVolumeStatus. +type inProcEvidence struct{ s *services } + +func (e inProcEvidence) QueryVolumeStatus(ctx context.Context, in *control.StatusRequest, _ ...grpc.CallOption) (*control.StatusResponse, error) { + return e.s.QueryVolumeStatus(ctx, in) +} + +// codex01 #416 P1-2: through the real CSI ControlStatusLookup, with supporting replicas reporting usable frontends, no +// target is published when the primary's slot (on the line's server) exists but carries no frontend, or when its only +// frontend is one CSI rejects (loopback, with loopback targets rejected). Control: the same lookup without the loopback +// rejection publishes the primary's own frontend. +func TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected(t *testing.T) { + h := newTestMasterWithControllerConfig(t, t.TempDir(), authority.TopologyControllerConfig{ExpectedSlotsPerVolume: 3}) + defer closeTestMaster(t, h) + seedObservationSnapshotVolume(t, h) + seedRF3PlacementForServers(t, h, "pvc-a", "m01", "m02", "tp01") + ingestObservationSnapshotRF3(t, h, true, true, true) + if _, err := h.RunLifecycleProductTick(); err != nil { + t.Fatalf("product tick: %v", err) + } + line := waitAuthorityLine(t, h.Publisher(), "pvc-a") + holder := h.workspaceSourceHost("pvc-a", line.ReplicaID, line.Epoch) + reprimary := func(fronts []authority.FrontendTargetFact, at time.Time) { + t.Helper() + if err := h.ObservationHost().Ingest(authority.Observation{ServerID: holder, ObservedAt: at, Server: authority.ServerFact{Reachable: true, Eligible: true}, + Slots: []authority.SlotFact{{VolumeID: "pvc-a", ReplicaID: line.ReplicaID, DataAddr: "192.0.2.1:19101", CtrlAddr: "192.0.2.1:19102", + Reachable: true, ReadyForPrimary: true, Eligible: true, EvidenceScore: 30, Frontends: fronts}}}); err != nil { + t.Fatal(err) + } + } + svc := newServices(h) + plain := csi.NewControlStatusLookup(inProcEvidence{svc}) + noLoopback := csi.NewControlStatusLookupWithOptions(inProcEvidence{svc}, csi.WithLoopbackPublishTargetsRejected()) + ctx := context.Background() + // (a) the primary slot exists on the holder but carries no frontend + reprimary(nil, time.Now().UTC().Add(time.Second)) + if resp, err := svc.QueryVolumeStatus(ctx, &control.StatusRequest{VolumeId: "pvc-a"}); err != nil || len(resp.Frontends) != 0 { + t.Fatalf("primary slot without a frontend: status frontends %v err %v, want none", resp.GetFrontends(), err) + } + if target, err := plain.LookupPublishTarget(ctx, "pvc-a", ""); !errors.Is(err, csi.ErrPublishTargetNotFound) { + t.Fatalf("primary slot without a frontend: CSI target %+v err %v, want ErrPublishTargetNotFound", target, err) + } + // (b) the primary's only frontend is loopback, which this CSI lookup rejects; supporting replicas are usable + reprimary([]authority.FrontendTargetFact{{Protocol: "iscsi", Addr: "127.0.0.1:3260", IQN: "iqn.2026-05.io.seaweedfs:pvc-a", LUN: 1}}, time.Now().UTC().Add(2*time.Second)) + if target, err := noLoopback.LookupPublishTarget(ctx, "pvc-a", ""); !errors.Is(err, csi.ErrPublishTargetNotFound) { + t.Fatalf("rejected primary frontend: CSI target %+v err %v, want ErrPublishTargetNotFound (no supporting stand-in)", target, err) + } + if target, err := plain.LookupPublishTarget(ctx, "pvc-a", ""); err != nil || target.ISCSIAddr != "127.0.0.1:3260" || target.ReplicaID != line.ReplicaID { + t.Fatalf("control: CSI target %+v err %v, want the primary's own 127.0.0.1:3260", target, err) + } +} + +// codex01 #416 P2: a workspace volume being deleted is still a workspace volume: its assignment stream keeps the holder +// host check (a deletion reservation must not open a bypass). +func TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck(t *testing.T) { + r := newIsolationRig(t, false, t.TempDir(), t.TempDir()) + r.createVolume(t, "w2") + if _, err := r.m.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "w2", DesiredRF: 1, + Candidates: []lifecycle.PlacementCandidate{{VolumeID: "w2", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + if len(r.m.replicaSlotsFor("w2")) == 0 { + t.Fatal("fixture: w2 has no replica slot, the stream would fail before the host check") + } + if _, err := r.m.Lifecycle().Deletions.Admit("w2", "del-1"); err != nil { + t.Fatal(err) + } + stream, err := control.NewAssignmentServiceClient(r.dialFrom(t, "127.0.0.2")).SubscribeAssignments(r.ctx, &control.SubscribeRequest{VolumeId: "w2", ReplicaId: "r1", ServerId: "node-a"}) + if err == nil { + _, err = stream.Recv() + } + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "refused from 127.0.0.2") { + t.Fatalf("deletion-reserved workspace volume, stream from another host: %v, want the host refusal", err) + } +} diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index 9a3733135c..f8a191b61f 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -393,7 +393,7 @@ func (s *services) SubscribeAssignments(req *control.SubscribeRequest, stream co } // INV-AUTH-HOLDER-IDENTITY-001: a workspace volume's line is delivered only to a registered server id streaming // from its registered host, so a second host with a copied --server-id never receives (never adopts) it. - if s.workspaceVolumeForRenewal(req.VolumeId) == nil { + if s.isWorkspaceVolume(req.VolumeId) { if err := s.host.refuseWorkspaceHolderHost(ctx, "assignment stream", req.GetServerId()); err != nil { return status.Error(codes.FailedPrecondition, err.Error()) } @@ -587,8 +587,8 @@ func statusFrontendsFor(obs *authority.ObservationHost, volumeID string, replica slotOf = func(replicaID string) (authority.SlotFact, bool) { return obs.Store().SlotFact(volumeID, replicaID) } } if primary != "" { - if _, ok := slotOf(primary); !ok { - return nil + if f, ok := slotOf(primary); !ok || len(f.Frontends) == 0 { + return nil // no primary evidence, or a primary slot with no frontend: nothing to publish } } out := make([]*control.FrontendTarget, 0, len(replicaIDs)) @@ -602,6 +602,7 @@ func statusFrontendsFor(obs *authority.ObservationHost, volumeID string, replica continue } for _, ft := range frontendTargetsToWire(slot.Frontends) { + ft.ReplicaId = replicaID // CSI selects only a primary-owned target (INV-AUTH-HOLDER-IDENTITY-001) key := frontendTargetKey(ft) if _, ok := seen[key]; ok { continue diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 8922ffdfb8..53b6238d21 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -54,6 +54,17 @@ func (s *services) workspaceVolumeForRenewal(volume string) error { return nil } +// isWorkspaceVolume reports whether volume is a workspace volume (workspace RPC on, an existing RF1 volume), from the +// lock-free lifecycle snapshot. Unlike workspaceVolumeForRenewal it ignores a deletion reservation: a volume being +// deleted is still a workspace volume, and its assignment stream keeps the holder host check (codex01 #416 P2). +func (s *services) isWorkspaceVolume(volume string) bool { + if !s.host.cfg.WorkspaceRPC || s.host.lifecycle == nil { + return false + } + r, ok := s.host.lifecycle.Volumes.GetVolumeSnapshot(volume) + return ok && r.Spec.ReplicationFactor == 1 +} + func workspaceError(err error) error { if err == nil { return nil diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index 20b29e695d..6c21d0cdec 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -64,9 +64,10 @@ type NodeRegistration struct { // NodeInventoryStore persists one JSON registration record per server. type NodeInventoryStore struct { - mu sync.Mutex - dir string - records map[string]NodeRegistration + mu sync.Mutex + dir string + records map[string]NodeRegistration + published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) } // OpenNodeInventoryStore opens or creates a node inventory store. @@ -84,9 +85,23 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) { if err := s.load(); err != nil { return nil, err } + for id, rec := range s.records { + s.published.Store(id, copyNodeRegistration(rec)) + } return s, nil } +// GetNodeSnapshot returns the last committed registration of serverID without taking the store mutex, which writers +// hold across file I/O: a lease renewal's holder host check never waits behind a registration write. The result is a +// copy (INV-WS-RENEW-NONBLOCKING-001, INV-AUTH-HOLDER-IDENTITY-001). +func (s *NodeInventoryStore) GetNodeSnapshot(serverID string) (NodeRegistration, bool) { + v, ok := s.published.Load(serverID) + if !ok { + return NodeRegistration{}, false + } + return copyNodeRegistration(v.(NodeRegistration)), true +} + // RegisterNode records the latest observed inventory for a server. // Repeating registration replaces observation fields, but still does not // publish authority or readiness. @@ -104,6 +119,7 @@ func (s *NodeInventoryStore) RegisterNode(reg NodeRegistration) (NodeRegistratio return NodeRegistration{}, err } s.records[reg.ServerID] = reg + s.published.Store(reg.ServerID, copyNodeRegistration(reg)) // committed: the file is in place return reg, nil } @@ -119,6 +135,7 @@ func (s *NodeInventoryStore) RemoveNode(serverID string) error { if err := os.Remove(s.path(serverID)); err != nil && !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("lifecycle: remove node %s: %w", serverID, err) } + s.published.Delete(serverID) // committed: the file is gone return nil } diff --git a/seaweed-block/core/lifecycle/node_snapshot_test.go b/seaweed-block/core/lifecycle/node_snapshot_test.go new file mode 100644 index 0000000000..f04cfe9575 --- /dev/null +++ b/seaweed-block/core/lifecycle/node_snapshot_test.go @@ -0,0 +1,71 @@ +package lifecycle + +import ( + "sync" + "testing" + "time" +) + +// INV-WS-RENEW-NONBLOCKING-001 + INV-AUTH-HOLDER-IDENTITY-001: the holder host check reads the node registry from a +// committed snapshot, so a lease renewal never waits behind a registration write (which holds the store mutex across +// file I/O). The snapshot is a copy, survives a reopen, and a removed node is unpublished. +func TestNodeSnapshotDoesNotWaitForARegistrationWrite(t *testing.T) { + dir := t.TempDir() + s, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + if _, err := s.RegisterNode(NodeRegistration{ServerID: "node-a", DataAddr: "127.0.0.1:19101", CtrlAddr: "127.0.0.1:19102"}); err != nil { + t.Fatal(err) + } + s.mu.Lock() // the mutex RegisterNode holds across file I/O: a held registration write + var once sync.Once + release := func() { once.Do(s.mu.Unlock) } + result := make(chan NodeRegistration, 1) + joined := make(chan struct{}) + t.Cleanup(func() { + release() + select { + case <-joined: + case <-time.After(5 * time.Second): + t.Error("snapshot reader did not join") + } + }) + go func() { defer close(joined); r, _ := s.GetNodeSnapshot("node-a"); result <- r }() + var got NodeRegistration + select { + case got = <-result: + case <-time.After(time.Second): + t.Fatal("node snapshot waited for a held registration write") + } + // control: the mutex-taking read does wait while the write is held + blocked := make(chan struct{}) + go func() { _, _ = s.GetNode("node-a"); close(blocked) }() + select { + case <-blocked: + t.Fatal("control: GetNode did not wait for the held registration write") + case <-time.After(200 * time.Millisecond): + } + release() + <-blocked + if got.DataAddr != "127.0.0.1:19101" { + t.Fatalf("wrong committed registration: %+v", got) + } + got.DataAddr = "changed-by-reader" + if again, _ := s.GetNodeSnapshot("node-a"); again.DataAddr != "127.0.0.1:19101" { + t.Fatal("caller mutated the published registration") + } + reopened, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + if r, ok := reopened.GetNodeSnapshot("node-a"); !ok || r.DataAddr != "127.0.0.1:19101" { + t.Fatal("reopened snapshot lost the registration") + } + if err := s.RemoveNode("node-a"); err != nil { + t.Fatal(err) + } + if _, ok := s.GetNodeSnapshot("node-a"); ok { + t.Fatal("removed node remained published") + } +} diff --git a/seaweed-block/core/rpc/control/control.pb.go b/seaweed-block/core/rpc/control/control.pb.go index e4e74aafe8..88a62df36d 100644 --- a/seaweed-block/core/rpc/control/control.pb.go +++ b/seaweed-block/core/rpc/control/control.pb.go @@ -324,6 +324,10 @@ type FrontendTarget struct { Lun uint32 `protobuf:"varint,5,opt,name=lun,proto3" json:"lun,omitempty"` Nsid uint32 `protobuf:"varint,6,opt,name=nsid,proto3" json:"nsid,omitempty"` Transport string `protobuf:"bytes,7,opt,name=transport,proto3" json:"transport,omitempty"` // NVMe: "tcp" (default) | "rdma"; empty for iSCSI + // the replica this frontend belongs to (StatusResponse): a CSI client publishes a target only when the primary + // replica has a usable frontend; another replica's frontend is at most an extra path to the same target + // (INV-AUTH-HOLDER-IDENTITY-001) + ReplicaId string `protobuf:"bytes,8,opt,name=replica_id,json=replicaId,proto3" json:"replica_id,omitempty"` } func (x *FrontendTarget) Reset() { @@ -407,6 +411,13 @@ func (x *FrontendTarget) GetTransport() string { return "" } +func (x *FrontendTarget) GetReplicaId() string { + if x != nil { + return x.ReplicaId + } + return "" +} + type HeartbeatAck struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2980,7 +2991,7 @@ var file_control_proto_rawDesc = []byte{ 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x69, 0x6e, 0x63, 0x61, 0x72, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x29, 0x0a, 0x10, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x75, 0x6e, - 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0xa8, 0x01, + 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0xc7, 0x01, 0x0a, 0x0e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, @@ -2991,352 +3002,374 @@ var file_control_proto_rawDesc = []byte{ 0x0d, 0x52, 0x03, 0x6c, 0x75, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6e, 0x73, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0x67, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x72, - 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x3b, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, - 0x70, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, - 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x22, 0x69, 0x0a, 0x0f, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x41, 0x63, 0x6b, 0x12, 0x3b, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, - 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x41, - 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x8e, 0x01, 0x0a, - 0x10, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, - 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x21, 0x0a, - 0x0c, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, - 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0xad, 0x01, - 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, - 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x22, 0xd6, 0x02, - 0x0a, 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x22, 0x67, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x72, 0x74, + 0x62, 0x65, 0x61, 0x74, 0x41, 0x63, 0x6b, 0x12, 0x3b, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, + 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x65, 0x64, 0x41, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, + 0x22, 0x69, 0x0a, 0x0f, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x41, 0x63, 0x6b, 0x12, 0x3b, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x5f, + 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x41, 0x74, + 0x12, 0x19, 0x0a, 0x08, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x8e, 0x01, 0x0a, 0x10, + 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, - 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, - 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, - 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, - 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, - 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, - 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x40, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, - 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x65, 0x65, - 0x72, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x70, 0x65, 0x65, 0x72, 0x53, 0x65, 0x74, 0x47, - 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, - 0x12, 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, - 0x65, 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x19, 0x6c, 0x61, 0x73, 0x74, - 0x5f, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x75, - 0x63, 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x6c, 0x61, 0x73, - 0x74, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x75, 0x63, - 0x6b, 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, - 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, - 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x12, 0x75, 0x6e, - 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, - 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x79, 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, - 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, - 0x19, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, - 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x22, 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x56, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, - 0x22, 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, - 0x0e, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, 0x43, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, - 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, - 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, - 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, - 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x6e, - 0x6f, 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, - 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, + 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, + 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0xad, 0x01, 0x0a, + 0x11, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x6f, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, + 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, + 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, + 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x22, 0xd6, 0x02, 0x0a, + 0x0e, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x12, + 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, + 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, + 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x64, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x74, 0x72, + 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x74, + 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x40, 0x0a, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x18, + 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, - 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, - 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, 0x6c, 0x61, - 0x69, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x6e, 0x43, 0x6c, - 0x61, 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, - 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, - 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, - 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x70, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, - 0x70, 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, 0x6c, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, - 0x62, 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6c, 0x61, 0x73, - 0x74, 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x61, 0x74, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, - 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, - 0x65, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x0e, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, - 0x25, 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, - 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, - 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, + 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, + 0x72, 0x52, 0x05, 0x70, 0x65, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x70, 0x65, 0x65, 0x72, + 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x11, 0x70, 0x65, 0x65, 0x72, 0x53, 0x65, 0x74, 0x47, 0x65, + 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x49, 0x64, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x12, + 0x36, 0x0a, 0x17, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x75, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x15, 0x6c, 0x61, 0x73, 0x74, 0x55, 0x6e, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x65, + 0x64, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x39, 0x0a, 0x19, 0x6c, 0x61, 0x73, 0x74, 0x5f, + 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x75, 0x63, + 0x6b, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x6c, 0x61, 0x73, 0x74, + 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x74, 0x75, 0x63, 0x6b, + 0x41, 0x74, 0x12, 0x45, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x18, + 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x09, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x12, 0x75, 0x6e, 0x68, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, + 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, + 0x52, 0x11, 0x75, 0x6e, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x73, 0x22, 0x49, 0x0a, 0x10, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x55, 0x6e, + 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x19, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x4c, 0x69, 0x73, + 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, + 0x35, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, + 0x41, 0x0a, 0x19, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0e, + 0x73, 0x69, 0x6e, 0x63, 0x65, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x69, 0x6e, 0x63, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x49, 0x64, 0x22, 0x90, 0x01, 0x0a, 0x14, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, + 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, + 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0xeb, 0x03, 0x0a, 0x15, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, + 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, + 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, + 0x64, 0x41, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x5f, 0x72, + 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3b, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x05, 0x6e, 0x6f, + 0x64, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x06, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x76, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, - 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x98, 0x06, 0x0a, - 0x0e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, - 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, - 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, - 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, - 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2d, - 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, - 0x63, 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1f, 0x0a, - 0x0b, 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x23, - 0x0a, 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x64, - 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x2b, - 0x0a, 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x70, - 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x18, 0x0c, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, - 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6d, - 0x61, 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, - 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x44, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x70, - 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, + 0x65, 0x6e, 0x74, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6e, 0x6f, 0x6e, 0x5f, 0x63, 0x6c, 0x61, 0x69, + 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x6e, 0x43, 0x6c, 0x61, + 0x69, 0x6d, 0x73, 0x22, 0xb5, 0x04, 0x0a, 0x0c, 0x4e, 0x6f, 0x64, 0x65, 0x45, 0x76, 0x69, 0x64, + 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, + 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, + 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, + 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, + 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x5f, 0x69, 0x70, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x49, 0x70, + 0x12, 0x20, 0x0a, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x61, 0x62, + 0x6c, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x05, 0x72, 0x65, 0x61, 0x64, 0x79, 0x12, 0x46, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, + 0x5f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x41, 0x74, + 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, + 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, + 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x25, + 0x0a, 0x0e, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x73, + 0x18, 0x0a, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0d, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, - 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x14, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, - 0x64, 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, - 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, - 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, - 0x6c, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, - 0x12, 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6c, 0x61, 0x74, 0x63, - 0x68, 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x64, 0x75, 0x72, 0x61, 0x62, - 0x6c, 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x64, 0x75, 0x72, - 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x6e, - 0x6f, 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, - 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x12, - 0x30, 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x69, 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x64, - 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4c, 0x73, - 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, - 0x65, 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x61, - 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x5f, 0x72, 0x65, - 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x61, 0x6e, 0x64, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x12, 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x72, 0x6f, - 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x23, 0x0a, - 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x41, 0x64, - 0x64, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x61, 0x64, 0x64, - 0x72, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x41, - 0x64, 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, - 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x46, - 0x65, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, - 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x5f, - 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x12, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, - 0x50, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, - 0x5f, 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x12, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, - 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xf8, 0x03, 0x0a, 0x0c, - 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, - 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, - 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, - 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, - 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, - 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, - 0x72, 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x76, 0x69, 0x64, 0x65, - 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, - 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, - 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, + 0x5f, 0x69, 0x70, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x66, 0x72, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x64, 0x49, 0x70, 0x12, 0x34, 0x0a, 0x16, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x5f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x18, + 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x22, 0x98, 0x06, 0x0a, 0x0e, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, + 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, + 0x74, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1f, 0x0a, 0x0b, + 0x61, 0x63, 0x6b, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0a, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x23, 0x0a, + 0x0d, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x50, 0x72, 0x6f, 0x66, 0x69, + 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x64, 0x65, 0x73, 0x69, 0x72, 0x65, 0x64, 0x5f, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x64, 0x65, + 0x73, 0x69, 0x72, 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x2b, 0x0a, + 0x11, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x72, + 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x6e, + 0x6f, 0x64, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x6d, 0x61, + 0x72, 0x79, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x10, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x44, + 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x52, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x73, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x12, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x18, 0x13, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x78, 0x74, 0x41, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x5f, 0x62, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x68, 0x69, 0x6e, 0x74, 0x18, 0x14, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, + 0x6c, 0x65, 0x48, 0x69, 0x6e, 0x74, 0x22, 0x81, 0x07, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, + 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x27, 0x0a, 0x0f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x65, 0x73, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0e, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x12, + 0x23, 0x0a, 0x0d, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x68, 0x6f, 0x73, 0x74, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x68, 0x79, 0x73, 0x69, 0x63, 0x61, 0x6c, + 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, + 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, + 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x6f, 0x6c, 0x65, 0x12, + 0x27, 0x0a, 0x0f, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6c, 0x61, 0x74, 0x63, 0x68, + 0x65, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, + 0x65, 0x4c, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x64, 0x75, 0x72, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x6b, 0x6e, 0x6f, + 0x77, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, + 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x12, 0x30, + 0x0a, 0x14, 0x64, 0x75, 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, + 0x65, 0x72, 0x5f, 0x6c, 0x73, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x64, 0x75, + 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x4c, 0x73, 0x6e, + 0x12, 0x27, 0x0a, 0x0f, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, + 0x61, 0x64, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x12, 0x34, 0x0a, 0x16, 0x63, 0x61, 0x6e, + 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x79, 0x5f, 0x72, 0x65, 0x61, + 0x73, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x63, 0x61, 0x6e, 0x64, 0x69, + 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, + 0x2b, 0x0a, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x66, 0x72, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x23, 0x0a, 0x0d, + 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x0e, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x41, 0x64, 0x64, + 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x41, 0x64, + 0x64, 0x72, 0x12, 0x30, 0x0a, 0x14, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, + 0x61, 0x72, 0x79, 0x5f, 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x12, 0x73, 0x74, 0x61, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x46, 0x65, + 0x6e, 0x63, 0x65, 0x64, 0x12, 0x4d, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, + 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x62, + 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x11, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x75, 0x6e, 0x64, 0x6c, 0x65, 0x50, + 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, + 0x6e, 0x71, 0x6e, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x72, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x64, 0x4e, 0x71, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x64, 0x5f, 0x6e, 0x73, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x66, + 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x4e, 0x73, 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x12, 0x66, + 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xf8, 0x03, 0x0a, 0x0c, 0x43, + 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x65, + 0x76, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, - 0x41, 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, - 0x72, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, - 0x65, 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, - 0x64, 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, - 0x22, 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, + 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x1b, 0x0a, + 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, + 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x76, + 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x6c, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0a, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6f, 0x6c, 0x64, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6e, 0x65, 0x77, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, + 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0f, 0x65, 0x6e, 0x64, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x25, 0x0a, 0x0e, 0x63, + 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x0e, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, + 0x65, 0x66, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, + 0x63, 0x65, 0x52, 0x65, 0x66, 0x22, 0xbc, 0x01, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, + 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, + 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, 0x64, 0x41, + 0x74, 0x12, 0x41, 0x0a, 0x07, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x07, 0x76, 0x6f, 0x6c, + 0x75, 0x6d, 0x65, 0x73, 0x22, 0xd8, 0x01, 0x0a, 0x16, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x25, 0x0a, 0x0e, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, + 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x75, 0x72, 0x65, + 0x64, 0x41, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, + 0x12, 0x3d, 0x0a, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0xbd, 0x02, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, 0x79, 0x74, + 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x79, + 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, 0x63, 0x74, + 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, + 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, + 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, + 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x22, + 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, 0x42, @@ -3355,220 +3388,200 @@ var file_control_proto_rawDesc = []byte{ 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x22, 0xbe, 0x02, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, + 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, + 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4e, 0x0a, 0x19, + 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, - 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x69, 0x7a, 0x65, 0x5f, 0x62, - 0x79, 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x73, 0x69, 0x7a, 0x65, - 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x12, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x11, 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x61, - 0x63, 0x74, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x23, 0x0a, 0x0d, 0x70, 0x76, 0x63, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x76, 0x63, 0x4e, 0x61, 0x6d, 0x65, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x70, 0x76, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x76, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x17, 0x0a, - 0x07, 0x70, 0x76, 0x63, 0x5f, 0x75, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x70, 0x76, 0x63, 0x55, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, - 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x22, 0x32, 0x0a, 0x13, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, - 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x49, 0x64, 0x22, 0x16, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x4e, 0x0a, - 0x19, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x48, 0x0a, 0x1a, + 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x48, 0x0a, - 0x1a, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x22, 0xa5, 0x04, 0x0a, 0x0f, 0x46, 0x61, 0x69, 0x6c, - 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x76, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, - 0x74, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, - 0x72, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x74, 0x72, 0x6c, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3d, 0x0a, 0x1b, 0x65, - 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, - 0x72, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, - 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x65, 0x78, 0x70, 0x65, - 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, - 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, 0x67, 0x69, 0x62, 0x6c, 0x65, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, 0x45, 0x6c, 0x69, 0x67, 0x69, - 0x62, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, - 0x66, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, 0x66, 0x61, - 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x66, 0x72, - 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, - 0x72, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x75, - 0x72, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x63, - 0x6f, 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x75, - 0x72, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x43, 0x6f, 0x76, - 0x65, 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, - 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, - 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, - 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x22, - 0xa7, 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, - 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, - 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x12, - 0x38, 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x65, 0x70, 0x6f, - 0x63, 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x70, 0x6f, 0x63, - 0x68, 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, 0x0a, 0x1d, 0x73, 0x69, 0x6e, - 0x67, 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x61, 0x66, 0x74, 0x65, - 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x41, - 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x50, 0x0a, 0x25, - 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x73, - 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x21, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x77, 0x61, 0x70, 0x70, 0x65, - 0x64, 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2e, - 0x0a, 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x75, 0x74, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6e, 0x6f, 0x53, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x44, - 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, - 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x12, 0x4f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, - 0x65, 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, - 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x25, 0x2e, - 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, - 0x74, 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x61, - 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, - 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81, 0x01, 0x0a, 0x11, - 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x41, 0x73, - 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, - 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, - 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x30, 0x01, 0x32, - 0x77, 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x16, 0x43, 0x6c, 0x75, - 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, - 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, 0x61, 0x77, - 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, - 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, 0x69, 0x73, - 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, - 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, - 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, - 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, - 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, - 0x12, 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, - 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, - 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, - 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x12, 0x57, 0x61, 0x74, - 0x63, 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, - 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, - 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, - 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xec, 0x04, 0x0a, - 0x10, 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, - 0x65, 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, - 0x0a, 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, - 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, - 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x65, 0x70, + 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x5f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x61, 0x74, 0x61, 0x41, 0x64, 0x64, 0x72, + 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x74, 0x72, 0x6c, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, + 0x65, 0x74, 0x43, 0x74, 0x72, 0x6c, 0x41, 0x64, 0x64, 0x72, 0x12, 0x3d, 0x0a, 0x1b, 0x65, 0x78, + 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x72, + 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x18, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x52, 0x65, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x16, 0x65, 0x78, 0x70, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x14, 0x65, 0x78, 0x70, 0x65, 0x63, + 0x74, 0x65, 0x64, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x45, 0x70, 0x6f, 0x63, 0x68, 0x12, + 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x6b, 0x5f, 0x65, 0x6c, 0x69, 0x67, 0x69, 0x62, 0x6c, 0x65, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x63, 0x6b, 0x45, 0x6c, 0x69, 0x67, 0x69, 0x62, + 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x1f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x5f, 0x66, + 0x65, 0x6e, 0x63, 0x65, 0x64, 0x5f, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x5f, 0x66, 0x61, 0x69, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1c, 0x66, 0x72, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x64, 0x46, 0x65, 0x6e, 0x63, 0x65, 0x64, 0x42, 0x65, 0x66, 0x6f, 0x72, + 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x38, 0x0a, 0x18, 0x64, 0x75, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x66, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x5f, 0x63, 0x6f, + 0x76, 0x65, 0x72, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x75, 0x72, + 0x61, 0x62, 0x6c, 0x65, 0x46, 0x72, 0x6f, 0x6e, 0x74, 0x69, 0x65, 0x72, 0x43, 0x6f, 0x76, 0x65, + 0x72, 0x65, 0x64, 0x12, 0x44, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, + 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, + 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, + 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, + 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, 0x72, 0x65, 0x66, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x22, 0xa7, + 0x03, 0x0a, 0x10, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, + 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x66, + 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x12, 0x38, + 0x0a, 0x18, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x65, 0x70, 0x6f, 0x63, + 0x68, 0x5f, 0x61, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x16, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x45, 0x70, 0x6f, 0x63, 0x68, + 0x41, 0x64, 0x76, 0x61, 0x6e, 0x63, 0x65, 0x64, 0x12, 0x41, 0x0a, 0x1d, 0x73, 0x69, 0x6e, 0x67, + 0x6c, 0x65, 0x5f, 0x70, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, + 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x1a, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x50, 0x72, 0x69, 0x6d, 0x61, 0x72, 0x79, 0x41, 0x66, + 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x50, 0x0a, 0x25, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x73, 0x77, + 0x61, 0x70, 0x70, 0x65, 0x64, 0x5f, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x66, 0x61, 0x69, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x21, 0x70, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, 0x77, 0x61, 0x70, 0x70, 0x65, 0x64, + 0x41, 0x66, 0x74, 0x65, 0x72, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x2e, 0x0a, + 0x13, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6d, 0x75, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x6e, 0x6f, 0x53, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4d, 0x75, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x44, 0x0a, + 0x1f, 0x6e, 0x6f, 0x5f, 0x63, 0x72, 0x6f, 0x73, 0x73, 0x5f, 0x76, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x5f, 0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x5f, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1b, 0x6e, 0x6f, 0x43, 0x72, 0x6f, 0x73, 0x73, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x49, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x43, 0x68, 0x61, + 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x5f, + 0x72, 0x65, 0x66, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x76, 0x69, 0x64, + 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x66, 0x73, 0x32, 0xdf, 0x01, 0x0a, 0x12, 0x4f, 0x62, 0x73, + 0x65, 0x72, 0x76, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x62, 0x0a, 0x0f, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, + 0x61, 0x74, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, + 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, - 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, - 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, 0x12, 0x4d, - 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, - 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, - 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7e, 0x0a, 0x13, 0x41, 0x62, - 0x6f, 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, - 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, - 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, - 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, - 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7f, 0x0a, 0x14, 0x43, 0x6f, - 0x6d, 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, - 0x6e, 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, - 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x48, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, + 0x41, 0x63, 0x6b, 0x12, 0x65, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, + 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x1a, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, + 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x6b, 0x32, 0x81, 0x01, 0x0a, 0x11, 0x41, + 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x6c, 0x0a, 0x14, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x41, 0x73, 0x73, + 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x41, 0x73, + 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x46, 0x61, 0x63, 0x74, 0x30, 0x01, 0x32, 0x77, + 0x0a, 0x0f, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x64, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x26, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, 0x0f, 0x46, - 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x66, - 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, - 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x73, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, + 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd1, 0x04, 0x0a, 0x16, 0x43, 0x6c, 0x75, 0x73, + 0x74, 0x65, 0x72, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x74, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x30, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, + 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x68, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x6b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, + 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x12, + 0x77, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x31, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x47, + 0x65, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, + 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x2e, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6c, 0x69, 0x6e, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x71, 0x0a, 0x12, 0x57, 0x61, 0x74, 0x63, + 0x68, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x32, + 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6c, + 0x75, 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x6c, 0x75, + 0x73, 0x74, 0x65, 0x72, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x32, 0xec, 0x04, 0x0a, 0x10, + 0x4c, 0x69, 0x66, 0x65, 0x63, 0x79, 0x63, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x6b, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, + 0x12, 0x2c, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, + 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, + 0x0c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x12, 0x2c, 0x2e, + 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, + 0x6c, 0x75, 0x6d, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2f, 0x73, - 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, 0x63, 0x6f, - 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x56, 0x6f, 0x6c, 0x75, + 0x6d, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7d, 0x0a, 0x12, 0x4d, 0x61, + 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, + 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7e, 0x0a, 0x13, 0x41, 0x62, 0x6f, + 0x72, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, + 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, 0x56, + 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, + 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, + 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x7f, 0x0a, 0x14, 0x43, 0x6f, 0x6d, + 0x6d, 0x69, 0x74, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, + 0x67, 0x12, 0x32, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x4d, 0x61, 0x72, 0x6b, + 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, + 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, + 0x4d, 0x61, 0x72, 0x6b, 0x56, 0x6f, 0x6c, 0x75, 0x6d, 0x65, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x79, 0x0a, 0x0f, 0x46, 0x61, + 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x66, 0x0a, + 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x12, 0x28, 0x2e, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x73, 0x65, 0x61, + 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x2e, 0x46, 0x61, 0x69, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x65, 0x61, 0x77, 0x65, 0x65, 0x64, 0x66, 0x73, 0x2f, 0x73, 0x65, + 0x61, 0x77, 0x65, 0x65, 0x64, 0x2d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x3b, 0x63, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/seaweed-block/core/rpc/proto/control.proto b/seaweed-block/core/rpc/proto/control.proto index 2d7eb8e29b..a130fb9537 100644 --- a/seaweed-block/core/rpc/proto/control.proto +++ b/seaweed-block/core/rpc/proto/control.proto @@ -170,6 +170,10 @@ message FrontendTarget { uint32 lun = 5; uint32 nsid = 6; string transport = 7; // NVMe: "tcp" (default) | "rdma"; empty for iSCSI + // the replica this frontend belongs to (StatusResponse): a CSI client publishes a target only when the primary + // replica has a usable frontend; another replica's frontend is at most an extra path to the same target + // (INV-AUTH-HOLDER-IDENTITY-001) + string replica_id = 8; } message HeartbeatAck { From e7d0114b1d1999046e5260070b2d4d42431f2808 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:53:59 -0800 Subject: [PATCH 119/204] docs: the volume role diagram's adopt edge names the registered-host delivery Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6506e3446d..678b308f7e 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -110,7 +110,7 @@ The role a blockvolume takes from each assignment, its replica listener's admiss ```mermaid stateDiagram-v2 [*] --> Unassigned: listener with a floor record, no role yet - Unassigned --> Primary: fact names self, listener fenced at e + Unassigned --> Primary: fact names self (server id + replica, delivered only to its registered host), listener fenced at e Unassigned --> Supporting: fact names another primary, self in peers Supporting --> Primary: promotion, fact names self at a higher epoch Primary --> Supporting: fact names another primary, self in peers From 8d103b2c85bb576f168e511d5c6be8d07bdf7e52 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:26:56 -0800 Subject: [PATCH 120/204] fix: iSCSI CSI paths bind IQN and LUN; live-renewal held-registration control; lease diagram guard codex01 review of #416 3439d278 (INV-AUTH-HOLDER-IDENTITY-001, INV-WS-RENEW-NONBLOCKING-001): - P1: primaryOwnedFrontends keys an iSCSI target by IQN AND LUN, so a supporting q/LUN2 never becomes a multipath path of the primary's q/LUN1 (mismatch and nonzero-match controls). - P2: TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite renews through holderMatches over gRPC while a registration write is held (NodeInventoryStore.HoldWritesForTest), and shows the hold is real. - Standards: the workspace lease diagram's holder edges name the registered-host guard; the snapshot test's control reader has a bounded, owned join. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/csi/master_backend.go | 4 +- .../core/csi/primary_owned_frontend_test.go | 12 +++++ .../host/master/server_host_identity_test.go | 54 +++++++++++++++++++ .../core/lifecycle/node_inventory.go | 8 +++ .../core/lifecycle/node_snapshot_test.go | 14 ++++- .../docs/design/agent-workspace-design.md | 8 +-- 6 files changed, 93 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/csi/master_backend.go b/seaweed-block/core/csi/master_backend.go index 6f84d42f9d..8dbfc649a4 100644 --- a/seaweed-block/core/csi/master_backend.go +++ b/seaweed-block/core/csi/master_backend.go @@ -256,7 +256,7 @@ func publishTargetFromStatus(resp *control.StatusResponse, enableMultipath bool, // primaryOwnedFrontends applies INV-AUTH-HOLDER-IDENTITY-001 when the master tags each frontend with its replica: the // usable frontends of the primary replica come first, and another replica's frontend is kept only as an extra path to a -// target the primary itself serves (same IQN, or same NQN/NSID/transport). No usable primary frontend: none at all, so +// target the primary itself serves (same IQN and LUN, or same NQN/NSID/transport). No usable primary frontend: none at all, so // a supporting replica is never published under the primary identity. An untagged (older) response is returned as is. func primaryOwnedFrontends(resp *control.StatusResponse, rejectLoopback bool) ([]*control.FrontendTarget, bool) { tagged := false @@ -273,7 +273,7 @@ func primaryOwnedFrontends(resp *control.StatusResponse, rejectLoopback bool) ([ case ft.GetAddr() == "" || rejectFrontendAddr(ft.GetAddr(), rejectLoopback): return "", false case ft.GetProtocol() == string(ProtocolISCSI) && ft.GetIqn() != "": - return "iscsi\x00" + ft.GetIqn(), true + return "iscsi\x00" + ft.GetIqn() + "\x00" + strconv.FormatUint(uint64(ft.GetLun()), 10), true // IQN AND LUN case ft.GetProtocol() == string(ProtocolNVMe) && ft.GetNqn() != "": return "nvme\x00" + ft.GetNqn() + "\x00" + strconv.FormatUint(uint64(ft.GetNsid()), 10) + "\x00" + string(normalizeFrontendTransport(ProtocolNVMe, FrontendTransport(ft.GetTransport()))), true diff --git a/seaweed-block/core/csi/primary_owned_frontend_test.go b/seaweed-block/core/csi/primary_owned_frontend_test.go index a276b139bd..f7e99b2565 100644 --- a/seaweed-block/core/csi/primary_owned_frontend_test.go +++ b/seaweed-block/core/csi/primary_owned_frontend_test.go @@ -33,6 +33,18 @@ func TestPublishTargetIsPrimaryOwned(t *testing.T) { if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.Multipath || got.IQN != "iqn.v1" { t.Fatalf("foreign target: %+v ok=%v, want only the primary's", got, ok) } + // iSCSI paths match on IQN AND LUN (codex01): a supporting q/LUN2 is another target, never a path to the primary's q/LUN1 + lun := func(replica, addr string, n uint32) *control.FrontendTarget { + return &control.FrontendTarget{Protocol: string(ProtocolISCSI), Addr: addr, Iqn: "iqn.q", Lun: n, ReplicaId: replica} + } + got, ok = publishTargetFromStatus(status(lun("r1", "192.0.2.1:3260", 1), lun("r2", "192.0.2.2:3260", 2)), true, false) + if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.LUN != 1 || got.Multipath || len(got.ISCSIAddrs) != 0 { + t.Fatalf("LUN mismatch: %+v ok=%v, want only the primary's q/LUN1 (no multipath)", got, ok) + } + got, ok = publishTargetFromStatus(status(lun("r1", "192.0.2.1:3260", 1), lun("r2", "192.0.2.2:3260", 1)), true, false) + if !ok || got.LUN != 1 || !got.Multipath || len(got.ISCSIAddrs) != 2 || got.ISCSIAddrs[0] != "192.0.2.1:3260" { + t.Fatalf("nonzero LUN match: %+v ok=%v, want multipath primary-first at LUN 1", got, ok) + } // no primary frontend at all, supporting present: no target if got, ok := publishTargetFromStatus(status(ft("r2", "192.0.2.2:3260", "iqn.v1")), false, false); ok { t.Fatalf("no primary frontend: published %+v, want no target", got) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index fff0ea9f4a..d9a720c59e 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -397,3 +397,57 @@ func TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck(t *testing.T) { t.Fatalf("deletion-reserved workspace volume, stream from another host: %v, want the host refusal", err) } } + +// codex01 #416 P2 (INV-WS-RENEW-NONBLOCKING-001): a LIVE lease renewal through holderMatches, whose host check reads the +// node registry, completes while a registration write is held (the store mutex RegisterNode keeps across file I/O). The +// hold is proven real: a concurrent RegisterNode does not finish until it is released. +func TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite(t *testing.T) { + r := newIsolationRig(t, false, t.TempDir(), t.TempDir()) // node-a registered on 127.0.0.1 + r.createVolume(t, "w3") + if _, err := r.m.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "w3", DesiredRF: 1, + Candidates: []lifecycle.PlacementCandidate{{VolumeID: "w3", ServerID: "node-a", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + if _, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, + Slots: []*control.HeartbeatSlot{{VolumeId: "w3", ReplicaId: "r1", DataAddr: "127.0.0.1:19131", CtrlAddr: "127.0.0.1:19132"}}}); err != nil { + t.Fatal(err) + } + if _, err := r.m.RunLifecycleProductTick(); err != nil { + t.Fatal(err) + } + line := waitAuthorityLine(t, r.m.Publisher(), "w3") + id := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "w3", ReplicaId: "r1", Epoch: line.Epoch} + if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err != nil { + t.Fatalf("first grant: %v", err) + } + release := r.m.Lifecycle().Nodes.HoldWritesForTest() + writer := make(chan struct{}) + t.Cleanup(func() { + release() + select { + case <-writer: + case <-time.After(5 * time.Second): + t.Error("held registration writer did not join") + } + }) + go func() { + defer close(writer) + _, _ = r.m.Lifecycle().Nodes.RegisterNode(lifecycle.NodeRegistration{ServerID: "node-c", DataAddr: "127.0.0.1:19501", CtrlAddr: "127.0.0.1:19502"}) + }() + ctx, cancel := context.WithTimeout(r.ctx, time.Second) + defer cancel() + if _, err := r.ws.RenewWorkspaceLease(ctx, id); err != nil { + t.Fatalf("live renewal during a held registration write: %v (it must not wait on the registry store)", err) + } + select { + case <-writer: + t.Fatal("control: the registration write was not actually held") + default: + } + release() + select { + case <-writer: + case <-time.After(5 * time.Second): + t.Fatal("registration write did not finish after the release") + } +} diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index 6c21d0cdec..c241b644da 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -102,6 +102,14 @@ func (s *NodeInventoryStore) GetNodeSnapshot(serverID string) (NodeRegistration, return copyNodeRegistration(v.(NodeRegistration)), true } +// HoldWritesForTest takes the mutex a registration write holds across file I/O and returns its release (idempotent): +// a held registration write, for controls that a reader (the holder host check) never waits on it. Tests only. +func (s *NodeInventoryStore) HoldWritesForTest() (release func()) { + s.mu.Lock() + var once sync.Once + return func() { once.Do(s.mu.Unlock) } +} + // RegisterNode records the latest observed inventory for a server. // Repeating registration replaces observation fields, but still does not // publish authority or readiness. diff --git a/seaweed-block/core/lifecycle/node_snapshot_test.go b/seaweed-block/core/lifecycle/node_snapshot_test.go index f04cfe9575..ee68635bbb 100644 --- a/seaweed-block/core/lifecycle/node_snapshot_test.go +++ b/seaweed-block/core/lifecycle/node_snapshot_test.go @@ -41,13 +41,25 @@ func TestNodeSnapshotDoesNotWaitForARegistrationWrite(t *testing.T) { // control: the mutex-taking read does wait while the write is held blocked := make(chan struct{}) go func() { _, _ = s.GetNode("node-a"); close(blocked) }() + t.Cleanup(func() { + release() + select { + case <-blocked: + case <-time.After(5 * time.Second): + t.Error("control reader did not join") + } + }) select { case <-blocked: t.Fatal("control: GetNode did not wait for the held registration write") case <-time.After(200 * time.Millisecond): } release() - <-blocked + select { + case <-blocked: + case <-time.After(5 * time.Second): + t.Fatal("control reader did not finish after the release") + } if got.DataAddr != "127.0.0.1:19101" { t.Fatalf("wrong committed registration: %+v", got) } diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 7679f68611..37c4091e7d 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -354,14 +354,14 @@ Lease states: ```mermaid stateDiagram-v2 state "Lease (blockmaster)" as L { - [*] --> Granted: first Renew after bind + [*] --> Granted: first Renew after bind (registered server id, from its registered host) [*] --> Granted: move issue starts the new holder's lease - Granted --> Granted: Renew before horizon and deadline (from memory) + Granted --> Granted: Renew before horizon and deadline (from memory; registered server id, from its registered host) Granted --> Revoking: BeginWorkspaceRevocation - Revoking --> Acked: host acks detached HEAD gen while the lease is valid + Revoking --> Acked: host acks detached HEAD gen while the lease is valid (from its registered host) Acked --> Moved: CLEAN move, including same host, new epoch Granted --> Expired: horizon or deadline passes - Expired --> Granted: unchanged holder, no move/revocation, MAX expiry + skew passed; durable re-grant + Expired --> Granted: unchanged holder from its registered host, no move/revocation, MAX expiry + skew passed; durable re-grant Expired --> Moved: FORCED move after expiry + skew bound, then HEAD read (an older-epoch HEAD is accepted) } ``` From a2e9930d4906c43a97746a731f435d88e3eb59ea Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:58:43 -0800 Subject: [PATCH 121/204] fix: the iSCSI multipath grouping binds IQN and LUN; NONBLOCKING row names the live renewal control codex01 review of #416 2cba5881: two primary-owned units of one IQN (q/LUN1 at A, q/LUN2 at B) are two targets, never one multipath target with LUN1 for both. Control added. INV-WS-RENEW-NONBLOCKING-001 lists TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/core/csi/master_backend.go | 15 +++++++++------ .../core/csi/primary_owned_frontend_test.go | 10 ++++++++++ seaweed-block/docs/design/invariants.md | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/seaweed-block/core/csi/master_backend.go b/seaweed-block/core/csi/master_backend.go index 8dbfc649a4..8ab11206b5 100644 --- a/seaweed-block/core/csi/master_backend.go +++ b/seaweed-block/core/csi/master_backend.go @@ -168,20 +168,23 @@ func publishTargetFromStatus(resp *control.StatusResponse, enableMultipath bool, if ft.GetProtocol() != string(ProtocolISCSI) || ft.GetAddr() == "" || ft.GetIqn() == "" || rejectFrontendAddr(ft.GetAddr(), rejectLoopback) { continue } - if _, ok := iscsiByIQN[ft.GetIqn()]; !ok { - iscsiOrder = append(iscsiOrder, ft.GetIqn()) + // one multipath target is one IQN AND LUN: paths to another LUN of the same IQN are another unit + // (INV-AUTH-HOLDER-IDENTITY-001) + key := ft.GetIqn() + "\x00" + strconv.FormatUint(uint64(ft.GetLun()), 10) + if _, ok := iscsiByIQN[key]; !ok { + iscsiOrder = append(iscsiOrder, key) } - iscsiByIQN[ft.GetIqn()] = append(iscsiByIQN[ft.GetIqn()], ft) + iscsiByIQN[key] = append(iscsiByIQN[key], ft) } - for _, iqn := range iscsiOrder { - frontends := iscsiByIQN[iqn] + for _, key := range iscsiOrder { + frontends := iscsiByIQN[key] if len(frontends) == 0 { continue } out := base out.Protocol = ProtocolISCSI out.ISCSIAddr = frontends[0].GetAddr() - out.IQN = iqn + out.IQN = frontends[0].GetIqn() out.LUN = frontends[0].GetLun() if len(frontends) > 1 { out.Multipath = true diff --git a/seaweed-block/core/csi/primary_owned_frontend_test.go b/seaweed-block/core/csi/primary_owned_frontend_test.go index f7e99b2565..e7aafe59fe 100644 --- a/seaweed-block/core/csi/primary_owned_frontend_test.go +++ b/seaweed-block/core/csi/primary_owned_frontend_test.go @@ -45,6 +45,16 @@ func TestPublishTargetIsPrimaryOwned(t *testing.T) { if !ok || got.LUN != 1 || !got.Multipath || len(got.ISCSIAddrs) != 2 || got.ISCSIAddrs[0] != "192.0.2.1:3260" { t.Fatalf("nonzero LUN match: %+v ok=%v, want multipath primary-first at LUN 1", got, ok) } + // two PRIMARY-owned units of one IQN (q/LUN1 at A, q/LUN2 at B) are two targets, never one multipath target with + // LUN1 for both (codex01: the final grouping binds IQN and LUN too) + got, ok = publishTargetFromStatus(status(lun("r1", "192.0.2.1:3260", 1), lun("r1", "192.0.2.2:3260", 2)), true, false) + if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.LUN != 1 || got.Multipath || len(got.ISCSIAddrs) != 0 { + t.Fatalf("two primary units: %+v ok=%v, want q/LUN1 at 192.0.2.1 alone (no multipath with LUN2's path)", got, ok) + } + got, ok = publishTargetFromStatus(status(lun("", "192.0.2.1:3260", 1), lun("", "192.0.2.2:3260", 2)), true, false) + if !ok || got.LUN != 1 || got.Multipath { + t.Fatalf("untagged two units: %+v ok=%v, want q/LUN1 alone", got, ok) + } // no primary frontend at all, supporting present: no target if got, ok := publishTargetFromStatus(status(ft("r2", "192.0.2.2:3260", "iqn.v1")), false, false); ok { t.Fatalf("no primary frontend: published %+v, want no target", got) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 678b308f7e..6506e3446d 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -110,7 +110,7 @@ The role a blockvolume takes from each assignment, its replica listener's admiss ```mermaid stateDiagram-v2 [*] --> Unassigned: listener with a floor record, no role yet - Unassigned --> Primary: fact names self (server id + replica, delivered only to its registered host), listener fenced at e + Unassigned --> Primary: fact names self, listener fenced at e Unassigned --> Supporting: fact names another primary, self in peers Supporting --> Primary: promotion, fact names self at a higher epoch Primary --> Supporting: fact names another primary, self in peers From 31878ce8d86cb9d9b2eab8f1f2e405bccdda4596 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:26:34 -0800 Subject: [PATCH 122/204] docs: re-apply the #416 trace on #411's final docs: Part A guards, volume diagram edge, INV-AUTH and NONBLOCKING rows Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6506e3446d..2e0b5ed147 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -92,14 +92,14 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | From | To | Event and guard | Enforced in | Protects | |---|---|---|---|---| -| none | Granted | `RenewWorkspaceLease` from the current primary (server id, replica id) at the current epoch; a missing/foreign server is refused by RPC holderMatches; no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-AUTH-HOLDER-IDENTITY-001` | -| Granted | Granted | current primary server/replica/epoch required by RPC holderMatches (missing server refused); renew from memory (the lease view, leaf lock only) before the durable horizon and the granted deadline; the grant is min(now + TTL, horizon), refused with an error when it would leave no host validity (grant − skew/2 ≤ now); an extender, an ordinary writer under the publisher lock, raises the horizon to trigger + 1.5·TTL | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LEASE-HORIZON-MONO-001`, `INV-WS-RENEW-NONBLOCKING-001`, `INV-LEASE-VIEW-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| none | Granted | `RenewWorkspaceLease` from the current primary (server id, replica id) at the current epoch; a missing/foreign server is refused by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`); no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Granted | Granted | current primary server/replica/epoch required by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) (missing server refused); renew from memory (the lease view, leaf lock only) before the durable horizon and the granted deadline; the grant is min(now + TTL, horizon), refused with an error when it would leave no host validity (grant − skew/2 ≤ now); an extender, an ordinary writer under the publisher lock, raises the horizon to trigger + 1.5·TTL | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LEASE-HORIZON-MONO-001`, `INV-WS-RENEW-NONBLOCKING-001`, `INV-LEASE-VIEW-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Granted | Revoking | `BeginWorkspaceRevocation` for the matching lease; a renew now returns the revoking lease with the granted expiry, min(horizon, deadline), without extending it | `core/authority/workspace.go` `BeginWorkspaceRevocation`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `WorkspaceLeaseReply` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001` | -| Revoking | Acked | `AckWorkspaceRevocation` from the primary server/replica at the current epoch, validated by the same RPC holderMatches (missing/foreign server refused), a nonzero HEAD generation, the lease still valid; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Revoking | Acked | `AckWorkspaceRevocation` from the primary server/replica at the current epoch, validated by the same RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) (missing/foreign server refused), a nonzero HEAD generation, the lease still valid; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Acked | Moved (clean) | HEAD detached by the expected holder at the expected epoch, and the acknowledgement names that HEAD generation; the target may be the same host, with a newly issued epoch and every binding/collision/isolation check retained | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `validateWorkspaceMoveRequest`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-SAME-HOST-CLEAN-MOVE-001` | | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | -| Expired | Granted | Same current primary server/replica/epoch, validated by RPC holderMatches with missing server refused, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Expired | Granted | Same current primary server/replica/epoch, validated by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) with missing server refused, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -110,7 +110,7 @@ The role a blockvolume takes from each assignment, its replica listener's admiss ```mermaid stateDiagram-v2 [*] --> Unassigned: listener with a floor record, no role yet - Unassigned --> Primary: fact names self, listener fenced at e + Unassigned --> Primary: fact names self (server id + replica, delivered only to its registered host), listener fenced at e Unassigned --> Supporting: fact names another primary, self in peers Supporting --> Primary: promotion, fact names self at a higher epoch Primary --> Supporting: fact names another primary, self in peers @@ -132,7 +132,7 @@ RF2 qualification limitation until ordered-live certification is wired (#297). S |---|---|---|---|---| | any | (no change) | local readiness blocked (recovery pending or failed): the fact is stored and replayed when readiness clears | `core/host/volume/host.go` `applyFact`, `replayLocalReadinessFactIfReady` | `INV-ROLE-READINESS-BLOCK-001` | | any | (no change) | a role call below the current desired epoch is refused and does not clear a newer admission failure | `core/host/volume/host.go` `fenceSelfWithPeers`, `latchRoleAdmission` | `INV-ROLE-STALE-REPLAY-001` | -| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); refusePrimaryAssignment rejects a candidate behind a newer foreign line or naming a different server at the same epoch before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Unassigned, Supporting | Primary at e | the primary fact names this process server and replica via assignmentNamesSelf, without comparing endpoint strings (routing data, reported as status/log warning on mismatch); missing/foreign server is refused; refused foreign facts are recorded but fence only an adopted own lineage that IsSuperseded finds strictly older (unassigned and older replay keep waiting); refusePrimaryAssignment rejects a candidate behind a newer foreign line or naming a different server at the same epoch before adapter admission; the replica set is installed; the listener is fenced as primary and its floor e is persisted before the adapter is told; for a workspace volume the master delivers the fact only to a registered server id streaming from its registered host (`SubscribeAssignments` with `refuseWorkspaceHolderHost`) | `core/host/volume/host.go` `applyFact`, `fenceSelfWithPeers`; `core/transport/replica.go` `FenceAsPrimary`, `raiseFloor` | `INV-FENCE-SELF-ON-PROMOTE-001`, `INV-FENCE-FLOOR-DURABLE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Unassigned, Primary | Supporting at e | the fact names another primary and lists this replica as a peer; the floor e is persisted first; the frontend stays gated | `core/host/volume/host.go` `applyFact`; `core/transport/replica.go` `AdmitAsReplica` | `INV-FENCE-FLOOR-DURABLE-001` | | Primary, Supporting | Excluded | another primary excludes this replica, or IsSuperseded finds a foreign-server fact strictly newer than an adopted own lineage; record the foreign line, close ingress and gate the frontend; unassigned and older/equal foreign replay do not fence; endpoints are not identity; refusePrimaryAssignment rejects any candidate changing a recorded server within the same epoch, regardless of endpoint version | `core/host/volume/host.go` `applyFact`, `recordOtherLine`; `core/host/volume/projection_bridge.go` `projectionWithSupersede` | `INV-ROLE-SUPERSEDED-001`, `INV-FENCE-STALE-PRIMARY-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Excluded | Excluded (no change) | an older recorded foreign fact cannot replace the newer epoch/endpoint-version fence; a stale replay cannot re-enable the frontend | `core/host/volume/host.go` `recordOtherLine`, `IsSuperseded` | `INV-AUTH-HOLDER-IDENTITY-001` | @@ -575,7 +575,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409 | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row | - (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend, iSCSI by IQN and LUN) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication | - (unit and RPC identity boundary) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | @@ -584,7 +584,7 @@ Notes: | `INV-LEASE-VIEW-OWNED-001` | The granted deadline and the extender flag exist only in the lease view; refreshing the view from its derive inputs never changes either of them. | M2 every workspace transition | `core/authority/workspace_lease_view.go` `refreshLeaseViewLocked`, `setLeaseDeadlineLocked`, `extendWorkspaceLease` | — | — | STUB | | `INV-WS-LEASE-HORIZON-001` | For the active lease of the current authority epoch, the `Lease.ExpiresAtNS` persisted in the authority store is at least the published horizon, and the published horizon is at least every grant issued since the last reload. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`, `newWorkspaceLease`, `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked`, `issueWorkspaceMove` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardFencesByHorizonUnderStalledStore` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease` | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`) | — | ACTIVE | +| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | From d65ac54ffbfc8fe7b520cba631899044288ee3d8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 04:39:43 -0800 Subject: [PATCH 123/204] fix(master): capture line owner and bind its model trace --- seaweed-block/core/adapter/normalize.go | 4 + .../core/authority/assignment_owner.go | 26 +++++++ .../core/authority/assignment_owner_test.go | 25 +++++++ seaweed-block/core/authority/authority.go | 6 +- .../core/authority/workspace_lease_view.go | 38 +++++----- .../core/authority/workspace_test.go | 13 +++- .../host/master/assignment_fact_owner_test.go | 28 +++++++ seaweed-block/core/host/master/services.go | 44 ++++++----- .../core/host/master/workspace_binding.go | 15 ++++ .../master/workspace_lease_horizon_test.go | 27 +++++++ .../host/master/workspace_line_owner_test.go | 74 +++++++++++++++++++ .../core/host/master/workspace_service.go | 6 +- seaweed-block/docs/design/invariants.md | 36 ++++++++- .../WorkspaceRegrant-owner-label-results.md | 48 ++++++++++++ 14 files changed, 342 insertions(+), 48 deletions(-) create mode 100644 seaweed-block/core/authority/assignment_owner.go create mode 100644 seaweed-block/core/authority/assignment_owner_test.go create mode 100644 seaweed-block/core/host/master/assignment_fact_owner_test.go create mode 100644 seaweed-block/core/host/master/workspace_line_owner_test.go create mode 100644 seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md diff --git a/seaweed-block/core/adapter/normalize.go b/seaweed-block/core/adapter/normalize.go index 082ab4e768..8871e7159c 100644 --- a/seaweed-block/core/adapter/normalize.go +++ b/seaweed-block/core/adapter/normalize.go @@ -23,6 +23,10 @@ import ( // AssignmentInfo is a raw assignment from the master heartbeat. type AssignmentInfo struct { + // ServerID is immutable for a moved authority line; an unknown moved + // owner remains empty instead of falling back to placement. + ServerID string + OwnerFromMove bool VolumeID string ReplicaID string Epoch uint64 diff --git a/seaweed-block/core/authority/assignment_owner.go b/seaweed-block/core/authority/assignment_owner.go new file mode 100644 index 0000000000..df7299423d --- /dev/null +++ b/seaweed-block/core/authority/assignment_owner.go @@ -0,0 +1,26 @@ +package authority + +import "github.com/seaweedfs/seaweed-block/core/adapter" + +// captureAssignmentOwner binds owner and line in one publication under p.mu +// (INV-AUTH-HOLDER-IDENTITY-001). Reload derives it from that same durable +// record's journal. A reserved/unissued move never permits placement fallback. +func (p *Publisher) captureAssignmentOwner(info *adapter.AssignmentInfo, issuing *WorkspaceState) { + state := issuing + if state == nil { + state = p.workspace[info.VolumeID] + } + if state == nil { + return + } + for _, move := range state.Moves { + if move.NewReplicaID == info.ReplicaID && move.NewEpoch == info.Epoch { + info.OwnerFromMove = true + info.ServerID = "" + if move.Issued { + info.ServerID = move.NewHost + } + return + } + } +} diff --git a/seaweed-block/core/authority/assignment_owner_test.go b/seaweed-block/core/authority/assignment_owner_test.go new file mode 100644 index 0000000000..a3cb7561e7 --- /dev/null +++ b/seaweed-block/core/authority/assignment_owner_test.go @@ -0,0 +1,25 @@ +package authority + +import ( + "github.com/seaweedfs/seaweed-block/core/adapter" + "testing" +) + +// INV-AUTH-HOLDER-IDENTITY-001: an unissued move cannot authorize a +// placement fallback, while a published move captures its own target. +func TestAssignmentOwnerReservedAndIssuedCapture(t *testing.T) { + p := NewPublisher(nil) + state := &WorkspaceState{Moves: []WorkspaceMoveRecord{{NewReplicaID: "r1", NewEpoch: 2, NewHost: "s2"}}} + for _, issued := range []bool{false, true} { + state.Moves[0].Issued = issued + info := adapter.AssignmentInfo{VolumeID: "v", ReplicaID: "r1", Epoch: 2, EndpointVersion: 1} + p.captureAssignmentOwner(&info, state) + want := "" + if issued { + want = "s2" + } + if !info.OwnerFromMove || info.ServerID != want { + t.Fatalf("issued=%t: captured %+v", issued, info) + } + } +} diff --git a/seaweed-block/core/authority/authority.go b/seaweed-block/core/authority/authority.go index c0fc650b39..cb28f1b74d 100644 --- a/seaweed-block/core/authority/authority.go +++ b/seaweed-block/core/authority/authority.go @@ -275,7 +275,7 @@ func (p *Publisher) reloadFromStore() { p.workspace[rec.VolumeID] = cloneWorkspace(rec.Workspace) } key := subKey{volumeID: rec.VolumeID, replicaID: rec.ReplicaID} - p.state[key] = assignmentState{ + loaded := assignmentState{ info: adapter.AssignmentInfo{ VolumeID: rec.VolumeID, ReplicaID: rec.ReplicaID, @@ -286,6 +286,8 @@ func (p *Publisher) reloadFromStore() { }, present: true, } + p.captureAssignmentOwner(&loaded.info, rec.Workspace) + p.state[key] = loaded if rec.WriteSeq > p.writeSeqByVolume[rec.VolumeID] { p.writeSeqByVolume[rec.VolumeID] = rec.WriteSeq } @@ -586,6 +588,8 @@ func (p *Publisher) applyWithWorkspaceMove(ask AssignmentAsk, grant *workspaceGr // sequenced after Put: on Put failure we simply return without // touching p.state / p.writeSeqByVolume, so no rollback is // needed. Subscribers never see a fact that isn't durable yet. + p.captureAssignmentOwner(&next, issuedWorkspace) + if p.store != nil { // Compute the per-volume WriteSeq for this mint. Starts // at the highest previously-persisted value for the diff --git a/seaweed-block/core/authority/workspace_lease_view.go b/seaweed-block/core/authority/workspace_lease_view.go index 49a0885727..05f7b84496 100644 --- a/seaweed-block/core/authority/workspace_lease_view.go +++ b/seaweed-block/core/authority/workspace_lease_view.go @@ -12,18 +12,19 @@ import ( // p.mu -> leaseMu at every point where an input changes, so that whenever // p.mu is released the view equals derive(published) (INV-LEASE-VIEW-001). type leaseDerived struct { - bound bool // an authority line exists for the volume - replica string - epoch uint64 - issuedHost string // NewHost of the issued move that minted the line; "" if none - leasePresent bool - revoking bool - movePending bool // the last workspace move is reserved, not issued - uncertain bool // a workspace write of the volume failed (INV-AUTH-UNCERTAIN-001) - storeless bool - horizon int64 // published Lease.ExpiresAtNS: durable upper bound of every grant - maxSkewNS int64 - lease WorkspaceLease // the published (durable) lease + bound bool // an authority line exists for the volume + replica string + epoch uint64 + ownerFromMove bool + issuedHost string // NewHost of the issued move that minted the line; "" if none + leasePresent bool + revoking bool + movePending bool // the last workspace move is reserved, not issued + uncertain bool // a workspace write of the volume failed (INV-AUTH-UNCERTAIN-001) + storeless bool + horizon int64 // published Lease.ExpiresAtNS: durable upper bound of every grant + maxSkewNS int64 + lease WorkspaceLease // the published (durable) lease } // leaseView is one volume's renewal state. Guarded by Publisher.leaseMu. @@ -43,14 +44,10 @@ func (p *Publisher) deriveLeaseLocked(volume string) leaseDerived { d := leaseDerived{uncertain: p.workspaceUncertain[volume], storeless: p.store == nil, maxSkewNS: int64(p.workspaceSkew(nil))} if _, line, ok := p.workspaceLineLocked(volume); ok { d.bound, d.replica, d.epoch = true, line.info.ReplicaID, line.info.Epoch + d.issuedHost, d.ownerFromMove = line.info.ServerID, line.info.OwnerFromMove } if s := p.workspace[volume]; s != nil { d.movePending = len(s.Moves) > 0 && !s.Moves[len(s.Moves)-1].Issued - for _, r := range s.Moves { - if d.bound && r.Issued && r.NewReplicaID == d.replica && r.NewEpoch == d.epoch { - d.issuedHost = r.NewHost - } - } if s.Lease != nil { d.leasePresent, d.revoking, d.horizon, d.lease = true, s.Lease.Revoking, s.Lease.ExpiresAtNS, *s.Lease d.maxSkewNS = int64(p.workspaceSkew(s.Lease)) @@ -154,7 +151,8 @@ type PublishedLine struct { Epoch uint64 // IssuedHost is the target host of the issued move that minted this line; // "" when no issued move did (a placement or static topology line). - IssuedHost string + IssuedHost string + OwnerFromMove bool } // PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity @@ -167,7 +165,7 @@ func (p *Publisher) PublishedAuthorityLine(volume string) (PublishedLine, bool) if lv == nil || !lv.d.bound { return PublishedLine{}, false } - return PublishedLine{ReplicaID: lv.d.replica, Epoch: lv.d.epoch, IssuedHost: lv.d.issuedHost}, true + return PublishedLine{ReplicaID: lv.d.replica, Epoch: lv.d.epoch, IssuedHost: lv.d.issuedHost, OwnerFromMove: lv.d.ownerFromMove}, true } // PublishedAuthorityLines returns the committed authority line of every @@ -181,7 +179,7 @@ func (p *Publisher) PublishedAuthorityLines() map[string]PublishedLine { out := make(map[string]PublishedLine, len(p.leaseViews)) for volume, lv := range p.leaseViews { if lv.d.bound { - out[volume] = PublishedLine{ReplicaID: lv.d.replica, Epoch: lv.d.epoch, IssuedHost: lv.d.issuedHost} + out[volume] = PublishedLine{ReplicaID: lv.d.replica, Epoch: lv.d.epoch, IssuedHost: lv.d.issuedHost, OwnerFromMove: lv.d.ownerFromMove} } } return out diff --git a/seaweed-block/core/authority/workspace_test.go b/seaweed-block/core/authority/workspace_test.go index 39473fec1f..546ca03ae0 100644 --- a/seaweed-block/core/authority/workspace_test.go +++ b/seaweed-block/core/authority/workspace_test.go @@ -86,7 +86,18 @@ func TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant(t *testing.T) { if err != nil || again != r { t.Fatal("grant replay changed", again, err) } - final := NewPublisher(nil, WithStore(disk)).WorkspaceState("v") + finalPublisher := NewPublisher(nil, WithStore(disk)) + for name, publisher := range map[string]*Publisher{"issued": loaded, "reloaded": finalPublisher} { + line, ok := publisher.LastPublished("v", "old") + if !ok || line.ServerID != "new-node" || !line.OwnerFromMove { + t.Fatalf("%s lost captured moved owner: %+v", name, line) + } + published, _ := publisher.PublishedAuthorityLine("v") + if published.IssuedHost != line.ServerID || !published.OwnerFromMove { + t.Fatalf("%s lease and stream owners differ: %+v / %+v", name, published, line) + } + } + final := finalPublisher.WorkspaceState("v") if final == nil || len(final.Moves) != 1 || !final.Moves[0].Issued { t.Fatal("issued epoch lost journal", final) } diff --git a/seaweed-block/core/host/master/assignment_fact_owner_test.go b/seaweed-block/core/host/master/assignment_fact_owner_test.go new file mode 100644 index 0000000000..44dae6679f --- /dev/null +++ b/seaweed-block/core/host/master/assignment_fact_owner_test.go @@ -0,0 +1,28 @@ +package master + +import ( + "github.com/seaweedfs/seaweed-block/core/adapter" + "github.com/seaweedfs/seaweed-block/core/authority" + "github.com/seaweedfs/seaweed-block/core/host/bootstrap" + "testing" +) + +// INV-AUTH-HOLDER-IDENTITY-001 / TERM-HOLDER-001: fault injection at the +// stream encoder, not a claim that publisher ordering can emit an unissued +// line. The captured E2 publication is available while its journal is not. +func TestAssignmentFactKeepsCapturedMoveOwnerWithoutReadableJournal(t *testing.T) { + h := &Host{boot: &bootstrap.DurableAuthorityBootstrap{Publisher: authority.NewPublisher(authority.NewStaticDirective(nil))}, topo: authority.AcceptedTopology{Volumes: []authority.VolumeExpected{{VolumeID: "v", Slots: []authority.ExpectedSlot{{ReplicaID: "r1", ServerID: "s1"}}}}}} + for _, owner := range []string{"s2", ""} { + t.Run("owner="+owner, func(t *testing.T) { + info := adapter.AssignmentInfo{VolumeID: "v", ReplicaID: "r1", Epoch: 2, EndpointVersion: 1, ServerID: owner, OwnerFromMove: true} + fact := (&services{host: h}).assignmentFact(info) + if fact.ServerId != owner { + t.Fatalf("captured owner %q relabelled %q from placement while journal unavailable", owner, fact.ServerId) + } + }) + } + initial := adapter.AssignmentInfo{VolumeID: "v", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1} + if got := (&services{host: h}).assignmentFact(initial).ServerId; got != "s1" { + t.Fatalf("move-less initial placement owner: %q", got) + } +} diff --git a/seaweed-block/core/host/master/services.go b/seaweed-block/core/host/master/services.go index f8a191b61f..ae22453d36 100644 --- a/seaweed-block/core/host/master/services.go +++ b/seaweed-block/core/host/master/services.go @@ -472,25 +472,7 @@ func (s *services) SubscribeAssignments(req *control.SubscribeRequest, stream co lastEpoch = info.Epoch lastEV = info.EndpointVersion sentAny = true - fact := &control.AssignmentFact{ - VolumeId: info.VolumeID, - ReplicaId: info.ReplicaID, - ServerId: s.host.workspaceSourceHost(info.VolumeID, info.ReplicaID, info.Epoch), - Epoch: info.Epoch, - EndpointVersion: info.EndpointVersion, - DataAddr: info.DataAddr, - CtrlAddr: info.CtrlAddr, - } - // Populate the peer set from publisher LastPublished - // queries for every non-self replica slot in this volume's - // topology. peer_set_generation is derived - // from the authoritative line's (Epoch, EndpointVersion) - // packed into one uint64 as (epoch<<32 | ev). Assertion - // above guarantees each fits in uint32 so no aliasing. - // Monotonic across process lifetimes because Epoch/EV are - // durable authority facts preserved across master restart. - fact.Peers = s.collectPeers(req.VolumeId, info) - fact.PeerSetGeneration = (info.Epoch << 32) | info.EndpointVersion + fact := s.assignmentFact(info) if err := stream.Send(fact); err != nil { return err } @@ -968,3 +950,27 @@ func (h *Host) ingestHeartbeatRecordingHealth(msg authority.HeartbeatMessage) er } return nil } + +// assignmentFact encodes one captured publication at the stream boundary. +func (s *services) assignmentFact(info adapter.AssignmentInfo) *control.AssignmentFact { + fact := &control.AssignmentFact{ + VolumeId: info.VolumeID, + ReplicaId: info.ReplicaID, + ServerId: s.host.workspaceLineOwner(authority.PublishedLine{ReplicaID: info.ReplicaID, Epoch: info.Epoch, IssuedHost: info.ServerID, OwnerFromMove: info.OwnerFromMove}, info.VolumeID, info.ReplicaID, info.Epoch), + Epoch: info.Epoch, + EndpointVersion: info.EndpointVersion, + DataAddr: info.DataAddr, + CtrlAddr: info.CtrlAddr, + } + // Populate the peer set from publisher LastPublished + // queries for every non-self replica slot in this volume's + // topology. peer_set_generation is derived + // from the authoritative line's (Epoch, EndpointVersion) + // packed into one uint64 as (epoch<<32 | ev). Assertion + // above guarantees each fits in uint32 so no aliasing. + // Monotonic across process lifetimes because Epoch/EV are + // durable authority facts preserved across master restart. + fact.Peers = s.collectPeers(info.VolumeID, info) + fact.PeerSetGeneration = (info.Epoch << 32) | info.EndpointVersion + return fact +} diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 5ef7f5356d..020c04d77a 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -68,6 +68,21 @@ func (h *Host) workspaceEndpointsAvailable(b lifecycle.WorkspaceBinding) error { // workspaceSourceHost resolves explicit holder membership for // INV-AUTH-HOLDER-IDENTITY-001; endpoints never select a server. func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string { + current, _ := h.Publisher().PublishedAuthorityLine(volume) + return h.workspaceLineOwner(current, volume, replica, epoch) +} + +// workspaceLineOwner is TERM-HOLDER-001's single owner decision function +// (INV-AUTH-HOLDER-IDENTITY-001). A captured current line never takes the +// publisher's store-write lock (INV-WS-RENEW-NONBLOCKING-001); only historical +// lines need the move journal. Endpoints never identify a server. +func (h *Host) workspaceLineOwner(current authority.PublishedLine, volume, replica string, epoch uint64) string { + if current.ReplicaID == replica && current.Epoch == epoch { + if current.OwnerFromMove || current.IssuedHost != "" { + return current.IssuedHost + } + return h.placementSourceHost(volume, replica) + } if state := h.Publisher().WorkspaceState(volume); state != nil { for _, r := range state.Moves { if r.Issued && r.NewReplicaID == replica && r.NewEpoch == epoch { diff --git a/seaweed-block/core/host/master/workspace_lease_horizon_test.go b/seaweed-block/core/host/master/workspace_lease_horizon_test.go index 4882279711..5910a0371c 100644 --- a/seaweed-block/core/host/master/workspace_lease_horizon_test.go +++ b/seaweed-block/core/host/master/workspace_lease_horizon_test.go @@ -148,6 +148,9 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { }() renewed := make(chan *control.WorkspaceLeaseFact, 1) renewErr := make(chan error, 1) + ownerResult := make(chan string, 1) + ownerJoined := make(chan struct{}) + ownerStarted := false renewStarted := false t.Cleanup(func() { // bounded: release, settle both workers, then clear the hook releaseHook() @@ -158,6 +161,14 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { settled = false t.Error("held reservation write did not settle") } + if ownerStarted { + select { + case <-ownerJoined: + case <-time.After(5 * time.Second): + settled = false + t.Error("owner lookup did not settle") + } + } if renewStarted { select { case <-renewErr: @@ -175,6 +186,22 @@ func TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation(t *testing.T) { case <-time.After(3 * time.Second): t.Fatal("reservation write of vol-b never reached the store") } + // TERM-HOLDER-001: current-line facts and lease admission resolve the + // same committed owner without entering the publisher's store-write lock. + ownerStarted = true + go func() { + defer close(ownerJoined) + ownerResult <- h.workspaceSourceHost("vol-b", line.ReplicaID, line.Epoch) + }() + select { + case owner := <-ownerResult: + matches, matchErr := svc.holderMatches(loopbackPeer(ctx), "vol-b", line.ReplicaID, owner, line.Epoch) + if owner != "node-a" || !matches || matchErr != nil { + t.Fatalf("fact and lease owner differ under held writer: %q", owner) + } + case <-time.After(time.Second): + t.Fatal("current owner lookup waited for publisher store write") + } renewStarted = true go func() { f, err := svc.RenewWorkspaceLease(loopbackPeer(ctx), id) diff --git a/seaweed-block/core/host/master/workspace_line_owner_test.go b/seaweed-block/core/host/master/workspace_line_owner_test.go new file mode 100644 index 0000000000..c99f7c4ab1 --- /dev/null +++ b/seaweed-block/core/host/master/workspace_line_owner_test.go @@ -0,0 +1,74 @@ +package master + +import ( + "github.com/seaweedfs/seaweed-block/core/lifecycle" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "testing" +) + +// TERM-HOLDER-001 / INV-AUTH-HOLDER-IDENTITY-001: current facts, leases and +// move-source history share the owner rule; placement does not override a move. +func TestWorkspaceLineOwnerIssuedAndHistorical(t *testing.T) { + h, conn, ctx := reviewBindingHost(t) + reviewLegacyBind(t, h, conn, ctx, "v") + ws := control.NewWorkspaceServiceClient(conn) + id := leaseHolderIdentity(t, 1, "node-a") + if _, err := ws.RenewWorkspaceLease(ctx, id); err != nil { + t.Fatal(err) + } + if _, err := ws.RevokeWorkspace(ctx, id); err != nil { + t.Fatal(err) + } + if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil { + t.Fatal(err) + } + target := &control.WorkspaceBinding{VolumeId: "v", ServerId: "node-b", DataAddr: "127.0.0.1:20000", CtrlAddr: "127.0.0.1:20001"} + if _, err := ws.RegisterWorkspaceBinding(ctx, target); err != nil { + t.Fatal(err) + } + grant, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "owner-move", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: target.DataAddr, TargetCtrlAddr: target.CtrlAddr, Kind: "clean"}) + if err != nil { + t.Fatal(err) + } + if !grant.Issued || grant.NewEpoch != 2 { + t.Fatal("move did not issue", grant) + } + svc := &services{host: h} + matches := func(server string) bool { + t.Helper() + ok, err := svc.holderMatches(loopbackPeer(ctx), "v", "r1", server, 2) + if err != nil { + t.Fatal(err) + } + return ok + } + if got := h.placementSourceHost("v", "r1"); got != "node-a" { + t.Fatal("fixture placement no longer differs from issued owner", got) + } + // Both consumers must prefer the issued owner to the old placement. + if got := h.workspaceSourceHost("v", "r1", 2); got != "node-b" || !matches(got) || matches("node-a") { + t.Fatal("fact/lease issued owner mismatch", got) + } + stream, err := control.NewAssignmentServiceClient(conn).SubscribeAssignments(ctx, &control.SubscribeRequest{VolumeId: "v", ReplicaId: "r1", ServerId: "node-b"}) + if err != nil { + t.Fatal(err) + } + fact, err := stream.Recv() + if err != nil || fact.GetServerId() != "node-b" || fact.GetEpoch() != 2 { + t.Fatal("wrong produced fact", fact, err) + } + if _, err := ws.RenewWorkspaceLease(ctx, leaseHolderIdentity(t, 2, "node-b")); err != nil { + t.Fatal("issued owner lease refused", err) + } + // Change only desired-placement metadata. It must not rewrite the owner of + // the historical e1 line retained in the actual issued move journal. + if _, err := h.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "v", DesiredRF: 1, Candidates: []lifecycle.PlacementCandidate{{VolumeID: "v", ServerID: "node-c", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil { + t.Fatal(err) + } + if got := h.workspaceSourceHost("v", "r1", 1); got != "node-a" { + t.Fatal("historical line guessed from current placement", got) + } + if got := h.workspaceSourceHost("v", "r1", 2); got != "node-b" || !matches(got) { + t.Fatal("issued owner changed with placement", got) + } +} diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 53b6238d21..7c72a96438 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -109,11 +109,7 @@ func (s *services) holderMatches(ctx context.Context, volume, replica, server st if !ok || server == "" || line.ReplicaID != replica || line.Epoch != epoch { return false, nil } - owner := line.IssuedHost - if owner == "" { - owner = s.host.placementSourceHost(volume, line.ReplicaID) - } - return server == owner, nil + return server == s.host.workspaceLineOwner(line, volume, replica, epoch), nil } func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 2e0b5ed147..dde4d9cc7e 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -90,6 +90,38 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a **Workspace lease and move, in blockmaster.** +TERM-HOLDER-001 uses one deciding function, `Host.workspaceLineOwner`. The +stream supplies the PublishedLine captured in its AssignmentInfo; lease/ACK +checks supply the captured leaf view; move source uses a leaf snapshot wrapper. +`Publisher.captureAssignmentOwner` captures the moved owner under the publication +lock and reloads it from that durable record's workspace journal. A moved line +with unknown owner sends an empty server id; only a move-less line falls back to +placement. Renewal never enters the publisher store-write lock for this lookup. +The stream regression injects an unavailable journal at encoding time; it does +not claim that a pre-issued publication is reachable in the current publisher. + + +```mermaid +flowchart LR + Reserved[Move reserved] --> Capture[Issue: capture line and moved owner under pub.mu] + Capture --> Durable[Persist line and issuing journal together] + Durable --> Published[Publish assignment and derived lease view] + Published --> Stream[Stream encodes captured line via workspaceLineOwner] + Published --> Lease[Lease and ACK use captured leaf owner] + Stream --> Known[Known moved owner: same server id] + Stream --> Unknown[Unknown moved owner: empty server id] + Stream --> Initial[Move-less epoch: placement owner] +``` + +Model trace: [WorkspaceRegrant round 4 pins and simulation results](../spec/WorkspaceRegrant-owner-label-results.md) +binds the owner-label switch, five configurations and reported results to exact +hashes. Captured labels use StreamLabelFromStore=FALSE; the mutant models a +lagging send-time owner store. Status is SIMULATION ONLY (3 seeds, 20,000 traces +each, depth 120); exhaustive combo10 is pending. No model proof is claimed. +The stream regression is an injected fault control; real P5 did not reproduce +a pre-issued publication. + + | From | To | Event and guard | Enforced in | Protects | |---|---|---|---|---| | none | Granted | `RenewWorkspaceLease` from the current primary (server id, replica id) at the current epoch; a missing/foreign server is refused by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`); no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-AUTH-HOLDER-IDENTITY-001` | @@ -101,7 +133,7 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current primary server/replica/epoch, validated by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) with missing server refused, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | -| Moved | epoch issued | the move journal record is durable first; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | +| Moved | epoch issued | the moved owner is captured with the assignment under pub.mu and persisted with the issuing move journal before publication; the stream uses that captured owner, empty when unknown, with placement fallback only for a move-less epoch; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/workspace_binding.go` `workspaceLineOwner`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | ### M3 Replica role and peer state @@ -575,7 +607,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend, iSCSI by IQN and LUN) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication | - (unit and RPC identity boundary) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409; `core/host/master/workspace_binding.go` `workspaceLineOwner`, `workspaceSourceHost`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestWorkspaceLineOwnerIssuedAndHistorical` (`core/host/master/workspace_line_owner_test.go`), `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestAssignmentFactKeepsCapturedMoveOwnerWithoutReadableJournal` (`core/host/master/assignment_fact_owner_test.go`), `TestAssignmentOwnerReservedAndIssuedCapture` (`core/authority/assignment_owner_test.go`), `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication | `WorkspaceRegrant` `NoForeignAdoption`, `TargetNotFencedByOwnLine` (round 4 pinned simulations only; exhaustive combo10 pending) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | diff --git a/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md new file mode 100644 index 0000000000..657c71b379 --- /dev/null +++ b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md @@ -0,0 +1,48 @@ +# Workspace owner-label model: round 4 pins + +This is a citation of claude06's external model and its reported simulations, +not an exhaustive public-spec result. Source bundle: +`V:/share/rdma/claude06-sw-tla-regrant-r0-20261122/`. + +`WorkspaceRegrant.tla` round 4 maps `StreamLabelFromStore = FALSE` to +`Publisher.captureAssignmentOwner` -> immutable `AssignmentInfo` -> +`services.assignmentFact` -> `Host.workspaceLineOwner`. The lease view derives +the same owner metadata (`INV-LEASE-VIEW-001`). A moved unknown owner is empty; +only a move-less line falls back to placement (`INV-AUTH-HOLDER-IDENTITY-001`). +The TRUE switch injects a send-time owner store that can lag. This is a model +fault schedule, not evidence of a reachable pre-issued publication in current +Go code; the real P5 trace showed the old host refusing both foreign facts. + +## Results and limits + +Status: **SIMULATION ONLY**. `summary-r4.tsv` reports 3 seeds x 20,000 traces, +depth 120, with these exact configurations: + +| Configuration | Reported result | +|---|---| +| `WR_id4_fix_label.cfg` | No violation in the simulations | +| `WR_id4_fix_label_ownline.cfg` | No violation in the simulations | +| `WR_id4_RED_label.cfg` | `NoForeignAdoption` violated at traces 14, 17, 15 | +| `WR_id4_RED_label_safety.cfg` | No safety-invariant violation in the simulations; lease layer stops the adopter | +| `WR_id4_fix_label_volguard.cfg` | `NoForeignAdoption` still violated at traces 14, 17, 15; a fresh process has no recorded foreign line | + +The result interpretation is in `REGRANT-REPORT.md`, "Round 4: adoption fence". +A simulation finding is a counterexample; no sampled violation does not prove +an invariant. Exhaustive round 4 is **PENDING** in claude06's next Azure slot, +bundle `combo10`, results expected under +`V:/share/rdma/claude06-tlc-azure-results-20261120/tlc-combo10-*`. +Date depends on the open budget decision. No exhaustive state count or GO claim +is made here. This pending model is not added to the Exhausted bounds table. + +## Exact source pins + +| Artifact (relative to source bundle) | SHA-256 | +|---|---| +| `WorkspaceRegrant.tla` | `d92922331afa2bb127d4f29b9d6fc266354c30b8d11a9a0bd3931e67d2c27d1c` | +| `cfg/WR_id4_fix_label.cfg` | `d716ed5a9d4fce039e2dda084901c789f85f5a44e03d2db28d30a17312ad199f` | +| `cfg/WR_id4_fix_label_ownline.cfg` | `49188ae6776114c9c4358bac0e0dbf8187622feba25a69c1aaf97ed0da8bcdc1` | +| `cfg/WR_id4_RED_label.cfg` | `d22cf52f84bc6b2eed4f0696e4f84285daba2fe5ad0111bbae3358da7a3d1d50` | +| `cfg/WR_id4_RED_label_safety.cfg` | `ca1b0b66fdeb4fef31d43a5efb4e3bb5ef501270f1a6441c8250fb084d4f0e69` | +| `cfg/WR_id4_fix_label_volguard.cfg` | `86fad07c3a9e321ea5dd52a1e4b104c61bdc34a3ce08b4bc123d9b2d97e47f65` | +| `summary-r4.tsv` | `4ca8155ff7c3922d5ff6b0880c41ef59ef13169cc1af9cc630f7fd06256cdbd3` | +| `REGRANT-REPORT.md` | `eab94a6d2e5d81ad9318cb56a90b77958b1a73719258c9500cf71f9c95fc286a` | From 94a6c0de4b235804c735c7d814a98155444cbd82 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 05:27:19 -0800 Subject: [PATCH 124/204] docs(spec): index owner-label simulations and clarify trace units --- seaweed-block/docs/spec/README.md | 8 ++++++++ .../docs/spec/WorkspaceRegrant-owner-label-results.md | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/seaweed-block/docs/spec/README.md b/seaweed-block/docs/spec/README.md index 78a1b3d446..4e8c11070a 100644 --- a/seaweed-block/docs/spec/README.md +++ b/seaweed-block/docs/spec/README.md @@ -103,6 +103,14 @@ Two kinds of config are **expected to violate**: Each `.cfg` names its spec on its first line. +## Owner-label simulation results + +[Workspace owner-label round 4: source pins and results](WorkspaceRegrant-owner-label-results.md) +is **SIMULATION ONLY** (3 seeds x 20,000 traces, depth 120); exhaustive round 4 +`combo10` is **PENDING**. Counterexample lengths are counts of states, including +the initial state, not trace identifiers. These results are separate from the +exhausted bounds below. + ## Exhausted bounds One row per spec: a configuration that TLC explored completely (breadth-first, diff --git a/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md index 657c71b379..985b5d69c1 100644 --- a/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md +++ b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md @@ -16,15 +16,16 @@ Go code; the real P5 trace showed the old host refusing both foreign facts. ## Results and limits Status: **SIMULATION ONLY**. `summary-r4.tsv` reports 3 seeds x 20,000 traces, -depth 120, with these exact configurations: +depth 120. Counterexample lengths below count states, including the initial +state; they are not trace identifiers. The exact configurations are: | Configuration | Reported result | |---|---| | `WR_id4_fix_label.cfg` | No violation in the simulations | | `WR_id4_fix_label_ownline.cfg` | No violation in the simulations | -| `WR_id4_RED_label.cfg` | `NoForeignAdoption` violated at traces 14, 17, 15 | +| `WR_id4_RED_label.cfg` | `NoForeignAdoption` violated; counterexamples contain 14, 17, 15 states | | `WR_id4_RED_label_safety.cfg` | No safety-invariant violation in the simulations; lease layer stops the adopter | -| `WR_id4_fix_label_volguard.cfg` | `NoForeignAdoption` still violated at traces 14, 17, 15; a fresh process has no recorded foreign line | +| `WR_id4_fix_label_volguard.cfg` | `NoForeignAdoption` still violated; counterexamples contain 14, 17, 15 states; a fresh process has no recorded foreign line | The result interpretation is in `REGRANT-REPORT.md`, "Round 4: adoption fence". A simulation finding is a counterexample; no sampled violation does not prove From d73acc54e944871b5989cf0e14186e515be2b445 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:00:00 -0800 Subject: [PATCH 125/204] test: #425 red: the forced move's epoch-2 lines carry the new owner's endpoints (procedure gate) Brings the two-process procedure gate (origin/test/procedure-gate, its three test files) onto main and adds the assertion to TestProcedureForcedMoveWithTheOldHostReturning: every assignment line delivered at the forced epoch, to s2 and to the returning s1, carries s2's own data and control endpoints (V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001). Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_checks_test.go | 58 ++- .../planned_handoff_integration_test.go | 133 +++-- .../procedure_gate_integration_test.go | 481 ++++++++++++++++++ 3 files changed, 634 insertions(+), 38 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go index dedf934a66..af534928eb 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go @@ -106,9 +106,12 @@ func showsAck(out string, e, g uint64) bool { return hasLine(out, fmt.Sprintf("recorded ACK: r1@%d HEAD generation %d", e, g)) } -// movedEpoch reads E2 from the clean move's answer. -func movedEpoch(out string, e, g, l uint64) (uint64, error) { - issued := regexp.MustCompile(fmt.Sprintf(`^clean move issued: volume v1 request move-v1-1: r1@%d -> r1@(\d+) on s1 \(sealed HEAD gen %d, remote LSN %d\)$`, e, g, l)) +// movedEpoch reads E2 from the clean move's answer to s1. +func movedEpoch(out string, e, g, l uint64) (uint64, error) { return movedEpochTo(out, e, g, l, "s1") } + +// movedEpochTo reads E2 from the clean move's answer to the target host. +func movedEpochTo(out string, e, g, l uint64, target string) (uint64, error) { + issued := regexp.MustCompile(fmt.Sprintf(`^clean move issued: volume v1 request move-v1-1: r1@%d -> r1@(\d+) on %s \(sealed HEAD gen %d, remote LSN %d\)$`, e, regexp.QuoteMeta(target), g, l)) first, _, _ := strings.Cut(out, "\n") e2, err := matchUint(issued, strings.TrimRight(first, "\r")) if err != nil { @@ -117,12 +120,14 @@ func movedEpoch(out string, e, g, l uint64) (uint64, error) { if e2 <= e { return 0, fmt.Errorf("clean move issued epoch %d; want above %d", e2, e) } - return e2, wantLines(out, "next: start volume v1 on s1 (this command moved authority only)") + return e2, wantLines(out, fmt.Sprintf("next: start volume v1 on %s (this command moved authority only)", target)) } -func checkClaimDone(line string, e2 uint64) error { - if !strings.Contains(line, "durable: HEAD claim for volume=v1 done in") || !strings.Contains(line, fmt.Sprintf(`epoch=%d holder="s1/r1"`, e2)) { - return fmt.Errorf("HEAD claim %q; want done at epoch %d holder s1/r1", line, e2) +func checkClaimDone(line string, e2 uint64) error { return checkClaimDoneBy(line, e2, "s1") } + +func checkClaimDoneBy(line string, e2 uint64, host string) error { + if !strings.Contains(line, "durable: HEAD claim for volume=v1 done in") || !strings.Contains(line, fmt.Sprintf(`epoch=%d holder="%s/r1"`, e2, host)) { + return fmt.Errorf("HEAD claim %q; want done at epoch %d holder %s/r1", line, e2, host) } return nil } @@ -134,16 +139,48 @@ func checkShowMoved(out string, e, e2, g, l uint64) error { } func checkHeadReopened(out string, e2, g, l uint64) error { + return checkHeadReopenedBy(out, e2, g, l, "s1") +} + +func checkHeadReopenedBy(out string, e2, g, l uint64, host string) error { h, err := parseHead(out) if err != nil { return err } - if h.State != "active" || h.Epoch != e2 || h.Holder != "s1/r1" || h.Gen <= g || h.RemoteLSN != l || h.DetachedBy != nil { - return fmt.Errorf("HEAD after the reopen %+v; want active, epoch %d, holder s1/r1, gen above %d, remote LSN %d, not detached", h, e2, g, l) + if h.State != "active" || h.Epoch != e2 || h.Holder != host+"/r1" || h.Gen <= g || h.RemoteLSN != l || h.DetachedBy != nil { + return fmt.Errorf("HEAD after the reopen %+v; want active, epoch %d, holder %s/r1, gen above %d, remote LSN %d, not detached", h, e2, host, g, l) } return nil } +// forcedEpoch reads E2 from a forced move's answer (`forced move issued: +// ... r1@E on FROM -> r1@E2 on TO (kept HEAD gen N, remote LSN L)`). +func forcedEpoch(out string, e uint64, from, to string) (uint64, error) { + re := regexp.MustCompile(fmt.Sprintf(`(?m)^forced move issued: volume v1 request \S+: r1@%d on %s -> r1@(\d+) on %s \(kept HEAD gen \d+, remote LSN \d+\)$`, e, regexp.QuoteMeta(from), regexp.QuoteMeta(to))) + e2, err := matchUint(re, out) + if err == nil && e2 <= e { + err = fmt.Errorf("forced move issued epoch %d; want above %d", e2, e) + } + return e2, err +} + +// forcedKeptLSN reads the remote LSN a forced move kept. +func forcedKeptLSN(out string) (uint64, error) { + return matchUint(regexp.MustCompile(`(?m)^forced move issued: .*\(kept HEAD gen \d+, remote LSN (\d+)\)$`), out) +} + +// previewAdmitted reports whether a force-move --dry-run says admitted. +func previewAdmitted(out string) bool { + return regexp.MustCompile(`(?m)^forced move admitted(: .*)?$`).MatchString(out) +} + +// frontendReady reports whether a /status?volume=v1 body says the frontend +// is ready to serve as primary. +func frontendReady(body []byte) bool { + var st struct{ FrontendPrimaryReady bool } + return json.Unmarshal(body, &st) == nil && st.FrontendPrimaryReady +} + // checkCleanMoveRefused checks a clean move refused for a missing ACK: exit // 1 (a failed precondition), nothing on stdout, the documented error. func checkCleanMoveRefused(stdout, stderr string, code int) error { @@ -265,6 +302,9 @@ func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { if r := read("show-revoked.stdout"); showsAck(r, e, g) || !hasLine(r, "recorded ACK: none") { t.Error("the revoked show without an ACK is read as acknowledged") } + if !frontendReady([]byte(read("status-primary.json"))) || frontendReady([]byte(`{"FrontendPrimaryReady":false,"Healthy":true}`)) { + t.Error("the frontend-ready check does not read FrontendPrimaryReady") + } if !statusPrimary([]byte(read("status-primary.json")), e2) || statusPrimary([]byte(read("status-primary.json")), e) { t.Error("status check does not read the epoch of a healthy primary") } diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index c431049689..24efa719f2 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -9,12 +9,14 @@ import ( "errors" "fmt" "io" + "math/rand" "net" "net/http" "os" "os/exec" "path/filepath" "strings" + "sync" "testing" "time" @@ -159,37 +161,67 @@ func TestStandaloneCleanMoveWithoutTheACKIsRefused(t *testing.T) { const plannedHandoffNQN = "nqn.2026-11.io.seaweedfs:handoff" -// startPlannedHandoff runs the chapter's steps 1-3: a weed cluster, the -// cluster spec, blockmaster with the lifecycle store, and the setup check. -// It returns the blockvolume arguments of step 4 and the show command. +// startPlannedHandoff runs the chapter's steps 1-3 for one host, s1, and +// returns the blockvolume arguments of step 4 and the show command. func startPlannedHandoff(t *testing.T) (h *plannedHandoffHarness, cluster *w4WeedCluster, chunkPath string, show, volArgs []string) { t.Helper() - h = newPlannedHandoffHarness(t) - cluster = startWorkspaceWeed(t) - chunkPath = fmt.Sprintf("/handoff-%d", time.Now().UnixNano()) + env := startHandoffEnv(t, 1) + return env.h, env.cluster, env.chunkPath, env.show, env.volArgs("s1") +} + +// handoffEnv is a running setup: weed, blockmaster with the cluster spec +// naming every host, and the hosts' blockvolume endpoints. The volume starts +// on s1. +type handoffEnv struct { + h *plannedHandoffHarness + cluster *w4WeedCluster + chunkPath string + show []string + hosts map[string]bvHost +} + +// bvHost is one host's blockvolume: its server id, endpoints and local root. +type bvHost struct { + id, data, ctrl, status, nvme, root string +} + +// startHandoffEnv runs the chapter's steps 1-3: a weed cluster, the cluster +// spec with hosts s1..sN, blockmaster with the lifecycle store (and +// masterArgs), and the setup check. +func startHandoffEnv(t *testing.T, n int, masterArgs ...string) *handoffEnv { + t.Helper() + h := newPlannedHandoffHarness(t) + env := &handoffEnv{h: h, cluster: startWorkspaceWeed(t), chunkPath: fmt.Sprintf("/handoff-%d", time.Now().UnixNano()), hosts: map[string]bvHost{}} must, _ := fatalOn(t) + env.hosts["s1"] = bvHost{id: "s1", data: h.dataAddr, ctrl: h.ctrlAddr, status: h.statusAddr, nvme: h.nvmeAddr, root: filepath.Join(h.dir, "vol")} + for i := 2; i <= n; i++ { + id := fmt.Sprintf("s%d", i) + env.hosts[id] = bvHost{id: id, data: handoffAddress(t), ctrl: handoffAddress(t), status: handoffAddress(t), nvme: handoffAddress(t), root: filepath.Join(h.dir, "vol-"+id)} + } + cluster, chunkPath := env.cluster, env.chunkPath // 1. The cluster spec. + var nodes strings.Builder + for i := 1; i <= n; i++ { + b := env.hosts[fmt.Sprintf("s%d", i)] + fmt.Fprintf(&nodes, " - server_id: %s\n data_addr: %s\n ctrl_addr: %s\n", b.id, b.data, b.ctrl) + } spec := filepath.Join(h.dir, "cluster-spec.yaml") - must(os.WriteFile(spec, []byte(fmt.Sprintf(`nodes: - - server_id: s1 - data_addr: %s - ctrl_addr: %s -volumes: + must(os.WriteFile(spec, []byte("nodes:\n"+nodes.String()+`volumes: - id: v1 size_bytes: 268435456 replication_factor: 1 placements: - server_id: s1 replica_id: r1 -`, h.dataAddr, h.ctrlAddr)), 0o644)) +`), 0o644)) // 2. blockmaster with the lifecycle store and the cluster spec. mstate := filepath.Join(h.dir, "master") - master := h.start(t, "blockmaster", h.master, + master := h.start(t, "blockmaster", h.master, append([]string{ "--authority-store", filepath.Join(mstate, "authority"), "--lifecycle-store", filepath.Join(mstate, "lifecycle"), "--cluster-spec", spec, "--expected-slots-per-volume", "1", "--listen", h.masterAddr, - "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+chunkPath) + "--workspace-rpc", "--workspace-head-base-url", "http://" + cluster.filerHTTP + chunkPath}, masterArgs...)...) if l := master.waitLog(t, 30*time.Second, "blockmaster: lock acquired, reloaded="); !strings.Contains(l, "listen="+h.masterAddr) { t.Fatalf("blockmaster start line %q does not name listen=%s", l, h.masterAddr) } @@ -198,17 +230,21 @@ volumes: } // 3. The setup answers before any blockvolume runs. - show = []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} - out, _ := h.command(t, show...) + env.show = []string{"ops", "workspace", "show", "--master", h.masterAddr, "--volume", "v1"} + out, _ := h.command(t, env.show...) must(checkShowBeforeStart(out)) + return env +} - volArgs = []string{"--master", h.masterAddr, "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", - "--data-addr", h.dataAddr, "--ctrl-addr", h.ctrlAddr, "--status-addr", h.statusAddr, - "--durable-root", filepath.Join(h.dir, "vol"), "--durable-impl", "walstore-chunk", +// volArgs is the chapter's blockvolume command for one host. +func (env *handoffEnv) volArgs(id string) []string { + b := env.hosts[id] + return []string{"--master", env.h.masterAddr, "--server-id", b.id, "--volume-id", "v1", "--replica-id", "r1", + "--data-addr", b.data, "--ctrl-addr", b.ctrl, "--status-addr", b.status, + "--durable-root", b.root, "--durable-impl", "walstore-chunk", "--durable-blocks", "65536", "--durable-blocksize", "4096", - "--chunk-filer", cluster.filerGRPC, "--chunk-path", chunkPath, "--chunk-control-endpoint", - "--workspace-lease", "--nvme-listen", h.nvmeAddr, "--nvme-subsysnqn", plannedHandoffNQN} - return h, cluster, chunkPath, show, volArgs + "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath, "--chunk-control-endpoint", + "--workspace-lease", "--nvme-listen", b.nvme, "--nvme-subsysnqn", plannedHandoffNQN} } func fatalOn(t *testing.T) (func(error), func(uint64, error) uint64) { @@ -259,14 +295,46 @@ func newPlannedHandoffHarness(t *testing.T) *plannedHandoffHarness { t.Fatalf("build %s: %v\n%s", b.name, err, out) } } - h.masterAddr = leaseBinaryAddress(t) - h.dataAddr = leaseBinaryAddress(t) - h.ctrlAddr = leaseBinaryAddress(t) - h.statusAddr = leaseBinaryAddress(t) - h.nvmeAddr = leaseBinaryAddress(t) + h.masterAddr = handoffAddress(t) + h.dataAddr = handoffAddress(t) + h.ctrlAddr = handoffAddress(t) + h.statusAddr = handoffAddress(t) + h.nvmeAddr = handoffAddress(t) return h } +var handoffPorts struct { + sync.Mutex + used map[int]bool +} + +// handoffAddress returns a free loopback address below the kernel's +// ephemeral range (32768 and up on Linux). A daemon restarted minutes later +// binds it again, and an outgoing connection may take any ephemeral port in +// between; ports below the range are never handed out that way. +func handoffAddress(t *testing.T) string { + t.Helper() + handoffPorts.Lock() + defer handoffPorts.Unlock() + if handoffPorts.used == nil { + handoffPorts.used = map[int]bool{} + } + for i := 0; i < 500; i++ { + p := 21000 + rand.Intn(11000) + if handoffPorts.used[p] { + continue + } + addr := fmt.Sprintf("127.0.0.1:%d", p) + if ln, err := net.Listen("tcp", addr); err == nil { + ln.Close() + handoffPorts.used[p] = true + return addr + } + } + t.Fatal("no free loopback port below the ephemeral range") + return "" +} + // daemon is one started child: its log file and its exit. type daemon struct { name, log string @@ -414,10 +482,17 @@ func (h *plannedHandoffHarness) run(t *testing.T, args ...string) (string, strin // waitPrimary polls the status endpoint until the volume serves as a // healthy primary at epoch. func (h *plannedHandoffHarness) waitPrimary(t *testing.T, epoch uint64) { + t.Helper() + h.waitPrimaryAt(t, h.statusAddr, epoch) +} + +// waitPrimaryAt polls one host's status endpoint until the volume serves +// there as a healthy primary at epoch. +func (h *plannedHandoffHarness) waitPrimaryAt(t *testing.T, statusAddr string, epoch uint64) { t.Helper() c := &http.Client{Timeout: 5 * time.Second} - poll(t, 60*time.Second, fmt.Sprintf("status never showed a healthy primary at epoch %d", epoch), func() bool { - resp, err := c.Get("http://" + h.statusAddr + "/status?volume=v1") + poll(t, 60*time.Second, fmt.Sprintf("status at %s never showed a healthy primary at epoch %d", statusAddr, epoch), func() bool { + resp, err := c.Get("http://" + statusAddr + "/status?volume=v1") if err != nil { return false } diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go new file mode 100644 index 0000000000..32cfb64b95 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -0,0 +1,481 @@ +//go:build subprocess && chunkstore_integration + +package main_test + +import ( + "bytes" + "errors" + "fmt" + "io" + "net" + "net/http" + "os" + "os/exec" + "strings" + "testing" + "time" +) + +// The procedure gate: every operator procedure of docs/volume-lifecycle.md +// runs as written, with real binaries, on two blockvolume processes with +// distinct server ids (s1 and s2) sharing one blockmaster and one SeaweedFS. +// The planned return to the same host is TestStandalonePlannedHandoffToTheSameHost. + +// TestProcedurePlannedHandoffToAnotherHost: the planned hand-over from s1 to +// s2. The new holder starts with no local copy, claims the sealed HEAD at the +// new epoch and serves the written block. +func TestProcedurePlannedHandoffToAnotherHost(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + block := pattern("to-another-host!") + env.writeBlock(t, "s1", 0, block) + + g := env.seal(t, "s1", e) + l := env.sealedLSN(t, e, g) + env.revoke(t, e, g) + if err := old.wait(30 * time.Second); err != nil { + t.Fatalf("s1 after the revocation: %v; want a clean exit by itself", err) + } + env.waitAck(t, e, g) + + moved, _ := h.command(t, env.moveClean(e, "s2", "move-v1-1")...) + e2 := mustU(movedEpochTo(moved, e, g, l, "s2")) + nw := env.start(t, "blockvolume-s2", "s2") + must(checkClaimDoneBy(nw.waitLog(t, 60*time.Second, "durable: HEAD claim for volume=v1 done in"), e2, "s2")) + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + out, _ := h.command(t, env.show...) + must(wantLines(out, fmt.Sprintf("holder: r1@%d (logical replica)", e2), + fmt.Sprintf("move: request=move-v1-1 kind=clean issued=true s1/r1@%d -> s2/r1@%d HEAD generation %d remote LSN %d", e, e2, g, l))) + out, _ = h.command(t, env.chunkShow()...) + must(checkHeadReopenedBy(out, e2, g, l, "s2")) + if !bytes.Equal(env.readBlock(t, "s2", 0), block) { + t.Fatal("the block written on s1 does not read back on s2") + } +} + +// TestProcedureSameHostRestartInsideTheLease: the holder's process dies and is +// started again on its host within the 30 s lease. It keeps holder and epoch +// and serves again at once from its local WAL. +func TestProcedureSameHostRestartInsideTheLease(t *testing.T) { + env := startHandoffEnv(t, 2) + must, _ := fatalOn(t) + + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("restart-in-lease") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + + again := env.start(t, "blockvolume-s1-again", "s1") + if got := env.adopt(t, again, "s1"); got != e { + t.Fatalf("the restarted holder adopted epoch %d; want the same epoch %d", got, e) + } + out, _ := env.h.command(t, env.show...) + must(checkShowGranted(out, e)) + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the restart does not read back") + } +} + +// TestProcedureReturnAfterALapsedLease: the holder's process dies and stays +// down past its lease. Started again 65 s after it stopped (the page's +// bound with default flags), it is granted again at the same epoch, reclaims +// HEAD and serves its local WAL. +func TestProcedureReturnAfterALapsedLease(t *testing.T) { + env := startHandoffEnv(t, 2) + must, _ := fatalOn(t) + + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("after-lapsed-ttl") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + stopped := time.Now() + + time.Sleep(time.Until(stopped.Add(65 * time.Second))) + back := env.start(t, "blockvolume-s1-back", "s1") + if got := env.adopt(t, back, "s1"); got != e { + t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) + } + if back.has("assignment unavailable, not serving") { + t.Fatal("started 65 s after the stop, the holder still logged the not-serving line") + } + out, _ := env.h.command(t, env.show...) + must(checkShowGranted(out, e)) + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the lapse does not read back") + } +} + +// TestProcedureForcedMoveWithTheOldHostReturning: the holder on s1 dies and +// never comes back in time. A forced move to s2, admitted after the barrier, +// restores the last HEAD: a block cut before the crash is kept, one written +// after the cut is lost, as the lost range says. The old s1 process then +// returns with its old local root and must not serve; s2 keeps serving. +func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + kept, lost := pattern("cut-before-crash"), pattern("after-the-cut!!!") + env.writeBlock(t, "s1", 0, kept) + h.command(t, "ops", "chunk", "cut", "--volume", "v1", "--status-addr", env.hosts["s1"].status) + env.writeBlock(t, "s1", 8, lost) + old.kill(t) + + out := env.forceMove(t, e, "s2", "force-v1-1") + e2, keptLSN := mustU(forcedEpoch(out, e, "s1", "s2")), mustU(forcedKeptLSN(out)) + must(wantLines(out, "next: start volume v1 on s2 (this command moved authority only)")) + if !strings.Contains(out, fmt.Sprintf("writes with LSN <= %d are preserved", keptLSN)) { + t.Fatalf("the forced move printed no lost range at LSN %d:\n%s", keptLSN, out) + } + ranges, _ := h.command(t, "ops", "workspace", "lost-range", "--master", h.masterAddr, "--volume", "v1") + if !strings.Contains(ranges, "range 1 of 1: request force-v1-1, r1@") { + t.Fatalf("lost-range does not show the forced move:\n%s", ranges) + } + + nw := env.start(t, "blockvolume-s2", "s2") + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + if !bytes.Equal(env.readBlock(t, "s2", 0), kept) { + t.Fatal("the block cut before the crash is not on s2") + } + if got := env.readBlock(t, "s2", 8); !bytes.Equal(got, make([]byte, 4096)) { + t.Fatal("the block written after the last cut reads back on s2; the page says it is lost") + } + + // The old host returns with its old local root. It must not take s2's + // line as its own (a holder is server and replica), report its frontend + // ready, or listen for I/O; the page says it does not serve. + back := env.start(t, "blockvolume-s1-back", "s1") + var failures []string + end := time.Now().Add(40 * time.Second) + for time.Now().Before(end) && len(failures) == 0 { + if l := back.line(fmt.Sprintf("adopted as PRIMARY at r1@%d", e2)); l != "" { + failures = append(failures, "it adopted s2's line: "+l) + } + if env.frontendReadyAt("s1") { + failures = append(failures, "its status reports FrontendPrimaryReady") + } + if listening(env.hosts["s1"].nvme) { + failures = append(failures, "its NVMe/TCP target listens") + } + time.Sleep(time.Second) + } + if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") && !back.has("is not this process") && !back.has("foreign assignment") { + failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") + } + if len(failures) > 0 { + t.Errorf("the returning old host after the forced move: %s", strings.Join(failures, "; ")) + } + // #425 (V1-SPEC r2.40: a line carries its owner and that owner's endpoints): every line delivered at the forced + // epoch, to the new owner and to the returning old host alike, carries s2's own endpoints, never another host's. + if bad := wrongOwnerEndpoints(e2, env.hosts["s2"], nw, back); len(bad) > 0 { + t.Errorf("an epoch-%d line was delivered with another host's endpoints (want s2's data=%s ctrl=%s):\n%s", + e2, env.hosts["s2"].data, env.hosts["s2"].ctrl, strings.Join(bad, "\n")) + } + env.h.waitPrimaryAt(t, env.hosts["s2"].status, e2) + if !bytes.Equal(env.readBlock(t, "s2", 0), kept) { + t.Fatal("s2 no longer serves the kept block after the old host returned") + } +} + +// TestProcedureRevokeWithoutACKThenForcedMove: the volume is sealed and +// revoked, but its process dies before it sends the ACK. The clean move is +// refused; only a forced move to another node remains, and since HEAD is +// sealed, nothing acknowledged is lost. +func TestProcedureRevokeWithoutACKThenForcedMove(t *testing.T) { + env := startHandoffEnv(t, 2) + must, mustU := fatalOn(t) + h := env.h + + old := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, old, "s1") + block := pattern("sealed-no-ack!!!") + env.writeBlock(t, "s1", 0, block) + g := env.seal(t, "s1", e) + l := env.sealedLSN(t, e, g) + old.kill(t) + env.revoke(t, e, g) + o, eo, code := h.run(t, env.moveClean(e, "s2", "move-v1-1")...) + must(checkCleanMoveRefused(o, eo, code)) + + out := env.forceMove(t, e, "s2", "force-v1-1") + e2 := mustU(forcedEpoch(out, e, "s1", "s2")) + if got := mustU(forcedKeptLSN(out)); got != l { + t.Fatalf("the forced move kept LSN %d; want the sealed HEAD's %d", got, l) + } + nw := env.start(t, "blockvolume-s2", "s2") + if got := env.adopt(t, nw, "s2"); got != e2 { + t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) + } + if !bytes.Equal(env.readBlock(t, "s2", 0), block) { + t.Fatal("the sealed block does not read back on s2") + } +} + +// TestProcedureStartInsideTheBarrierWaitIsReGranted: the holder's process +// dies and is started again 40 s later: its lease has ended, the re-grant +// barrier (at least 50 s and at most 65 s after the stop, default flags) has +// not passed, and it passes within the process's 30 s authority wait. It must not +// serve while its renewals are still refused for the barrier; once +// re-granted it serves its local WAL at the same epoch. +func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { + env := startHandoffEnv(t, 1) + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("inside-the-wait!") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + time.Sleep(40 * time.Second) + + back := env.start(t, "blockvolume-s1-back", "s1") + var ready []time.Time + end := time.Now().Add(90 * time.Second) + for time.Now().Before(end) { + if env.frontendReadyAt("s1") || listening(env.hosts["s1"].nvme) { + ready = append(ready, time.Now()) + if len(ready) >= 5 { + break + } + } + time.Sleep(200 * time.Millisecond) + } + if len(ready) == 0 { + t.Fatal("the returning holder never served within 90 s") + } + if last := lastLogTime(back, "clock-skew margin has not elapsed"); !last.IsZero() && ready[0].Before(last) { + t.Errorf("the returning holder served at %s, before its renewal was still refused for the barrier at %s: it served without a lease", + ready[0].Format("15:04:05.000"), last.Format("15:04:05")) + } + if got := env.adopt(t, back, "s1"); got != e { + t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) + } + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the stop does not read back") + } +} + +// TestProcedureStartTooEarlyExitsAndARestartServes: with +// --workspace-max-clock-skew 50s the barrier is at most 95 s after the stop. +// A holder started 31 s after the stop ends its 30 s authority wait before +// the barrier: it does not serve and exits with status 75, so a supervisor +// (Restart=on-failure, RestartSec=5s) starts it again; a start that waits +// past the barrier is re-granted and serves at the same epoch. +func TestProcedureStartTooEarlyExitsAndARestartServes(t *testing.T) { + env := startHandoffEnv(t, 1, "--workspace-max-clock-skew", "50s") + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("start-too-early!") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + time.Sleep(31 * time.Second) + + for attempt := 1; ; attempt++ { + d := env.start(t, fmt.Sprintf("blockvolume-s1-try%d", attempt), "s1") + served := false + end := time.Now().Add(45 * time.Second) + for time.Now().Before(end) { + if env.frontendReadyAt("s1") { + served = true + break + } + select { + case <-d.done: + end = time.Now() + default: + time.Sleep(200 * time.Millisecond) + } + } + if served { + if attempt == 1 { + t.Fatal("started before the barrier with its wait ending first, the holder served") + } + if got := env.adopt(t, d, "s1"); got != e { + t.Fatalf("attempt %d adopted epoch %d; want the same epoch %d", attempt, got, e) + } + break + } + if err := d.wait(5 * time.Second); exitCode(err) != 75 { + t.Fatalf("attempt %d did not serve and did not exit 75: %v", attempt, err) + } + if attempt == 4 { + t.Fatal("four supervised starts never served") + } + time.Sleep(5 * time.Second) + } + if !bytes.Equal(env.readBlock(t, "s1", 0), block) { + t.Fatal("the block written before the stop does not read back") + } +} + +// lastLogTime is the time of the last log line containing s (second +// resolution, the log's local time), or zero. +func lastLogTime(d *daemon, s string) time.Time { + data, _ := os.ReadFile(d.log) + var last time.Time + for _, l := range strings.Split(string(data), "\n") { + if strings.Contains(l, s) && len(l) >= 19 { + if ts, err := time.ParseInLocation("2006/01/02 15:04:05", l[:19], time.Local); err == nil { + last = ts + } + } + } + return last +} + +// exitCode is a child's exit status (-1 when it did not exit with one). +func exitCode(err error) int { + var exit *exec.ExitError + if err == nil { + return 0 + } + if errors.As(err, &exit) { + return exit.ExitCode() + } + return -1 +} + +func pattern(s string) []byte { return bytes.Repeat([]byte(s), 4096/len(s)) } + +func (env *handoffEnv) start(t *testing.T, name, id string) *daemon { + t.Helper() + return env.h.start(t, name, env.h.volume, env.volArgs(id)...) +} + +// adopt waits for the process to adopt v1 as primary and its host to report +// it healthy, and returns the epoch. +func (env *handoffEnv) adopt(t *testing.T, d *daemon, id string) uint64 { + t.Helper() + _, mustU := fatalOn(t) + e := mustU(adoptedEpoch(d.waitLog(t, 60*time.Second, "blockvolume: volume v1 adopted as PRIMARY at r1@"))) + env.h.waitPrimaryAt(t, env.hosts[id].status, e) + return e +} + +// frontendReadyAt reports whether the host's status shows v1's frontend +// ready to serve. +func (env *handoffEnv) frontendReadyAt(id string) bool { + c := &http.Client{Timeout: 2 * time.Second} + resp, err := c.Get("http://" + env.hosts[id].status + "/status?volume=v1") + if err != nil { + return false + } + defer resp.Body.Close() + b, _ := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) + return frontendReady(b) +} + +// listening reports whether something accepts TCP connections at addr. +func listening(addr string) bool { + c, err := net.DialTimeout("tcp", addr, time.Second) + if err != nil { + return false + } + c.Close() + return true +} + +func (env *handoffEnv) writeBlock(t *testing.T, id string, lba uint64, data []byte) { + t.Helper() + c := dialNVMe(t, env.hosts[id].nvme, plannedHandoffNQN) + defer c.close() + c.write(t, lba, data) + c.flush(t) +} + +func (env *handoffEnv) readBlock(t *testing.T, id string, lba uint64) []byte { + t.Helper() + c := dialNVMe(t, env.hosts[id].nvme, plannedHandoffNQN) + defer c.close() + return c.read(t, lba, 4096) +} + +func (env *handoffEnv) seal(t *testing.T, id string, e uint64) uint64 { + t.Helper() + _, mustU := fatalOn(t) + out, errOut := env.h.command(t, "ops", "chunk", "detach", "--plain", "--volume", "v1", "--status-addr", env.hosts[id].status, "--timeout", "120s") + return mustU(sealedGen(out, errOut, e)) +} + +func (env *handoffEnv) chunkShow() []string { + return []string{"ops", "chunk", "show", "--volume", "v1", "--chunk-filer", env.cluster.filerGRPC, "--chunk-path", env.chunkPath} +} + +func (env *handoffEnv) sealedLSN(t *testing.T, e, g uint64) uint64 { + t.Helper() + _, mustU := fatalOn(t) + out, _ := env.h.command(t, env.chunkShow()...) + return mustU(sealedHeadLSN(out, e, g)) +} + +func (env *handoffEnv) revoke(t *testing.T, e, g uint64) { + t.Helper() + must, _ := fatalOn(t) + out, _ := env.h.command(t, "ops", "workspace", "revoke", "--master", env.h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--sealed-gen", fmt.Sprint(g)) + must(checkRevoke(out, e, g)) +} + +func (env *handoffEnv) waitAck(t *testing.T, e, g uint64) { + t.Helper() + poll(t, 30*time.Second, fmt.Sprintf("workspace show never reported the ACK of r1@%d at generation %d", e, g), func() bool { + out, _ := env.h.command(t, env.show...) + return showsAck(out, e, g) + }) +} + +func (env *handoffEnv) moveClean(e uint64, target, request string) []string { + b := env.hosts[target] + return []string{"ops", "workspace", "move", "--clean", "--master", env.h.masterAddr, "--volume", "v1", "--replica", "r1", + "--epoch", fmt.Sprint(e), "--target-host", b.id, "--target-data", b.data, "--target-ctrl", b.ctrl, "--request-id", request} +} + +// forceMove runs the page's forced move: --dry-run until it says admitted +// (the barrier: at most 65 s after the holder stopped, with defaults, plus a +// margin), then the move itself, whose stdout it returns. +func (env *handoffEnv) forceMove(t *testing.T, e uint64, target, request string) string { + t.Helper() + b := env.hosts[target] + args := []string{"ops", "workspace", "force-move", "--master", env.h.masterAddr, "--volume", "v1", + "--target-host", b.id, "--target-data", b.data, "--target-ctrl", b.ctrl, + "--request-id", request, "--confirm-forced", fmt.Sprintf("v1@%d", e)} + first, _ := env.h.command(t, append(args, "--dry-run")...) + if !previewAdmitted(first) && !strings.Contains(first, "admissible at ") { + t.Fatalf("a refused preview does not say when the move is admissible:\n%s", first) + } + poll(t, 90*time.Second, "the forced move was never admitted", func() bool { + out, _ := env.h.command(t, append(args, "--dry-run")...) + return previewAdmitted(out) + }) + out, _ := env.h.command(t, args...) + return out +} + +// wrongOwnerEndpoints returns every "assignment stream delivery" log line at epoch e (in any of ds) whose data or control +// endpoint is not owner's (#425). +func wrongOwnerEndpoints(e uint64, owner bvHost, ds ...*daemon) []string { + var bad []string + tag := fmt.Sprintf(" epoch=%d ev=", e) + for _, d := range ds { + raw, _ := os.ReadFile(d.log) + for _, l := range strings.Split(string(raw), "\n") { + if !strings.Contains(l, "assignment stream delivery") || !strings.Contains(l, tag) { + continue + } + if !strings.Contains(l, fmt.Sprintf("data=%q", owner.data)) || !strings.Contains(l, fmt.Sprintf("ctrl=%q", owner.ctrl)) { + bad = append(bad, d.name+": "+strings.TrimSpace(l)) + } + } + } + return bad +} From 764a208f4e0b9103e64420ceac5de2285615d10b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:05:41 -0800 Subject: [PATCH 126/204] fix: share supersession comparison across named lineage evidence --- .../process_exit_authority_test.go | 2 +- seaweed-block/core/host/volume/host.go | 32 +++++++------- .../core/host/volume/workspace_startup.go | 6 +-- .../host/volume/workspace_startup_test.go | 42 ++++++++++++++++--- seaweed-block/docs/design/invariants.md | 1 + 5 files changed, 55 insertions(+), 28 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index 80d8296aaa..e86edd7c0c 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -79,7 +79,7 @@ func exitAuthorityHost(t *testing.T, configure ...func(*exitAssignmentStream)) ( }) return h, func(replica string, epoch uint64) { t.Helper() - stream.facts <- &control.AssignmentFact{VolumeId: "v", ReplicaId: replica, Epoch: epoch, EndpointVersion: 1} + stream.facts <- &control.AssignmentFact{VolumeId: "v", ReplicaId: replica, ServerId: "s", Epoch: epoch, EndpointVersion: 1} deadline := time.NewTimer(3 * time.Second) defer deadline.Stop() tick := time.NewTicker(time.Millisecond) diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index ddfc9c8e61..43e68fba2e 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -523,29 +523,27 @@ func (h *Host) getReplication() replicaSetUpdater { return h.replication } -// IsSuperseded gates a newer foreign replica line, or a same-replica foreign -// server identity strictly newer than an adopted local lineage. An explicitly -// matching self identity remains an ordinary adapter update. +// IsSuperseded compares an adopted lineage. Before adoption there is no +// serving incarnation to fence (INV-AUTH-HOLDER-IDENTITY-001). func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool { + return selfEpoch != 0 && h.isSupersededLineage(selfReplicaID, selfEpoch, selfEV) +} + +// isSupersededLineage is the one foreign-holder comparison. Callers name +// their evidence: adopted engine lineage for fencing, observed own assignment +// for process exit (INV-WS-STARTUP-RETRY-001). Zero observed lineage means this +// process never received its own assignment, not that a foreign line is ours. +func (h *Host) isSupersededLineage(selfReplicaID string, selfEpoch, selfEV uint64) bool { h.otherMu.Lock() defer h.otherMu.Unlock() - if h.lastOther == nil || selfEpoch == 0 { + other := h.lastOther + if other == nil || other.ReplicaId == "" || other.VolumeId != h.cfg.VolumeID { return false } - other := h.lastOther - if other.ReplicaId == selfReplicaID { - if h.assignmentNamesSelf(other) { - return false - } - return other.Epoch > selfEpoch || other.Epoch == selfEpoch && other.EndpointVersion > selfEV + if other.ReplicaId == selfReplicaID && h.assignmentNamesSelf(other) { + return false } - if other.Epoch > selfEpoch { - return true - } - if other.Epoch == selfEpoch && other.EndpointVersion > selfEV { - return true - } - return false + return other.Epoch > selfEpoch || other.Epoch == selfEpoch && other.EndpointVersion > selfEV } // ProjectionView returns the AdapterProjectionView that bridges diff --git a/seaweed-block/core/host/volume/workspace_startup.go b/seaweed-block/core/host/volume/workspace_startup.go index e3942fa611..1a270eb801 100644 --- a/seaweed-block/core/host/volume/workspace_startup.go +++ b/seaweed-block/core/host/volume/workspace_startup.go @@ -22,9 +22,5 @@ func (h *Host) recordSelfAssignment(f *control.AssignmentFact) { func (h *Host) IsCurrentReplicaSuperseded() bool { h.ownAssignmentMu.RLock() defer h.ownAssignmentMu.RUnlock() - other := h.LastOtherLine() - if other == nil || other.ReplicaId == "" || other.VolumeId != h.cfg.VolumeID { - return false - } - return h.IsSuperseded(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) + return h.isSupersededLineage(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) } diff --git a/seaweed-block/core/host/volume/workspace_startup_test.go b/seaweed-block/core/host/volume/workspace_startup_test.go index ca8e39af63..47643da2a0 100644 --- a/seaweed-block/core/host/volume/workspace_startup_test.go +++ b/seaweed-block/core/host/volume/workspace_startup_test.go @@ -7,12 +7,12 @@ import ( func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { h, _, _ := newStubbedHost(t, "v", "r", &orderingRecorder{}) - h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "other", Epoch: 6, EndpointVersion: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "other", Epoch: 6, EndpointVersion: 1}) if !h.IsCurrentReplicaSuperseded() { t.Fatal("never-assigned newer other line did not supersede") } h.BlockLocalReadiness("local recovery pending") - h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 7, EndpointVersion: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 7, EndpointVersion: 1}) if h.IsCurrentReplicaSuperseded() { t.Fatal("blocked own assignment left historical other line current for exit") } @@ -20,7 +20,7 @@ func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { if !h.IsSuperseded("r", 5, 1) { t.Fatal("exit observation weakened serving supersede predicate") } - h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 4, EndpointVersion: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 4, EndpointVersion: 1}) if h.IsCurrentReplicaSuperseded() { t.Fatal("older own delivery lowered the exit lineage") } @@ -32,9 +32,41 @@ func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { func TestWorkspaceEmptyOtherReplicaNeverSelectsNoRetry(t *testing.T) { h, _, _ := newStubbedHost(t, "v", "r", &orderingRecorder{}) - h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 5, EndpointVersion: 1}) - h.applyFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "", Epoch: 7, EndpointVersion: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 5, EndpointVersion: 1}) + h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "", Epoch: 7, EndpointVersion: 1}) if h.IsCurrentReplicaSuperseded() { t.Fatal("empty replica id is not another holder; must retry") } } + +// The two Part T facts are intentionally different: a validated assignment can +// be observed while local recovery prevents the engine from adopting it. +func TestWorkspaceExitAndFenceUseNamedLineages(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "self", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304"}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + fencer := &holderFenceCounter{} + if err := h.SetSelfFence(fencer); err != nil { + t.Fatal(err) + } + h.BlockLocalReadiness("local recovery pending") + foreign := holderAssignment(t, "other") + foreign.Epoch = 6 + h.applyFact(foreign) + if !h.IsCurrentReplicaSuperseded() || h.IsSuperseded("r1", 0, 0) || fencer.calls.Load() != 0 { + t.Fatal("foreign same-replica server must select exit78 without fencing an unadopted incarnation") + } + own := holderAssignment(t, "self") + own.Epoch = 7 + h.applyFact(own) + if h.view.EngineProjection().Epoch != 0 || h.IsCurrentReplicaSuperseded() || fencer.calls.Load() != 0 { + t.Fatal("observed own7 must suppress historical foreign6 for exit while adopted lineage stays zero") + } + foreign.Epoch = 8 + h.applyFact(foreign) + if !h.IsCurrentReplicaSuperseded() || h.IsSuperseded("r1", 0, 0) || fencer.calls.Load() != 0 { + t.Fatal("foreign8 must supersede observed own7 without changing the unadopted fencing rule") + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 759082daf5..7611fc2df8 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -717,6 +717,7 @@ Notes: | `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- Part T lineage evidence: `recordSelfAssignment` records the newest identity-validated observed-own assignment before local-readiness admission; `EngineProjection` is the adopted-own lineage. Exit compares the former (zero means never assigned); fencing requires a nonzero latter. Both use `isSupersededLineage` through their named entry points; neither fact grants I/O. `TestWorkspaceExitAndFenceUseNamedLineages` and `TestWorkspaceExitLineageIncludesBlockedOwnAssignment` (`core/host/volume/workspace_startup_test.go`) keep the distinction causal. - Part T evidence scope: `workspaceRetryOutcome` is the one retry/no-retry decision. Startup `chooseChunkStartupExit` supplies the recovery-generation-bound refused-claim HEAD proof; runtime lease-end supplies none. Both combine that input with the newer other-replica master line; absent proof means retry 75. - 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. From 290b43c58b09c24f9ce829689dd3007c5be2bfe6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:04:36 -0800 Subject: [PATCH 127/204] fix: a moved line's replica is expected on its owner, so no other server refreshes its endpoints #425 (V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): the topology controller took the line replica's facts from the server the accepted topology names (the old host after a forced move); the returning old host's report raised an endpoint refresh that republished the line (EV+1, owner s2) with s1's endpoints. BuildSnapshot now binds the expected slot of the line's replica to the move-named owner (PublishedLine.IssuedHost), so that replica's health, endpoints and refreshes come only from the owner. Co-Authored-By: Claude Opus 5.5 --- .../core/authority/snapshot_builder.go | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/seaweed-block/core/authority/snapshot_builder.go b/seaweed-block/core/authority/snapshot_builder.go index 16585e17b0..0fe437a3f2 100644 --- a/seaweed-block/core/authority/snapshot_builder.go +++ b/seaweed-block/core/authority/snapshot_builder.go @@ -98,6 +98,9 @@ func BuildSnapshot(store storeSnapshot, topology AcceptedTopology, reader Author if reader != nil { basis, hasLine = reader.VolumeAuthorityLine(vid) } + if hasLine { + expected = expectOwnerForLine(expected, vid, basis, reader) + } verdict := evaluateVolume(vid, expected, freshSlotsByVolume[vid], store, basis, hasLine) switch verdict.state { @@ -473,3 +476,31 @@ func assembleVolumeTopology( Slots: slots, } } + +// lineOwnerReader is the publisher's view of a line's owner (the server a move issued it to). +type lineOwnerReader interface { + PublishedAuthorityLine(volume string) (PublishedLine, bool) +} + +// expectOwnerForLine binds the expected slot of the line's replica to the line's owner when a move named it (#425, +// V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): a line carries its owner and that owner's endpoints, so its replica's +// facts (health, endpoints, and any endpoint refresh) come only from that server, never from the placement or +// topology server it was moved away from. Without a move-named owner the expected topology stands unchanged. +func expectOwnerForLine(expected VolumeExpected, volumeID string, line AuthorityBasis, reader AuthorityBasisReader) VolumeExpected { + r, ok := reader.(lineOwnerReader) + if !ok { + return expected + } + pl, ok := r.PublishedAuthorityLine(volumeID) + if !ok || pl.ReplicaID != line.ReplicaID || pl.Epoch != line.Epoch || !(pl.OwnerFromMove || pl.IssuedHost != "") || pl.IssuedHost == "" { + return expected + } + out := VolumeExpected{VolumeID: expected.VolumeID, Slots: make([]ExpectedSlot, len(expected.Slots))} + copy(out.Slots, expected.Slots) + for i := range out.Slots { + if out.Slots[i].ReplicaID == line.ReplicaID { + out.Slots[i].ServerID = pl.IssuedHost + } + } + return out +} From 77873e8d546bd699878a2832cde87823c163ae36 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:09:05 -0800 Subject: [PATCH 128/204] test: the moved line's replica candidate comes from its owner (#425 unit red + control) Co-Authored-By: Claude Opus 5.5 --- .../authority/line_owner_snapshot_test.go | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 seaweed-block/core/authority/line_owner_snapshot_test.go diff --git a/seaweed-block/core/authority/line_owner_snapshot_test.go b/seaweed-block/core/authority/line_owner_snapshot_test.go new file mode 100644 index 0000000000..4181458252 --- /dev/null +++ b/seaweed-block/core/authority/line_owner_snapshot_test.go @@ -0,0 +1,51 @@ +package authority + +import ( + "testing" + "time" +) + +// ownerReader is the publisher view the snapshot builder reads: the line plus the server a move issued it to. +type ownerReader struct { + *fakeReaderForHost + owner map[string]PublishedLine +} + +func (r ownerReader) PublishedAuthorityLine(volume string) (PublishedLine, bool) { + pl, ok := r.owner[volume] + return pl, ok +} + +// #425 (V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): after a forced move s1 -> s2 the accepted topology still names +// s1 for r1. When s1 returns and reports r1 at its own endpoints, the controller's input for the line's replica must +// come from the line's owner s2, never s1: otherwise an endpoint refresh republishes the line with s1's endpoints. +func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) { + start := time.Date(2026, 11, 22, 14, 0, 0, 0, time.UTC) + clk := newFakeClock(start) + store := NewObservationStore(FreshnessConfig{FreshnessWindow: 500 * time.Millisecond, PendingGrace: 100 * time.Millisecond}, clk.Now) + topo := AcceptedTopology{Volumes: []VolumeExpected{{VolumeID: "v1", Slots: []ExpectedSlot{{ReplicaID: "r1", ServerID: "s1"}}}}} + at := func(addr string) SlotFact { + s := healthySlot("v1", "r1") + s.DataAddr, s.CtrlAddr = addr+":1", addr+":2" + return s + } + _ = ingest(t, store, serverObs("s2", start, at("owner-s2"))) + _ = ingest(t, store, serverObs("s1", start, at("old-s1"))) // the old host, back with its own endpoints + reader := ownerReader{fakeReaderForHost: newFakeReaderForHost(), owner: map[string]PublishedLine{ + "v1": {ReplicaID: "r1", Epoch: 2, IssuedHost: "s2", OwnerFromMove: true}}} + reader.SetVolume("v1", AuthorityBasis{Assigned: true, ReplicaID: "r1", Epoch: 2, EndpointVersion: 1, DataAddr: "owner-s2:1", CtrlAddr: "owner-s2:2"}) + v, ok := findSupported(BuildSnapshot(store.Snapshot(), topo, reader), "v1") + if !ok { + t.Fatal("v1 not supported") + } + r1, ok := candidateByReplica(v, "r1") + if !ok || r1.ServerID != "s2" || r1.DataAddr != "owner-s2:1" || r1.CtrlAddr != "owner-s2:2" { + t.Fatalf("line replica candidate %+v ok=%v, want the owner s2 at owner-s2:1/2 (never the old host s1)", r1, ok) + } + // without a move-named owner the accepted topology stands (control) + plain := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2}}} + v, _ = findSupported(BuildSnapshot(store.Snapshot(), topo, plain), "v1") + if r1, _ := candidateByReplica(v, "r1"); r1.ServerID != "s1" || r1.DataAddr != "old-s1:1" { + t.Fatalf("control: no move-named owner, candidate %+v, want the topology's s1", r1) + } +} From 2332cba69650635e91f369f91eaa4ad5c804ba1b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:09:57 -0800 Subject: [PATCH 129/204] test: assert observed lineage precedes every adoption handoff --- .../host/volume/workspace_startup_test.go | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/seaweed-block/core/host/volume/workspace_startup_test.go b/seaweed-block/core/host/volume/workspace_startup_test.go index 47643da2a0..319e1a7b28 100644 --- a/seaweed-block/core/host/volume/workspace_startup_test.go +++ b/seaweed-block/core/host/volume/workspace_startup_test.go @@ -1,6 +1,7 @@ package volume import ( + "github.com/seaweedfs/seaweed-block/core/adapter" control "github.com/seaweedfs/seaweed-block/core/rpc/control" "testing" ) @@ -70,3 +71,71 @@ func TestWorkspaceExitAndFenceUseNamedLineages(t *testing.T) { t.Fatal("foreign8 must supersede observed own7 without changing the unadopted fencing rule") } } + +// Check at the adoption handoff, not just after applyFact: moving observation +// after adapter adoption must fail even when the eventual snapshots match. +type observationCheckedAdoption struct { + assignmentConsumer + before func(adapter.AssignmentInfo) +} + +func (a observationCheckedAdoption) OnAssignment(info adapter.AssignmentInfo) adapter.ApplyLog { + a.before(info) + return a.assignmentConsumer.OnAssignment(info) +} + +func TestWorkspaceObservedLineageNeverTrailsAdoption(t *testing.T) { + h, err := New(Config{MasterAddr: "127.0.0.1:1", ServerID: "self", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:19303", CtrlAddr: "127.0.0.1:19304"}) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = h.Close() }) + check := func(epoch, ev uint64) { + t.Helper() + h.ownAssignmentMu.RLock() + defer h.ownAssignmentMu.RUnlock() + if h.ownAssignmentEpoch < epoch || h.ownAssignmentEpoch == epoch && h.ownAssignmentEV < ev { + t.Fatalf("observation trails adoption handoff: observed=%d/%d adopted=%d/%d", h.ownAssignmentEpoch, h.ownAssignmentEV, epoch, ev) + } + } + adoptions := 0 + h.adpt = observationCheckedAdoption{h.adpt, func(info adapter.AssignmentInfo) { + check(info.Epoch, info.EndpointVersion) + adoptions++ + }} + assertAdopted := func(epoch, ev uint64) { + t.Helper() + p := h.view.EngineProjection() + if p.Epoch != epoch || p.EndpointVersion != ev { + t.Fatalf("adopted=%d/%d want=%d/%d", p.Epoch, p.EndpointVersion, epoch, ev) + } + check(p.Epoch, p.EndpointVersion) + } + own := holderAssignment(t, "self") + own.Epoch = 3 + h.applyFact(own) + assertAdopted(3, 1) + h.BlockLocalReadiness("local recovery pending") + own.Epoch = 7 + h.applyFact(own) + own.EndpointVersion = 2 + h.applyFact(own) + check(7, 2) + assertAdopted(3, 1) + h.ClearLocalReadinessBlock() + h.replayLocalReadinessFactIfReady() + assertAdopted(7, 2) + foreign := holderAssignment(t, "other") + foreign.Epoch = 8 + h.applyFact(foreign) + assertAdopted(7, 2) + own.Epoch = 9 + h.applyFact(own) + assertAdopted(9, 2) + own.Epoch = 7 + h.applyFact(own) + assertAdopted(9, 2) + if adoptions != 3 { + t.Fatalf("adoption handoffs=%d want3 (initial, readiness replay, move back)", adoptions) + } +} From e1edfe04da6671e2d324fc8ac616466560184a8d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:19:34 -0800 Subject: [PATCH 130/204] fix: apply zero-lineage retry rule to observed and adopted facts --- .../process_exit_authority_test.go | 2 +- .../startup_systemd_integration_test.go | 30 +++++++++---------- seaweed-block/core/host/volume/host.go | 16 ++++------ .../core/host/volume/workspace_startup.go | 2 +- .../host/volume/workspace_startup_test.go | 10 ++++--- seaweed-block/docs/design/invariants.md | 2 +- 6 files changed, 28 insertions(+), 34 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go index e86edd7c0c..44cbe8bece 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_authority_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_authority_test.go @@ -126,7 +126,7 @@ func TestWorkspaceRetryUsesNewestOwnAssignment(t *testing.T) { {"never assigned", []struct { replica string epoch uint64 - }{{"other", 6}}, 78}, + }{{"other", 6}}, 75}, {"empty replica newer epoch", []struct { replica string epoch uint64 diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index fa869e29b3..ce34dde5d6 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -191,7 +191,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { t.Fatalf("systemd rate limit hit: %+v", s) } gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, "r1", s["NRestarts"], s["InvocationID"]) - gap1SupersededDoesNotRestart(t, fixture, stem, filepath.Join(bin, "blockvolume"), args, root, volume) + gap1NeverAssignedRetries(t, fixture, stem, filepath.Join(bin, "blockvolume"), args, root, volume) } // Roots are deliberately independent of testing.TempDir: unknown unit cleanup @@ -499,11 +499,11 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie }) } -// The master keeps the real r1 authority line. This process has never had an -// assignment and names r-old, so only the observed different-replica fact may -// permit 78. Run after the live holder has ACKed and exited, avoiding a node -// registration change while that holder is serving. -func gap1SupersededDoesNotRestart(t *testing.T, fixture *gap1Fixture, stem, exe string, args []string, root, volume string) { +// The master keeps the real r1 authority line. A fresh r-old process has +// zero observed-own lineage, so a foreign fact selects retry75, never78. +// Run after the live holder has ACKed and exited, avoiding a node registration +// change while that holder is serving. This is not a superseded-holder witness. +func gap1NeverAssignedRetries(t *testing.T, fixture *gap1Fixture, stem, exe string, args []string, root, volume string) { t.Helper() changed := append([]string(nil), args...) addr := leaseBinaryAddress(t) @@ -538,7 +538,7 @@ func gap1SupersededDoesNotRestart(t *testing.T, fixture *gap1Fixture, stem, exe } // A never-assigned replica remains ModeIdle, so /status intentionally // reports unknown even after recording the other-replica fact. Prove - // receipt in this process before checking its terminal78 decision. + // receipt in this process before checking its retry75 decision. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() journal, err := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=cat").CombinedOutput() @@ -552,18 +552,16 @@ func gap1SupersededDoesNotRestart(t *testing.T, fixture *gap1Fixture, stem, exe } return false }) - waitGAP1(t, "positive supersede did not exit78 without restart", 45*time.Second, func() bool { + waitGAP1(t, "never-assigned foreign identity did not exit75 and restart", 45*time.Second, func() bool { s := gap1Unit(t, unit) - if s["NRestarts"] != "0" { - t.Fatalf("superseded unit restarted: %+v", s) + n, err := strconv.Atoi(s["NRestarts"]) + if err != nil { + t.Fatalf("invalid restart count: %+v", s) } - if s["MainPID"] != "0" { - return false + if s["ExecMainStatus"] == "78" { + t.Fatalf("zero-lineage process chose no-retry: %+v", s) } - if s["ExecMainStatus"] != "78" || s["ActiveState"] != "failed" || s["SubState"] != "failed" { - t.Fatalf("supersede not a terminal no-retry exit: %+v", s) - } - return true + return n >= 1 && s["MainPID"] != "0" && s["ExecMainStatus"] == "75" }) } diff --git a/seaweed-block/core/host/volume/host.go b/seaweed-block/core/host/volume/host.go index 43e68fba2e..78b5613748 100644 --- a/seaweed-block/core/host/volume/host.go +++ b/seaweed-block/core/host/volume/host.go @@ -523,21 +523,15 @@ func (h *Host) getReplication() replicaSetUpdater { return h.replication } -// IsSuperseded compares an adopted lineage. Before adoption there is no -// serving incarnation to fence (INV-AUTH-HOLDER-IDENTITY-001). +// IsSuperseded is the one foreign-holder comparison. Callers supply the +// named lineage: adopted engine state for fencing, observed own assignment +// for exit classification. Zero lineage selects neither fencing nor exit78 +// (INV-AUTH-HOLDER-IDENTITY-001; INV-WS-STARTUP-RETRY-001). func (h *Host) IsSuperseded(selfReplicaID string, selfEpoch, selfEV uint64) bool { - return selfEpoch != 0 && h.isSupersededLineage(selfReplicaID, selfEpoch, selfEV) -} - -// isSupersededLineage is the one foreign-holder comparison. Callers name -// their evidence: adopted engine lineage for fencing, observed own assignment -// for process exit (INV-WS-STARTUP-RETRY-001). Zero observed lineage means this -// process never received its own assignment, not that a foreign line is ours. -func (h *Host) isSupersededLineage(selfReplicaID string, selfEpoch, selfEV uint64) bool { h.otherMu.Lock() defer h.otherMu.Unlock() other := h.lastOther - if other == nil || other.ReplicaId == "" || other.VolumeId != h.cfg.VolumeID { + if selfEpoch == 0 || other == nil || other.ReplicaId == "" || other.VolumeId != h.cfg.VolumeID { return false } if other.ReplicaId == selfReplicaID && h.assignmentNamesSelf(other) { diff --git a/seaweed-block/core/host/volume/workspace_startup.go b/seaweed-block/core/host/volume/workspace_startup.go index 1a270eb801..22a743f114 100644 --- a/seaweed-block/core/host/volume/workspace_startup.go +++ b/seaweed-block/core/host/volume/workspace_startup.go @@ -22,5 +22,5 @@ func (h *Host) recordSelfAssignment(f *control.AssignmentFact) { func (h *Host) IsCurrentReplicaSuperseded() bool { h.ownAssignmentMu.RLock() defer h.ownAssignmentMu.RUnlock() - return h.isSupersededLineage(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) + return h.IsSuperseded(h.cfg.ReplicaID, h.ownAssignmentEpoch, h.ownAssignmentEV) } diff --git a/seaweed-block/core/host/volume/workspace_startup_test.go b/seaweed-block/core/host/volume/workspace_startup_test.go index 319e1a7b28..cec944cd7f 100644 --- a/seaweed-block/core/host/volume/workspace_startup_test.go +++ b/seaweed-block/core/host/volume/workspace_startup_test.go @@ -9,8 +9,10 @@ import ( func TestWorkspaceExitLineageIncludesBlockedOwnAssignment(t *testing.T) { h, _, _ := newStubbedHost(t, "v", "r", &orderingRecorder{}) h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "other", Epoch: 6, EndpointVersion: 1}) - if !h.IsCurrentReplicaSuperseded() { - t.Fatal("never-assigned newer other line did not supersede") + // Zero observed-own lineage inherits the fencing predicate's zero rule: + // a never-assigned process retries75; it has no own incarnation to supersede. + if h.IsCurrentReplicaSuperseded() { + t.Fatal("never-assigned process must retry75 despite a foreign line") } h.BlockLocalReadiness("local recovery pending") h.applyFixtureFact(&control.AssignmentFact{VolumeId: "v", ReplicaId: "r", Epoch: 7, EndpointVersion: 1}) @@ -56,8 +58,8 @@ func TestWorkspaceExitAndFenceUseNamedLineages(t *testing.T) { foreign := holderAssignment(t, "other") foreign.Epoch = 6 h.applyFact(foreign) - if !h.IsCurrentReplicaSuperseded() || h.IsSuperseded("r1", 0, 0) || fencer.calls.Load() != 0 { - t.Fatal("foreign same-replica server must select exit78 without fencing an unadopted incarnation") + if h.IsCurrentReplicaSuperseded() || h.IsSuperseded("r1", 0, 0) || fencer.calls.Load() != 0 { + t.Fatal("foreign same-replica server must select retry75 and no fence before any own assignment") } own := holderAssignment(t, "self") own.Epoch = 7 diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 7611fc2df8..54a0d8c31a 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -717,7 +717,7 @@ Notes: | `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | - `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. -- Part T lineage evidence: `recordSelfAssignment` records the newest identity-validated observed-own assignment before local-readiness admission; `EngineProjection` is the adopted-own lineage. Exit compares the former (zero means never assigned); fencing requires a nonzero latter. Both use `isSupersededLineage` through their named entry points; neither fact grants I/O. `TestWorkspaceExitAndFenceUseNamedLineages` and `TestWorkspaceExitLineageIncludesBlockedOwnAssignment` (`core/host/volume/workspace_startup_test.go`) keep the distinction causal. +- Part T lineage evidence: `recordSelfAssignment` records the newest identity-validated observed-own assignment before local-readiness admission; `EngineProjection` is the adopted-own lineage. Exit compares the former; fencing compares the latter. Both use `IsSuperseded` with explicit lineage; zero lineage selects retry75 and no fence; neither fact grants I/O. `TestWorkspaceExitAndFenceUseNamedLineages` and `TestWorkspaceExitLineageIncludesBlockedOwnAssignment` (`core/host/volume/workspace_startup_test.go`) keep the distinction causal. - Part T evidence scope: `workspaceRetryOutcome` is the one retry/no-retry decision. Startup `chooseChunkStartupExit` supplies the recovery-generation-bound refused-claim HEAD proof; runtime lease-end supplies none. Both combine that input with the newer other-replica master line; absent proof means retry 75. - 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. From d7b7f2a432e8370675e750bd0c6cd3d6d95e8f2d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:19:50 -0800 Subject: [PATCH 131/204] test: observe retry exit before checking its restarted process --- .../startup_systemd_integration_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index ce34dde5d6..8c5cb64012 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -552,16 +552,20 @@ func gap1NeverAssignedRetries(t *testing.T, fixture *gap1Fixture, stem, exe stri } return false }) - waitGAP1(t, "never-assigned foreign identity did not exit75 and restart", 45*time.Second, func() bool { + waitGAP1(t, "never-assigned foreign identity did not exit75", 45*time.Second, func() bool { s := gap1Unit(t, unit) - n, err := strconv.Atoi(s["NRestarts"]) - if err != nil { - t.Fatalf("invalid restart count: %+v", s) - } if s["ExecMainStatus"] == "78" { t.Fatalf("zero-lineage process chose no-retry: %+v", s) } - return n >= 1 && s["MainPID"] != "0" && s["ExecMainStatus"] == "75" + return s["ExecMainStatus"] == "75" + }) + waitGAP1(t, "never-assigned retry75 did not restart", 15*time.Second, func() bool { + s := gap1Unit(t, unit) + n, err := strconv.Atoi(s["NRestarts"]) + if err != nil || n > 2 { + t.Fatalf("invalid or unbounded restart count: %+v", s) + } + return n >= 1 && s["MainPID"] != "0" }) } From 38732f5e886e73441de545e9c92761169a5abd9c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:21:18 -0800 Subject: [PATCH 132/204] docs: INV-AUTH-HOLDER-IDENTITY-001 traces the moved line's owner binding and its tests (#425) Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index bbc99df173..272f5adcfa 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -616,7 +616,7 @@ Notes: | ID | Statement | Machine / transition | Enforced in | Test | TLA+ property | Status | |---|---|---|---|---|---|---| -| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409; `core/host/master/workspace_binding.go` `workspaceLineOwner`, `workspaceSourceHost`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestWorkspaceLineOwnerIssuedAndHistorical` (`core/host/master/workspace_line_owner_test.go`), `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestAssignmentFactKeepsCapturedMoveOwnerWithoutReadableJournal` (`core/host/master/assignment_fact_owner_test.go`), `TestAssignmentOwnerReservedAndIssuedCapture` (`core/authority/assignment_owner_test.go`), `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication | `WorkspaceRegrant` `NoForeignAdoption`, `TargetNotFencedByOwnLine` (round 4 pinned simulations only; exhaustive combo10 pending) | ACTIVE | +| `INV-AUTH-HOLDER-IDENTITY-001` | A primary holder is the pair (server id, replica id): every site that decides holdership (adopting a fact, lease first grant, renew, re-grant, HEAD claim, superseded exit) compares both; a missing server id is refused, never guessed. | AUTHORITY: PRIMARY holdership (supporting replicas are not holders) | `core/host/volume/host.go` `applyFact`, `IsSuperseded`, `recordOtherLine`; `assignment_holder.go` `assignmentNamesSelf`, `observeForeignHolder`, `refusePrimaryAssignment`; `host.go` `IsSuperseded`; `core/host/master/services.go` `SubscribeAssignments`; `workspace_service.go` `holderMatches`, `RenewWorkspaceLease`, `AckWorkspaceRevoked`; `cmd/blockvolume/chunk_remote.go` `chunkHolder`; `core/storage/chunk_restore.go` `ClaimChunkHead`; superseded exit covered by #409; `core/host/master/workspace_binding.go` `workspaceLineOwner`, `workspaceSourceHost`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/server_host_identity.go` `refuseServerIDFromOtherHost` (from `ReportHeartbeat`), `refuseWorkspaceHolderHost` (from `holderMatches` and, for a workspace volume, `SubscribeAssignments`), `holderSlotFact` (from `QueryVolumeStatus` and `observationVolume`/`observationReplicas`); `core/csi/master_backend.go` `primaryOwnedFrontends` (a CSI target only from a usable primary frontend); `core/authority/snapshot_builder.go` `expectOwnerForLine` (a moved line's replica facts and endpoint refreshes only from its owner, #425) | `TestAssignmentHolderIdentityRestartedOldProcess`, `TestAssignmentHolderIdentityMatchingServerStillAdopts`, `TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica`, `TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch`, `TestAssignmentHolderIdentityForeignStreamOrdering`, `TestAssignmentHolderIdentityForcedMoveRefusesEveryDeliveredVersion`, `TestAssignmentHolderIdentitySameEpochCannotChangeServer` (`core/host/volume/assignment_holder_test.go`); `TestWorkspaceLeaseGuardCarriesHolderServerIdentity` (`core/host/volume/workspace_holder_identity_test.go`); `TestWorkspaceLeaseRequiresHolderServerForGrantRenewAndRegrant`, `TestWorkspaceRevocationACKRequiresHolderServer` (`core/host/master/workspace_holder_identity_test.go`); `TestWorkspaceRPCCleanMovePreservesReplicaIdentity` (`core/host/master/workspace_service_test.go`); HEAD claim: `TestChunkHolderIsServerAndReplica` (`cmd/blockvolume/chunk_remote_test.go`), `TestWALStoreChunk_SameReplicaOnAnotherServerIsFenced` (`core/frontend/durable/provider_chunk_holder_test.go`); superseded exit: covered by #409 (server-id/replica-id pair, never replica alone); supporting replicas are not holders; descriptor identity not in this row; `TestWorkspaceLineOwnerIssuedAndHistorical` (`core/host/master/workspace_line_owner_test.go`), `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestAssignmentFactKeepsCapturedMoveOwnerWithoutReadableJournal` (`core/host/master/assignment_fact_owner_test.go`), `TestAssignmentOwnerReservedAndIssuedCapture` (`core/authority/assignment_owner_test.go`), `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestServerIDRefusedFromAHostOtherThanItsRegisteredOne`, `TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream`, `TestPortalAndPrimaryComeFromTheLineServerNotTheFreshestHeartbeat`, `TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot`, `TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing`, `TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected`, `TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck` (`core/host/master/server_host_identity_test.go`); `TestPublishTargetIsPrimaryOwned` (`core/csi/primary_owned_frontend_test.go`). Host scope: registered advertised-host consistency, not process uniqueness; a workspace holder's server id must be registered (no first-seen binding: host addresses change); non-workspace heartbeats from an unregistered id are not checked. Limits: trusts the network peer address (no NAT or proxy between volume and master in OSS); not authentication; `TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner` (`core/authority/line_owner_snapshot_test.go`); `TestProcedureForcedMoveWithTheOldHostReturning` (`cmd/blockvolume/procedure_gate_integration_test.go`, tags subprocess chunkstore_integration: every forced-epoch line carries the new owner's endpoints) | `WorkspaceRegrant` `NoForeignAdoption`, `TargetNotFencedByOwnLine` (round 4 pinned simulations only; exhaustive combo10 pending) | ACTIVE | | `INV-AUTH-EPOCH-MINT-001` | Only the publisher mints epochs; a reassignment takes the per-volume maximum epoch plus one, also after a restart. | M2 Bound → Reassigned | `core/authority/authority.go` `applyWithWorkspaceMove`, `maxPublishedEpochForVolume` | `TestG8_0_Publisher_ReassignAdvancesPerVolumeEpochAcrossReplicaSlots` (`core/authority/g8_0_authority_failover_test.go`); `TestDurableAuthority_PublisherAdvancesFromReloaded` (`core/authority/authority_restart_test.go`); `TestG9F2_AssignmentRequestShapeHasNoEpochOrEndpointVersion` (`core/host/master/authority_request_bridge_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-PERSIST-BEFORE-PUBLISH-001` | With an authority store configured, an assignment is written to the store before memory or any subscriber sees it, and a failed write does not publish it: see M2 any → (store write first). | M2 any → (store write first) | `core/authority/authority.go` `applyWithWorkspaceMove` | `TestDurableAuthority_PutFailureRollsBackInMemoryState` (`core/authority/authority_restart_test.go`) | `ControlPlane` `UniqueEpoch` | ACTIVE | | `INV-AUTH-MOVE-JOURNAL-001` | A workspace move's epoch is issued only after its journal record is durable, and one move request id gets exactly one epoch, also across restarts. | M2 MoveReserved → MoveIssued | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `MoveWorkspace`, `sameWorkspaceRequest` | `TestWorkspaceMoveCannotIssueEpochWithoutJournal`, `TestWorkspaceCrashAfterJournalBeforeEpochResumesSameGrant` (`core/authority/workspace_test.go`); `TestWorkspaceReplayedIssueStartsGranteeLease` (`core/authority/workspace_unclaimed_grant_test.go`) | `ControlPlane` `Idempotent`, `JournalComplete` | ACTIVE | From 027c16171974131b547dfebedf77ddee174d6c5f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:21:22 -0800 Subject: [PATCH 133/204] docs: state nonzero observed-lineage requirement for superseded exit --- seaweed-block/docs/design/invariants.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 54a0d8c31a..db47d15a00 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -135,7 +135,7 @@ a pre-issued publication. | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | | Expired | Granted | Same current primary server/replica/epoch, validated by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) with missing server refused, no pending move or revocation/ACK, store certain; horizon and granted/restart deadline plus full skew both passed (the existing forced-move barrier); a busy authority writer refuses this attempt, otherwise persist the new horizon before its grant. A terminal guard stays terminal; a new process claims HEAD before I/O. | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-REGRANT-001`, `INV-WS-REOPEN-FENCE-001`, `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-AUTH-HOLDER-IDENTITY-001` | -| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; a newer other-replica master fact or exact foreign HEAD at or above the assigned epoch permits 78. Planned drain retires startup monitoring before cleanup; ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait or lease fence exits 75 after bounded cleanup; a foreign master fact newer than nonzero observed-own lineage or exact foreign HEAD at or above the assigned epoch permits 78. Planned drain retires startup monitoring before cleanup; ACK and signal retain normal exit. Restart follows the unchanged grant and HEAD-claim gates. | `cmd/blockvolume/process_exit.go` `superviseProcess`, `watchChunkStartup`, `waitWorkspaceStop`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | explicit force; the persisted lease horizon (at least every grant) plus the clock-skew bound and the granted or restart deadline plus the bound have both passed, for the lease the last move issue started (never a predecessor's); blockmaster reads HEAD only after this admission; HEAD is the expected holder's at the expected epoch or any HEAD at an older epoch (the holder never claimed it, or an earlier holder's late claim landed; the lost range starts at that HEAD's remote LSN); a HEAD at the expected or a higher epoch that is not the expected holder's is refused; the lost range (the HEAD's remote LSN, the barrier as LostUntil, the HEAD's generation via the move record and the HEAD entry's filer mtime read with HEAD, or unknown) is written before the reservation. The OSS operator client sends the explicit force only with `--confirm-forced @`; `PreviewWorkspaceMove` runs this admission (HEAD read only once admitted) and writes nothing | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`, `PreviewWorkspaceForcedMove`; `core/authority/workspace_lost_range.go` `recordLostRangeLocked`; `core/host/master/workspace_service.go` `MoveWorkspace`, `PreviewWorkspaceMove`; `core/rpc/wsclient/wsclient.go` `ForceMove` | `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | Moved | epoch issued | the moved owner is captured with the assignment under pub.mu and persisted with the issuing move journal before publication; the stream uses that captured owner, empty when unknown, with placement fallback only for a move-less epoch; a retried request id gets the same epoch; the issue write starts the new holder's lease (horizon issue + 1.5·TTL, granted deadline issue + TTL), published with the epoch in one lease-view section and never lowering a deadline a renewal raised; the new holder is then Granted, and one that dies before its first renewal still expires; the answer to an issued forced move (also a replay) carries its stored lost range, or no range and the reason when that record is missing or fails its checks; a failure after the issue is answered as issued-but-failed (`Internal`, rerun with the same request id), never as a refusal, and the issue is still logged; an issuing write whose durable outcome is unknown is answered as unknown (`Internal`, restart then rerun with the same request id) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `issueWorkspaceMove`, `MoveWorkspace`; `core/authority/assignment_owner.go` `captureAssignmentOwner`; `core/host/master/services.go` `assignmentFact`; `core/host/master/workspace_binding.go` `workspaceLineOwner`; `core/authority/workspace_lease_view.go` `publishIssuedLeaseLocked`; `core/host/master/workspace_service.go` `grantWithLostRange`, `postIssueError` | `INV-AUTH-MOVE-JOURNAL-001`, `INV-LEASE-VIEW-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-LOST-RANGE-FAILCLOSED-001`, `INV-WS-LOST-RANGE-AUDIT-001`, `INV-WS-LOST-RANGE-UNCERTAIN-001` | @@ -714,11 +714,11 @@ Notes: | `INV-WS-FORCED-CONFIRM-LOCAL-001` | A missing or malformed `--confirm-forced` is refused before any connection or RPC, with exit 2. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`; `core/rpc/wsclient/wsclient.go` `ParseConfirmation`, `request` | `TestWorkspaceForceMove_Row1_ConfirmationRefusedLocally` (`cmd/sw-block/workspace_test.go`); `TestParseConfirmation` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-HOLDER-001` | A confirmation at an epoch the master reports no holder for, in its lease or its move journal, is refused without sending a move. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `core/rpc/wsclient/wsclient.go` `holderAt`, `request` | `TestForceMoveResolvesTheHolder` (`core/rpc/wsclient/wsclient_test.go`) | — | ACTIVE | | `INV-WS-FORCED-CONFIRM-NO-BYPASS-001` | No force-move flag bypasses the confirmation, and `--dry-run` is never a confirmation: it sends only a preview, which needs the same confirmation. | M2 lease: Expired → Moved (forced) (the explicit-force guard) | `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `workspacePreview`; `core/rpc/wsclient/wsclient.go` `PreviewForcedMove` | `TestWorkspaceForceMove_Row2_DryRunPreview`, `TestWorkspaceHelpText` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | -| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry, with bounded cleanup; a newer other-replica master fact or an exact foreign HEAD at or above the assigned epoch permits 78. ACKed revocation and signal retain normal exit. Lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | A workspace primary exits 75 on assignment timeout or lease expiry after bounded cleanup. A master fact newer than nonzero observed-own, or an exact foreign HEAD at/above the assigned epoch, permits 78. ACK and signal keep normal exit; lease and claim gates never relax. | M2 restart | `cmd/blockvolume/process_exit.go` `superviseProcess`, `workspaceRetryOutcome`; `core/frontend/durable/provider_chunk.go` `claimHeadSupersedes`; `core/frontend/durable/provider_startup.go` `endChunkStartup` | `TestChunkAssignmentTimeoutExposesCurrentRecoveryOutcome` (`core/frontend/durable/provider_startup_outcome_test.go`); `TestChunkStartupOutcomeRejectsOldGenerationAndCoalescesWake` (`core/frontend/durable/provider_startup_internal_test.go`); `TestWorkspaceDisplacedClaimUsesAssignedEpoch`, `TestWorkspaceRetryUsesNewestOwnAssignment`, `TestWorkspaceForeignHeadClaimChoosesNoRetry`, `TestWorkspaceOldLocalHolderForeignHeadChoosesNoRetry` (`cmd/blockvolume/process_exit_authority_test.go`); `TestWorkspaceExitFirstOutcomeIsLatched`, `TestWorkspaceExitDoesNotWaitForBlockedFrontendClose`, `TestWorkspacePlannedStopKeepsSuccess` (`cmd/blockvolume/process_exit_test.go`) | Existing WorkspaceRegrant restart transition; no new grant rule | ACTIVE | -- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another replica (compared with the latest own assignment, zero before any), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. -- Part T lineage evidence: `recordSelfAssignment` records the newest identity-validated observed-own assignment before local-readiness admission; `EngineProjection` is the adopted-own lineage. Exit compares the former; fencing compares the latter. Both use `IsSuperseded` with explicit lineage; zero lineage selects retry75 and no fence; neither fact grants I/O. `TestWorkspaceExitAndFenceUseNamedLineages` and `TestWorkspaceExitLineageIncludesBlockedOwnAssignment` (`core/host/volume/workspace_startup_test.go`) keep the distinction causal. -- Part T evidence scope: `workspaceRetryOutcome` is the one retry/no-retry decision. Startup `chooseChunkStartupExit` supplies the recovery-generation-bound refused-claim HEAD proof; runtime lease-end supplies none. Both combine that input with the newer other-replica master line; absent proof means retry 75. +- `INV-WS-STARTUP-RETRY-001`: exit 78 is permitted by a NEWER observed master fact for this volume naming another holder (compared with nonzero observed-own assignment; never-assigned zero retries75), or by the exact refused HEAD claim image proving another holder at or above the assigned epoch. The provider binds the latter proof to its recovery generation. Both existing-root checks and claim CAS readback use the same epoch-qualified supersede classifier. A lower-epoch foreign HEAD on an existing root retains the move-back diagnostic; a displaced lower-epoch claim on a fresh root retries 75 without serving. A same-holder higher-epoch HEAD fence retries 75. Unknown/no line, same replica at a higher epoch, and status codes alone mean retry 75. A wrong retry costs a bounded restart loop; a wrong 78 causes an outage until an explicit operator start. Sealed same-epoch recovery remains up for read-only replay after assignment; stale local roots, corrupt WAL and I/O faults retain diagnostic wait. The first chosen outcome wins. Process cleanup reuses `WorkspaceDrainTimeout` (5 s), including a blocked Close; only main exits the process. +- Part T lineage evidence: `recordSelfAssignment` records the newest identity-validated observed-own assignment before local-readiness admission; `EngineProjection` is the adopted-own lineage. Exit compares the former; fencing compares the latter. Both use `IsSuperseded` with explicit lineage; zero lineage selects retry75 and no fence; neither fact grants I/O. `TestWorkspaceExitAndFenceUseNamedLineages`, `TestWorkspaceExitLineageIncludesBlockedOwnAssignment`, and `TestWorkspaceObservedLineageNeverTrailsAdoption` (`core/host/volume/workspace_startup_test.go`) keep the distinction causal. +- Part T evidence scope: `workspaceRetryOutcome` is the one retry/no-retry decision. Startup `chooseChunkStartupExit` supplies the recovery-generation-bound refused-claim HEAD proof; runtime lease-end supplies none. Both combine that input with a foreign master line newer than nonzero observed-own; absent proof means retry 75. - 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. From abff1959767a05ac7ec6149824f7171720f676a0 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:27:33 -0800 Subject: [PATCH 134/204] ci: refuse internal names in a pull request's public text A check on the lines a pull request adds, its commit messages, its title and its description: internal seat names and internal file-share paths are refused, each hit printed with file and line. Runs beside the spec trace check from the base branch; no pull request code is run. Co-Authored-By: Claude Fable 5.2 --- .../.github/scripts/public-text-check-test.sh | 32 +++++++++++++++ .../.github/scripts/public-text-check.sh | 41 +++++++++++++++++++ .../.github/workflows/spec-trace.yml | 6 +++ 3 files changed, 79 insertions(+) create mode 100755 seaweed-block/.github/scripts/public-text-check-test.sh create mode 100755 seaweed-block/.github/scripts/public-text-check.sh diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh new file mode 100755 index 0000000000..a05d393a8f --- /dev/null +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Self-test of public-text-check.sh in a throwaway repository. +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +cd "$t"; git init -q .; git config user.email t@example.invalid; git config user.name t +echo base > a.txt; git add a.txt; git commit -q -m "base" +mb=$(git rev-parse HEAD) +: > title; : > body +run() { bash "$here/public-text-check.sh" "$@" >out 2>&1; } +expect() { # expect RC NAME + local want=$1 name=$2 rc=0 + shift 2 + run "$@" || rc=$? + [ "$rc" = "$want" ] || { echo "public-text-check-test: $name: exit $rc, want $want"; cat out; exit 1; } +} +echo "plain line" >> a.txt; git commit -q -am "add a plain line" +expect 0 "clean change" "$mb" HEAD title body +seat="clau""de06"; path="V:/sha""re/x"; nas="share/rd""ma/y" +echo "// asked by $seat" >> a.txt; git commit -q -am "comment" +expect 1 "seat name in an added line" "$mb" HEAD title body +grep -q "a.txt:3" out || { echo "public-text-check-test: hit does not name file and line"; cat out; exit 1; } +git reset -q --hard HEAD~1 +echo "ok" >> a.txt; git commit -q -am "review by $seat" +expect 1 "seat name in a commit subject" "$mb" HEAD title body +git reset -q --hard HEAD~1 +echo "see $path" > title; expect 1 "share path in the title" "$mb" HEAD title body; : > title +echo "results under $nas" > body; expect 1 "share path in the description" "$mb" HEAD title body; : > body +echo "an old line with $seat" >> a.txt; git commit -q -am "old"; mb2=$(git rev-parse HEAD) +echo "new clean line" >> a.txt; git commit -q -am "new" +expect 0 "an existing line is not this change's" "$mb2" HEAD title body +echo "public-text-check-test: ok" diff --git a/seaweed-block/.github/scripts/public-text-check.sh b/seaweed-block/.github/scripts/public-text-check.sh new file mode 100755 index 0000000000..9400c384f4 --- /dev/null +++ b/seaweed-block/.github/scripts/public-text-check.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Refuses internal names in what a pull request makes public: the lines it +# adds, its commit messages, its title and its description. This repository is +# public; internal seat names and internal file-share paths do not belong in it. +# +# Usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE +# Exit 0: clean. Exit 1: at least one hit (each printed). Exit 2: usage. +# +# The patterns live only here and in this check's own test; both files are +# excluded from the scan of added lines. +set -euo pipefail +[ "$#" -eq 4 ] || { echo "usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE" >&2; exit 2; } +mb=$1; head=$2; title=$3; body=$4 +pat='(claude|codex)0[0-9]|share/rdma|V:[/\]share|diskstation' +out=$(mktemp); trap 'rm -f "$out"' EXIT +report() { # report WHERE < matching lines + local where=$1 line + while IFS= read -r line; do + printf 'public-text: %s: %s +' "$where" "${line:0:160}" >>"$out" + done +} +# Added lines of the diff, with file and line number. +git diff --no-color --no-renames -U0 "$mb" "$head" -- . \ + ':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' | + awk ' + /^\+\+\+ / { f = substr($0, 7); next } + /^@@ / { split($3, a, ","); n = substr(a[1], 2) + 0; next } + /^\+/ { print f ":" n ": " substr($0, 2); n++ } + ' | { grep -E -i -- "$pat" || true; } | report "added line" +# Commit messages (subjects and bodies) of the pull request. +git log --format='%h %s%n%b' "$mb..$head" | { grep -E -i -- "$pat" || true; } | report "commit message" +{ grep -E -i -- "$pat" "$title" || true; } | report "title" +{ grep -E -i -- "$pat" "$body" || true; } | report "description" +hits=$(wc -l <"$out" | tr -d ' ') +if [ "$hits" -gt 0 ]; then + cat "$out" + echo "public-text: $hits hit(s). Say what the code or test does instead of who asked for it; keep internal paths out." >&2 + exit 1 +fi +echo "public-text: clean" diff --git a/seaweed-block/.github/workflows/spec-trace.yml b/seaweed-block/.github/workflows/spec-trace.yml index 2e09b1c3cb..7bd9bdaa40 100644 --- a/seaweed-block/.github/workflows/spec-trace.yml +++ b/seaweed-block/.github/workflows/spec-trace.yml @@ -43,6 +43,7 @@ jobs: HEAD: ${{ github.event.pull_request.head.sha }} PR: ${{ github.event.pull_request.number }} BODY: ${{ github.event.pull_request.body }} + TITLE: ${{ github.event.pull_request.title }} run: | set -euo pipefail bash .github/scripts/spec-trace-check-test.sh @@ -60,3 +61,8 @@ jobs: done mkdir -p blobs bash .github/scripts/spec-trace-check.sh body.txt blobs title.txt + bash .github/scripts/public-text-check.sh "$mb" "$HEAD" title.txt body.txt From 5e7728e65a77e685fbd91bd2f1f7ab56ee4388a1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:28:48 -0800 Subject: [PATCH 135/204] docs: keep model results and identity comments public-facing --- .../core/csi/primary_owned_frontend_test.go | 4 +- .../host/master/server_host_identity_test.go | 10 ++-- .../core/host/master/workspace_service.go | 2 +- .../host/volume/assignment_holder_test.go | 2 +- seaweed-block/docs/spec/README.md | 6 +-- .../WorkspaceRegrant-owner-label-results.md | 52 ++++++------------- 6 files changed, 28 insertions(+), 48 deletions(-) diff --git a/seaweed-block/core/csi/primary_owned_frontend_test.go b/seaweed-block/core/csi/primary_owned_frontend_test.go index e7aafe59fe..4edf5713d3 100644 --- a/seaweed-block/core/csi/primary_owned_frontend_test.go +++ b/seaweed-block/core/csi/primary_owned_frontend_test.go @@ -33,7 +33,7 @@ func TestPublishTargetIsPrimaryOwned(t *testing.T) { if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.Multipath || got.IQN != "iqn.v1" { t.Fatalf("foreign target: %+v ok=%v, want only the primary's", got, ok) } - // iSCSI paths match on IQN AND LUN (codex01): a supporting q/LUN2 is another target, never a path to the primary's q/LUN1 + // iSCSI paths match on both IQN and LUN: a supporting q/LUN2 is another target, not a path to the primary's q/LUN1. lun := func(replica, addr string, n uint32) *control.FrontendTarget { return &control.FrontendTarget{Protocol: string(ProtocolISCSI), Addr: addr, Iqn: "iqn.q", Lun: n, ReplicaId: replica} } @@ -46,7 +46,7 @@ func TestPublishTargetIsPrimaryOwned(t *testing.T) { t.Fatalf("nonzero LUN match: %+v ok=%v, want multipath primary-first at LUN 1", got, ok) } // two PRIMARY-owned units of one IQN (q/LUN1 at A, q/LUN2 at B) are two targets, never one multipath target with - // LUN1 for both (codex01: the final grouping binds IQN and LUN too) + // LUN1 for both: the final grouping also binds IQN and LUN. got, ok = publishTargetFromStatus(status(lun("r1", "192.0.2.1:3260", 1), lun("r1", "192.0.2.2:3260", 2)), true, false) if !ok || got.ISCSIAddr != "192.0.2.1:3260" || got.LUN != 1 || got.Multipath || len(got.ISCSIAddrs) != 0 { t.Fatalf("two primary units: %+v ok=%v, want q/LUN1 at 192.0.2.1 alone (no multipath with LUN2's path)", got, ok) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index d9a720c59e..645103f1a2 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -115,7 +115,7 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) { } } } - // the whole primary row is the issued holder (codex01 P2): never placement's node-b carrying node-a's frontend + // The whole primary row names the issued holder, never placement's node-b carrying node-a's frontend. if vol == nil || vol.node != "node-a" || vol.target != "127.0.0.1:3260" || vol.rowServer != "node-a" || vol.rowNode != "node-a" || vol.rowFrontend != "127.0.0.1:3260" { t.Fatalf("displayed primary %+v, want node-a at 127.0.0.1:3260 in the volume and its primary row (the issued holder, not the placement slot or the old host)", vol) } @@ -296,7 +296,7 @@ func registerWorkspaceHolder(t *testing.T, h *Host, server string) { } } -// codex01 P1: a CSI client takes the first frontend as the primary. When the primary's evidence (from the line's server) +// A CSI client takes the first frontend as the primary. When the primary's evidence (from the line's server) // is missing, the status lists NO frontend, even though supporting replicas report theirs; without the rule a // supporting replica's frontend would be published under the primary identity. func TestStatusListsNoFrontendWhenThePrimaryEvidenceIsMissing(t *testing.T) { @@ -329,7 +329,7 @@ func (e inProcEvidence) QueryVolumeStatus(ctx context.Context, in *control.Statu return e.s.QueryVolumeStatus(ctx, in) } -// codex01 #416 P1-2: through the real CSI ControlStatusLookup, with supporting replicas reporting usable frontends, no +// Through the real CSI ControlStatusLookup, with supporting replicas reporting usable frontends, no // target is published when the primary's slot (on the line's server) exists but carries no frontend, or when its only // frontend is one CSI rejects (loopback, with loopback targets rejected). Control: the same lookup without the loopback // rejection publishes the primary's own frontend. @@ -374,7 +374,7 @@ func TestCSIPublishesNoTargetWhenThePrimaryFrontendIsMissingOrRejected(t *testin } } -// codex01 #416 P2: a workspace volume being deleted is still a workspace volume: its assignment stream keeps the holder +// A workspace volume being deleted is still a workspace volume: its assignment stream keeps the holder // host check (a deletion reservation must not open a bypass). func TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck(t *testing.T) { r := newIsolationRig(t, false, t.TempDir(), t.TempDir()) @@ -398,7 +398,7 @@ func TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck(t *testing.T) { } } -// codex01 #416 P2 (INV-WS-RENEW-NONBLOCKING-001): a LIVE lease renewal through holderMatches, whose host check reads the +// INV-WS-RENEW-NONBLOCKING-001: a live lease renewal through holderMatches, whose host check reads the // node registry, completes while a registration write is held (the store mutex RegisterNode keeps across file I/O). The // hold is proven real: a concurrent RegisterNode does not finish until it is released. func TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite(t *testing.T) { diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 7c72a96438..2a84382c6a 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -56,7 +56,7 @@ func (s *services) workspaceVolumeForRenewal(volume string) error { // isWorkspaceVolume reports whether volume is a workspace volume (workspace RPC on, an existing RF1 volume), from the // lock-free lifecycle snapshot. Unlike workspaceVolumeForRenewal it ignores a deletion reservation: a volume being -// deleted is still a workspace volume, and its assignment stream keeps the holder host check (codex01 #416 P2). +// deleted is still a workspace volume, and its assignment stream keeps the holder host check. func (s *services) isWorkspaceVolume(volume string) bool { if !s.host.cfg.WorkspaceRPC || s.host.lifecycle == nil { return false diff --git a/seaweed-block/core/host/volume/assignment_holder_test.go b/seaweed-block/core/host/volume/assignment_holder_test.go index bb6ad8d4ad..d9f462bf22 100644 --- a/seaweed-block/core/host/volume/assignment_holder_test.go +++ b/seaweed-block/core/host/volume/assignment_holder_test.go @@ -110,7 +110,7 @@ func TestAssignmentHolderIdentityFencesPreviouslyHealthySameReplica(t *testing.T } } -// Endpoints are routing data, not the holder identity (claude06 ruling). +// INV-AUTH-HOLDER-IDENTITY-001: endpoint differences warn without refusing the matching holder. func TestAssignmentHolderIdentityAdoptsAndWarnsCarriedEndpointMismatch(t *testing.T) { for _, endpoint := range []string{"data", "control"} { t.Run(endpoint, func(t *testing.T) { diff --git a/seaweed-block/docs/spec/README.md b/seaweed-block/docs/spec/README.md index 4e8c11070a..6be254496d 100644 --- a/seaweed-block/docs/spec/README.md +++ b/seaweed-block/docs/spec/README.md @@ -105,9 +105,9 @@ Each `.cfg` names its spec on its first line. ## Owner-label simulation results -[Workspace owner-label round 4: source pins and results](WorkspaceRegrant-owner-label-results.md) -is **SIMULATION ONLY** (3 seeds x 20,000 traces, depth 120); exhaustive round 4 -`combo10` is **PENDING**. Counterexample lengths are counts of states, including +[Workspace owner-label simulation results](WorkspaceRegrant-owner-label-results.md) +is **SIMULATION ONLY** (3 seeds x 20,000 traces, depth 120); exhaustive checking +is **PENDING**. Counterexample lengths are counts of states, including the initial state, not trace identifiers. These results are separate from the exhausted bounds below. diff --git a/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md index 985b5d69c1..60975bbe86 100644 --- a/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md +++ b/seaweed-block/docs/spec/WorkspaceRegrant-owner-label-results.md @@ -1,49 +1,29 @@ -# Workspace owner-label model: round 4 pins +# Workspace owner-label simulation results -This is a citation of claude06's external model and its reported simulations, -not an exhaustive public-spec result. Source bundle: -`V:/share/rdma/claude06-sw-tla-regrant-r0-20261122/`. +An assignment carries the owner of its published line. Reconstructing that +owner from a later store read can label a line with a different server when +the store view lags. An unknown moved owner remains empty, so the volume +refuses adoption; only a move-less line can use placement as its owner. -`WorkspaceRegrant.tla` round 4 maps `StreamLabelFromStore = FALSE` to -`Publisher.captureAssignmentOwner` -> immutable `AssignmentInfo` -> -`services.assignmentFact` -> `Host.workspaceLineOwner`. The lease view derives -the same owner metadata (`INV-LEASE-VIEW-001`). A moved unknown owner is empty; -only a move-less line falls back to placement (`INV-AUTH-HOLDER-IDENTITY-001`). -The TRUE switch injects a send-time owner store that can lag. This is a model -fault schedule, not evidence of a reachable pre-issued publication in current -Go code; the real P5 trace showed the old host refusing both foreign facts. +`NoForeignAdoption` checks that a process does not adopt another server's line. +`TargetNotFencedByOwnLine` checks that a target is not fenced by its own line +because its owner label was reconstructed incorrectly. ## Results and limits -Status: **SIMULATION ONLY**. `summary-r4.tsv` reports 3 seeds x 20,000 traces, -depth 120. Counterexample lengths below count states, including the initial -state; they are not trace identifiers. The exact configurations are: +Status: **SIMULATION ONLY**. The reported search used 3 seeds x 20,000 traces, +depth 120. Counterexample lengths count states, including the initial state; +they are not trace identifiers. | Configuration | Reported result | |---|---| | `WR_id4_fix_label.cfg` | No violation in the simulations | | `WR_id4_fix_label_ownline.cfg` | No violation in the simulations | | `WR_id4_RED_label.cfg` | `NoForeignAdoption` violated; counterexamples contain 14, 17, 15 states | -| `WR_id4_RED_label_safety.cfg` | No safety-invariant violation in the simulations; lease layer stops the adopter | +| `WR_id4_RED_label_safety.cfg` | No safety-invariant violation in the simulations; lease validation stops the adopter | | `WR_id4_fix_label_volguard.cfg` | `NoForeignAdoption` still violated; counterexamples contain 14, 17, 15 states; a fresh process has no recorded foreign line | -The result interpretation is in `REGRANT-REPORT.md`, "Round 4: adoption fence". -A simulation finding is a counterexample; no sampled violation does not prove -an invariant. Exhaustive round 4 is **PENDING** in claude06's next Azure slot, -bundle `combo10`, results expected under -`V:/share/rdma/claude06-tlc-azure-results-20261120/tlc-combo10-*`. -Date depends on the open budget decision. No exhaustive state count or GO claim -is made here. This pending model is not added to the Exhausted bounds table. - -## Exact source pins - -| Artifact (relative to source bundle) | SHA-256 | -|---|---| -| `WorkspaceRegrant.tla` | `d92922331afa2bb127d4f29b9d6fc266354c30b8d11a9a0bd3931e67d2c27d1c` | -| `cfg/WR_id4_fix_label.cfg` | `d716ed5a9d4fce039e2dda084901c789f85f5a44e03d2db28d30a17312ad199f` | -| `cfg/WR_id4_fix_label_ownline.cfg` | `49188ae6776114c9c4358bac0e0dbf8187622feba25a69c1aaf97ed0da8bcdc1` | -| `cfg/WR_id4_RED_label.cfg` | `d22cf52f84bc6b2eed4f0696e4f84285daba2fe5ad0111bbae3358da7a3d1d50` | -| `cfg/WR_id4_RED_label_safety.cfg` | `ca1b0b66fdeb4fef31d43a5efb4e3bb5ef501270f1a6441c8250fb084d4f0e69` | -| `cfg/WR_id4_fix_label_volguard.cfg` | `86fad07c3a9e321ea5dd52a1e4b104c61bdc34a3ce08b4bc123d9b2d97e47f65` | -| `summary-r4.tsv` | `4ca8155ff7c3922d5ff6b0880c41ef59ef13169cc1af9cc630f7fd06256cdbd3` | -| `REGRANT-REPORT.md` | `eab94a6d2e5d81ad9318cb56a90b77958b1a73719258c9500cf71f9c95fc286a` | +A counterexample demonstrates a failure in the model. No sampled violation +does not prove an invariant. Exhaustive checking is **PENDING**; no exhaustive +state count or safety proof is claimed. These results are separate from the +Exhausted bounds table. From 4a517ed9aef2ad9faeb150fb497070d1faa62402 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:29:14 -0800 Subject: [PATCH 136/204] test: qualify supervised target started before its clean move --- .../startup_systemd_integration_test.go | 153 +++++++++++++----- 1 file changed, 111 insertions(+), 42 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 8c5cb64012..f2c954c029 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -9,6 +9,7 @@ import ( "encoding/json" "fmt" "io" + "net" "net/http" "os" "os/exec" @@ -66,14 +67,15 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { volume := stem base := "/" + stem masterAddr := leaseBinaryAddress(t) + target, masterListen := gap1TargetAddresses(t, masterAddr) dataAddr, ctrlAddr, statusAddr, nvmeAddr := leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t), leaseBinaryAddress(t) - cfg := fmt.Sprintf("nodes:\n - server_id: s1\n data_addr: %s\n ctrl_addr: %s\nvolumes:\n - id: %s\n size_bytes: 262144\n replication_factor: 1\n placements:\n - server_id: s1\n replica_id: r1\n source: existing_replica\n", dataAddr, ctrlAddr, volume) + cfg := fmt.Sprintf("nodes:\n - server_id: s1\n data_addr: %s\n ctrl_addr: %s\n - server_id: s2\n data_addr: %s\n ctrl_addr: %s\nvolumes:\n - id: %s\n size_bytes: 262144\n replication_factor: 1\n placements:\n - server_id: s1\n replica_id: r1\n source: existing_replica\n", dataAddr, ctrlAddr, target.dataAddr, target.ctrlAddr, volume) spec := filepath.Join(root, "cluster.yaml") if err := os.WriteFile(spec, []byte(cfg), 0600); err != nil { t.Fatal(err) } fixture.start(t, stem+"-master", false, filepath.Join(bin, "blockmaster"), - "--listen", masterAddr, "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), + "--listen", masterListen, "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), "--cluster-spec", spec, "--lifecycle-product-loop-interval", "200ms", "--expected-slots-per-volume", "1", "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+base) w4WaitTCP(t, masterAddr, 20*time.Second) @@ -191,7 +193,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { t.Fatalf("systemd rate limit hit: %+v", s) } gap1PlannedStopDoesNotRestart(t, ws, unit, statusAddr, volume, after.Epoch, "r1", s["NRestarts"], s["InvocationID"]) - gap1NeverAssignedRetries(t, fixture, stem, filepath.Join(bin, "blockvolume"), args, root, volume) + gap1PrestartedTargetServesAfterMove(t, fixture, ws, remote, target, stem, filepath.Join(bin, "blockvolume"), args, root, volume, want) } // Roots are deliberately independent of testing.TempDir: unknown unit cleanup @@ -499,74 +501,141 @@ func gap1PlannedStopDoesNotRestart(t *testing.T, ws control.WorkspaceServiceClie }) } -// The master keeps the real r1 authority line. A fresh r-old process has -// zero observed-own lineage, so a foreign fact selects retry75, never78. -// Run after the live holder has ACKed and exited, avoiding a node registration -// change while that holder is serving. This is not a superseded-holder witness. -func gap1NeverAssignedRetries(t *testing.T, fixture *gap1Fixture, stem, exe string, args []string, root, volume string) { +// The host-consistency check uses the actual gRPC peer address. Model two +// registered hosts with loopback and a real non-loopback local IPv4 address; +// the target dials the master over that second address. Both processes and +// every restart still run under the same real WSL systemd (not two machines). +type gap1Target struct { + masterAddr, dataAddr, ctrlAddr string +} + +func gap1TargetAddresses(t *testing.T, masterAddr string) (gap1Target, string) { + t.Helper() + _, port, err := net.SplitHostPort(masterAddr) + if err != nil { + t.Fatal(err) + } + interfaces, err := net.Interfaces() + if err != nil { + t.Fatal(err) + } + for _, iface := range interfaces { + if iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 { + continue + } + addresses, err := iface.Addrs() + if err != nil { + t.Fatal(err) + } + for _, address := range addresses { + ip, _, err := net.ParseCIDR(address.String()) + if err != nil || ip.To4() == nil || ip.IsLoopback() || ip.IsLinkLocalUnicast() { + continue + } + allocate := func() string { + ln, err := net.Listen("tcp", net.JoinHostPort(ip.String(), "0")) + if err != nil { + t.Fatal(err) + } + addr := ln.Addr().String() + if err := ln.Close(); err != nil { + t.Fatal(err) + } + return addr + } + return gap1Target{net.JoinHostPort(ip.String(), port), allocate(), allocate()}, net.JoinHostPort("0.0.0.0", port) + } + } + t.Fatal("qualification requires a real non-loopback IPv4 address; no skip is proof") + return gap1Target{}, "" +} + +// Start the future target before a clean move is issued. It has the same +// logical r1 slot but a different server id, and no own lineage: the source +// line cannot mean it lost anything. Prove75 and automatic restart, then issue +// a real MoveWorkspace and prove lease/HEAD/data admission without touching +// the target unit again. This is not a positive78/no-restart witness. +func gap1PrestartedTargetServesAfterMove(t *testing.T, fixture *gap1Fixture, ws control.WorkspaceServiceClient, remote storage.ChunkRemote, target gap1Target, stem, exe string, args []string, root, volume string, want []byte) { t.Helper() changed := append([]string(nil), args...) - addr := leaseBinaryAddress(t) - replacements := map[string]string{"--replica-id": "r-old", "--data-addr": leaseBinaryAddress(t), "--ctrl-addr": leaseBinaryAddress(t), "--status-addr": addr, "--durable-root": filepath.Join(root, "superseded-store"), "--nvme-listen": leaseBinaryAddress(t), "--nvme-subsysnqn": "nqn.2026-11.test:" + stem + "-superseded"} + addr, nvmeAddr := leaseBinaryAddress(t), leaseBinaryAddress(t) + nqn := "nqn.2026-11.test:" + stem + "-prestarted-target" + replacements := map[string]string{"--master": target.masterAddr, "--server-id": "s2", "--data-addr": target.dataAddr, "--ctrl-addr": target.ctrlAddr, "--status-addr": addr, "--durable-root": filepath.Join(root, "target-store"), "--nvme-listen": nvmeAddr, "--nvme-subsysnqn": nqn} for i := 0; i+1 < len(changed); i++ { if value, ok := replacements[changed[i]]; ok { changed[i+1] = value } } - unit := stem + "-superseded" + unit := stem + "-prestarted-target" fixture.start(t, unit, true, exe, changed...) - waitGAP1(t, "superseded process never observed the master's other-replica fact", 15*time.Second, func() bool { - resp, err := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status?volume=" + volume) - if err != nil { + waitGAP1(t, "target never observed the source holder before the move", 15*time.Second, func() bool { + status, body, err := gap1Status(addr, volume) + if err != nil || status != http.StatusOK { return false } - defer resp.Body.Close() - raw, err := io.ReadAll(resp.Body) - if err != nil { - return false - } - t.Logf("captured real supersede status: status%d body%s", resp.StatusCode, raw) - if resp.StatusCode != http.StatusOK { - return false - } - var status hostvolume.StatusProjection - if err := json.Unmarshal(raw, &status); err != nil { + var projection hostvolume.StatusProjection + if err := json.Unmarshal(body, &projection); err != nil { t.Fatal(err) } - if status.Healthy || status.FrontendPrimaryReady { - t.Fatalf("unassigned old identity served: %+v", status) + if projection.Healthy || projection.FrontendPrimaryReady { + t.Fatalf("future target served before the move: %s", body) } - // A never-assigned replica remains ModeIdle, so /status intentionally - // reports unknown even after recording the other-replica fact. Prove - // receipt in this process before checking its retry75 decision. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - journal, err := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=cat").CombinedOutput() + cmd := exec.CommandContext(ctx, "journalctl", "--unit="+unit, "--no-pager", "--output=cat") + cmd.WaitDelay = time.Second + journal, err := cmd.CombinedOutput() if err != nil { - t.Fatalf("supersede journal: %v %s", err, journal) + t.Fatalf("target journal: %v %s", err, journal) } - observed := fmt.Sprintf("volume %s authority is now r1@1 (not this replica r-old); recording supersede", volume) - if strings.Contains(string(journal), observed) { - t.Logf("captured authoritative other-replica observation: %s", observed) - return true - } - return false + observed := fmt.Sprintf("assignment identity refusal volume=%q replica=%q server=%q", volume, "r1", "s1") + return strings.Contains(string(journal), observed) }) - waitGAP1(t, "never-assigned foreign identity did not exit75", 45*time.Second, func() bool { + waitGAP1(t, "prestarted target did not exit75 before the move", 45*time.Second, func() bool { s := gap1Unit(t, unit) if s["ExecMainStatus"] == "78" { - t.Fatalf("zero-lineage process chose no-retry: %+v", s) + t.Fatalf("zero-lineage target chose no-retry before its move: %+v", s) } return s["ExecMainStatus"] == "75" }) - waitGAP1(t, "never-assigned retry75 did not restart", 15*time.Second, func() bool { + waitGAP1(t, "prestarted target retry75 did not restart", 15*time.Second, func() bool { s := gap1Unit(t, unit) n, err := strconv.Atoi(s["NRestarts"]) if err != nil || n > 2 { - t.Fatalf("invalid or unbounded restart count: %+v", s) + t.Fatalf("invalid or unbounded target restart count: %+v", s) } return n >= 1 && s["MainPID"] != "0" }) + sealed, err := gap1ReadHead(t, remote) + if err != nil || sealed.State != storage.ChunkHeadDetached || sealed.Holder != "s1/r1" || sealed.Gen == 0 { + t.Fatalf("move source not sealed by its exact holder: %+v %v", sealed, err) + } + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + grant, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: stem + "-target-move", VolumeId: volume, ExpectedReplicaId: "r1", ExpectedEpoch: sealed.Epoch, TargetReplicaId: "r1", TargetServerId: "s2", TargetDataAddr: target.dataAddr, TargetCtrlAddr: target.ctrlAddr, Kind: "clean"}) + cancel() + if err != nil || !grant.GetIssued() || grant.GetNewEpoch() <= sealed.Epoch || grant.GetOldHost() != "s1" || grant.GetNewHost() != "s2" || grant.GetHeadGen() != sealed.Gen { + t.Fatalf("real clean move failed: grant=%v err=%v", grant, err) + } + t.Logf("prestarted target move issued after its automatic restart: %s", grant) + waitGAP1(t, "automatically restarted target did not serve after the move", 60*time.Second, func() bool { + s := gap1Unit(t, unit) + n, err := strconv.Atoi(s["NRestarts"]) + if err != nil || n < 1 || n > 2 || s["Result"] == "start-limit-hit" { + t.Fatalf("target restart bound violated after move: %+v", s) + } + return gap1Operational(t, addr, volume) + }) + head, err := gap1ReadHead(t, remote) + if err != nil || head.Gen <= sealed.Gen || head.Epoch != grant.NewEpoch || head.Holder != "s2/r1" || head.State != storage.ChunkHeadActive { + t.Fatalf("target did not claim its issued HEAD: %+v %v", head, err) + } + client := gap1ConnectNVMe(t, nvmeAddr, nqn) + client.readExact(t, 8, want) + client.readExact(t, 9, want) + client.writeFlush(t, 10, want) + client.readExact(t, 10, want) + client.close() + t.Logf("prestarted target served after a real clean move without operator restart: unit=%s HEAD=%+v", unit, head) } // Register before the units: their exact-unit cleanup runs first, then this From eba1949fb182a9a8b33be45f2c1ec4d3aaa49a88 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:32:48 -0800 Subject: [PATCH 137/204] ci: public-text check: header-like added lines, backslash paths, unreadable inputs An added line that begins with '++ ' is an added line, not a diff header; the share path is matched with either slash; a missing title or description file, an unknown commit or a failing grep is an error (exit 2), never 'clean'. Controls for each in the self-test; each fails on the previous script. Co-Authored-By: Claude Fable 5.2 --- .../.github/scripts/public-text-check-test.sh | 12 ++++++++++ .../.github/scripts/public-text-check.sh | 24 ++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh index a05d393a8f..964c440636 100755 --- a/seaweed-block/.github/scripts/public-text-check-test.sh +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -29,4 +29,16 @@ echo "results under $nas" > body; expect 1 "share path in the description" "$mb" echo "an old line with $seat" >> a.txt; git commit -q -am "old"; mb2=$(git rev-parse HEAD) echo "new clean line" >> a.txt; git commit -q -am "new" expect 0 "an existing line is not this change's" "$mb2" HEAD title body +# A file line that begins with "++ " shows in the diff as "+++ ...": an added line, not a header. +printf '%s +' "++ $seat" >> a.txt; git commit -q -am "plus line" +expect 1 "an added line that looks like a diff header" "$mb2" HEAD title body +git reset -q --hard HEAD~1 +bs=$(printf '\') +printf '%s +' "${bs}${bs}nas${bs}sha""re${bs}rd""ma${bs}z" > title +expect 1 "backslash form of the share path in the title" "$mb2" HEAD title body; : > title +expect 2 "a missing title file is an error, not clean" "$mb2" HEAD no-such-title body +expect 2 "a missing description file is an error, not clean" "$mb2" HEAD title no-such-body +expect 2 "an unknown commit is an error, not clean" 0000000000000000000000000000000000000000 HEAD title body echo "public-text-check-test: ok" diff --git a/seaweed-block/.github/scripts/public-text-check.sh b/seaweed-block/.github/scripts/public-text-check.sh index 9400c384f4..3146d095c5 100755 --- a/seaweed-block/.github/scripts/public-text-check.sh +++ b/seaweed-block/.github/scripts/public-text-check.sh @@ -11,7 +11,14 @@ set -euo pipefail [ "$#" -eq 4 ] || { echo "usage: public-text-check.sh MERGE_BASE HEAD TITLE_FILE BODY_FILE" >&2; exit 2; } mb=$1; head=$2; title=$3; body=$4 -pat='(claude|codex)0[0-9]|share/rdma|V:[/\]share|diskstation' +for f in "$title" "$body"; do + [ -f "$f" ] && [ -r "$f" ] || { echo "public-text: cannot read $f" >&2; exit 2; } +done +git rev-parse -q --verify "$mb^{commit}" >/dev/null && git rev-parse -q --verify "$head^{commit}" >/dev/null || + { echo "public-text: unknown commit $mb or $head" >&2; exit 2; } +# match: a grep error fails the check instead of reading as "no hit". +match() { local rc=0; grep -E -i -- "$pat" "$@" || rc=$?; [ "$rc" -le 1 ] || { echo "public-text: grep failed ($rc)" >&2; exit 2; }; } +pat='(claude|codex)0[0-9]|share[/\]rdma|V:[/\]share|diskstation' out=$(mktemp); trap 'rm -f "$out"' EXIT report() { # report WHERE < matching lines local where=$1 line @@ -24,14 +31,15 @@ report() { # report WHERE < matching lines git diff --no-color --no-renames -U0 "$mb" "$head" -- . \ ':(exclude).github/scripts/public-text-check.sh' ':(exclude).github/scripts/public-text-check-test.sh' | awk ' - /^\+\+\+ / { f = substr($0, 7); next } - /^@@ / { split($3, a, ","); n = substr(a[1], 2) + 0; next } - /^\+/ { print f ":" n ": " substr($0, 2); n++ } - ' | { grep -E -i -- "$pat" || true; } | report "added line" + /^diff --git / { hdr = 1; next } + hdr && /^\+\+\+ / { f = substr($0, 7); next } + /^@@ / { hdr = 0; split($3, a, ","); n = substr(a[1], 2) + 0; next } + !hdr && /^\+/ { print f ":" n ": " substr($0, 2); n++ } + ' | match | report "added line" # Commit messages (subjects and bodies) of the pull request. -git log --format='%h %s%n%b' "$mb..$head" | { grep -E -i -- "$pat" || true; } | report "commit message" -{ grep -E -i -- "$pat" "$title" || true; } | report "title" -{ grep -E -i -- "$pat" "$body" || true; } | report "description" +git log --format='%h %s%n%b' "$mb..$head" | match | report "commit message" +match "$title" | report "title" +match "$body" | report "description" hits=$(wc -l <"$out" | tr -d ' ') if [ "$hits" -gt 0 ]; then cat "$out" From 83751bbaef203a3ba27a2a15cc39eacdf957b762 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:33:38 -0800 Subject: [PATCH 138/204] fix: preserve permanent causes across joined backend errors --- seaweed-block/core/frontend/error_class.go | 28 +++++++++++++++++++ .../iscsi/backend_error_class_test.go | 8 ++++++ .../frontend/nvme/backend_error_class_test.go | 9 +++++- seaweed-block/docs/design/invariants.md | 5 ++-- 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go index fe1062c6e8..2fedcc060a 100644 --- a/seaweed-block/core/frontend/error_class.go +++ b/seaweed-block/core/frontend/error_class.go @@ -20,6 +20,11 @@ const ( // Call only for a non-nil backend error. A pure expired command deadline is // transient; a joined physical cause keeps its permanent classification. func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { + // M1 I/O error completion: every cause must be transient before any + // sentinel can select retry status (INV-FE-ERROR-RETRY-CLASS-001). + if !backendCausesKnown(ctx, err) { + return BackendErrorPermanent + } switch { case IsWriteDeadline(ctx, err): return BackendErrorNotReady @@ -35,3 +40,26 @@ func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { return BackendErrorPermanent } } + +// Inspect children before matching sentinels: errors.Is on a joined error can +// match one transient branch while another branch carries a permanent fault. +func backendCausesKnown(ctx context.Context, err error) bool { + if joined, ok := err.(interface{ Unwrap() []error }); ok { + causes := joined.Unwrap() + if len(causes) == 0 { + return false + } + for _, cause := range causes { + if !backendCausesKnown(ctx, cause) { + return false + } + } + return true + } + if cause := errors.Unwrap(err); cause != nil { + return backendCausesKnown(ctx, cause) + } + return errors.Is(err, ErrBackendBusy) || errors.Is(err, ErrStalePrimary) || + errors.Is(err, ErrBackendClosed) || errors.Is(err, ErrNotReady) || + (ctx.Err() == context.DeadlineExceeded && err == context.DeadlineExceeded) +} diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go index 1df2506638..3bbff22607 100644 --- a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -38,6 +38,14 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { {name: "permanent", err: errors.New("media read failure"), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "deadline", err: context.DeadlineExceeded, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82, deadline: true}, {name: "deadline-and-physical", err: errors.Join(context.DeadlineExceeded, errors.New("media sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-and-busy", err: errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy), status: 0x08, sct: 0, sc: 0x82, deadline: true}, + {name: "deadline-busy-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, errors.New("physical sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-busy-physical-first", err: errors.Join(errors.New("physical sync failure"), frontend.ErrBackendBusy, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-busy-nested-physical", err: errors.Join(frontend.ErrBackendBusy, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, errors.New("physical sync failure")))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-and-not-ready", err: errors.Join(context.DeadlineExceeded, frontend.ErrNotReady), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82, deadline: true}, + {name: "deadline-not-ready-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, errors.New("physical sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-not-ready-physical-first", err: errors.Join(errors.New("physical sync failure"), frontend.ErrNotReady, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-not-ready-nested-physical", err: errors.Join(frontend.ErrNotReady, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, errors.New("physical sync failure")))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, } { for _, op := range []string{"read", "write", "sync"} { t.Run(tc.name+"/"+op, func(t *testing.T) { diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go index c1102796b7..541e9f46af 100644 --- a/seaweed-block/core/frontend/nvme/backend_error_class_test.go +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -6,6 +6,7 @@ import ( "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" "testing" + "time" ) type retryClassBackend struct { @@ -27,11 +28,17 @@ func TestBackendRetryClassClearsWireDNR(t *testing.T) { {"not-ready", frontend.ErrNotReady, false}, {"busy", frontend.ErrBackendBusy, false}, {"permanent", errors.New("physical media fault"), true}, + {"deadline-busy", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy), false}, + {"deadline-not-ready", errors.Join(context.DeadlineExceeded, frontend.ErrNotReady), false}, + {"deadline-busy-physical", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, errors.New("physical sync failure")), true}, + {"deadline-not-ready-physical", errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, errors.New("physical sync failure")), true}, } { for _, op := range []uint8{ioRead, ioWrite, ioFlush} { t.Run(tc.name+string(rune('0'+op)), func(t *testing.T) { h := NewIOHandler(HandlerConfig{Backend: retryClassBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: tc.err}}) - result := h.Handle(context.Background(), IOCommand{Opcode: op, NSID: 1, NLB: 1, Data: make([]byte, 512)}) + ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-time.Second)) + defer cancel() + result := h.Handle(ctx, IOCommand{Opcode: op, NSID: 1, NLB: 1, Data: make([]byte, 512)}) if dnr := result.completionStatus()&(1<<15) != 0; dnr != tc.dnr { t.Fatalf("DNR=%t want %t, result=%+v", dnr, tc.dnr, result) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 724b2f1566..be7b15a7b9 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -381,8 +381,9 @@ snapshot lifetime; local persistence does not bypass it. deadlines map to SCSI NOT READY04/01 or NVMe NamespaceNotReady/DNR0; local busy maps to SCSI BUSY or NVMe NamespaceNotReady/DNR0. Stale lineage and closed preserve their distinct path-status meanings. - Permanent errors retain terminal protocol mapping, including a deadline - joined with a physical error. Read, write and sync use the same classifier; + Every leaf of a wrapped or joined error is checked before selecting a + retry class: any physical or unknown cause retains terminal mapping, even + alongside a deadline and busy/not-ready sentinel. Read, write and sync use the same classifier; no storage/authority state changes on this mapping. - A flusher cycle sorts native snapshot entries by record offset and reuses at most one fully validated record (bounded by WALSize). Every block still checks From 0a01e8156ca9487ece3bda6b146bb77f7ffe073b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:34:01 -0800 Subject: [PATCH 139/204] test: use neutral startup qualification names --- seaweed-block/cmd/blockvolume/process_exit.go | 2 +- .../blockvolume/startup_systemd_integration_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index f1f5925e3b..88c03b0c0c 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -62,7 +62,7 @@ func (e *processExit) choose(out workspaceExit) { if e.parent.Err() != nil { out = workspaceExit{reason: "signal"} } - e.decision <- out // exactly one send; the sole slot cannot block under a provider lock + e.decision <- out // exactly one send fits the buffer without blocking under a provider lock close(e.done) }) } diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index f2c954c029..41e2cc901c 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -31,10 +31,10 @@ import ( // The first assertion is RED on GAP-1: the expired startup stays alive. func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if os.Getenv("GAP1_SYSTEMD_AUTHORIZED") != "1" { - t.Fatal("explicit booked WSL systemd qualification required; no skip counts as proof") + t.Fatal("explicit real-systemd qualification authorization required; no skip counts as proof") } if os.Geteuid() != 0 { - t.Fatal("systemd qualification needs the booked root harness") + t.Fatal("systemd qualification needs root") } if os.Getenv("CHUNKSTORE_WEED") == "" { t.Fatal("real CHUNKSTORE_WEED binary required") @@ -62,7 +62,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { } cluster := startWorkspaceWeedAt(t, filepath.Join(root, "weed")) gap1PreserveFailure(t, root, cluster.dir) - stem := fmt.Sprintf("codex03-gap1-%d", time.Now().UnixNano()) + stem := fmt.Sprintf("gap1-%d", time.Now().UnixNano()) gap1ProbeTerminalSuccess(t, fixture, stem+"-policy-probe") volume := stem base := "/" + stem @@ -205,7 +205,7 @@ type gap1Fixture struct { func newGAP1Fixture(t *testing.T) *gap1Fixture { t.Helper() - root, err := os.MkdirTemp("", "codex03-gap1-runtime-") + root, err := os.MkdirTemp("", "gap1-runtime-") if err != nil { t.Fatal(err) } @@ -551,7 +551,7 @@ func gap1TargetAddresses(t *testing.T, masterAddr string) (gap1Target, string) { } // Start the future target before a clean move is issued. It has the same -// logical r1 slot but a different server id, and no own lineage: the source +// logical r1 identity but a different server id, and no own lineage: the source // line cannot mean it lost anything. Prove75 and automatic restart, then issue // a real MoveWorkspace and prove lease/HEAD/data admission without touching // the target unit again. This is not a positive78/no-restart witness. From a9ff14e232453ea33f3a00b4d789e104319c8603 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:38:53 -0800 Subject: [PATCH 140/204] test: use explicit external bind and validate readiness response schema --- .../startup_systemd_integration_test.go | 86 +++++++++++++++++-- 1 file changed, 80 insertions(+), 6 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index 41e2cc901c..baeb17f0ea 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -75,7 +75,7 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { t.Fatal(err) } fixture.start(t, stem+"-master", false, filepath.Join(bin, "blockmaster"), - "--listen", masterListen, "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), + "--listen", masterListen, "--insecure-external-bind", "--authority-store", filepath.Join(root, "auth"), "--lifecycle-store", filepath.Join(root, "life"), "--cluster-spec", spec, "--lifecycle-product-loop-interval", "200ms", "--expected-slots-per-volume", "1", "--workspace-rpc", "--workspace-head-base-url", "http://"+cluster.filerHTTP+base) w4WaitTCP(t, masterAddr, 20*time.Second) @@ -94,6 +94,22 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { bootstrap := stem + "-bootstrap" fixture.start(t, bootstrap, false, filepath.Join(bin, "blockvolume"), args...) waitGAP1(t, "bootstrap did not attach under a real lease", 60*time.Second, func() bool { return gap1Operational(t, statusAddr, volume) }) + // Calibrate the readiness parser on the serving source's actual /status + // response before using it for the target's negative readiness assertion. + waitGAP1(t, "source readiness control never became true", 20*time.Second, func() bool { + status, body, err := gap1StatusAt(statusAddr, volume, "/status") + if err != nil || status != http.StatusOK { + return false + } + serving, err := gap1Readiness(status, body, volume) + if err != nil { + t.Fatal(err) + } + if serving { + t.Logf("captured real readiness control: status%d body%s", status, body) + } + return serving + }) // Calibrate verdict parsing against actual binary responses BEFORE kill. status, payload, err := gap1Status(statusAddr, volume) t.Logf("captured real status200: status%d body%s", status, payload) @@ -367,7 +383,10 @@ func gap1ReadUnit(unit string) (map[string]string, error) { return m, nil } func gap1Status(addr, volume string) (int, []byte, error) { - r, e := (&http.Client{Timeout: time.Second}).Get("http://" + addr + "/status/durable?volume=" + volume) + return gap1StatusAt(addr, volume, "/status/durable") +} +func gap1StatusAt(addr, volume, route string) (int, []byte, error) { + r, e := (&http.Client{Timeout: time.Second}).Get("http://" + addr + route + "?volume=" + volume) if e != nil { return 0, nil, e } @@ -375,6 +394,61 @@ func gap1Status(addr, volume string) (int, []byte, error) { body, e := io.ReadAll(io.LimitReader(r.Body, 1<<20)) return r.StatusCode, body, e } + +// /status is a different schema from /status/durable. Presence checks make +// a wrong route or a missing field a failed oracle, not false readiness. +func gap1Readiness(status int, payload []byte, volume string) (bool, error) { + if status != http.StatusOK { + return false, fmt.Errorf("readiness HTTP status%d", status) + } + var body struct { + VolumeID string + Healthy, FrontendPrimaryReady *bool + } + if err := json.Unmarshal(payload, &body); err != nil { + return false, err + } + if body.VolumeID != volume || body.Healthy == nil || body.FrontendPrimaryReady == nil { + return false, fmt.Errorf("readiness response lacks exact volume and readiness fields: %s", payload) + } + return *body.Healthy || *body.FrontendPrimaryReady, nil +} + +func TestGAP1ReadinessRejectsWrongSchema(t *testing.T) { + projection := hostvolume.StatusProjection{} + projection.VolumeID = "v" + projectionPayload := func(healthy, ready bool) []byte { + t.Helper() + projection.Healthy, projection.FrontendPrimaryReady = healthy, ready + b, err := json.Marshal(projection) + if err != nil { + t.Fatal(err) + } + return b + } + for _, tc := range []struct { + name string + status int + body []byte + serving, refused bool + }{ + {"not-ready", 200, projectionPayload(false, false), false, false}, + {"healthy", 200, projectionPayload(true, false), true, false}, + {"frontend-ready", 200, projectionPayload(false, true), true, false}, + {"durable-route", 200, []byte(`{"VolumeID":"v","Volumes":[{"VolumeID":"v","Operational":false}]}`), false, true}, + {"missing-readiness", 200, []byte(`{"VolumeID":"v","Healthy":false}`), false, true}, + {"wrong-volume", 200, []byte(`{"VolumeID":"other","Healthy":false,"FrontendPrimaryReady":false}`), false, true}, + {"http-refusal", 404, projectionPayload(false, false), false, true}, + } { + t.Run(tc.name, func(t *testing.T) { + got, err := gap1Readiness(tc.status, tc.body, "v") + if got != tc.serving || (err != nil) != tc.refused { + t.Fatalf("serving=%v err=%v want=%v refused=%v", got, err, tc.serving, tc.refused) + } + }) + } +} + func gap1StatusOperational(status int, payload []byte, volume string) bool { if status != http.StatusOK { return false @@ -569,15 +643,15 @@ func gap1PrestartedTargetServesAfterMove(t *testing.T, fixture *gap1Fixture, ws unit := stem + "-prestarted-target" fixture.start(t, unit, true, exe, changed...) waitGAP1(t, "target never observed the source holder before the move", 15*time.Second, func() bool { - status, body, err := gap1Status(addr, volume) + status, body, err := gap1StatusAt(addr, volume, "/status") if err != nil || status != http.StatusOK { return false } - var projection hostvolume.StatusProjection - if err := json.Unmarshal(body, &projection); err != nil { + serving, err := gap1Readiness(status, body, volume) + if err != nil { t.Fatal(err) } - if projection.Healthy || projection.FrontendPrimaryReady { + if serving { t.Fatalf("future target served before the move: %s", body) } ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) From b602330daa2c83e6ce22b18318c67780eb5db954 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:42:26 -0800 Subject: [PATCH 141/204] fix: apply explicit retry precedence to backend cause trees --- .../core/frontend/durable/storage_adapter.go | 2 +- seaweed-block/core/frontend/error_class.go | 64 ++++++++++--------- seaweed-block/core/frontend/errors.go | 4 ++ .../iscsi/backend_error_class_test.go | 61 +++++++++++++++--- .../frontend/nvme/backend_error_class_test.go | 8 ++- .../frontend/nvme/flush_error_log_test.go | 5 +- seaweed-block/core/frontend/nvme/fua_test.go | 5 +- .../core/frontend/nvme/pressure_retry_test.go | 4 +- .../frontend/nvme/read_command_budget_test.go | 3 +- .../frontend/nvme/read_ready_retry_test.go | 3 +- .../nvme/write_command_budget_test.go | 3 +- seaweed-block/docs/design/invariants.md | 21 +++--- 12 files changed, 123 insertions(+), 60 deletions(-) diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 98c7023841..1766a99f43 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -71,7 +71,7 @@ const ( // ErrReplicationAckUnavailable is returned when WriteAckRequireObserverAck // cannot obtain the configured replication acknowledgement. -var ErrReplicationAckUnavailable = errors.New("durable: replication ack unavailable") +var ErrReplicationAckUnavailable = frontend.ErrReplicationAckUnavailable // WriteObserver is the narrow seam StorageBackend uses to notify the // replication layer of each successfully-applied local write and to diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go index 2fedcc060a..51e11a0237 100644 --- a/seaweed-block/core/frontend/error_class.go +++ b/seaweed-block/core/frontend/error_class.go @@ -3,6 +3,12 @@ package frontend import ( "context" "errors" + "io" + "log" + "sync/atomic" + "syscall" + + "github.com/seaweedfs/seaweed-block/core/storage" ) // BackendErrorClass is independent of transport status (INV-FE-ERROR-RETRY-CLASS-001). @@ -16,50 +22,48 @@ const ( BackendErrorClosed ) -// ClassifyBackendError implements INV-FE-ERROR-RETRY-CLASS-001. -// Call only for a non-nil backend error. A pure expired command deadline is -// transient; a joined physical cause keeps its permanent classification. +var unclassifiedBackendErrors atomic.Uint64 + +// UnclassifiedBackendErrorCount reports completions using the unknown-cause +// fallback in V1-SPEC r2.42. It is cumulative for this process. +func UnclassifiedBackendErrorCount() uint64 { return unclassifiedBackendErrors.Load() } + +// ClassifyBackendError implements INV-FE-ERROR-RETRY-CLASS-001 and V1-SPEC r2.42. +// Call only for a non-nil backend error. Known permanent causes win across the +// entire wrapped/joined tree; unknown causes are counted and retryable. func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { - // M1 I/O error completion: every cause must be transient before any - // sentinel can select retry status (INV-FE-ERROR-RETRY-CLASS-001). - if !backendCausesKnown(ctx, err) { + // M1 I/O error completion: inspect permanent causes before any retry marker. + if hasPermanentBackendCause(err) { return BackendErrorPermanent } switch { - case IsWriteDeadline(ctx, err): - return BackendErrorNotReady - case errors.Is(err, ErrBackendBusy): + case errors.Is(err, ErrBackendBusy), errors.Is(err, storage.ErrWALPressureTimeout), + errors.Is(err, storage.ErrChunkHydrationPending), + errors.Is(err, ErrReplicationAckUnavailable) && errors.Is(err, context.DeadlineExceeded): return BackendErrorBusy case errors.Is(err, ErrStalePrimary): return BackendErrorStale case errors.Is(err, ErrBackendClosed): return BackendErrorClosed - case errors.Is(err, ErrNotReady): + case errors.Is(err, ErrNotReady), IsWriteDeadline(ctx, err): return BackendErrorNotReady default: - return BackendErrorPermanent + // M1 unknown completion: V1-SPEC r2.42 bounds retry at the initiator. + count := unclassifiedBackendErrors.Add(1) + log.Printf("frontend: unclassified backend error count=%d: %v", count, err) + return BackendErrorNotReady } } -// Inspect children before matching sentinels: errors.Is on a joined error can -// match one transient branch while another branch carries a permanent fault. -func backendCausesKnown(ctx context.Context, err error) bool { - if joined, ok := err.(interface{ Unwrap() []error }); ok { - causes := joined.Unwrap() - if len(causes) == 0 { - return false +func hasPermanentBackendCause(err error) bool { + // errors.Is traverses every child of joins, so neither an outer transient + // wrapper nor a sibling deadline can hide a typed storage/media failure. + for _, cause := range []error{syscall.EIO, syscall.ENOSPC, syscall.EROFS, + io.ErrUnexpectedEOF, storage.ErrWALIntegrityFault, storage.ErrFsyncFailed, + storage.ErrAppendFailed, storage.ErrMapInvalid} { + if errors.Is(err, cause) { + return true } - for _, cause := range causes { - if !backendCausesKnown(ctx, cause) { - return false - } - } - return true } - if cause := errors.Unwrap(err); cause != nil { - return backendCausesKnown(ctx, cause) - } - return errors.Is(err, ErrBackendBusy) || errors.Is(err, ErrStalePrimary) || - errors.Is(err, ErrBackendClosed) || errors.Is(err, ErrNotReady) || - (ctx.Err() == context.DeadlineExceeded && err == context.DeadlineExceeded) + return false } diff --git a/seaweed-block/core/frontend/errors.go b/seaweed-block/core/frontend/errors.go index 84691012a8..c62078bed8 100644 --- a/seaweed-block/core/frontend/errors.go +++ b/seaweed-block/core/frontend/errors.go @@ -20,3 +20,7 @@ var ErrBackendClosed = errors.New("frontend: backend closed") // ErrBackendBusy is a transient local admission timeout. Retry may succeed; // it must not be used for a sticky persistence or integrity fault. var ErrBackendBusy = errors.New("frontend: backend temporarily busy") + +// ErrReplicationAckUnavailable means the configured replication acknowledgement +// was unavailable. It is retryable busy only together with a deadline cause. +var ErrReplicationAckUnavailable = errors.New("durable: replication ack unavailable") diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go index 3bbff22607..a58e3264c2 100644 --- a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -1,16 +1,23 @@ package iscsi_test import ( + "bytes" "context" "errors" "fmt" + "io" + "log" + "strings" + "syscall" "testing" "time" "github.com/seaweedfs/seaweed-block/core/frontend" + "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/frontend/iscsi" "github.com/seaweedfs/seaweed-block/core/frontend/nvme" "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "github.com/seaweedfs/seaweed-block/core/storage" ) type classifiedErrorBackend struct { @@ -31,21 +38,37 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { status, key, asc, ascq, sct, sc uint8 deadline bool }{ + {name: "wal-pressure", err: fmt.Errorf("%w: %w", frontend.ErrBackendBusy, storage.ErrWALPressureTimeout), status: 0x08, sct: 0, sc: 0x82}, + {name: "hydration-pending", err: fmt.Errorf("%w: %w", frontend.ErrBackendBusy, storage.ErrChunkHydrationPending), status: 0x08, sct: 0, sc: 0x82}, + {name: "observer-deadline", err: fmt.Errorf("%w: %w: %w", frontend.ErrBackendBusy, durable.ErrReplicationAckUnavailable, context.DeadlineExceeded), status: 0x08, sct: 0, sc: 0x82, deadline: true}, + {name: "unknown", err: errors.New("unrecognized backend cause"), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, + {name: "pressure-without-busy-marker", err: storage.ErrWALPressureTimeout, status: 0x08, sct: 0, sc: 0x82}, + {name: "hydration-without-busy-marker", err: storage.ErrChunkHydrationPending, status: 0x08, sct: 0, sc: 0x82}, + {name: "observer-deadline-without-busy-marker", err: errors.Join(durable.ErrReplicationAckUnavailable, context.DeadlineExceeded), status: 0x08, sct: 0, sc: 0x82, deadline: true}, + {name: "unknown-with-busy", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrBackendBusy), status: 0x08, sct: 0, sc: 0x82}, + {name: "unknown-with-physical", err: errors.Join(errors.New("unrecognized backend cause"), syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "fsync-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrFsyncFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "append-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrAppendFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "integrity-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrWALIntegrityFault), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "invalid-map", err: errors.Join(frontend.ErrBackendBusy, storage.ErrMapInvalid), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "no-space", err: errors.Join(frontend.ErrBackendBusy, syscall.ENOSPC), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "read-only", err: errors.Join(frontend.ErrBackendBusy, syscall.EROFS), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "truncated-io", err: errors.Join(frontend.ErrBackendBusy, io.ErrUnexpectedEOF), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "not-ready", err: frontend.ErrNotReady, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, {name: "busy", err: frontend.ErrBackendBusy, status: 0x08, sct: 0, sc: 0x82}, {name: "stale", err: frontend.ErrStalePrimary, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x0a, sct: 3, sc: 3}, {name: "closed", err: frontend.ErrBackendClosed, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x03, sct: 3, sc: 2}, - {name: "permanent", err: errors.New("media read failure"), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "permanent", err: syscall.EIO, status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "deadline", err: context.DeadlineExceeded, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82, deadline: true}, - {name: "deadline-and-physical", err: errors.Join(context.DeadlineExceeded, errors.New("media sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-and-physical", err: errors.Join(context.DeadlineExceeded, syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, {name: "deadline-and-busy", err: errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy), status: 0x08, sct: 0, sc: 0x82, deadline: true}, - {name: "deadline-busy-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, errors.New("physical sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, - {name: "deadline-busy-physical-first", err: errors.Join(errors.New("physical sync failure"), frontend.ErrBackendBusy, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, - {name: "deadline-busy-nested-physical", err: errors.Join(frontend.ErrBackendBusy, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, errors.New("physical sync failure")))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-busy-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-busy-physical-first", err: errors.Join(syscall.EIO, frontend.ErrBackendBusy, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-busy-nested-physical", err: errors.Join(frontend.ErrBackendBusy, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, syscall.EIO))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, {name: "deadline-and-not-ready", err: errors.Join(context.DeadlineExceeded, frontend.ErrNotReady), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82, deadline: true}, - {name: "deadline-not-ready-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, errors.New("physical sync failure")), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, - {name: "deadline-not-ready-physical-first", err: errors.Join(errors.New("physical sync failure"), frontend.ErrNotReady, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, - {name: "deadline-not-ready-nested-physical", err: errors.Join(frontend.ErrNotReady, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, errors.New("physical sync failure")))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-not-ready-physical-last", err: errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-not-ready-physical-first", err: errors.Join(syscall.EIO, frontend.ErrNotReady, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, + {name: "deadline-not-ready-nested-physical", err: errors.Join(frontend.ErrNotReady, fmt.Errorf("durability: %w", errors.Join(context.DeadlineExceeded, syscall.EIO))), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, } { for _, op := range []string{"read", "write", "sync"} { t.Run(tc.name+"/"+op, func(t *testing.T) { @@ -100,3 +123,25 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { } } } + +// INV-FE-ERROR-RETRY-CLASS-001 / V1-SPEC r2.42: unknown completions are +// retryable on both protocols, counted once per completion, and diagnosable. +func TestUnclassifiedBackendErrorIsRetryableAndCounted(t *testing.T) { + var logs bytes.Buffer + previous := log.Writer() + log.SetOutput(&logs) + t.Cleanup(func() { log.SetOutput(previous) }) + before := frontend.UnclassifiedBackendErrorCount() + b := classifiedErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: errors.New("unknown completion cause")} + scsi := iscsi.NewSCSIHandler(iscsi.HandlerConfig{Backend: b}).HandleCommand(context.Background(), [16]byte{iscsi.ScsiSyncCache10}, nil) + nv := nvme.NewIOHandler(nvme.HandlerConfig{Backend: b}).Handle(context.Background(), nvme.IOCommand{NSID: 1}) + if scsi.Status != 0x02 || scsi.SenseKey != 0x02 || scsi.ASC != 0x04 || scsi.ASCQ != 0x01 || nv.SCT != 0 || nv.SC != 0x82 { + t.Fatalf("unknown completion not retryable: SCSI=%+v NVMe=%+v", scsi, nv) + } + if got := frontend.UnclassifiedBackendErrorCount() - before; got != 2 { + t.Fatalf("unclassified completions=%d want 2", got) + } + if strings.Count(logs.String(), "frontend: unclassified backend error count=") != 2 || !strings.Contains(logs.String(), "unknown completion cause") { + t.Fatalf("unclassified reason/count missing: %q", logs.String()) + } +} diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go index 541e9f46af..929966c0da 100644 --- a/seaweed-block/core/frontend/nvme/backend_error_class_test.go +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "syscall" "testing" "time" ) @@ -26,12 +27,13 @@ func TestBackendRetryClassClearsWireDNR(t *testing.T) { dnr bool }{ {"not-ready", frontend.ErrNotReady, false}, + {"unknown", errors.New("unrecognized backend cause"), false}, {"busy", frontend.ErrBackendBusy, false}, - {"permanent", errors.New("physical media fault"), true}, + {"permanent", syscall.EIO, true}, {"deadline-busy", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy), false}, {"deadline-not-ready", errors.Join(context.DeadlineExceeded, frontend.ErrNotReady), false}, - {"deadline-busy-physical", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, errors.New("physical sync failure")), true}, - {"deadline-not-ready-physical", errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, errors.New("physical sync failure")), true}, + {"deadline-busy-physical", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy, syscall.EIO), true}, + {"deadline-not-ready-physical", errors.Join(context.DeadlineExceeded, frontend.ErrNotReady, syscall.EIO), true}, } { for _, op := range []uint8{ioRead, ioWrite, ioFlush} { t.Run(tc.name+string(rune('0'+op)), func(t *testing.T) { diff --git a/seaweed-block/core/frontend/nvme/flush_error_log_test.go b/seaweed-block/core/frontend/nvme/flush_error_log_test.go index a83c59a90b..de1fbb9213 100644 --- a/seaweed-block/core/frontend/nvme/flush_error_log_test.go +++ b/seaweed-block/core/frontend/nvme/flush_error_log_test.go @@ -3,11 +3,12 @@ package nvme import ( "bytes" "context" - "errors" + "fmt" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" "log" "strings" + "syscall" "testing" ) @@ -20,7 +21,7 @@ func (b *flushErrorBackend) Sync(context.Context) error { return b.syncErr } func TestSessionFlushLogsBackendReason(t *testing.T) { var logs bytes.Buffer - b := &flushErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1"}), syncErr: errors.New("injected Sync failure: extent EIO")} + b := &flushErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1"}), syncErr: fmt.Errorf("injected Sync failure: extent EIO: %w", syscall.EIO)} s := &Session{handler: NewIOHandler(HandlerConfig{Backend: b}), logger: log.New(&logs, "", 0), qid: 7, respCh: make(chan *response, 1), done: make(chan struct{})} req := &Request{} req.capsule.OpCode = ioFlush diff --git a/seaweed-block/core/frontend/nvme/fua_test.go b/seaweed-block/core/frontend/nvme/fua_test.go index acd01356a9..1d44a9a2a4 100644 --- a/seaweed-block/core/frontend/nvme/fua_test.go +++ b/seaweed-block/core/frontend/nvme/fua_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "sync/atomic" + "syscall" "testing" "time" @@ -47,9 +48,9 @@ func TestNVMeWriteFUACompletion(t *testing.T) { wantSC uint8 }{ {name: "FUA waits for Sync", fua: true}, - {name: "Sync failure is not success", fua: true, syncErr: errors.New("sync failed"), wantSC: nvme.SCInternalError}, + {name: "Sync failure is not success", fua: true, syncErr: syscall.EIO, wantSC: nvme.SCInternalError}, {name: "ordinary write does not Sync"}, - {name: "failed write does not Sync", fua: true, writeErr: errors.New("write failed"), wantSC: nvme.SCInternalError}, + {name: "failed write does not Sync", fua: true, writeErr: syscall.EIO, wantSC: nvme.SCInternalError}, } { t.Run(tc.name, func(t *testing.T) { b := &fuaBackend{RecordingBackend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}), entered: make(chan struct{}), release: make(chan struct{}), syncErr: tc.syncErr, writeErr: tc.writeErr} diff --git a/seaweed-block/core/frontend/nvme/pressure_retry_test.go b/seaweed-block/core/frontend/nvme/pressure_retry_test.go index 094c26274e..92f47a75a8 100644 --- a/seaweed-block/core/frontend/nvme/pressure_retry_test.go +++ b/seaweed-block/core/frontend/nvme/pressure_retry_test.go @@ -2,9 +2,9 @@ package nvme import ( "context" - "errors" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "syscall" "testing" ) @@ -19,7 +19,7 @@ func TestSessionPressureTimeoutIsRetryableNamespaceNotReady(t *testing.T) { s := &Session{handler: NewIOHandler(HandlerConfig{Backend: b}), respCh: make(chan *response, 1), done: make(chan struct{})} for _, busy := range []bool{true, false} { if !busy { - b.err = errors.New("sticky physical I/O fault") + b.err = syscall.EIO } req := &Request{payload: make([]byte, 512)} req.capsule.OpCode = ioWrite diff --git a/seaweed-block/core/frontend/nvme/read_command_budget_test.go b/seaweed-block/core/frontend/nvme/read_command_budget_test.go index 5ff7456770..4bc44c57e1 100644 --- a/seaweed-block/core/frontend/nvme/read_command_budget_test.go +++ b/seaweed-block/core/frontend/nvme/read_command_budget_test.go @@ -3,6 +3,7 @@ package nvme import ( "context" "errors" + "syscall" "testing" "time" @@ -20,7 +21,7 @@ func (b *budgetReadBackend) Read(ctx context.Context, _ int64, p []byte) (int, e b.deadline, _ = ctx.Deadline() <-ctx.Done() if b.physical { - return 0, errors.Join(ctx.Err(), errors.New("physical read failure")) + return 0, errors.Join(ctx.Err(), syscall.EIO) } return 0, frontend.ErrBackendBusy } diff --git a/seaweed-block/core/frontend/nvme/read_ready_retry_test.go b/seaweed-block/core/frontend/nvme/read_ready_retry_test.go index 0b89d1dfad..e49a327eda 100644 --- a/seaweed-block/core/frontend/nvme/read_ready_retry_test.go +++ b/seaweed-block/core/frontend/nvme/read_ready_retry_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "syscall" "testing" "github.com/seaweedfs/seaweed-block/core/frontend" @@ -27,7 +28,7 @@ func TestSessionReadNotReadyIsRetryable(t *testing.T) { {"attach-pending", fmt.Errorf("awaiting HEAD attach: %w", frontend.ErrNotReady), SCTGeneric, SCNamespaceNotReady, false}, {"not-ready-closed", errors.Join(frontend.ErrNotReady, frontend.ErrBackendClosed), SCTPathRelated, SCPathAsymAccessInaccessible, true}, {"not-ready-stale", errors.Join(frontend.ErrNotReady, frontend.ErrStalePrimary), SCTPathRelated, SCPathAsymAccessTransition, true}, - {"physical-fault", errors.New("physical read failure"), SCTGeneric, SCInternalError, true}, + {"physical-fault", syscall.EIO, SCTGeneric, SCInternalError, true}, {"closed", frontend.ErrBackendClosed, SCTPathRelated, SCPathAsymAccessInaccessible, true}, {"stale", frontend.ErrStalePrimary, SCTPathRelated, SCPathAsymAccessTransition, true}, } { diff --git a/seaweed-block/core/frontend/nvme/write_command_budget_test.go b/seaweed-block/core/frontend/nvme/write_command_budget_test.go index 71910cc639..5adbf10708 100644 --- a/seaweed-block/core/frontend/nvme/write_command_budget_test.go +++ b/seaweed-block/core/frontend/nvme/write_command_budget_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "syscall" "testing" "time" @@ -49,7 +50,7 @@ type joinedBudgetBackend struct { func (b *joinedBudgetBackend) result(ctx context.Context) error { if b.physical { - return errors.Join(errors.New("physical fsync failure"), ctx.Err()) + return errors.Join(syscall.EIO, ctx.Err()) } return fmt.Errorf("durability wait: %w", ctx.Err()) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 658fc1261d..ee5a1033ef 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -413,14 +413,17 @@ snapshot lifetime; local persistence does not bypass it. non-retryable mapping. This is a local pressure outcome, not a whole-I/O deadline; the broader budget gap is tracked separately in issue221. - Every frontend I/O error completion uses one shared retry class - (`INV-FE-ERROR-RETRY-CLASS-001`): not-ready and pure expired-command - deadlines map to SCSI NOT READY04/01 or NVMe NamespaceNotReady/DNR0; - local busy maps to SCSI BUSY or NVMe NamespaceNotReady/DNR0. Stale - lineage and closed preserve their distinct path-status meanings. - Every leaf of a wrapped or joined error is checked before selecting a - retry class: any physical or unknown cause retains terminal mapping, even - alongside a deadline and busy/not-ready sentinel. Read, write and sync use the same classifier; - no storage/authority state changes on this mapping. + (`INV-FE-ERROR-RETRY-CLASS-001`, V1-SPEC r2.42): known permanent causes + anywhere in the wrapped/joined tree win over transient markers. These are + EIO, ENOSPC, EROFS, unexpected EOF, WAL integrity, prior fsync/append failure, + and invalid chunk maps. Busy, WAL pressure, hydration pending, and replication + ACK unavailable with a deadline map to SCSI BUSY or NVMe NotReady/DNR0. + Not-ready and pure command deadlines map to SCSI NOT READY04/01 or NVMe + NotReady/DNR0; stale lineage and closed retain distinct path meanings. + Otherwise the error is unclassified: increment the process counter, log the + error text, and return retryable not-ready. Initiators bound the retries. + Read, write and sync use the same classifier; no authority/storage state changes. + - A flusher cycle sorts native snapshot entries by record offset and reuses at most one fully validated record (bounded by WALSize). Every block still checks its LBA/data offset/LSN/nonce; the cache is local to the snapshot recovery @@ -500,7 +503,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-ADMISSION-EXPIRY-STATE-001` | A v3 write refused for an expired deadline before its append leaves the WAL bytes, nextLSN and the dirty map unchanged. | M1 Serving (write admission) | `core/storage/walstore.go` `WALStore.WriteContext`, `WALStore.WriteBatchContext` | `TestStorageBackendExpiredWriteDoesNotAppend` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-PREFIX-ERR-001` | A write batch that returns a committed prefix with a storage error keeps that error in the error set the frontend classifies. | M1 Serving (write admission) | `core/frontend/durable/storage_adapter.go` `writeFullBlockBatch`, `withStorageCause`, `observeWriteCause` | `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-RETRYABLE-001` | A write that fails only because the caller's deadline expired is reported retryable, also through a required write observer and on NVMe; a write whose error carries a physical cause is reported terminal. | M1 Serving (write admission) | `core/frontend/write_budget.go` `IsWriteDeadline`; `core/frontend/durable/storage_adapter.go` `StorageBackend.Write`, `replicationWriteError`; `core/frontend/nvme/io.go` `mapBackendError`; `core/frontend/nvme/session.go` `Session.handleWrite` | `TestStorageBackendRequiredObserverDeadlineStaysRetryable`, `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline`; `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | — | ACTIVE | -| `INV-FE-ERROR-RETRY-CLASS-001` | A backend error's retry class is decided once and every frontend reports it with its protocol's retryable form; only permanent errors become medium errors. | M1 I/O error completion (shared frontend classifier) | `core/frontend/error_class.go` `ClassifyBackendError`; `core/frontend/iscsi/scsi.go`, `core/frontend/nvme/io.go` `mapBackendError` | `TestBackendErrorClassesAcrossFrontends` (`core/frontend/iscsi/backend_error_class_test.go`); `TestBackendRetryClassClearsWireDNR` (`core/frontend/nvme/backend_error_class_test.go`); `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | Protocol output only; existing backend states, no new automaton state | ACTIVE | +| `INV-FE-ERROR-RETRY-CLASS-001` | A backend error's retry class is decided once and every frontend reports it with its protocol's retryable form; only permanent errors become medium errors. | M1 I/O error completion (shared frontend classifier) | `core/frontend/error_class.go` `ClassifyBackendError`; `core/frontend/iscsi/scsi.go`, `core/frontend/nvme/io.go` `mapBackendError` | `TestBackendErrorClassesAcrossFrontends` (`core/frontend/iscsi/backend_error_class_test.go`); `TestBackendRetryClassClearsWireDNR` (`core/frontend/nvme/backend_error_class_test.go`); `TestUnclassifiedBackendErrorIsRetryableAndCounted` (`core/frontend/iscsi/backend_error_class_test.go`); `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | Protocol output only; existing backend states, no new automaton state | ACTIVE | | `INV-WAL-V3-RECLAIM-001` | A mapped v3 checkpoint at cp moves retainedTail only to the end of a complete validated record whose last LSN is at most cp minus the retention window, and, while a BASE is installing, never past BaseCursor. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/wal_io_v3.go` `walWriterV3.reclaimThroughV3` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | Existing dual-slot retirement and nonce/cursor contract; concrete index/recovery/caller wiring is a code-test obligation | STUB | | `INV-WAL-V3-RECLAIM-INDEX-001` | A physical v3 recovery rebuilds the writer's volatile record-boundary index only from trusted write records of the kept scan; an installing reopen indexes them without moving the writer's cursor. | M1 checkpoint / existing two-slot retirement | `core/storage/wal_io_v3.go` `walWriterV3.restoreScanV3`, `walWriterV3.rememberReclaimScanV3`, `walWriterV3.indexReclaimScanLockedV3`; `core/storage/walstore_v3.go` `WALStore.recoverV3` | `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | — | STUB | | `INV-WAL-V3-RECLAIM-PUBLISH-001` | A mapped v3 checkpoint publishes retainedTail, retainedHead, the map root, CheckpointLSN and W in one slot publication, followed by a metadata-only rollover when the fallback slot still pins a lower tail. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.rolloverIfPinned` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | — | STUB | From eb906bb4ffec61f3af4af930169d11857066ed4d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:48:08 -0800 Subject: [PATCH 142/204] fix: retain marker-free permanent errors and log unknown types once --- .../core/frontend/durable/storage_adapter.go | 2 +- seaweed-block/core/frontend/error_class.go | 42 ++++++++----- seaweed-block/core/frontend/errors.go | 4 -- .../iscsi/backend_error_class_test.go | 62 +++++++++++++------ .../frontend/nvme/backend_error_class_test.go | 54 +++++++++++++++- .../frontend/nvme/flush_error_log_test.go | 5 +- seaweed-block/core/frontend/nvme/fua_test.go | 5 +- .../core/frontend/nvme/pressure_retry_test.go | 4 +- .../frontend/nvme/read_command_budget_test.go | 3 +- .../frontend/nvme/read_ready_retry_test.go | 3 +- .../nvme/write_command_budget_test.go | 3 +- seaweed-block/docs/design/invariants.md | 22 +++---- 12 files changed, 146 insertions(+), 63 deletions(-) diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 1766a99f43..98c7023841 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -71,7 +71,7 @@ const ( // ErrReplicationAckUnavailable is returned when WriteAckRequireObserverAck // cannot obtain the configured replication acknowledgement. -var ErrReplicationAckUnavailable = frontend.ErrReplicationAckUnavailable +var ErrReplicationAckUnavailable = errors.New("durable: replication ack unavailable") // WriteObserver is the narrow seam StorageBackend uses to notify the // replication layer of each successfully-applied local write and to diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go index 51e11a0237..aab910a9c6 100644 --- a/seaweed-block/core/frontend/error_class.go +++ b/seaweed-block/core/frontend/error_class.go @@ -5,7 +5,8 @@ import ( "errors" "io" "log" - "sync/atomic" + "reflect" + "sync" "syscall" "github.com/seaweedfs/seaweed-block/core/storage" @@ -22,24 +23,19 @@ const ( BackendErrorClosed ) -var unclassifiedBackendErrors atomic.Uint64 - -// UnclassifiedBackendErrorCount reports completions using the unknown-cause -// fallback in V1-SPEC r2.42. It is cumulative for this process. -func UnclassifiedBackendErrorCount() uint64 { return unclassifiedBackendErrors.Load() } +var unclassifiedBackendErrorTypes sync.Map // reflect.Type -> struct{} // ClassifyBackendError implements INV-FE-ERROR-RETRY-CLASS-001 and V1-SPEC r2.42. // Call only for a non-nil backend error. Known permanent causes win across the -// entire wrapped/joined tree; unknown causes are counted and retryable. +// entire wrapped/joined tree. Deliberate frontend markers decide otherwise; +// a marker-free unknown error stays permanent and is logged once per leaf type. func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { // M1 I/O error completion: inspect permanent causes before any retry marker. if hasPermanentBackendCause(err) { return BackendErrorPermanent } switch { - case errors.Is(err, ErrBackendBusy), errors.Is(err, storage.ErrWALPressureTimeout), - errors.Is(err, storage.ErrChunkHydrationPending), - errors.Is(err, ErrReplicationAckUnavailable) && errors.Is(err, context.DeadlineExceeded): + case errors.Is(err, ErrBackendBusy): return BackendErrorBusy case errors.Is(err, ErrStalePrimary): return BackendErrorStale @@ -48,10 +44,10 @@ func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { case errors.Is(err, ErrNotReady), IsWriteDeadline(ctx, err): return BackendErrorNotReady default: - // M1 unknown completion: V1-SPEC r2.42 bounds retry at the initiator. - count := unclassifiedBackendErrors.Add(1) - log.Printf("frontend: unclassified backend error count=%d: %v", count, err) - return BackendErrorNotReady + // M1 marker-free completion: amended V1-SPEC r2.42 retains the + // permanent default. Backend owners must classify types seen in gates. + logUnclassifiedBackendError(err) + return BackendErrorPermanent } } @@ -67,3 +63,21 @@ func hasPermanentBackendCause(err error) bool { } return false } + +// Wrapper types are not backend error types: inspect each unknown leaf so one +// fmt wrapper cannot suppress the first diagnostic for a different cause type. +func logUnclassifiedBackendError(err error) { + if joined, ok := err.(interface{ Unwrap() []error }); ok && len(joined.Unwrap()) != 0 { + for _, cause := range joined.Unwrap() { + logUnclassifiedBackendError(cause) + } + return + } + if cause := errors.Unwrap(err); cause != nil { + logUnclassifiedBackendError(cause) + return + } + if _, logged := unclassifiedBackendErrorTypes.LoadOrStore(reflect.TypeOf(err), struct{}{}); !logged { + log.Printf("frontend: unclassified backend error type=%T: %v", err, err) + } +} diff --git a/seaweed-block/core/frontend/errors.go b/seaweed-block/core/frontend/errors.go index c62078bed8..84691012a8 100644 --- a/seaweed-block/core/frontend/errors.go +++ b/seaweed-block/core/frontend/errors.go @@ -20,7 +20,3 @@ var ErrBackendClosed = errors.New("frontend: backend closed") // ErrBackendBusy is a transient local admission timeout. Retry may succeed; // it must not be used for a sticky persistence or integrity fault. var ErrBackendBusy = errors.New("frontend: backend temporarily busy") - -// ErrReplicationAckUnavailable means the configured replication acknowledgement -// was unavailable. It is retryable busy only together with a deadline cause. -var ErrReplicationAckUnavailable = errors.New("durable: replication ack unavailable") diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go index a58e3264c2..4bbe3324f0 100644 --- a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -7,6 +7,8 @@ import ( "fmt" "io" "log" + "os" + "os/exec" "strings" "syscall" "testing" @@ -41,11 +43,14 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { {name: "wal-pressure", err: fmt.Errorf("%w: %w", frontend.ErrBackendBusy, storage.ErrWALPressureTimeout), status: 0x08, sct: 0, sc: 0x82}, {name: "hydration-pending", err: fmt.Errorf("%w: %w", frontend.ErrBackendBusy, storage.ErrChunkHydrationPending), status: 0x08, sct: 0, sc: 0x82}, {name: "observer-deadline", err: fmt.Errorf("%w: %w: %w", frontend.ErrBackendBusy, durable.ErrReplicationAckUnavailable, context.DeadlineExceeded), status: 0x08, sct: 0, sc: 0x82, deadline: true}, - {name: "unknown", err: errors.New("unrecognized backend cause"), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, - {name: "pressure-without-busy-marker", err: storage.ErrWALPressureTimeout, status: 0x08, sct: 0, sc: 0x82}, - {name: "hydration-without-busy-marker", err: storage.ErrChunkHydrationPending, status: 0x08, sct: 0, sc: 0x82}, - {name: "observer-deadline-without-busy-marker", err: errors.Join(durable.ErrReplicationAckUnavailable, context.DeadlineExceeded), status: 0x08, sct: 0, sc: 0x82, deadline: true}, + {name: "unknown", err: errors.New("unrecognized backend cause"), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "pressure-without-busy-marker", err: storage.ErrWALPressureTimeout, status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "hydration-without-busy-marker", err: storage.ErrChunkHydrationPending, status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "observer-deadline-without-busy-marker", err: errors.Join(durable.ErrReplicationAckUnavailable, context.DeadlineExceeded), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6, deadline: true}, {name: "unknown-with-busy", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrBackendBusy), status: 0x08, sct: 0, sc: 0x82}, + {name: "unknown-with-not-ready", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrNotReady), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, + {name: "unknown-with-stale", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrStalePrimary), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x0a, sct: 3, sc: 3}, + {name: "unknown-with-closed", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrBackendClosed), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x03, sct: 3, sc: 2}, {name: "unknown-with-physical", err: errors.Join(errors.New("unrecognized backend cause"), syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "fsync-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrFsyncFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "append-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrAppendFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, @@ -124,24 +129,45 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { } } -// INV-FE-ERROR-RETRY-CLASS-001 / V1-SPEC r2.42: unknown completions are -// retryable on both protocols, counted once per completion, and diagnosable. -func TestUnclassifiedBackendErrorIsRetryableAndCounted(t *testing.T) { +type unknownCompletionError struct{ message string } + +func (e unknownCompletionError) Error() string { return e.message } + +type otherUnknownCompletionError struct{} + +func (otherUnknownCompletionError) Error() string { return "unknown completion B" } + +// INV-FE-ERROR-RETRY-CLASS-001 / amended V1-SPEC r2.42: no marker means +// permanent. Unknown leaf types are logged once across wrappers and protocols. +func TestUnclassifiedBackendErrorIsPermanentAndLoggedOncePerType(t *testing.T) { + // The log-once cache is process-wide; give each test repetition a fresh + // process rather than exposing an implementation-only reset operation. + if os.Getenv("FRONTEND_UNCLASSIFIED_LOG_CHILD") != "1" { + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestUnclassifiedBackendErrorIsPermanentAndLoggedOncePerType$", "-test.count=1") + cmd.Env = append(os.Environ(), "FRONTEND_UNCLASSIFIED_LOG_CHILD=1") + if output, err := cmd.CombinedOutput(); err != nil { + t.Fatalf("log-once child: %v\n%s", err, output) + } + return + } var logs bytes.Buffer previous := log.Writer() log.SetOutput(&logs) t.Cleanup(func() { log.SetOutput(previous) }) - before := frontend.UnclassifiedBackendErrorCount() - b := classifiedErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: errors.New("unknown completion cause")} - scsi := iscsi.NewSCSIHandler(iscsi.HandlerConfig{Backend: b}).HandleCommand(context.Background(), [16]byte{iscsi.ScsiSyncCache10}, nil) - nv := nvme.NewIOHandler(nvme.HandlerConfig{Backend: b}).Handle(context.Background(), nvme.IOCommand{NSID: 1}) - if scsi.Status != 0x02 || scsi.SenseKey != 0x02 || scsi.ASC != 0x04 || scsi.ASCQ != 0x01 || nv.SCT != 0 || nv.SC != 0x82 { - t.Fatalf("unknown completion not retryable: SCSI=%+v NVMe=%+v", scsi, nv) + for _, cause := range []error{ + fmt.Errorf("wrapped: %w", unknownCompletionError{"unknown completion A"}), + errors.Join(unknownCompletionError{"same type, other value"}, otherUnknownCompletionError{}), + } { + b := classifiedErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: cause} + scsi := iscsi.NewSCSIHandler(iscsi.HandlerConfig{Backend: b}).HandleCommand(context.Background(), [16]byte{iscsi.ScsiSyncCache10}, nil) + nv := nvme.NewIOHandler(nvme.HandlerConfig{Backend: b}).Handle(context.Background(), nvme.IOCommand{NSID: 1}) + if scsi.Status != 0x02 || scsi.SenseKey != 0x03 || scsi.ASC != 0x0c || nv.SCT != 0 || nv.SC != 6 { + t.Fatalf("marker-free completion not permanent: SCSI=%+v NVMe=%+v", scsi, nv) + } } - if got := frontend.UnclassifiedBackendErrorCount() - before; got != 2 { - t.Fatalf("unclassified completions=%d want 2", got) - } - if strings.Count(logs.String(), "frontend: unclassified backend error count=") != 2 || !strings.Contains(logs.String(), "unknown completion cause") { - t.Fatalf("unclassified reason/count missing: %q", logs.String()) + if strings.Count(logs.String(), "frontend: unclassified backend error type=") != 2 || !strings.Contains(logs.String(), "unknown completion A") || !strings.Contains(logs.String(), "unknown completion B") { + t.Fatalf("expected one log for each leaf type across both frontends: %q", logs.String()) } } diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go index 929966c0da..a5f91031e3 100644 --- a/seaweed-block/core/frontend/nvme/backend_error_class_test.go +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -3,8 +3,10 @@ package nvme import ( "context" "errors" + "fmt" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" + "github.com/seaweedfs/seaweed-block/core/storage" "syscall" "testing" "time" @@ -27,7 +29,7 @@ func TestBackendRetryClassClearsWireDNR(t *testing.T) { dnr bool }{ {"not-ready", frontend.ErrNotReady, false}, - {"unknown", errors.New("unrecognized backend cause"), false}, + {"unknown", errors.New("unrecognized backend cause"), true}, {"busy", frontend.ErrBackendBusy, false}, {"permanent", syscall.EIO, true}, {"deadline-busy", errors.Join(context.DeadlineExceeded, frontend.ErrBackendBusy), false}, @@ -48,3 +50,53 @@ func TestBackendRetryClassClearsWireDNR(t *testing.T) { } } } + +type durabilityClassBackend struct { + frontend.Backend + err error + writes, syncs int +} + +func (b *durabilityClassBackend) Write(_ context.Context, _ int64, p []byte) (int, error) { + b.writes++ + return len(p), nil +} +func (b *durabilityClassBackend) Sync(context.Context) error { + b.syncs++ + return b.err +} + +// INV-FE-ERROR-RETRY-CLASS-001 / amended V1-SPEC r2.42: a failed durability +// operation's latched permanent cause wins even beneath a deliberate busy marker. +func TestSyncAndFUALatchedFaultOverridesBusy(t *testing.T) { + for _, fua := range []bool{false, true} { + for _, latched := range []bool{false, true} { + t.Run(fmt.Sprintf("fua=%t/latched=%t", fua, latched), func(t *testing.T) { + cause := errors.Join(frontend.ErrBackendBusy, errors.New("untyped durability cause")) + if latched { + cause = errors.Join(cause, storage.ErrFsyncFailed) + } + b := &durabilityClassBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: cause} + cmd := IOCommand{Opcode: ioFlush, NSID: 1} + if fua { + cmd = IOCommand{Opcode: ioWrite, NSID: 1, NLB: 1, Data: make([]byte, 512), FUA: true} + } + got := NewIOHandler(HandlerConfig{Backend: b}).Handle(context.Background(), cmd) + want := MakeStatusField(SCTGeneric, SCNamespaceNotReady, false) + if latched { + want = MakeStatusField(SCTGeneric, SCInternalError, true) + } + if got.completionStatus() != want { + t.Fatalf("completion=%#x want %#x", got.completionStatus(), want) + } + writes := 0 + if fua { + writes = 1 + } + if b.writes != writes || b.syncs != 1 { + t.Fatalf("durability seam not reached once: writes=%d syncs=%d", b.writes, b.syncs) + } + }) + } + } +} diff --git a/seaweed-block/core/frontend/nvme/flush_error_log_test.go b/seaweed-block/core/frontend/nvme/flush_error_log_test.go index de1fbb9213..a83c59a90b 100644 --- a/seaweed-block/core/frontend/nvme/flush_error_log_test.go +++ b/seaweed-block/core/frontend/nvme/flush_error_log_test.go @@ -3,12 +3,11 @@ package nvme import ( "bytes" "context" - "fmt" + "errors" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" "log" "strings" - "syscall" "testing" ) @@ -21,7 +20,7 @@ func (b *flushErrorBackend) Sync(context.Context) error { return b.syncErr } func TestSessionFlushLogsBackendReason(t *testing.T) { var logs bytes.Buffer - b := &flushErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1"}), syncErr: fmt.Errorf("injected Sync failure: extent EIO: %w", syscall.EIO)} + b := &flushErrorBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1"}), syncErr: errors.New("injected Sync failure: extent EIO")} s := &Session{handler: NewIOHandler(HandlerConfig{Backend: b}), logger: log.New(&logs, "", 0), qid: 7, respCh: make(chan *response, 1), done: make(chan struct{})} req := &Request{} req.capsule.OpCode = ioFlush diff --git a/seaweed-block/core/frontend/nvme/fua_test.go b/seaweed-block/core/frontend/nvme/fua_test.go index 1d44a9a2a4..acd01356a9 100644 --- a/seaweed-block/core/frontend/nvme/fua_test.go +++ b/seaweed-block/core/frontend/nvme/fua_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "sync/atomic" - "syscall" "testing" "time" @@ -48,9 +47,9 @@ func TestNVMeWriteFUACompletion(t *testing.T) { wantSC uint8 }{ {name: "FUA waits for Sync", fua: true}, - {name: "Sync failure is not success", fua: true, syncErr: syscall.EIO, wantSC: nvme.SCInternalError}, + {name: "Sync failure is not success", fua: true, syncErr: errors.New("sync failed"), wantSC: nvme.SCInternalError}, {name: "ordinary write does not Sync"}, - {name: "failed write does not Sync", fua: true, writeErr: syscall.EIO, wantSC: nvme.SCInternalError}, + {name: "failed write does not Sync", fua: true, writeErr: errors.New("write failed"), wantSC: nvme.SCInternalError}, } { t.Run(tc.name, func(t *testing.T) { b := &fuaBackend{RecordingBackend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}), entered: make(chan struct{}), release: make(chan struct{}), syncErr: tc.syncErr, writeErr: tc.writeErr} diff --git a/seaweed-block/core/frontend/nvme/pressure_retry_test.go b/seaweed-block/core/frontend/nvme/pressure_retry_test.go index 92f47a75a8..094c26274e 100644 --- a/seaweed-block/core/frontend/nvme/pressure_retry_test.go +++ b/seaweed-block/core/frontend/nvme/pressure_retry_test.go @@ -2,9 +2,9 @@ package nvme import ( "context" + "errors" "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/testback" - "syscall" "testing" ) @@ -19,7 +19,7 @@ func TestSessionPressureTimeoutIsRetryableNamespaceNotReady(t *testing.T) { s := &Session{handler: NewIOHandler(HandlerConfig{Backend: b}), respCh: make(chan *response, 1), done: make(chan struct{})} for _, busy := range []bool{true, false} { if !busy { - b.err = syscall.EIO + b.err = errors.New("sticky physical I/O fault") } req := &Request{payload: make([]byte, 512)} req.capsule.OpCode = ioWrite diff --git a/seaweed-block/core/frontend/nvme/read_command_budget_test.go b/seaweed-block/core/frontend/nvme/read_command_budget_test.go index 4bc44c57e1..5ff7456770 100644 --- a/seaweed-block/core/frontend/nvme/read_command_budget_test.go +++ b/seaweed-block/core/frontend/nvme/read_command_budget_test.go @@ -3,7 +3,6 @@ package nvme import ( "context" "errors" - "syscall" "testing" "time" @@ -21,7 +20,7 @@ func (b *budgetReadBackend) Read(ctx context.Context, _ int64, p []byte) (int, e b.deadline, _ = ctx.Deadline() <-ctx.Done() if b.physical { - return 0, errors.Join(ctx.Err(), syscall.EIO) + return 0, errors.Join(ctx.Err(), errors.New("physical read failure")) } return 0, frontend.ErrBackendBusy } diff --git a/seaweed-block/core/frontend/nvme/read_ready_retry_test.go b/seaweed-block/core/frontend/nvme/read_ready_retry_test.go index e49a327eda..0b89d1dfad 100644 --- a/seaweed-block/core/frontend/nvme/read_ready_retry_test.go +++ b/seaweed-block/core/frontend/nvme/read_ready_retry_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "syscall" "testing" "github.com/seaweedfs/seaweed-block/core/frontend" @@ -28,7 +27,7 @@ func TestSessionReadNotReadyIsRetryable(t *testing.T) { {"attach-pending", fmt.Errorf("awaiting HEAD attach: %w", frontend.ErrNotReady), SCTGeneric, SCNamespaceNotReady, false}, {"not-ready-closed", errors.Join(frontend.ErrNotReady, frontend.ErrBackendClosed), SCTPathRelated, SCPathAsymAccessInaccessible, true}, {"not-ready-stale", errors.Join(frontend.ErrNotReady, frontend.ErrStalePrimary), SCTPathRelated, SCPathAsymAccessTransition, true}, - {"physical-fault", syscall.EIO, SCTGeneric, SCInternalError, true}, + {"physical-fault", errors.New("physical read failure"), SCTGeneric, SCInternalError, true}, {"closed", frontend.ErrBackendClosed, SCTPathRelated, SCPathAsymAccessInaccessible, true}, {"stale", frontend.ErrStalePrimary, SCTPathRelated, SCPathAsymAccessTransition, true}, } { diff --git a/seaweed-block/core/frontend/nvme/write_command_budget_test.go b/seaweed-block/core/frontend/nvme/write_command_budget_test.go index 5adbf10708..71910cc639 100644 --- a/seaweed-block/core/frontend/nvme/write_command_budget_test.go +++ b/seaweed-block/core/frontend/nvme/write_command_budget_test.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "syscall" "testing" "time" @@ -50,7 +49,7 @@ type joinedBudgetBackend struct { func (b *joinedBudgetBackend) result(ctx context.Context) error { if b.physical { - return errors.Join(syscall.EIO, ctx.Err()) + return errors.Join(errors.New("physical fsync failure"), ctx.Err()) } return fmt.Errorf("durability wait: %w", ctx.Err()) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index ee5a1033ef..52b4d4aad2 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -413,16 +413,16 @@ snapshot lifetime; local persistence does not bypass it. non-retryable mapping. This is a local pressure outcome, not a whole-I/O deadline; the broader budget gap is tracked separately in issue221. - Every frontend I/O error completion uses one shared retry class - (`INV-FE-ERROR-RETRY-CLASS-001`, V1-SPEC r2.42): known permanent causes - anywhere in the wrapped/joined tree win over transient markers. These are - EIO, ENOSPC, EROFS, unexpected EOF, WAL integrity, prior fsync/append failure, - and invalid chunk maps. Busy, WAL pressure, hydration pending, and replication - ACK unavailable with a deadline map to SCSI BUSY or NVMe NotReady/DNR0. - Not-ready and pure command deadlines map to SCSI NOT READY04/01 or NVMe - NotReady/DNR0; stale lineage and closed retain distinct path meanings. - Otherwise the error is unclassified: increment the process counter, log the - error text, and return retryable not-ready. Initiators bound the retries. - Read, write and sync use the same classifier; no authority/storage state changes. + (`INV-FE-ERROR-RETRY-CLASS-001`, amended V1-SPEC r2.42): (a) a known permanent + cause anywhere in the wrapped/joined tree wins: EIO, ENOSPC, EROFS, unexpected + EOF, WAL integrity, prior fsync/append failure, or invalid chunk maps; + (b) otherwise a deliberate busy, not-ready, stale, closed or pure expired + command-deadline marker decides. Unknown causes under markers do not override + them; pressure/hydration/observer causes are not frontend classification atoms; + (c) no marker and no known permanent cause retains the permanent default, + logged once per unknown leaf error type. Backend owners must classify any + unclassified type seen in a gate before GO. Both frontend mappers consume + ClassifyBackendError; no storage/authority state changes on completion. - A flusher cycle sorts native snapshot entries by record offset and reuses at most one fully validated record (bounded by WALSize). Every block still checks @@ -503,7 +503,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-WAL-V3-ADMISSION-EXPIRY-STATE-001` | A v3 write refused for an expired deadline before its append leaves the WAL bytes, nextLSN and the dirty map unchanged. | M1 Serving (write admission) | `core/storage/walstore.go` `WALStore.WriteContext`, `WALStore.WriteBatchContext` | `TestStorageBackendExpiredWriteDoesNotAppend` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-PREFIX-ERR-001` | A write batch that returns a committed prefix with a storage error keeps that error in the error set the frontend classifies. | M1 Serving (write admission) | `core/frontend/durable/storage_adapter.go` `writeFullBlockBatch`, `withStorageCause`, `observeWriteCause` | `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline` | — | ACTIVE | | `INV-WAL-V3-ADMISSION-RETRYABLE-001` | A write that fails only because the caller's deadline expired is reported retryable, also through a required write observer and on NVMe; a write whose error carries a physical cause is reported terminal. | M1 Serving (write admission) | `core/frontend/write_budget.go` `IsWriteDeadline`; `core/frontend/durable/storage_adapter.go` `StorageBackend.Write`, `replicationWriteError`; `core/frontend/nvme/io.go` `mapBackendError`; `core/frontend/nvme/session.go` `Session.handleWrite` | `TestStorageBackendRequiredObserverDeadlineStaysRetryable`, `TestStorageBackendPartialBatchPhysicalFaultSurvivesObserverDeadline`; `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | — | ACTIVE | -| `INV-FE-ERROR-RETRY-CLASS-001` | A backend error's retry class is decided once and every frontend reports it with its protocol's retryable form; only permanent errors become medium errors. | M1 I/O error completion (shared frontend classifier) | `core/frontend/error_class.go` `ClassifyBackendError`; `core/frontend/iscsi/scsi.go`, `core/frontend/nvme/io.go` `mapBackendError` | `TestBackendErrorClassesAcrossFrontends` (`core/frontend/iscsi/backend_error_class_test.go`); `TestBackendRetryClassClearsWireDNR` (`core/frontend/nvme/backend_error_class_test.go`); `TestUnclassifiedBackendErrorIsRetryableAndCounted` (`core/frontend/iscsi/backend_error_class_test.go`); `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | Protocol output only; existing backend states, no new automaton state | ACTIVE | +| `INV-FE-ERROR-RETRY-CLASS-001` | A backend error's retry class is decided once and every frontend reports it with its protocol's retryable form; only permanent errors become medium errors. | M1 I/O error completion (shared frontend classifier) | `core/frontend/error_class.go` `ClassifyBackendError`; `core/frontend/iscsi/scsi.go`, `core/frontend/nvme/io.go` `mapBackendError` | `TestBackendErrorClassesAcrossFrontends` (`core/frontend/iscsi/backend_error_class_test.go`); `TestBackendRetryClassClearsWireDNR`, `TestSyncAndFUALatchedFaultOverridesBusy` (`core/frontend/nvme/backend_error_class_test.go`); `TestUnclassifiedBackendErrorIsPermanentAndLoggedOncePerType` (`core/frontend/iscsi/backend_error_class_test.go`); `TestSessionWriteBudgetDeadlineIsRetryableIncludingFUA` (`core/frontend/nvme/write_command_budget_test.go`) | Protocol output only; existing backend states, no new automaton state | ACTIVE | | `INV-WAL-V3-RECLAIM-001` | A mapped v3 checkpoint at cp moves retainedTail only to the end of a complete validated record whose last LSN is at most cp minus the retention window, and, while a BASE is installing, never past BaseCursor. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/wal_io_v3.go` `walWriterV3.reclaimThroughV3` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimKeepsPartialBatchAndRetention`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | Existing dual-slot retirement and nonce/cursor contract; concrete index/recovery/caller wiring is a code-test obligation | STUB | | `INV-WAL-V3-RECLAIM-INDEX-001` | A physical v3 recovery rebuilds the writer's volatile record-boundary index only from trusted write records of the kept scan; an installing reopen indexes them without moving the writer's cursor. | M1 checkpoint / existing two-slot retirement | `core/storage/wal_io_v3.go` `walWriterV3.restoreScanV3`, `walWriterV3.rememberReclaimScanV3`, `walWriterV3.indexReclaimScanLockedV3`; `core/storage/walstore_v3.go` `WALStore.recoverV3` | `TestWALStoreV3ReclaimRebuildsIndexAfterPhysicalRecovery`, `TestWALStoreV3ReclaimAfterInstallingPhysicalReopen` | — | STUB | | `INV-WAL-V3-RECLAIM-PUBLISH-001` | A mapped v3 checkpoint publishes retainedTail, retainedHead, the map root, CheckpointLSN and W in one slot publication, followed by a metadata-only rollover when the fallback slot still pins a lower tail. | M1 checkpoint / existing two-slot retirement | `core/storage/walstore_map_checkpoint_v3.go` `WALStore.publishCheckpointV3`; `core/storage/descriptor_v3.go` `descriptorPublisherV3.rolloverIfPinned` | `TestWALStoreV3CheckpointReclaimsAcrossRingLaps`, `TestWALStoreV3ReclaimSecondSlotFailureKeepsOldPin` | — | STUB | From 2cf83f5922f8d843a3e92f694100c772b4d86930 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:53:20 -0800 Subject: [PATCH 143/204] ci: public-text check self-test: a failing grep refuses Co-Authored-By: Claude Fable 5.2 --- seaweed-block/.github/scripts/public-text-check-test.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/seaweed-block/.github/scripts/public-text-check-test.sh b/seaweed-block/.github/scripts/public-text-check-test.sh index 964c440636..a59dc7e096 100755 --- a/seaweed-block/.github/scripts/public-text-check-test.sh +++ b/seaweed-block/.github/scripts/public-text-check-test.sh @@ -41,4 +41,11 @@ expect 1 "backslash form of the share path in the title" "$mb2" HEAD title body; expect 2 "a missing title file is an error, not clean" "$mb2" HEAD no-such-title body expect 2 "a missing description file is an error, not clean" "$mb2" HEAD title no-such-body expect 2 "an unknown commit is an error, not clean" 0000000000000000000000000000000000000000 HEAD title body +# A grep that fails (exit 2) is an error: the check must refuse and never print "clean". +mkdir -p fakebin; printf '#!/bin/sh +exit 2 +' > fakebin/grep; chmod +x fakebin/grep +rc=0; PATH="$PWD/fakebin:$PATH" bash "$here/public-text-check.sh" "$mb2" HEAD title body >out 2>&1 || rc=$? +[ "$rc" = 2 ] || { echo "public-text-check-test: failing grep: exit $rc, want 2"; cat out; exit 1; } +if PATH=/usr/bin:/bin grep -q "clean" out; then echo "public-text-check-test: failing grep printed clean"; cat out; exit 1; fi echo "public-text-check-test: ok" From 79d5d9f7982b912f52fdd0068dc74576b0422aa3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:55:01 -0800 Subject: [PATCH 144/204] fix: one owner decision (PublishedLine.Owner); a moved line with an unknown owner takes facts from no server Design review of #429 (V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001, TERM-HOLDER-001): - PublishedLine.Owner is the single owner decision (move-named server; move-named but unknown; not from a move), called by Host.workspaceLineOwner and expectOwnerForLine. - A move-minted line whose owner is unknown binds its replica to no server: no health, endpoints or refresh from anyone (control: the placement server's fresh report changes nothing). Only a line no move minted keeps the accepted topology. - var _ lineOwnerReader = (*Publisher)(nil): dropping the method is a build error. Co-Authored-By: Claude Opus 5.5 --- .../authority/line_owner_snapshot_test.go | 26 +++++++++++++++++++ .../core/authority/snapshot_builder.go | 18 ++++++++----- .../core/authority/workspace_lease_view.go | 16 ++++++++++++ .../core/host/master/workspace_binding.go | 4 +-- seaweed-block/docs/design/invariants.md | 6 +++-- 5 files changed, 60 insertions(+), 10 deletions(-) diff --git a/seaweed-block/core/authority/line_owner_snapshot_test.go b/seaweed-block/core/authority/line_owner_snapshot_test.go index 4181458252..ea6177c519 100644 --- a/seaweed-block/core/authority/line_owner_snapshot_test.go +++ b/seaweed-block/core/authority/line_owner_snapshot_test.go @@ -42,6 +42,14 @@ func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) { if !ok || r1.ServerID != "s2" || r1.DataAddr != "owner-s2:1" || r1.CtrlAddr != "owner-s2:2" { t.Fatalf("line replica candidate %+v ok=%v, want the owner s2 at owner-s2:1/2 (never the old host s1)", r1, ok) } + // a move minted the line but its owner is unknown: NO server supplies the replica's facts, so the returning + // placement server's fresh report changes nothing (no endpoint change, hence no refresh) + unknown := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2, OwnerFromMove: true}}} + if v, ok := findSupported(BuildSnapshot(store.Snapshot(), topo, unknown), "v1"); ok { + if r1, _ := candidateByReplica(v, "r1"); r1.ServerID == "s1" || r1.DataAddr == "old-s1:1" || (r1.DataAddr != "" && r1.DataAddr != "owner-s2:1") { + t.Fatalf("unknown owner: candidate %+v takes the placement server's report (want no server's facts)", r1) + } + } // without a move-named owner the accepted topology stands (control) plain := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2}}} v, _ = findSupported(BuildSnapshot(store.Snapshot(), topo, plain), "v1") @@ -49,3 +57,21 @@ func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) { t.Fatalf("control: no move-named owner, candidate %+v, want the topology's s1", r1) } } + +// TERM-HOLDER-001's single owner decision: the three outcomes of PublishedLine.Owner. +func TestPublishedLineOwnerOutcomes(t *testing.T) { + for _, c := range []struct { + pl PublishedLine + server string + fromMove bool + }{ + {PublishedLine{IssuedHost: "s2", OwnerFromMove: true}, "s2", true}, + {PublishedLine{IssuedHost: "s2"}, "s2", true}, + {PublishedLine{OwnerFromMove: true}, "", true}, + {PublishedLine{}, "", false}, + } { + if server, fromMove := c.pl.Owner(); server != c.server || fromMove != c.fromMove { + t.Fatalf("%+v.Owner() = %q, %v; want %q, %v", c.pl, server, fromMove, c.server, c.fromMove) + } + } +} diff --git a/seaweed-block/core/authority/snapshot_builder.go b/seaweed-block/core/authority/snapshot_builder.go index 0fe437a3f2..9ad6d7a499 100644 --- a/seaweed-block/core/authority/snapshot_builder.go +++ b/seaweed-block/core/authority/snapshot_builder.go @@ -482,24 +482,30 @@ type lineOwnerReader interface { PublishedAuthorityLine(volume string) (PublishedLine, bool) } -// expectOwnerForLine binds the expected slot of the line's replica to the line's owner when a move named it (#425, -// V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): a line carries its owner and that owner's endpoints, so its replica's -// facts (health, endpoints, and any endpoint refresh) come only from that server, never from the placement or -// topology server it was moved away from. Without a move-named owner the expected topology stands unchanged. +// expectOwnerForLine binds the expected slot of the line's replica to the line's owner (PublishedLine.Owner) when a +// move minted the line (#425, V1-SPEC r2.40, INV-AUTH-HOLDER-IDENTITY-001): a line carries its owner and that owner's +// endpoints, so its replica's facts (health, endpoints, and any endpoint refresh) come only from that server, never +// from the placement or topology server it was moved away from. A move-minted line whose owner is unknown is bound to +// NO server (no fact from anyone, so no refresh) until the owner is known. Only a line no move minted keeps the +// accepted topology. func expectOwnerForLine(expected VolumeExpected, volumeID string, line AuthorityBasis, reader AuthorityBasisReader) VolumeExpected { r, ok := reader.(lineOwnerReader) if !ok { return expected } pl, ok := r.PublishedAuthorityLine(volumeID) - if !ok || pl.ReplicaID != line.ReplicaID || pl.Epoch != line.Epoch || !(pl.OwnerFromMove || pl.IssuedHost != "") || pl.IssuedHost == "" { + if !ok || pl.ReplicaID != line.ReplicaID || pl.Epoch != line.Epoch { + return expected + } + server, fromMove := pl.Owner() + if !fromMove { return expected } out := VolumeExpected{VolumeID: expected.VolumeID, Slots: make([]ExpectedSlot, len(expected.Slots))} copy(out.Slots, expected.Slots) for i := range out.Slots { if out.Slots[i].ReplicaID == line.ReplicaID { - out.Slots[i].ServerID = pl.IssuedHost + out.Slots[i].ServerID = server // "" for an unknown owner: no server supplies this replica's facts } } return out diff --git a/seaweed-block/core/authority/workspace_lease_view.go b/seaweed-block/core/authority/workspace_lease_view.go index 05f7b84496..354aff74bd 100644 --- a/seaweed-block/core/authority/workspace_lease_view.go +++ b/seaweed-block/core/authority/workspace_lease_view.go @@ -155,6 +155,22 @@ type PublishedLine struct { OwnerFromMove bool } +// Owner is TERM-HOLDER-001's single owner decision for a line (INV-AUTH-HOLDER-IDENTITY-001), shared by the master's +// workspaceLineOwner and the snapshot builder. Three outcomes: +// - fromMove, server != "": a move minted the line on server; +// - fromMove, server == "": a move minted it but its owner is unknown: no server may supply its facts; +// - !fromMove: no move minted it; the caller uses placement / the accepted topology. +func (pl PublishedLine) Owner() (server string, fromMove bool) { + if pl.OwnerFromMove || pl.IssuedHost != "" { + return pl.IssuedHost, true + } + return "", false +} + +// The snapshot builder binds a moved line's replica to its owner through this method; the production reader must +// provide it (a refactor dropping it is a build error, not a silent return to placement). +var _ lineOwnerReader = (*Publisher)(nil) + // PublishedAuthorityLine reads one committed line under leaf leaseMu. Identity // checks on renewal must not wait for p.mu, which spans authority store I/O // (INV-LEASE-VIEW-001, INV-WS-RENEW-NONBLOCKING-001). diff --git a/seaweed-block/core/host/master/workspace_binding.go b/seaweed-block/core/host/master/workspace_binding.go index 020c04d77a..5d9bce2d58 100644 --- a/seaweed-block/core/host/master/workspace_binding.go +++ b/seaweed-block/core/host/master/workspace_binding.go @@ -78,8 +78,8 @@ func (h *Host) workspaceSourceHost(volume, replica string, epoch uint64) string // lines need the move journal. Endpoints never identify a server. func (h *Host) workspaceLineOwner(current authority.PublishedLine, volume, replica string, epoch uint64) string { if current.ReplicaID == replica && current.Epoch == epoch { - if current.OwnerFromMove || current.IssuedHost != "" { - return current.IssuedHost + if server, fromMove := current.Owner(); fromMove { // the single owner decision (PublishedLine.Owner) + return server } return h.placementSourceHost(volume, replica) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 272f5adcfa..092f712dc5 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -93,7 +93,9 @@ blockmaster's publisher is the only component that mints epochs. Diagrams: the a **Workspace lease and move, in blockmaster.** -TERM-HOLDER-001 uses one deciding function, `Host.workspaceLineOwner`. The +TERM-HOLDER-001 uses one owner decision, `PublishedLine.Owner` (core/authority), +called by `Host.workspaceLineOwner` and by the snapshot builder's `expectOwnerForLine` +(a moved line's replica facts come only from its owner, none for an unknown owner). The stream supplies the PublishedLine captured in its AssignmentInfo; lease/ACK checks supply the captured leaf view; move source uses a leaf snapshot wrapper. `Publisher.captureAssignmentOwner` captures the moved owner under the publication @@ -1019,7 +1021,7 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| -| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines. The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines (through `PublishedLine.Owner`, which the snapshot builder's `expectOwnerForLine` also calls). The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | From f557cdfbc81f9d074a5d8b4225019247623e3710 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:10:15 -0800 Subject: [PATCH 145/204] test: positive per-recipient evidence in the gate; the unknown owner's exact placeholder Test review of #429 79d5d9f7: - wrongOwnerEndpoints fails a recipient whose log cannot be read or shows no forced-epoch delivery, so each recipient must positively receive the owner's line. - The unknown-owner unit check requires the volume unsupported or exactly the no-observation placeholder (no server, the line's endpoints), so neither s1's nor s2's report may supply it. Co-Authored-By: Claude Opus 5.5 --- .../procedure_gate_integration_test.go | 16 +++++++++++++--- .../core/authority/line_owner_snapshot_test.go | 7 +++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 32cfb64b95..8f4543f8b9 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -180,7 +180,7 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { // #425 (V1-SPEC r2.40: a line carries its owner and that owner's endpoints): every line delivered at the forced // epoch, to the new owner and to the returning old host alike, carries s2's own endpoints, never another host's. if bad := wrongOwnerEndpoints(e2, env.hosts["s2"], nw, back); len(bad) > 0 { - t.Errorf("an epoch-%d line was delivered with another host's endpoints (want s2's data=%s ctrl=%s):\n%s", + t.Errorf("epoch-%d deliveries not proven to carry s2's endpoints (want data=%s ctrl=%s in every recipient's lines):\n%s", e2, env.hosts["s2"].data, env.hosts["s2"].ctrl, strings.Join(bad, "\n")) } env.h.waitPrimaryAt(t, env.hosts["s2"].status, e2) @@ -462,20 +462,30 @@ func (env *handoffEnv) forceMove(t *testing.T, e uint64, target, request string) } // wrongOwnerEndpoints returns every "assignment stream delivery" log line at epoch e (in any of ds) whose data or control -// endpoint is not owner's (#425). +// endpoint is not owner's (#425), plus an entry for each recipient whose log cannot be read or shows no epoch-e +// delivery at all (each recipient must positively have received the owner's line). func wrongOwnerEndpoints(e uint64, owner bvHost, ds ...*daemon) []string { var bad []string tag := fmt.Sprintf(" epoch=%d ev=", e) for _, d := range ds { - raw, _ := os.ReadFile(d.log) + raw, err := os.ReadFile(d.log) + if err != nil { + bad = append(bad, d.name+": log unreadable: "+err.Error()) + continue + } + seen := 0 for _, l := range strings.Split(string(raw), "\n") { if !strings.Contains(l, "assignment stream delivery") || !strings.Contains(l, tag) { continue } + seen++ if !strings.Contains(l, fmt.Sprintf("data=%q", owner.data)) || !strings.Contains(l, fmt.Sprintf("ctrl=%q", owner.ctrl)) { bad = append(bad, d.name+": "+strings.TrimSpace(l)) } } + if seen == 0 { // positive evidence per recipient: a check that saw no forced-epoch delivery proves nothing + bad = append(bad, d.name+": no epoch delivery logged") + } } return bad } diff --git a/seaweed-block/core/authority/line_owner_snapshot_test.go b/seaweed-block/core/authority/line_owner_snapshot_test.go index ea6177c519..5125f8462f 100644 --- a/seaweed-block/core/authority/line_owner_snapshot_test.go +++ b/seaweed-block/core/authority/line_owner_snapshot_test.go @@ -45,9 +45,12 @@ func TestBuildSnapshotTakesTheMovedLinesReplicaFromItsOwner(t *testing.T) { // a move minted the line but its owner is unknown: NO server supplies the replica's facts, so the returning // placement server's fresh report changes nothing (no endpoint change, hence no refresh) unknown := ownerReader{fakeReaderForHost: reader.fakeReaderForHost, owner: map[string]PublishedLine{"v1": {ReplicaID: "r1", Epoch: 2, OwnerFromMove: true}}} + // exact outcome: the volume is not supported, or the replica is the no-observation placeholder (no server, the + // line's own endpoints, nothing reachable/ready/eligible): neither s1's nor s2's report may supply it if v, ok := findSupported(BuildSnapshot(store.Snapshot(), topo, unknown), "v1"); ok { - if r1, _ := candidateByReplica(v, "r1"); r1.ServerID == "s1" || r1.DataAddr == "old-s1:1" || (r1.DataAddr != "" && r1.DataAddr != "owner-s2:1") { - t.Fatalf("unknown owner: candidate %+v takes the placement server's report (want no server's facts)", r1) + want := ReplicaCandidate{ReplicaID: "r1", DataAddr: "owner-s2:1", CtrlAddr: "owner-s2:2"} + if r1, _ := candidateByReplica(v, "r1"); r1 != want { + t.Fatalf("unknown owner: candidate %+v, want exactly the no-observation placeholder %+v (no server's facts)", r1, want) } } // without a move-named owner the accepted topology stands (control) From 564c0df27f500f55f9057e50e2128ad43f474649 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:12:31 -0800 Subject: [PATCH 146/204] fix(blockvolume): restore workspace drain diagnostic --- seaweed-block/cmd/blockvolume/process_exit.go | 1 + 1 file changed, 1 insertion(+) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index 88c03b0c0c..d86fb0aa29 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -158,6 +158,7 @@ func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan case <-e.done: return nil, done case request := <-requests: + fmt.Fprintln(os.Stderr, "blockvolume: stopping: the workspace lease guard fenced and requested the drain") e.stopChunkStartup() out := workspaceExit{reason: "revoked"} if !h.WorkspaceLeaseRevoking() { From 34675c093065c30a6cb3e14eb21c00d74d0e1ca3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 00:28:20 -0800 Subject: [PATCH 147/204] blockvolume: no frontend listens and status is not primary-ready until the backend admits I/O A restarted old holder (G-O2 r8) started its NVMe target unconditionally at startup and reported FrontendPrimaryReady=true from the authority view alone, before and after its chunk-layer claim was refused ("fenced, not serving"). The admit gate refused every command with Namespace Not Ready, but that status is retried on the same path and then fails to the guest, and the path advertised ANA optimized, so a listening, ready-looking but fenced target is not safe. - status: FrontendPrimaryReady is false while the volume's local durable backend admits no I/O (attach pending, fenced, detached), with the backend's evidence in the new NotReadyReason; Healthy stays the authority view. - blockvolume: the iSCSI, NVMe and ublk targets start only once the backend first admits I/O (awaitBackendAdmitsIO, 10 ms); signals and the workspace lease guard now start before that wait, and a stop requested during it skips the frontends and goes straight to shutdown. INV-FE-PRIMARY-READY-OPERATIONAL-001 (304 rows, 218 ACTIVE); M1 Recovering -> Serving names the guard. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/frontend_gate.go | 42 ++ .../cmd/blockvolume/frontend_gate_test.go | 85 ++++ seaweed-block/cmd/blockvolume/main.go | 418 ++++++++++-------- .../frontend/durable/first_serving_test.go | 49 ++ .../core/frontend/durable/storage_adapter.go | 26 +- .../core/host/volume/status_server.go | 43 +- .../core/host/volume/status_server_test.go | 86 ++++ .../core/host/volume/status_warnings_test.go | 2 +- seaweed-block/docs/design/invariants.md | 7 +- seaweed-block/docs/status-schema.md | 3 +- 10 files changed, 554 insertions(+), 207 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/frontend_gate.go create mode 100644 seaweed-block/cmd/blockvolume/frontend_gate_test.go create mode 100644 seaweed-block/core/frontend/durable/first_serving_test.go diff --git a/seaweed-block/cmd/blockvolume/frontend_gate.go b/seaweed-block/cmd/blockvolume/frontend_gate.go new file mode 100644 index 0000000000..69a5b84bdc --- /dev/null +++ b/seaweed-block/cmd/blockvolume/frontend_gate.go @@ -0,0 +1,42 @@ +package main + +import ( + "fmt" + "os" +) + +// workspaceStopWait is what the process's one stop waiter (waitWorkspaceStop) +// returned: the lease drain request to honour, and the lease guard's done +// channel (nil once consumed). +type workspaceStopWait struct { + leaseStop *workspaceStopRequest + leaseDone <-chan error +} + +// awaitFrontendStart races the backend's first admitted I/O against the stop +// waiter (INV-FE-PRIMARY-READY-OPERATIONAL-001). serving is closed the first +// time the backend admits I/O (for a chunk volume: after its storage claim); +// nil means there is no durable backend to wait for. It returns start = true +// when the frontends may start; otherwise the stop that won, which the caller +// shuts down with exactly as after the frontends. A stop decided meanwhile by +// INV-WS-STARTUP-RETRY-001 (exit 75 or 78) ends the stop waiter too, so a +// refused claim never starts a frontend. +func awaitFrontendStart(serving <-chan struct{}, stopWait <-chan workspaceStopWait) (stopped *workspaceStopWait, start bool) { + if serving == nil { + return nil, true + } + select { + case <-serving: + return nil, true + default: + } + fmt.Fprintln(os.Stderr, "blockvolume: frontends wait for the storage claim: the backend admits no I/O yet") + select { + case <-serving: + fmt.Fprintln(os.Stderr, "blockvolume: backend admits I/O: starting the frontends") + return nil, true + case w := <-stopWait: + fmt.Fprintln(os.Stderr, "blockvolume: stopping before any frontend started") + return &w, false + } +} diff --git a/seaweed-block/cmd/blockvolume/frontend_gate_test.go b/seaweed-block/cmd/blockvolume/frontend_gate_test.go new file mode 100644 index 0000000000..d250af7539 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/frontend_gate_test.go @@ -0,0 +1,85 @@ +package main + +import ( + "context" + "testing" + "time" +) + +type gateResult struct { + stopped *workspaceStopWait + start bool +} + +func runGate(serving <-chan struct{}, stopWait <-chan workspaceStopWait) <-chan gateResult { + out := make(chan gateResult, 1) + go func() { + s, ok := awaitFrontendStart(serving, stopWait) + out <- gateResult{s, ok} + }() + return out +} + +// INV-FE-PRIMARY-READY-OPERATIONAL-001: the frontends start only once the +// backend first admits I/O. With no durable backend, and with a backend that +// already serves, they start at once. Sampled every 10 ms while the backend +// admits no I/O (a chunk volume before its storage claim), the gate never +// releases; it releases as soon as the backend's first-serving channel closes. +func TestFrontendGateWaitsForTheStorageClaim(t *testing.T) { + for name, serving := range map[string]chan struct{}{"no durable backend": nil, "already serving": make(chan struct{})} { + if serving != nil { + close(serving) + } + var ch <-chan struct{} + if serving != nil { + ch = serving + } + select { + case r := <-runGate(ch, make(chan workspaceStopWait)): + if !r.start || r.stopped != nil { + t.Fatalf("%s: %+v, want the frontends started at once", name, r) + } + case <-time.After(time.Second): + t.Fatalf("%s: the gate did not release at once", name) + } + } + + serving := make(chan struct{}) + res := runGate(serving, make(chan workspaceStopWait)) + for i := 0; i < 30; i++ { // 300 ms of samples while the claim is pending + select { + case r := <-res: + t.Fatalf("sample %d: the gate released (%+v) before the backend admitted I/O", i, r) + case <-time.After(10 * time.Millisecond): + } + } + close(serving) // the storage claim succeeded + select { + case r := <-res: + if !r.start { + t.Fatalf("after the claim: %+v, want the frontends started", r) + } + case <-time.After(time.Second): + t.Fatal("the gate did not release after the backend admitted I/O") + } +} + +// A refused claim never closes the first-serving channel; the process's stop +// waiter then wins (a signal, the lease guard, or INV-WS-STARTUP-RETRY-001's +// latched exit 75/78) and no frontend starts: the stop is handed back for +// the ordinary shutdown, its lease drain request included. +func TestFrontendGateStopsWithoutStartingTheFrontends(t *testing.T) { + stopWait := make(chan workspaceStopWait, 1) + res := runGate(make(chan struct{}), stopWait) // fenced: never serves + select { + case r := <-res: + t.Fatalf("a backend that never serves released the gate: %+v", r) + case <-time.After(100 * time.Millisecond): + } + req := &workspaceStopRequest{ctx: context.Background()} + stopWait <- workspaceStopWait{leaseStop: req} + r := <-res + if r.start || r.stopped == nil || r.stopped.leaseStop != req { + t.Fatalf("stop before serving: %+v, want no frontends and the lease drain request handed back", r) + } +} diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index a49a250db3..5ffa393c22 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -1019,70 +1019,163 @@ func runVolume(f flags, exits *processExit) int { var iscsiTarget *iscsi.Target var frontendTargets []*control.FrontendTarget - if f.iscsiListen != "" { - prov := provider - var probeProvider iscsi.ProbeBackendProvider - if durableProv != nil { - probeProvider = &durableProbeProvider{provider: durableProv} - } - negotiation := iscsi.NegotiableConfig{} - if f.iscsiCHAPSecret != "" { - negotiation = iscsi.DefaultNegotiableConfig() - negotiation.CHAP = iscsi.CHAPConfig{ - Username: f.iscsiCHAPUser, - Secret: f.iscsiCHAPSecret, - } - } - iscsiTarget = iscsi.NewTarget(iscsi.TargetConfig{ - Listen: f.iscsiListen, - IQN: f.iscsiIQN, - PortalAddr: f.iscsiPortalAddr, - VolumeID: f.volumeID, - Provider: prov, - ProbeProvider: probeProvider, - Negotiation: negotiation, - DataOutTimeout: f.iscsiDataOutTTL, - Handler: iscsi.HandlerConfig{ - BlockSize: frontendBlockSize, - VolumeSize: frontendVolumeSize, - ALUA: newProjectionALUAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.iscsiIQN), - }, - }) - iscsiAddr, err := iscsiTarget.Start() - if err != nil { - fmt.Fprintln(os.Stderr, "blockvolume: iscsi target:", err) - if status != nil { - shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) - _ = status.Close(shutCtx) - shutCancel() - } - _ = h.Close() - return 1 - } - _ = json.NewEncoder(os.Stdout).Encode(iscsiReadyLine{ - Component: "blockvolume", - Phase: "iscsi-listening", - IscsiAddr: iscsiAddr, - IQN: f.iscsiIQN, - }) - frontendTargets = append(frontendTargets, &control.FrontendTarget{ - Protocol: "iscsi", - Addr: iscsiAddr, - Iqn: f.iscsiIQN, - Lun: uint32(f.iscsiLUN), - }) - h.SetFrontendTargets(frontendTargets) - } - var nvmeTarget interface { Start() (string, error) Close() error } - if f.nvmeListen != "" { - if f.nvmeTransport == "rdma" { - start := nvmeRDMAListenerStartDecision(true, nvmeRDMAPreflightFacts(f.nvmeListen)) - if !start.allowed { - fmt.Fprintf(os.Stderr, "blockvolume: nvme rdma start refused: reason=%s\n", start.reason) + var ublkTarget *ublk.Target + + // One startup order (INV-FE-PRIMARY-READY-OPERATIONAL-001 with + // INV-WS-STARTUP-RETRY-001): the workspace lease guard and the process's + // one stop waiter (waitWorkspaceStop: signal, lease drain request, lease + // end, or the latched startup outcome) run from here, before any frontend; + // the frontends start only when the backend first admits I/O, and never + // if a stop wins that race. + shutdownCtx := exits.parent + var leaseRequests <-chan workspaceStopRequest + var leaseDone <-chan error + if f.workspaceLease { + leaseRequests, leaseDone = startWorkspaceLease(shutdownCtx, h) + } + stopWait := make(chan workspaceStopWait, 1) + go func(requests <-chan workspaceStopRequest, done <-chan error) { + ls, ld := waitWorkspaceStop(exits, f, h, requests, done) + stopWait <- workspaceStopWait{leaseStop: ls, leaseDone: ld} + }(leaseRequests, leaseDone) + var serving <-chan struct{} // nil: no durable backend, start at once + if durableProv != nil { + if b := durableProv.Backend(f.volumeID); b != nil { + serving = b.FirstServing() + } + } + stopped, startFrontends := awaitFrontendStart(serving, stopWait) + if startFrontends { + if f.iscsiListen != "" { + prov := provider + var probeProvider iscsi.ProbeBackendProvider + if durableProv != nil { + probeProvider = &durableProbeProvider{provider: durableProv} + } + negotiation := iscsi.NegotiableConfig{} + if f.iscsiCHAPSecret != "" { + negotiation = iscsi.DefaultNegotiableConfig() + negotiation.CHAP = iscsi.CHAPConfig{ + Username: f.iscsiCHAPUser, + Secret: f.iscsiCHAPSecret, + } + } + iscsiTarget = iscsi.NewTarget(iscsi.TargetConfig{ + Listen: f.iscsiListen, + IQN: f.iscsiIQN, + PortalAddr: f.iscsiPortalAddr, + VolumeID: f.volumeID, + Provider: prov, + ProbeProvider: probeProvider, + Negotiation: negotiation, + DataOutTimeout: f.iscsiDataOutTTL, + Handler: iscsi.HandlerConfig{ + BlockSize: frontendBlockSize, + VolumeSize: frontendVolumeSize, + ALUA: newProjectionALUAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.iscsiIQN), + }, + }) + iscsiAddr, err := iscsiTarget.Start() + if err != nil { + fmt.Fprintln(os.Stderr, "blockvolume: iscsi target:", err) + if status != nil { + shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) + _ = status.Close(shutCtx) + shutCancel() + } + _ = h.Close() + return 1 + } + _ = json.NewEncoder(os.Stdout).Encode(iscsiReadyLine{ + Component: "blockvolume", + Phase: "iscsi-listening", + IscsiAddr: iscsiAddr, + IQN: f.iscsiIQN, + }) + frontendTargets = append(frontendTargets, &control.FrontendTarget{ + Protocol: "iscsi", + Addr: iscsiAddr, + Iqn: f.iscsiIQN, + Lun: uint32(f.iscsiLUN), + }) + h.SetFrontendTargets(frontendTargets) + } + + if f.nvmeListen != "" { + if f.nvmeTransport == "rdma" { + start := nvmeRDMAListenerStartDecision(true, nvmeRDMAPreflightFacts(f.nvmeListen)) + if !start.allowed { + fmt.Fprintf(os.Stderr, "blockvolume: nvme rdma start refused: reason=%s\n", start.reason) + if iscsiTarget != nil { + _ = iscsiTarget.Close() + } + if replListen != nil { + replListen.Stop() + } + if replVolume != nil { + _ = replVolume.Close() + } + if durableProv != nil { + _ = durableProv.Close() + } + if status != nil { + shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) + _ = status.Close(shutCtx) + shutCancel() + } + _ = h.Close() + return 1 + } + blockSize := frontendBlockSize + volumeSize := frontendVolumeSize + if blockSize == 0 { + blockSize = nvme.DefaultBlockSize + } + if volumeSize == 0 { + volumeSize = nvme.DefaultVolumeBlocks * uint64(blockSize) + } + nvmeTarget = nvmerdma.NewTarget(nvmerdma.TargetConfig{ + Listen: f.nvmeListen, + SubsysNQN: f.nvmeSubsysNQN, + VolumeID: f.volumeID, + NSID: uint32(f.nvmeNS), + BlockSize: blockSize, + VolumeSize: volumeSize, + Provider: provider, + }) + } else { + var probeProvider nvme.ProbeBackendProvider + if durableProv != nil { + probeProvider = &durableProbeProvider{provider: durableProv} + } + nvmeTarget = nvme.NewTarget(nvme.TargetConfig{ + Transport: nvme.TransportTCP, + Listen: f.nvmeListen, + SubsysNQN: f.nvmeSubsysNQN, + VolumeID: f.volumeID, + Provider: provider, + ProbeProvider: probeProvider, + ControllerID: nvmeControllerIDFromReplicaID(f.replicaID), + MaxH2CDataLength: uint32(f.nvmeMaxH2C), + Handler: nvme.HandlerConfig{ + NSID: uint32(f.nvmeNS), + BlockSize: frontendBlockSize, + VolumeSize: frontendVolumeSize, + ANA: newProjectionANAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.nvmeSubsysNQN), + }, + }) + } + nvmeAddr, err := nvmeTarget.Start() + if err != nil { + if f.nvmeTransport == "rdma" { + fmt.Fprintf(os.Stderr, "blockvolume: nvme rdma start refused: reason=%s error=%v\n", nvmeRDMATargetStartFailureReason(err), err) + } else { + fmt.Fprintln(os.Stderr, "blockvolume: nvme target:", err) + } if iscsiTarget != nil { _ = iscsiTarget.Close() } @@ -1103,6 +1196,34 @@ func runVolume(f flags, exits *processExit) int { _ = h.Close() return 1 } + if status != nil { + status.SetNVMeListenerReady(true) + } + _ = json.NewEncoder(os.Stdout).Encode(nvmeReadyLine{ + Component: "blockvolume", + Phase: "nvme-listening", + NvmeAddr: nvmeAddr, + SubsysNQN: f.nvmeSubsysNQN, + }) + if shouldPublishNVMeFrontendTarget(f.nvmeTransport) { + frontendTargets = append(frontendTargets, &control.FrontendTarget{ + Protocol: "nvme", + Transport: f.nvmeTransport, + Addr: nvmeAddr, + Nqn: f.nvmeSubsysNQN, + Nsid: uint32(f.nvmeNS), + }) + h.SetFrontendTargets(frontendTargets) + } + if status != nil { + status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, f.nvmeTransport, true)) + if source, ok := nvmeTarget.(interface{ Stats() nvme.Stats }); ok { + status.SetNVMeStatusSource(source) + } + } + } + + if f.ublkDevice >= 0 { blockSize := frontendBlockSize volumeSize := frontendVolumeSize if blockSize == 0 { @@ -1111,153 +1232,58 @@ func runVolume(f flags, exits *processExit) int { if volumeSize == 0 { volumeSize = nvme.DefaultVolumeBlocks * uint64(blockSize) } - nvmeTarget = nvmerdma.NewTarget(nvmerdma.TargetConfig{ - Listen: f.nvmeListen, - SubsysNQN: f.nvmeSubsysNQN, + ublkTarget = ublk.NewTarget(ublk.TargetConfig{ VolumeID: f.volumeID, - NSID: uint32(f.nvmeNS), + Provider: provider, + DevID: f.ublkDevice, BlockSize: blockSize, VolumeSize: volumeSize, - Provider: provider, + Queues: f.ublkQueues, + QueueDepth: f.ublkQueueDepth, }) - } else { - var probeProvider nvme.ProbeBackendProvider - if durableProv != nil { - probeProvider = &durableProbeProvider{provider: durableProv} - } - nvmeTarget = nvme.NewTarget(nvme.TargetConfig{ - Transport: nvme.TransportTCP, - Listen: f.nvmeListen, - SubsysNQN: f.nvmeSubsysNQN, - VolumeID: f.volumeID, - Provider: provider, - ProbeProvider: probeProvider, - ControllerID: nvmeControllerIDFromReplicaID(f.replicaID), - MaxH2CDataLength: uint32(f.nvmeMaxH2C), - Handler: nvme.HandlerConfig{ - NSID: uint32(f.nvmeNS), - BlockSize: frontendBlockSize, - VolumeSize: frontendVolumeSize, - ANA: newProjectionANAProvider(h.ProjectionView(), f.volumeID, f.replicaID, f.nvmeSubsysNQN), - }, - }) - } - nvmeAddr, err := nvmeTarget.Start() - if err != nil { - if f.nvmeTransport == "rdma" { - fmt.Fprintf(os.Stderr, "blockvolume: nvme rdma start refused: reason=%s error=%v\n", nvmeRDMATargetStartFailureReason(err), err) - } else { - fmt.Fprintln(os.Stderr, "blockvolume: nvme target:", err) - } - if iscsiTarget != nil { - _ = iscsiTarget.Close() - } - if replListen != nil { - replListen.Stop() - } - if replVolume != nil { - _ = replVolume.Close() - } - if durableProv != nil { - _ = durableProv.Close() + ublkPath, err := ublkTarget.Start() + if err != nil { + fmt.Fprintln(os.Stderr, "blockvolume: ublk device:", err) + if nvmeTarget != nil { + _ = nvmeTarget.Close() + } + if iscsiTarget != nil { + _ = iscsiTarget.Close() + } + if replListen != nil { + replListen.Stop() + } + if replVolume != nil { + _ = replVolume.Close() + } + if durableProv != nil { + _ = durableProv.Close() + } + if status != nil { + shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) + _ = status.Close(shutCtx) + shutCancel() + } + _ = h.Close() + return 1 } if status != nil { - shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) - _ = status.Close(shutCtx) - shutCancel() + status.SetUblkStatusSource(ublkTarget) } - _ = h.Close() - return 1 - } - if status != nil { - status.SetNVMeListenerReady(true) - } - _ = json.NewEncoder(os.Stdout).Encode(nvmeReadyLine{ - Component: "blockvolume", - Phase: "nvme-listening", - NvmeAddr: nvmeAddr, - SubsysNQN: f.nvmeSubsysNQN, - }) - if shouldPublishNVMeFrontendTarget(f.nvmeTransport) { - frontendTargets = append(frontendTargets, &control.FrontendTarget{ - Protocol: "nvme", - Transport: f.nvmeTransport, - Addr: nvmeAddr, - Nqn: f.nvmeSubsysNQN, - Nsid: uint32(f.nvmeNS), + _ = json.NewEncoder(os.Stdout).Encode(ublkReadyLine{ + Component: "blockvolume", + Phase: "ublk-ready", + Device: ublkPath, }) - h.SetFrontendTargets(frontendTargets) } - if status != nil { - status.SetFrontendCapabilities(nvmeFrontendCapabilities(f.nvmeListen, f.nvmeTransport, true)) - if source, ok := nvmeTarget.(interface{ Stats() nvme.Stats }); ok { - status.SetNVMeStatusSource(source) - } - } - } + } // startFrontends - var ublkTarget *ublk.Target - if f.ublkDevice >= 0 { - blockSize := frontendBlockSize - volumeSize := frontendVolumeSize - if blockSize == 0 { - blockSize = nvme.DefaultBlockSize - } - if volumeSize == 0 { - volumeSize = nvme.DefaultVolumeBlocks * uint64(blockSize) - } - ublkTarget = ublk.NewTarget(ublk.TargetConfig{ - VolumeID: f.volumeID, - Provider: provider, - DevID: f.ublkDevice, - BlockSize: blockSize, - VolumeSize: volumeSize, - Queues: f.ublkQueues, - QueueDepth: f.ublkQueueDepth, - }) - ublkPath, err := ublkTarget.Start() - if err != nil { - fmt.Fprintln(os.Stderr, "blockvolume: ublk device:", err) - if nvmeTarget != nil { - _ = nvmeTarget.Close() - } - if iscsiTarget != nil { - _ = iscsiTarget.Close() - } - if replListen != nil { - replListen.Stop() - } - if replVolume != nil { - _ = replVolume.Close() - } - if durableProv != nil { - _ = durableProv.Close() - } - if status != nil { - shutCtx, shutCancel := context.WithTimeout(context.Background(), 2*time.Second) - _ = status.Close(shutCtx) - shutCancel() - } - _ = h.Close() - return 1 - } - if status != nil { - status.SetUblkStatusSource(ublkTarget) - } - _ = json.NewEncoder(os.Stdout).Encode(ublkReadyLine{ - Component: "blockvolume", - Phase: "ublk-ready", - Device: ublkPath, - }) + // The one stop waiter has already returned if a stop won the race above. + if stopped == nil { + w := <-stopWait + stopped = &w } - - shutdownCtx := exits.parent - var leaseRequests <-chan workspaceStopRequest - var leaseDone <-chan error - if f.workspaceLease { - leaseRequests, leaseDone = startWorkspaceLease(shutdownCtx, h) - } - leaseStop, leaseDone := waitWorkspaceStop(exits, f, h, leaseRequests, leaseDone) + leaseStop, leaseDone := stopped.leaseStop, stopped.leaseDone // The resource owner performs shutdown. The lease callback waits for this // exact drain; it cannot ACK a merely requested or failed close. h.FenceWorkspaceLease() diff --git a/seaweed-block/core/frontend/durable/first_serving_test.go b/seaweed-block/core/frontend/durable/first_serving_test.go new file mode 100644 index 0000000000..4cd3e6c097 --- /dev/null +++ b/seaweed-block/core/frontend/durable/first_serving_test.go @@ -0,0 +1,49 @@ +package durable_test + +import ( + "context" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" +) + +// INV-FE-PRIMARY-READY-OPERATIONAL-001: a non-chunk durable volume admits I/O +// right after open and recovery (the role, primary or supporting, does not +// enter), so its first-serving channel is already closed and its frontends +// start at once, as before the gate. A later loss of readiness does not +// reopen the channel (the process exit owns that window). +func TestDurableProvider_NonChunkVolumeServesRightAfterOpen(t *testing.T) { + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: 64, + }, v1View()) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { p.Close() }) + if _, err := p.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + b := p.Backend("v1") + if b == nil { + t.Fatal("no backend after EnsureStorage") + } + select { + case <-b.FirstServing(): + t.Fatal("first-serving closed before recovery") + default: + } + if _, err := p.RecoverVolume(context.Background(), "v1"); err != nil { + t.Fatal(err) + } + select { + case <-b.FirstServing(): + default: + t.Fatal("a recovered non-chunk volume has not admitted I/O: its frontends would wait") + } + b.SetOperational(false, "test: readiness lost") + select { + case <-b.FirstServing(): + default: + t.Fatal("a later loss of readiness reopened the first-serving channel") + } +} diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 98c7023841..703b005ad7 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -181,6 +181,11 @@ type StorageBackend struct { readyChanged chan struct{} operational atomic.Bool opEvidence atomic.Value // string + // firstServing is closed the first time the backend admits I/O (under + // mu); it never reopens. INV-FE-PRIMARY-READY-OPERATIONAL-001: the + // frontends start on it. + firstServing chan struct{} + served bool // under mu: firstServing is closed // ioMu is the I/O admission boundary: every Read, Write and Sync holds // its read side for the whole operation, gate included, so StopIO can @@ -221,10 +226,11 @@ type StorageBackend struct { // impl changes it mid-session). func NewStorageBackend(s storage.LogicalStorage, view frontend.ProjectionView, id frontend.Identity) *StorageBackend { b := &StorageBackend{ - storage: s, - view: view, - id: id, - blockSize: s.BlockSize(), + storage: s, + view: view, + id: id, + blockSize: s.BlockSize(), + firstServing: make(chan struct{}), } b.opEvidence.Store("awaiting first SetOperational") // operational.Store(false) is zero-value default; be explicit. @@ -488,11 +494,23 @@ func (b *StorageBackend) SetOperational(ok bool, evidence string) { b.mu.Unlock() } +// FirstServing is closed the first time the backend admits I/O (for a chunk +// volume: after its storage claim succeeded) and never reopens. A later loss +// of readiness does not reopen it: the process exit of +// INV-WS-STARTUP-RETRY-001 owns that window. +func (b *StorageBackend) FirstServing() <-chan struct{} { return b.firstServing } + // The caller owns mu; publication never calls the store or waits for I/O. func (b *StorageBackend) setOperationalLocked(ok bool, evidence string) { flipped := !ok && b.operational.Load() b.opEvidence.Store(evidence) b.operational.Store(ok) + if ok && !b.served { + b.served = true + if b.firstServing != nil { // nil only for a backend built without NewStorageBackend + close(b.firstServing) + } + } if flipped { b.stopFlipAt = time.Now() // after the store: no gate after this instant admits } diff --git a/seaweed-block/core/host/volume/status_server.go b/seaweed-block/core/host/volume/status_server.go index cea8a7c79d..ccd1bd53d0 100644 --- a/seaweed-block/core/host/volume/status_server.go +++ b/seaweed-block/core/host/volume/status_server.go @@ -187,8 +187,15 @@ type StatusProjection struct { // Memory is the process's memory use at the time of the request. Memory ProcessMemoryStatus // FrontendPrimaryReady: this replica is the healthy, non-superseded - // primary and may serve guest I/O. + // primary, its local durable backend admits I/O, and it may serve guest + // I/O (INV-FE-PRIMARY-READY-OPERATIONAL-001). FrontendPrimaryReady bool + // NotReadyReason says why FrontendPrimaryReady is false, first match: the + // local durable backend admits no I/O (its evidence: attach pending, + // fenced, detached) or has no status for the volume; the frontend target + // is not listening yet; this replica is not the healthy primary. Empty + // when ready. + NotReadyReason string `json:",omitempty"` // AuthorityRole is primary, superseded or unknown. AuthorityRole string // ReplicationRole is none (a primary), recovering, not_ready, @@ -485,17 +492,47 @@ func (s *StatusServer) handleStatusNVMe(w http.ResponseWriter, r *http.Request) func (s *StatusServer) statusProjection() StatusProjection { p := s.authorityProjection() + authorityReady := p.FrontendPrimaryReady s.mu.Lock() - p.Healthy = p.Healthy && !s.nvmePending - p.FrontendPrimaryReady = p.FrontendPrimaryReady && !s.nvmePending + nvmePending := s.nvmePending + p.Healthy = p.Healthy && !nvmePending + p.FrontendPrimaryReady = p.FrontendPrimaryReady && !nvmePending src := s.durableSource s.mu.Unlock() + // INV-FE-PRIMARY-READY-OPERATIONAL-001: not FrontendPrimaryReady while the + // local backend admits no I/O (before the storage claim of a chunk volume, + // after a refused claim: fenced, after a detach), and not when there is no + // durable status for the volume at all (fail closed). The authority view + // alone (the adapter's PublishHealthy) is not readiness; Healthy stays that + // view. Whenever FrontendPrimaryReady is false, NotReadyReason says why. + backendReason := "" if src != nil { // outside s.mu: the provider takes its own lock + found := false for _, st := range src.DurableStatuses() { if st.VolumeID == p.VolumeID { + found = true p.Warnings = append(p.Warnings, st.Warnings...) + if !st.Operational { + backendReason = "durable backend not operational: " + st.Evidence + } } } + if !found { + backendReason = "no durable status for volume " + p.VolumeID + } + } + if backendReason != "" { + p.FrontendPrimaryReady = false + } + if !p.FrontendPrimaryReady { + switch { + case backendReason != "": + p.NotReadyReason = backendReason + case nvmePending: + p.NotReadyReason = "frontend target not listening yet" + case !authorityReady: + p.NotReadyReason = "not the healthy primary: authority role " + p.AuthorityRole + ", replication role " + p.ReplicationRole + } } return p } diff --git a/seaweed-block/core/host/volume/status_server_test.go b/seaweed-block/core/host/volume/status_server_test.go index cbdf18d3eb..1e341c9a3d 100644 --- a/seaweed-block/core/host/volume/status_server_test.go +++ b/seaweed-block/core/host/volume/status_server_test.go @@ -1183,3 +1183,89 @@ func TestStatusServer_UblkStatusEndpoint(t *testing.T) { resp.Body.Close() } } + +// INV-FE-PRIMARY-READY-OPERATIONAL-001: a healthy primary authority view is +// not readiness. While the volume's local durable backend admits no I/O +// (a chunk volume awaiting its attach, a refused claim: fenced, a detach), +// /status does not report FrontendPrimaryReady and says why (NotReadyReason), +// while Healthy stays the authority view; once the backend admits I/O, +// readiness follows the authority view again. A status for another +// volume does not count. +func TestStatusServer_ReadyOnlyWhileBackendOperational(t *testing.T) { + p := stubProjector{p: engine.ReplicaProjection{Mode: engine.ModeHealthy, Epoch: 2, EndpointVersion: 2}} + s := NewStatusServer(NewAdapterProjectionView(p, "v1", "r1", nil)) + addr, err := s.Start("127.0.0.1:0") + if err != nil { + t.Fatalf("start: %v", err) + } + defer func() { _ = s.Close(context.Background()) }() + read := func() StatusProjection { + t.Helper() + resp, err := http.Get("http://" + addr + "/status?volume=v1") + if err != nil { + t.Fatalf("get: %v", err) + } + defer resp.Body.Close() + var body StatusProjection + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + t.Fatalf("decode: %v", err) + } + return body + } + for _, tc := range []struct { + name string + vols []durable.VolumeStatus + want bool + }{ + {"attach pending", []durable.VolumeStatus{{VolumeID: "v1", Operational: false, Evidence: "recovered; chunk layer awaiting master authority"}}, false}, + {"fenced", []durable.VolumeStatus{{VolumeID: "v1", Operational: false, Evidence: "chunk layer attach refused: HEAD holder h1/r1 is not this holder"}}, false}, + {"other volume not operational", []durable.VolumeStatus{{VolumeID: "v2", Operational: false}, {VolumeID: "v1", Operational: true}}, true}, + {"no status for the volume (fail closed)", []durable.VolumeStatus{{VolumeID: "v2", Operational: true}}, false}, + {"operational", []durable.VolumeStatus{{VolumeID: "v1", Operational: true}}, true}, + } { + s.SetDurableStatusSource(stubDurableStatusSource{vols: tc.vols}) + body := read() + if !body.Healthy || body.FrontendPrimaryReady != tc.want || (body.NotReadyReason == "") != tc.want { + t.Errorf("%s: Healthy=%v FrontendPrimaryReady=%v NotReadyReason=%q, want Healthy (the authority view), ready=%v, a reason exactly when not ready", tc.name, body.Healthy, body.FrontendPrimaryReady, body.NotReadyReason, tc.want) + } + } + + // The NVMe listener mask does not hide the backend's reason: with the + // target not yet listening AND the backend fenced, the reason is the + // backend's; with only the listener pending, it says so. + s.SetNVMeListenerReady(false) + s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: false, Evidence: "chunk layer attach refused"}}}) + if body := read(); body.FrontendPrimaryReady || body.NotReadyReason != "durable backend not operational: chunk layer attach refused" { + t.Errorf("listener pending + fenced: ready=%v reason=%q, want the backend's reason", body.FrontendPrimaryReady, body.NotReadyReason) + } + s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: true}}}) + if body := read(); body.FrontendPrimaryReady || body.NotReadyReason != "frontend target not listening yet" { + t.Errorf("listener pending only: ready=%v reason=%q", body.FrontendPrimaryReady, body.NotReadyReason) + } + s.SetNVMeListenerReady(true) +} + +// INV-FE-PRIMARY-READY-OPERATIONAL-001: whenever FrontendPrimaryReady is +// false, NotReadyReason is set, also when the authority view itself is not a +// healthy primary (an observed process before its assignment). +func TestStatusServer_NotReadyAlwaysHasAReason(t *testing.T) { + s := NewStatusServer(NewAdapterProjectionView(stubProjector{}, "v1", "r1", nil)) + addr, err := s.Start("127.0.0.1:0") + if err != nil { + t.Fatalf("start: %v", err) + } + defer func() { _ = s.Close(context.Background()) }() + s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: true}}}) + resp, err := http.Get("http://" + addr + "/status?volume=v1") + if err != nil { + t.Fatalf("get: %v", err) + } + defer resp.Body.Close() + var body StatusProjection + if err := json.NewDecoder(resp.Body).Decode(&body); err != nil { + t.Fatalf("decode: %v", err) + } + if body.FrontendPrimaryReady || body.NotReadyReason == "" { + t.Fatalf("not-ready authority view: ready=%v reason=%q, want not ready with a reason", body.FrontendPrimaryReady, body.NotReadyReason) + } +} diff --git a/seaweed-block/core/host/volume/status_warnings_test.go b/seaweed-block/core/host/volume/status_warnings_test.go index 73bb785e40..ed9c4370fa 100644 --- a/seaweed-block/core/host/volume/status_warnings_test.go +++ b/seaweed-block/core/host/volume/status_warnings_test.go @@ -48,7 +48,7 @@ func statusWarningsCase(t *testing.T, view *AdapterProjectionView, wantHealthy b t.Fatalf("before the warning: healthy=%t ready=%t; want %t", before.Healthy, before.FrontendPrimaryReady, wantHealthy) } s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{ - VolumeID: "v1", Impl: "walstore", Warnings: []string{"wal_hole_suspected: WAL entry at offset=4134 fails its check"}, HolesSuspected: 1, + VolumeID: "v1", Impl: "walstore", Operational: true, Warnings: []string{"wal_hole_suspected: WAL entry at offset=4134 fails its check"}, HolesSuspected: 1, }}}) after := get() if len(after.Warnings) != 1 || after.Warnings[0][:18] != "wal_hole_suspected" { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index db47d15a00..0fecbcfd52 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -60,7 +60,7 @@ stateDiagram-v2 |---|---|---|---|---| | — | Opened | v3 A/B descriptors and owned-map dependencies valid, exclusive file ownership acquired; legacy formats refused; backend starts not operational | `core/storage/walstore.go` `OpenWALStoreWithOptions`; `core/frontend/durable/provider.go` `openOrCreate` | `INV-WAL-OPGATE-001`, `INV-WAL-V3-ACTIVATION-001`, `INV-WAL-V3-DESCRIPTOR-001`, `INV-WAL-V3-MAP-PUBLISH-001` | | Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001` | -| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001` | +| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001` | | Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001`, `INV-WAL-V3-W-RECOVERY-001` | | Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; write admission samples the active writer's native pressure before waiting; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001`, `INV-WAL-V3-ADMISSION-001`, `INV-WAL-V3-W-001` | | Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001`, `INV-WAL-V3-MAP-PRIOR-LIVE-001` | @@ -447,7 +447,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -309 rows: 238 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 294 new. +310 rows: 239 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 295 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -461,6 +461,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-001` | A read or write on a successfully recovered chunk volume awaiting attachment waits for attachment readiness, before storage admission, for at most 3 s or until an earlier caller deadline, on the local monotonic clock. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `admitAfterAttachUnqueued`, `awaitAttachAdmission`, `readyCheck` | `TestWALStoreChunk_PendingReadWaitIsBounded`; `TestWALStoreChunk_PendingReadHonoursEarlierDeadline`; `TestWALStoreChunk_TakeoverWriteWaitsForAttach`; `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-STATUS-001` | An NVMe read or write whose attachment-readiness wait times out or is refused completes with Namespace Not Ready (SC 0x82), DNR=0, without reading or mutating storage. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestWALStoreChunk_TakeoverReadBeforeAttachIsRetryable`; `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestWALStoreChunk_PendingAttachBeyondHostRetryBudget` (`core/frontend/durable/takeover_read_ready_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | +| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target starts listening only after it first does; attach-pending, fenced or no durable status reports not ready with the reason; a fence after the target listens ends the process within 5 s (`INV-WS-STARTUP-RETRY-001`). | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | | `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE | @@ -979,6 +980,8 @@ One row per wait in the data and control paths. Guest-visible rows on one path m | Site | Waits for | Bound | Owner that ends it | On expiry | Lock held while waiting | Guest-visible | |---|---|---|---|---|---|---| | `core/storage/chunk_publish_settled.go` `runPublishSettled` (from `unlockCap`, on the cut or detach caller's goroutine) | the `OnPublishSettled` hook to return | the hook's duration: the hook must return without blocking and without remote calls, enqueueing its work to its own worker | the hook implementer | none: a stalled hook stalls its caller, and later reports queue without a bound (a nil hook queues nothing) | none (`capMu` and `stMu` released) | yes on detach (the detach caller delivers before returning) | +| `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (from `runVolume`, before any frontend starts) | the backend's first admitted I/O (`StorageBackend.FirstServing`), or the process's stop waiter returning | none of its own: it ends on the stop waiter, which INV-WS-STARTUP-RETRY-001 bounds (a refused or timed-out claim latches exit 75/78) | `runVolume` (`INV-FE-PRIMARY-READY-OPERATIONAL-001`) | no frontend starts; shutdown as after the frontends | none | no (no target listens yet) | +| `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched startup outcome | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded) | none | no | Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed scan result preserves trusted records, absolute end, highest LSN, contiguous frontier, trusted DurableLSN and stop cause separately. The W/BASE/fence owner (`WALStore.recoverV3`) must check R < W*, fence and publish bounds before readiness or append admission; neither codec nor scan success is readiness. The installed scan begins at max(BaseCursor, retainedTail). No ACTIVE v2 machine/guard is replaced by this step. diff --git a/seaweed-block/docs/status-schema.md b/seaweed-block/docs/status-schema.md index f6243d2c8d..9556f4fa09 100644 --- a/seaweed-block/docs/status-schema.md +++ b/seaweed-block/docs/status-schema.md @@ -27,7 +27,8 @@ The volume's authority and health projection. Go type `volume.StatusProjection`. | `Memory.SoftLimitBytes` | int64 | the Go soft memory limit in force (--memory-limit-mib or GOMEMLIMIT) | | `Memory.RSSBytes` | uint64 | resident set size from /proc/self/status (VmRSS); 0 off Linux | | `Memory.AnonymousRSSBytes` | uint64 | anonymous resident memory (RssAnon); 0 off Linux | -| `FrontendPrimaryReady` | bool | FrontendPrimaryReady: this replica is the healthy, non-superseded primary and may serve guest I/O. | +| `FrontendPrimaryReady` | bool | FrontendPrimaryReady: this replica is the healthy, non-superseded primary, its local durable backend admits I/O, and it may serve guest I/O (INV-FE-PRIMARY-READY-OPERATIONAL-001). | +| `NotReadyReason` | string | NotReadyReason says why FrontendPrimaryReady is false, first match: the local durable backend admits no I/O (its evidence: attach pending, fenced, detached) or has no status for the volume; the frontend target is not listening yet; this replica is not the healthy primary. Empty when ready. (omitted when empty) | | `AuthorityRole` | string | AuthorityRole is primary, superseded or unknown. | | `ReplicationRole` | string | ReplicationRole is none (a primary), recovering, not_ready, replica_ready or unknown. | | `RoleAdmissionFailure` | string | RoleAdmissionFailure (G1) explains a not-Healthy projection caused by a failed role call on the replica listener; empty otherwise. (omitted when empty) | From 1b675b39d037aec54db0e3f1c5bf1860f756be3e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 01:49:36 -0800 Subject: [PATCH 148/204] blockvolume: lease_not_held reason and a one-time grant log for a workspace primary A workspace primary whose lease guard is missing or holds no granted lease now reports NotReadyReason=lease_not_held first (the guard decides, through the new WorkspaceLeaseGuard.Held, the lease term permits already used). The guard logs its first grant once, as "re-granted after N refused renewal(s)" when renewals were refused first (a restart before the forced-move barrier), with the request-start time in unix_ms. Co-Authored-By: Claude Opus 5.5 --- .../core/host/volume/projection_bridge.go | 10 ++ .../core/host/volume/status_server.go | 12 ++- .../core/host/volume/workspace_lease.go | 34 ++++++- .../host/volume/workspace_lease_held_test.go | 95 +++++++++++++++++++ seaweed-block/docs/status-schema.md | 2 +- 5 files changed, 149 insertions(+), 4 deletions(-) create mode 100644 seaweed-block/core/host/volume/workspace_lease_held_test.go diff --git a/seaweed-block/core/host/volume/projection_bridge.go b/seaweed-block/core/host/volume/projection_bridge.go index 36e89ad268..88d7e23240 100644 --- a/seaweed-block/core/host/volume/projection_bridge.go +++ b/seaweed-block/core/host/volume/projection_bridge.go @@ -124,6 +124,16 @@ func (v *AdapterProjectionView) projectionWithSupersede() (frontend.Projection, return result, superseded } +// workspaceLeaseNotHeld: a workspace primary whose lease guard is not +// installed yet, or does not hold a granted lease now (the guard decides). +func (v *AdapterProjectionView) workspaceLeaseNotHeld() bool { + if !v.workspaceRequired { + return false + } + g := v.workspaceGuard.Load() + return g == nil || !g.Held() +} + func (v *AdapterProjectionView) supportingReplicaReady(selfEpoch, selfEV uint64) bool { if v == nil || v.probe == nil { return false diff --git a/seaweed-block/core/host/volume/status_server.go b/seaweed-block/core/host/volume/status_server.go index ccd1bd53d0..cbf1286ff5 100644 --- a/seaweed-block/core/host/volume/status_server.go +++ b/seaweed-block/core/host/volume/status_server.go @@ -190,7 +190,8 @@ type StatusProjection struct { // primary, its local durable backend admits I/O, and it may serve guest // I/O (INV-FE-PRIMARY-READY-OPERATIONAL-001). FrontendPrimaryReady bool - // NotReadyReason says why FrontendPrimaryReady is false, first match: the + // NotReadyReason says why FrontendPrimaryReady is false, first match: a + // workspace primary holds no granted lease now (NotReadyLeaseNotHeld); the // local durable backend admits no I/O (its evidence: attach pending, // fenced, detached) or has no status for the volume; the frontend target // is not listening yet; this replica is not the healthy primary. Empty @@ -490,6 +491,10 @@ func (s *StatusServer) handleStatusNVMe(w http.ResponseWriter, r *http.Request) _ = json.NewEncoder(w).Encode(NVMeStatus{VolumeID: p.VolumeID, Stats: src.Stats()}) } +// NotReadyLeaseNotHeld: a workspace primary without a granted lease holds at +// the gate (no claim, no listen, not ready); V1-SPEC r2.37. +const NotReadyLeaseNotHeld = "lease_not_held" + func (s *StatusServer) statusProjection() StatusProjection { p := s.authorityProjection() authorityReady := p.FrontendPrimaryReady @@ -521,11 +526,14 @@ func (s *StatusServer) statusProjection() StatusProjection { backendReason = "no durable status for volume " + p.VolumeID } } - if backendReason != "" { + leaseNotHeld := s.view.workspaceLeaseNotHeld() + if backendReason != "" || leaseNotHeld { p.FrontendPrimaryReady = false } if !p.FrontendPrimaryReady { switch { + case leaseNotHeld: + p.NotReadyReason = NotReadyLeaseNotHeld case backendReason != "": p.NotReadyReason = backendReason case nvmePending: diff --git a/seaweed-block/core/host/volume/workspace_lease.go b/seaweed-block/core/host/volume/workspace_lease.go index 944510ce1e..581140618a 100644 --- a/seaweed-block/core/host/volume/workspace_lease.go +++ b/seaweed-block/core/host/volume/workspace_lease.go @@ -46,6 +46,9 @@ type WorkspaceLeaseGuard struct { // Run from its sleep. stopPending bool kick chan struct{} + // refusedBeforeGrant counts failed renewals before the first grant + // (under mu), for the one grant log line. + refusedBeforeGrant int // after schedules Run's sleep between renewals (time.After; tests // replace it before Run starts to observe the delays chosen). after func(time.Duration) <-chan time.Time @@ -160,10 +163,23 @@ func (g *WorkspaceLeaseGuard) Projection() frontend.Projection { func (g *WorkspaceLeaseGuard) permits(p frontend.Projection) bool { g.mu.Lock() defer g.mu.Unlock() + return g.heldLocked() && p.VolumeID == g.id.VolumeId && p.ReplicaID == g.id.ReplicaId && p.Epoch == g.id.Epoch +} + +// Held reports whether the lease is granted and valid now (the lease term of +// permits, without the projection identity). Never call with mu held. +func (g *WorkspaceLeaseGuard) Held() bool { + g.mu.Lock() + defer g.mu.Unlock() + return g.heldLocked() +} + +// heldLocked latches the expiry fence; the caller owns mu. +func (g *WorkspaceLeaseGuard) heldLocked() bool { if !g.until.IsZero() && !g.now().Before(g.until) { g.fenceLocked(fmt.Sprintf("lease expired at %s without a successful renewal", g.until.UTC().Format(time.RFC3339Nano))) } - return !g.fenced && !g.until.IsZero() && p.VolumeID == g.id.VolumeId && p.ReplicaID == g.id.ReplicaId && p.Epoch == g.id.Epoch + return !g.fenced && !g.until.IsZero() } // Refresh anchors validity to the request START. Reply latency can only shorten @@ -197,6 +213,9 @@ func (g *WorkspaceLeaseGuard) Refresh(ctx context.Context) error { elapsed := end.Sub(start).Round(time.Millisecond) hit := renewalLimitHit(start, end, until) g.mu.Lock() + if g.until.IsZero() { + g.refusedBeforeGrant++ + } expired := !g.until.IsZero() && !end.Before(g.until) if expired { g.fenceLocked(fmt.Sprintf("lease expired after a failed renewal (renewal failed after %s, %s: %v)", elapsed, hit, err)) @@ -235,6 +254,8 @@ func (g *WorkspaceLeaseGuard) Refresh(ctx context.Context) error { case rpcCtx.Err() != nil: g.fenceLocked(fmt.Sprintf("renewal reply arrived after the renewal call's context ended (renewal took %s; lease still valid until %s)", g.now().Sub(start).Round(time.Millisecond), g.until.UTC().Format(time.RFC3339Nano))) } + firstGrant := !g.fenced && g.until.IsZero() + refused := g.refusedBeforeGrant if !g.fenced { g.until = start.Add(time.Duration(reply.ValidForNs)) } @@ -244,6 +265,17 @@ func (g *WorkspaceLeaseGuard) Refresh(ctx context.Context) error { } closed := g.fenced g.mu.Unlock() + if firstGrant { + // Once per guard: the first grant, or the re-grant after refused + // renewals (a restart before the forced-move barrier); unix_ms is the + // request start, which the lease validity is anchored to. + what := "granted" + if refused > 0 { + what = fmt.Sprintf("re-granted after %d refused renewal(s)", refused) + } + log.Printf("workspace lease: %s volume=%s replica=%s epoch=%d valid for %s at unix_ms=%d", + what, g.id.VolumeId, g.id.ReplicaId, g.id.Epoch, time.Duration(reply.ValidForNs), start.UnixMilli()) + } if closed { g.logFence() return g.drain(ctx, reply.Revoking) diff --git a/seaweed-block/core/host/volume/workspace_lease_held_test.go b/seaweed-block/core/host/volume/workspace_lease_held_test.go new file mode 100644 index 0000000000..4c149faa3e --- /dev/null +++ b/seaweed-block/core/host/volume/workspace_lease_held_test.go @@ -0,0 +1,95 @@ +package volume + +import ( + "context" + "errors" + "strings" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/engine" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" +) + +// V1-SPEC r2.37: renewals refused before the first grant (a restart before the +// forced-move barrier) leave the lease not held; the first successful renewal +// is logged as a re-grant after the refused ones, with its time. +func TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals(t *testing.T) { + logs := captureLog(t) + now := time.Unix(1000, 0) + calls := 0 + client := workspaceTestClient{renew: func() (*control.WorkspaceLeaseFact, error) { + calls++ + if calls <= 2 { + return nil, errors.New("workspace forced move lease expiry plus clock-skew margin has not elapsed") + } + return &control.WorkspaceLeaseFact{VolumeId: "v", ReplicaId: "r", Epoch: 1, ValidForNs: int64(10 * time.Second)}, nil + }} + g, err := NewWorkspaceLeaseGuard(workspaceTestView{}, client, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return now }) + if err != nil { + t.Fatal(err) + } + for i := 0; i < 2; i++ { + if err := g.Refresh(context.Background()); err == nil { + t.Fatal("a refused renewal was not reported") + } + if g.Held() || g.Projection().Healthy { + t.Fatal("the lease is held before any grant") + } + } + if strings.Contains(logs.String(), "granted") { + t.Fatalf("a grant was logged before any grant; log=%q", logs.String()) + } + // One successful renewal: with the fake clock a second one would run + // against a real-time context deadline in 1970. + if err := g.Refresh(context.Background()); err != nil { + t.Fatal(err) + } + if !g.Held() || !g.Projection().Healthy { + t.Fatal("the granted lease is not held") + } + out := logs.String() + if n := strings.Count(out, "granted"); n != 1 || !strings.Contains(out, "workspace lease: re-granted after 2 refused renewal(s) volume=v replica=r epoch=1 valid for 10s at unix_ms=1000000") { + t.Fatalf("want exactly one re-grant line with its time, got %d; log=%q", n, out) + } + now = now.Add(11 * time.Second) + if g.Held() { + t.Fatal("an expired lease is still held") + } +} + +// V1-SPEC r2.37: a workspace primary reports NotReadyReason=lease_not_held, +// first, while its guard is missing or holds no granted lease, even with the +// backend admitting I/O; ready once the lease is held; lease_not_held again +// after the guard fences. +func TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease(t *testing.T) { + now := time.Unix(1000, 0) + p := stubProjector{p: engine.ReplicaProjection{Mode: engine.ModeHealthy, Epoch: 1, EndpointVersion: 1}} + view := NewAdapterProjectionView(p, "v1", "r1", nil) + view.workspaceRequired = true + s := NewStatusServer(view) + s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: true}}}) + check := func(name string, wantReady bool) { + t.Helper() + got := s.statusProjection() + if got.FrontendPrimaryReady != wantReady || (!wantReady && got.NotReadyReason != NotReadyLeaseNotHeld) || (wantReady && got.NotReadyReason != "") { + t.Errorf("%s: ready=%v reason=%q, want ready=%v (reason %q when not ready)", name, got.FrontendPrimaryReady, got.NotReadyReason, wantReady, NotReadyLeaseNotHeld) + } + } + check("no guard installed", false) + g, err := NewWorkspaceLeaseGuard(view, workspaceTestClient{}, &control.WorkspaceIdentity{VolumeId: "v1", ReplicaId: "r1", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return now }) + if err != nil { + t.Fatal(err) + } + view.workspaceGuard.Store(g) + check("guard without a grant", false) + g.mu.Lock() + g.until = now.Add(10 * time.Second) + g.mu.Unlock() + check("lease held", true) + g.mu.Lock() + g.fenceLocked("test: revoked") + g.mu.Unlock() + check("guard fenced", false) +} diff --git a/seaweed-block/docs/status-schema.md b/seaweed-block/docs/status-schema.md index 9556f4fa09..93db9c50d6 100644 --- a/seaweed-block/docs/status-schema.md +++ b/seaweed-block/docs/status-schema.md @@ -28,7 +28,7 @@ The volume's authority and health projection. Go type `volume.StatusProjection`. | `Memory.RSSBytes` | uint64 | resident set size from /proc/self/status (VmRSS); 0 off Linux | | `Memory.AnonymousRSSBytes` | uint64 | anonymous resident memory (RssAnon); 0 off Linux | | `FrontendPrimaryReady` | bool | FrontendPrimaryReady: this replica is the healthy, non-superseded primary, its local durable backend admits I/O, and it may serve guest I/O (INV-FE-PRIMARY-READY-OPERATIONAL-001). | -| `NotReadyReason` | string | NotReadyReason says why FrontendPrimaryReady is false, first match: the local durable backend admits no I/O (its evidence: attach pending, fenced, detached) or has no status for the volume; the frontend target is not listening yet; this replica is not the healthy primary. Empty when ready. (omitted when empty) | +| `NotReadyReason` | string | NotReadyReason says why FrontendPrimaryReady is false, first match: a workspace primary holds no granted lease now (NotReadyLeaseNotHeld); the local durable backend admits no I/O (its evidence: attach pending, fenced, detached) or has no status for the volume; the frontend target is not listening yet; this replica is not the healthy primary. Empty when ready. (omitted when empty) | | `AuthorityRole` | string | AuthorityRole is primary, superseded or unknown. | | `ReplicationRole` | string | ReplicationRole is none (a primary), recovering, not_ready, replica_ready or unknown. | | `RoleAdmissionFailure` | string | RoleAdmissionFailure (G1) explains a not-Healthy projection caused by a failed role call on the replica listener; empty otherwise. (omitted when empty) | From 22a540d34d84ef92163fbc22bbdfa259644d72c2 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:15:51 -0800 Subject: [PATCH 149/204] blockvolume: a runtime HEAD fence exits 78 head_fenced; serve only while the lease is held A chunk layer that fences after startup (HEAD has another publication owner) while the lease is still valid now latches the backend not operational with that evidence, and the process owner chooses the no-restart exit 78 head_fenced through processExit.choose. I/O is refused from the fence itself. The first-grant log line is written only for a reply that grants: a first reply that revokes fences the guard and logs no grant. The frontend-gate tests own their workers: cleanup is registered before each worker starts and every receive is bounded. docs/design/invariants.md: INV-WS-SERVE-LEASE-HELD-001 (V1-SPEC r2.37); INV-FE-PRIMARY-READY-OPERATIONAL-001 statement within 300 characters, with the runtime fence enforcement and tests; M1 diagram and table carry the lease-held order and the runtime fence exit; C.W names the runVolume receive of the stop waiter's result. 306 rows, 220 ACTIVE. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/frontend_gate_test.go | 76 ++++++++++------ seaweed-block/cmd/blockvolume/main.go | 1 + seaweed-block/cmd/blockvolume/process_exit.go | 29 ++++++ .../blockvolume/runtime_fence_exit_test.go | 54 +++++++++++ .../core/frontend/durable/provider.go | 3 + .../core/frontend/durable/provider_chunk.go | 1 + .../core/frontend/durable/provider_startup.go | 63 ++++++++++++- .../frontend/durable/runtime_fence_test.go | 89 +++++++++++++++++++ .../core/host/volume/workspace_lease.go | 5 +- .../host/volume/workspace_lease_held_test.go | 31 +++++++ seaweed-block/docs/design/invariants.md | 14 +-- 11 files changed, 329 insertions(+), 37 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go create mode 100644 seaweed-block/core/frontend/durable/runtime_fence_test.go diff --git a/seaweed-block/cmd/blockvolume/frontend_gate_test.go b/seaweed-block/cmd/blockvolume/frontend_gate_test.go index d250af7539..7f6abc571b 100644 --- a/seaweed-block/cmd/blockvolume/frontend_gate_test.go +++ b/seaweed-block/cmd/blockvolume/frontend_gate_test.go @@ -11,13 +11,47 @@ type gateResult struct { start bool } -func runGate(serving <-chan struct{}, stopWait <-chan workspaceStopWait) <-chan gateResult { +// gateWait bounds every receive of a gate result in these tests. +const gateWait = 5 * time.Second + +// runGate runs awaitFrontendStart on serving and a stop channel it owns +// (buffered, returned for the test to send on). Its cleanup, registered +// before the worker starts, releases a gate that is still waiting with a +// stop and joins the worker within gateWait, so a failing check never +// strands it. +func runGate(t *testing.T, serving <-chan struct{}) (<-chan gateResult, chan<- workspaceStopWait) { + t.Helper() out := make(chan gateResult, 1) + stopWait := make(chan workspaceStopWait, 1) + exited := make(chan struct{}) + t.Cleanup(func() { + select { + case stopWait <- workspaceStopWait{}: + default: + } + select { + case <-exited: + case <-time.After(gateWait): + t.Errorf("the gate worker did not exit within %s of a stop", gateWait) + } + }) go func() { + defer close(exited) s, ok := awaitFrontendStart(serving, stopWait) out <- gateResult{s, ok} }() - return out + return out, stopWait +} + +func receiveGate(t *testing.T, res <-chan gateResult, what string) gateResult { + t.Helper() + select { + case r := <-res: + return r + case <-time.After(gateWait): + t.Fatalf("%s: the gate did not return within %s", what, gateWait) + return gateResult{} + } } // INV-FE-PRIMARY-READY-OPERATIONAL-001: the frontends start only once the @@ -26,26 +60,17 @@ func runGate(serving <-chan struct{}, stopWait <-chan workspaceStopWait) <-chan // admits no I/O (a chunk volume before its storage claim), the gate never // releases; it releases as soon as the backend's first-serving channel closes. func TestFrontendGateWaitsForTheStorageClaim(t *testing.T) { - for name, serving := range map[string]chan struct{}{"no durable backend": nil, "already serving": make(chan struct{})} { - if serving != nil { - close(serving) - } - var ch <-chan struct{} - if serving != nil { - ch = serving - } - select { - case r := <-runGate(ch, make(chan workspaceStopWait)): - if !r.start || r.stopped != nil { - t.Fatalf("%s: %+v, want the frontends started at once", name, r) - } - case <-time.After(time.Second): - t.Fatalf("%s: the gate did not release at once", name) + served := make(chan struct{}) + close(served) + for name, ch := range map[string]<-chan struct{}{"no durable backend": nil, "already serving": served} { + res, _ := runGate(t, ch) + if r := receiveGate(t, res, name); !r.start || r.stopped != nil { + t.Fatalf("%s: %+v, want the frontends started at once", name, r) } } serving := make(chan struct{}) - res := runGate(serving, make(chan workspaceStopWait)) + res, _ := runGate(t, serving) for i := 0; i < 30; i++ { // 300 ms of samples while the claim is pending select { case r := <-res: @@ -54,13 +79,8 @@ func TestFrontendGateWaitsForTheStorageClaim(t *testing.T) { } } close(serving) // the storage claim succeeded - select { - case r := <-res: - if !r.start { - t.Fatalf("after the claim: %+v, want the frontends started", r) - } - case <-time.After(time.Second): - t.Fatal("the gate did not release after the backend admitted I/O") + if r := receiveGate(t, res, "after the claim"); !r.start { + t.Fatalf("after the claim: %+v, want the frontends started", r) } } @@ -69,8 +89,7 @@ func TestFrontendGateWaitsForTheStorageClaim(t *testing.T) { // latched exit 75/78) and no frontend starts: the stop is handed back for // the ordinary shutdown, its lease drain request included. func TestFrontendGateStopsWithoutStartingTheFrontends(t *testing.T) { - stopWait := make(chan workspaceStopWait, 1) - res := runGate(make(chan struct{}), stopWait) // fenced: never serves + res, stopWait := runGate(t, make(chan struct{})) // fenced: never serves select { case r := <-res: t.Fatalf("a backend that never serves released the gate: %+v", r) @@ -78,8 +97,7 @@ func TestFrontendGateStopsWithoutStartingTheFrontends(t *testing.T) { } req := &workspaceStopRequest{ctx: context.Background()} stopWait <- workspaceStopWait{leaseStop: req} - r := <-res - if r.start || r.stopped == nil || r.stopped.leaseStop != req { + if r := receiveGate(t, res, "stop before serving"); r.start || r.stopped == nil || r.stopped.leaseStop != req { t.Fatalf("stop before serving: %+v, want no frontends and the lease drain request handed back", r) } } diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 5ffa393c22..893b2af0c5 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -724,6 +724,7 @@ func runVolume(f flags, exits *processExit) int { watchCtx, stopWatch := context.WithCancel(exits.parent) defer stopWatch() go watchChunkStartup(watchCtx, exits, f, h, dp) + go watchChunkRuntimeFence(watchCtx, exits, f, dp) provider = dp if status != nil { status.SetDurableStatusSource(dp) diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index d86fb0aa29..c264aea4bd 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -149,6 +149,35 @@ func watchChunkStartup(ctx context.Context, e *processExit, f flags, h *volume.H } } +// chunkRuntimeFenceProvider reports a runtime HEAD fence of the attached layer. +type chunkRuntimeFenceProvider interface { + ChunkRuntimeFenced(string) bool + ChunkRuntimeFenceUpdates() <-chan struct{} +} + +// watchChunkRuntimeFence: a HEAD fence after startup, while the lease may +// still be valid, ends the process with no restart (78 head_fenced): another +// holder owns HEAD (INV-FE-PRIMARY-READY-OPERATIONAL-001). Workspace chunk +// primaries only. +func watchChunkRuntimeFence(ctx context.Context, e *processExit, f flags, p chunkRuntimeFenceProvider) { + if !f.workspaceLease || f.durableImpl != "walstore-chunk" { + return + } + for { + if p.ChunkRuntimeFenced(f.volumeID) { + e.choose(workspaceExit{exitWorkspaceSuperseded, "head_fenced"}) + return + } + select { + case <-ctx.Done(): + return + case <-e.done: + return + case <-p.ChunkRuntimeFenceUpdates(): + } + } +} + // M2 process exit / Revoking -> Revoked; INV-WS-STARTUP-RETRY-001. func waitWorkspaceStop(e *processExit, f flags, h *volume.Host, requests <-chan workspaceStopRequest, done <-chan error) (*workspaceStopRequest, <-chan error) { select { diff --git a/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go new file mode 100644 index 0000000000..dad78fbec4 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go @@ -0,0 +1,54 @@ +package main + +import ( + "context" + "sync/atomic" + "testing" + "time" +) + +type runtimeFenceStub struct { + fenced atomic.Bool + updates chan struct{} +} + +func (s *runtimeFenceStub) ChunkRuntimeFenced(string) bool { return s.fenced.Load() } +func (s *runtimeFenceStub) ChunkRuntimeFenceUpdates() <-chan struct{} { return s.updates } + +// INV-FE-PRIMARY-READY-OPERATIONAL-001 (condition A): a runtime HEAD fence of +// a workspace chunk primary chooses the no-restart exit 78 head_fenced through +// the process owner's one chooser; nothing is chosen while not fenced, and a +// non-workspace volume never watches. +func TestRuntimeHeadFenceChoosesHeadFencedExit(t *testing.T) { + f := flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v1"} + e := newProcessExit(context.Background()) + stub := &runtimeFenceStub{updates: make(chan struct{}, 1)} + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + done := make(chan struct{}) + go func() { watchChunkRuntimeFence(ctx, e, f, stub); close(done) }() + select { + case out := <-e.decision: + t.Fatalf("an exit was chosen while not fenced: %+v", out) + case <-time.After(100 * time.Millisecond): + } + stub.fenced.Store(true) + stub.updates <- struct{}{} + select { + case out := <-e.decision: + if out != (workspaceExit{exitWorkspaceSuperseded, "head_fenced"}) { + t.Fatalf("exit %+v, want 78 head_fenced", out) + } + case <-time.After(5 * time.Second): + t.Fatal("no exit chosen after the runtime fence") + } + <-done + + plain := newProcessExit(context.Background()) + watchChunkRuntimeFence(ctx, plain, flags{volumeID: "v1"}, stub) // returns at once: not a workspace chunk primary + select { + case out := <-plain.decision: + t.Fatalf("a non-workspace volume chose %+v", out) + default: + } +} diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 19ffa5acc5..220a254251 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -238,6 +238,7 @@ type DurableProvider struct { opening map[string]*sync.Mutex // keyed by volumeID; serializes open/create closed bool startupUpdates chan struct{} // wake only; the generation-bound result stays on the handle + fenceUpdates chan struct{} // wake only; runtimeFenced stays on the handle // testAfterChunkResolve, test-only, runs in CutVolume right after the // volume's handle and layer are resolved. @@ -289,6 +290,7 @@ type volHandle struct { waitGen uint64 startupSuperseded bool // exact foreign-holder claim proof for startupEnded; guarded by p.mu startupEnded uint64 // recovery generation with a terminal startup outcome; guarded by p.mu + runtimeFenced bool // the attached layer fenced after startup (HEAD has another owner); guarded by p.mu chunk storage.ChunkLayer // after RecoverVolume chunkLineage chunkLineage // immutable authority captured by this attachment // Private until the owner commit succeeds; retained for attach retry. @@ -402,6 +404,7 @@ func NewDurableProvider(cfg ProviderConfig, view frontend.ProjectionView) (*Dura closeCtx: closeCtx, closeCancel: closeCancel, startupUpdates: make(chan struct{}, 1), + fenceUpdates: make(chan struct{}, 1), }, nil } diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 17e438f558..6818949132 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -336,6 +336,7 @@ func (p *DurableProvider) attachChunk(ctx context.Context, volumeID string, h *v h.backend.chunkFenced = layer.Fenced h.backend.mu.Unlock() p.startChunkLoop(volumeID, h, layer) + go p.watchChunkFence(volumeID, h, layer) } return nil } diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go index 1d10da2aaf..fb22ace560 100644 --- a/seaweed-block/core/frontend/durable/provider_startup.go +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -1,6 +1,11 @@ package durable -import "errors" +import ( + "errors" + "time" + + "github.com/seaweedfs/seaweed-block/core/storage" +) // ChunkStartupUpdates wakes the process owner when a startup wait ends. It is // not an event queue: the owner must read ChunkStartupOutcome for its volume. @@ -57,3 +62,59 @@ func (p *DurableProvider) ChooseChunkStartupExit(volumeID string, gen uint64, ch choose() return true } + +// chunkFenceWatchInterval bounds how long after a runtime fence the backend +// reports not operational and the process owner is woken. I/O is refused +// from the fence itself (readyCheck reads the layer's latched flag). +const chunkFenceWatchInterval = 50 * time.Millisecond + +// watchChunkFence waits for the attached layer to fence after startup (its +// publication found HEAD owned by another holder or epoch: the layer latches +// fenced only on supersede or owner change, never on a clean detach), then +// latches the backend not operational with that evidence and marks the +// volume runtime-fenced (INV-FE-PRIMARY-READY-OPERATIONAL-001). It ends when +// the provider closes or the layer is no longer this volume's. +func (p *DurableProvider) watchChunkFence(volumeID string, h *volHandle, layer storage.ChunkLayer) { + t := time.NewTicker(chunkFenceWatchInterval) + defer t.Stop() + for { + select { + case <-p.closeCtx.Done(): + return + case <-t.C: + } + p.mu.Lock() + current := !p.closed && p.volumes[volumeID] == h && h.chunk == layer + p.mu.Unlock() + if !current { + return + } + if !layer.Fenced() { + continue + } + h.backend.SetOperational(false, "chunk layer fenced after startup: HEAD has another publication owner") + p.mu.Lock() + if !p.closed && p.volumes[volumeID] == h && h.chunk == layer { + h.runtimeFenced = true + select { + case p.fenceUpdates <- struct{}{}: + default: + } + } + p.mu.Unlock() + return + } +} + +// ChunkRuntimeFenceUpdates wakes the process owner when a volume's attached +// layer fenced after startup; read ChunkRuntimeFenced for the volume. +func (p *DurableProvider) ChunkRuntimeFenceUpdates() <-chan struct{} { return p.fenceUpdates } + +// ChunkRuntimeFenced reports a latched runtime fence of the volume's +// attached layer (HEAD has another publication owner). +func (p *DurableProvider) ChunkRuntimeFenced(volumeID string) bool { + p.mu.Lock() + defer p.mu.Unlock() + h := p.volumes[volumeID] + return !p.closed && h != nil && h.runtimeFenced +} diff --git a/seaweed-block/core/frontend/durable/runtime_fence_test.go b/seaweed-block/core/frontend/durable/runtime_fence_test.go new file mode 100644 index 0000000000..d359d463a6 --- /dev/null +++ b/seaweed-block/core/frontend/durable/runtime_fence_test.go @@ -0,0 +1,89 @@ +package durable_test + +import ( + "context" + "testing" + "time" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// INV-FE-PRIMARY-READY-OPERATIONAL-001 (condition A): a HEAD fence after +// startup, while the lease would still be valid, refuses I/O from the fence, +// latches the backend not operational with its evidence and marks the volume +// runtime-fenced with a wakeup, so the process owner chooses the no-restart +// exit. Another holder claims HEAD at a newer epoch, or at the same epoch +// under another holder string; this holder's next publication fences. +func TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational(t *testing.T) { + for _, tc := range []struct { + name string + epoch func(uint64) uint64 + holder string + }{ + {"newer epoch", func(e uint64) uint64 { return e + 1 }, "s2/r1"}, + {"same epoch, other holder", func(e uint64) uint64 { return e }, "s2/r1"}, + } { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + remote := storage.NewMemChunkRemote() + p := chunkProvider(t, t.TempDir(), remote, v1View(), 0) + s := openRecovered(t, p) + if _, err := s.Write(1, block(1)); err != nil { + t.Fatal(err) + } + if _, err := p.CaptureVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + if p.ChunkRuntimeFenced("v1") { + t.Fatal("runtime-fenced while serving") + } + backend, err := p.Open(ctx, "v1") + if err != nil { + t.Fatal(err) + } + + head, err := remote.GetHead(ctx) + if err != nil { + t.Fatal(err) + } + next := head + next.Epoch, next.Holder = tc.epoch(head.Epoch), tc.holder + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{Gen: head.Gen, Epoch: head.Epoch}, next); err != nil { + t.Fatal(err) + } + if _, err := s.Write(2, block(2)); err != nil { + t.Fatal(err) + } + if _, err := p.CaptureVolume(ctx, "v1"); err == nil { + t.Fatal("a capture over another holder's HEAD succeeded") + } + // From the fence on, no I/O is admitted (before the watcher runs). + if n, err := backend.Write(ctx, 3*4096, block(3)); err == nil || n != 0 { + t.Fatalf("a write after the fence: n=%d err=%v, want refused", n, err) + } + + select { + case <-p.ChunkRuntimeFenceUpdates(): + case <-time.After(5 * time.Second): + t.Fatal("no runtime-fence wakeup within the cleanup bound") + } + if !p.ChunkRuntimeFenced("v1") { + t.Fatal("woken but not runtime-fenced") + } + var st *durable.VolumeStatus + for _, v := range p.DurableStatuses() { + if v.VolumeID == "v1" { + v := v + st = &v + } + } + if st == nil || st.Operational || st.Evidence != "chunk layer fenced after startup: HEAD has another publication owner" { + t.Fatalf("durable status after a runtime fence: %+v, want not operational with the fence evidence", st) + } + if _, err := backend.Write(ctx, 3*4096, block(3)); err == nil { + t.Fatal("a write after the runtime fence was admitted") + } + }) + } +} diff --git a/seaweed-block/core/host/volume/workspace_lease.go b/seaweed-block/core/host/volume/workspace_lease.go index 581140618a..f3ae20dbbc 100644 --- a/seaweed-block/core/host/volume/workspace_lease.go +++ b/seaweed-block/core/host/volume/workspace_lease.go @@ -265,10 +265,11 @@ func (g *WorkspaceLeaseGuard) Refresh(ctx context.Context) error { } closed := g.fenced g.mu.Unlock() - if firstGrant { + if firstGrant && !closed { // Once per guard: the first grant, or the re-grant after refused // renewals (a restart before the forced-move barrier); unix_ms is the - // request start, which the lease validity is anchored to. + // request start, which the lease validity is anchored to. A first + // reply that revokes (or arrives fenced) grants nothing: no line. what := "granted" if refused > 0 { what = fmt.Sprintf("re-granted after %d refused renewal(s)", refused) diff --git a/seaweed-block/core/host/volume/workspace_lease_held_test.go b/seaweed-block/core/host/volume/workspace_lease_held_test.go index 4c149faa3e..6bb07c16e8 100644 --- a/seaweed-block/core/host/volume/workspace_lease_held_test.go +++ b/seaweed-block/core/host/volume/workspace_lease_held_test.go @@ -59,6 +59,37 @@ func TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals(t *testing.T) { } } +// A first reply that revokes grants nothing: after refused renewals, a valid +// first reply with Revoking set fences the guard, is never held and logs no +// grant line (the line is a readiness timing witness). +func TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant(t *testing.T) { + logs := captureLog(t) + now := time.Unix(1000, 0) + calls := 0 + client := workspaceTestClient{ + renew: func() (*control.WorkspaceLeaseFact, error) { + calls++ + if calls == 1 { + return nil, errors.New("workspace forced move lease expiry plus clock-skew margin has not elapsed") + } + return &control.WorkspaceLeaseFact{VolumeId: "v", ReplicaId: "r", Epoch: 1, ValidForNs: int64(10 * time.Second), Revoking: true}, nil + }, + ack: func() error { return nil }, + } + g, err := NewWorkspaceLeaseGuard(workspaceTestView{}, client, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 1}, func(context.Context) (uint64, error) { return 7, nil }, func() time.Time { return now }) + if err != nil { + t.Fatal(err) + } + _ = g.Refresh(context.Background()) + _ = g.Refresh(context.Background()) + if g.Held() || g.Projection().Healthy { + t.Fatal("a revoking first reply left the lease held") + } + if out := logs.String(); strings.Contains(out, "granted") || !strings.Contains(out, "revoked by the master") { + t.Fatalf("want no grant line and the revocation fence; log=%q", out) + } +} + // V1-SPEC r2.37: a workspace primary reports NotReadyReason=lease_not_held, // first, while its guard is missing or holds no granted lease, even with the // backend admitting I/O; ready once the lease is held; lease_not_held again diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0fecbcfd52..40671fdea4 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -46,7 +46,8 @@ The local storage engine and the durable backend in front of it. Diagrams in the stateDiagram-v2 [*] --> Opened: OpenWALStore / CreateWALStore Opened --> Recovering: RecoverVolume - Recovering --> Serving: Recover ok, backend operational + Recovering --> Serving: Recover ok, backend operational; workspace primary: lease held, then HEAD claim, then frontends listen, then ready + Serving --> Closed: runtime HEAD fence, exit 78 head_fenced Recovering --> RecoveryFailed: Recover error (typed reason) Serving --> Serving: map prepare refused (prior root released, no latch, retry) Serving --> FaultLatched: fsync or WAL append fails @@ -60,13 +61,14 @@ stateDiagram-v2 |---|---|---|---|---| | — | Opened | v3 A/B descriptors and owned-map dependencies valid, exclusive file ownership acquired; legacy formats refused; backend starts not operational | `core/storage/walstore.go` `OpenWALStoreWithOptions`; `core/frontend/durable/provider.go` `openOrCreate` | `INV-WAL-OPGATE-001`, `INV-WAL-V3-ACTIVATION-001`, `INV-WAL-V3-DESCRIPTOR-001`, `INV-WAL-V3-MAP-PUBLISH-001` | | Opened | Recovering | the volume is open in the provider | `core/frontend/durable/provider.go` `RecoverVolume` | `INV-WAL-OPGATE-001` | -| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001` | +| Recovering | Serving | v3 nonce/cursor-bound physical prefix satisfies its W/BASE gate; rollback fence and rebuilt bounds publish before reuse; `Recover` aborts/drains an open COW window before lower locks, holds the capture barrier and invalidates proofs at start/end; the frontend targets start, and `FrontendPrimaryReady` is reported, only once the backend admits I/O (a chunk volume: after its storage claim; attach-pending or fenced reports not ready with the reason); a workspace primary claims HEAD, listens and reports ready only while its lease guard permits now (`WorkspaceLeaseGuard.Held`; without a grant: `NotReadyReason=lease_not_held`, exit 75 after the start-time wait) | `core/storage/walstore_v3.go` `recoverV3`; `core/storage/walstore.go` `WALStore.Recover`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `core/host/volume/status_server.go` `statusProjection`; `core/host/volume/workspace_lease.go` `Held` | `INV-WAL-SYNCED-RECOVERED-001`, `INV-WAL-REPLAY-LWW-001`, `INV-WAL-FRONTIER-GAP-001`, `INV-CUT-RECOVER-BARRIER-001`, `INV-WAL-V3-W-RECOVERY-001`, `INV-WAL-V3-FENCE-001`, `INV-WAL-V3-MAP-PUBLISH-001`, `INV-FE-PRIMARY-READY-OPERATIONAL-001`, `INV-WS-SERVE-LEASE-HELD-001` | | Recovering | RecoveryFailed | a WAL integrity failure or an I/O error; the backend stays not operational and the host blocks local readiness with `wal_corrupt` or `io_error` | `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable`; `core/host/volume/recovery_watchdog.go` `LocalRecoveryHealthReason` | `INV-WAL-TYPED-FAILCLOSED-001`, `INV-WAL-OPGATE-001`, `INV-WAL-V3-W-RECOVERY-001` | | Serving | Serving | each `Read`, `Write`, `Sync` passes the operational, chunk-fence and lineage checks; write admission samples the active writer's native pressure before waiting; a write is durable only when a covering `Sync` returns | `core/frontend/durable/storage_adapter.go` `gate`; `core/storage/walstore.go` `WALStore.Sync` | `INV-FE-LINEAGE-GATE-001`, `INV-WAL-SYNC-FRONTIER-001`, `INV-FE-FUA-SYNC-001`, `INV-FE-FLUSH-SYNC-001`, `INV-WAL-V3-ADMISSION-001`, `INV-WAL-V3-W-001` | | Serving | Serving (checkpoint) | the flusher binds its snapshot/materialization to one recovery lifetime; extent and owned COW map are durable before the shared descriptor publisher advances checkpoint/tail; both slot tails pin reuse | `core/storage/flusher.go` `flushOnceInternal`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `INV-WAL-CHECKPOINT-SNAPSHOT-001`, `INV-WAL-REUSE-PERSISTED-TAIL-001`, `INV-WAL-CKPT-META-FAIL-001`, `INV-CUT-BITMAP-001`, `INV-WAL-FLUSH-SYNC-COVERS-WAL-001`, `INV-WAL-V3-RECLAIM-001`, `INV-WAL-V3-PUBLISH-NONCE-FLOOR-001`, `INV-WAL-V3-MAP-PRIOR-LIVE-001` | | Serving | Serving (map prepare refused) | a map preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) captured prior and a publication released it before the prepare's live-set snapshot: the prepare reuses no page, writes nothing, refuses with `prior_released` without latching, counts it, and the caller's next cycle prepares from the current root | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `INV-WAL-V3-MAP-PRIOR-LIVE-001` | | Serving | FaultLatched | the first failed `fsync` of the store file, or a WAL append whose write failed | `core/storage/walstore.go` `noteFsyncFailure`, `syncFile`; `core/storage/walstore_v3.go` `appendWriteV3` | `INV-WAL-FSYNC-STICKY-001`, `INV-WAL-APPEND-STICKY-001` | | FaultLatched | FaultLatched | every later `Sync`, write, checkpoint and `Recover` on the same open store is refused | `core/storage/walstore.go` `stickyIOFault` | `INV-WAL-FSYNC-STICKY-001` | +| Serving | Closed (process exit 78 `head_fenced`) | workspace chunk primary: the attached layer fenced after startup (HEAD has another publication owner); I/O is refused from the fence, the backend latches not operational with the evidence, and the process owner chooses the no-restart exit | `core/frontend/durable/provider_startup.go` `watchChunkFence`; `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` | `INV-FE-PRIMARY-READY-OPERATIONAL-001` | | any | Closed | `Close`; a store with a latched fault does not write the final superblock | `core/storage/walstore.go` `WALStore.Close` | — | The v2 writer, scanner, checkpoint path, C11 codec/reconciler and in-place converter are retired. Native map and descriptor rules remain enforced; v2 inputs refuse open without mutation. `TestNativeReplacementLegacyBytesRefusedWithoutMutation` and `TestChunkAttachRefusesAnUnmappedNativeStore` cover these admission boundaries. The receiver session bitmap is separate and unchanged. @@ -447,7 +449,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -310 rows: 239 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 295 new. +311 rows: 240 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 296 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -461,7 +463,8 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-001` | A read or write on a successfully recovered chunk volume awaiting attachment waits for attachment readiness, before storage admission, for at most 3 s or until an earlier caller deadline, on the local monotonic clock. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `admitAfterAttachUnqueued`, `awaitAttachAdmission`, `readyCheck` | `TestWALStoreChunk_PendingReadWaitIsBounded`; `TestWALStoreChunk_PendingReadHonoursEarlierDeadline`; `TestWALStoreChunk_TakeoverWriteWaitsForAttach`; `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-STATUS-001` | An NVMe read or write whose attachment-readiness wait times out or is refused completes with Namespace Not Ready (SC 0x82), DNR=0, without reading or mutating storage. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestWALStoreChunk_TakeoverReadBeforeAttachIsRetryable`; `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestWALStoreChunk_PendingAttachBeyondHostRetryBudget` (`core/frontend/durable/takeover_read_ready_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | -| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target starts listening only after it first does; attach-pending, fenced or no durable status reports not ready with the reason; a fence after the target listens ends the process within 5 s (`INV-WS-STARTUP-RETRY-001`). | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | +| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason; a fence after the target listens ends the process within 5 s. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop`; a runtime HEAD fence: `core/frontend/durable/provider_startup.go` `watchChunkFence` (not operational with the evidence) and `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (exit 78 `head_fenced`) | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`); `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`) | — | ACTIVE | +| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/host/volume/status_server.go` `statusProjection` (`NotReadyReason=lease_not_held`); `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (frontends start after the claim); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | | `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE | @@ -981,7 +984,8 @@ One row per wait in the data and control paths. Guest-visible rows on one path m |---|---|---|---|---|---|---| | `core/storage/chunk_publish_settled.go` `runPublishSettled` (from `unlockCap`, on the cut or detach caller's goroutine) | the `OnPublishSettled` hook to return | the hook's duration: the hook must return without blocking and without remote calls, enqueueing its work to its own worker | the hook implementer | none: a stalled hook stalls its caller, and later reports queue without a bound (a nil hook queues nothing) | none (`capMu` and `stMu` released) | yes on detach (the detach caller delivers before returning) | | `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (from `runVolume`, before any frontend starts) | the backend's first admitted I/O (`StorageBackend.FirstServing`), or the process's stop waiter returning | none of its own: it ends on the stop waiter, which INV-WS-STARTUP-RETRY-001 bounds (a refused or timed-out claim latches exit 75/78) | `runVolume` (`INV-FE-PRIMARY-READY-OPERATIONAL-001`) | no frontend starts; shutdown as after the frontends | none | no (no target listens yet) | -| `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched startup outcome | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded) | none | no | +| `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched process outcome (startup, or a runtime HEAD fence) | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded or `head_fenced`) | none | no | +| `cmd/blockvolume/main.go` `runVolume`, the receive of `stopWait` after the frontends started (when `awaitFrontendStart` released on first serving) | the one result of the `waitWorkspaceStop` goroutine (its only producer, a 1-slot channel it sends to exactly once) | the process lifetime, as `waitWorkspaceStop` | the process exit owner (`superviseProcess`) | shutdown with the handed-back lease drain request | none | no (the targets serve until the stop) | Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed scan result preserves trusted records, absolute end, highest LSN, contiguous frontier, trusted DurableLSN and stop cause separately. The W/BASE/fence owner (`WALStore.recoverV3`) must check R < W*, fence and publish bounds before readiness or append admission; neither codec nor scan success is readiness. The installed scan begins at max(BaseCursor, retainedTail). No ACTIVE v2 machine/guard is replaced by this step. From 33e72fd0834af8e3660c68e86f85e4a02941dbd6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:34:10 -0800 Subject: [PATCH 150/204] blockvolume: state the fence-to-exit bound as detection plus cleanup; join the fence watcher INV-FE-PRIMARY-READY-OPERATIONAL-001 keeps the readiness and listen property; the fence-to-exit bound is its own row, INV-FE-FENCE-EXIT-001, stated as what is guaranteed: the fence's detection time (a HEAD fence: 50 ms) plus the existing 5 s cleanup bound from the decision. 307 rows, 221 ACTIVE. Provider Close joins each layer's fence watcher through p.inflight (counted under p.mu while not closed). C.W lists the two new waits. The runtime-fence watcher test owns its worker: cleanup registered before the start, the return joined with a bound on both paths. Co-Authored-By: Claude Opus 5.5 --- .../blockvolume/runtime_fence_exit_test.go | 52 +++++++++++++++---- .../core/frontend/durable/provider.go | 3 +- .../core/frontend/durable/provider_chunk.go | 1 + .../core/frontend/durable/provider_startup.go | 4 +- seaweed-block/docs/design/invariants.md | 9 ++-- 5 files changed, 54 insertions(+), 15 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go index dad78fbec4..48e9d3bbe3 100644 --- a/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go +++ b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go @@ -15,18 +15,41 @@ type runtimeFenceStub struct { func (s *runtimeFenceStub) ChunkRuntimeFenced(string) bool { return s.fenced.Load() } func (s *runtimeFenceStub) ChunkRuntimeFenceUpdates() <-chan struct{} { return s.updates } -// INV-FE-PRIMARY-READY-OPERATIONAL-001 (condition A): a runtime HEAD fence of -// a workspace chunk primary chooses the no-restart exit 78 head_fenced through -// the process owner's one chooser; nothing is chosen while not fenced, and a +// runtimeFenceWait bounds every receive and join in this test. +const runtimeFenceWait = 5 * time.Second + +// startRuntimeFenceWatch runs watchChunkRuntimeFence with a context it owns. +// Its cleanup, registered before the worker starts, cancels that context and +// joins the worker within runtimeFenceWait, so an earlier failed check never +// strands it. The returned channel closes when the worker returned. +func startRuntimeFenceWatch(t *testing.T, e *processExit, f flags, p chunkRuntimeFenceProvider) <-chan struct{} { + t.Helper() + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan struct{}) + t.Cleanup(func() { + cancel() + select { + case <-done: + case <-time.After(runtimeFenceWait): + t.Errorf("the runtime-fence watcher did not return within %s of its cancel", runtimeFenceWait) + } + }) + go func() { + defer close(done) + watchChunkRuntimeFence(ctx, e, f, p) + }() + return done +} + +// INV-FE-FENCE-EXIT-001: a runtime HEAD fence of a workspace chunk primary +// chooses the no-restart exit 78 head_fenced through the process owner's one +// chooser, and the watcher returns; nothing is chosen while not fenced, and a // non-workspace volume never watches. func TestRuntimeHeadFenceChoosesHeadFencedExit(t *testing.T) { f := flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v1"} e := newProcessExit(context.Background()) stub := &runtimeFenceStub{updates: make(chan struct{}, 1)} - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - done := make(chan struct{}) - go func() { watchChunkRuntimeFence(ctx, e, f, stub); close(done) }() + done := startRuntimeFenceWatch(t, e, f, stub) select { case out := <-e.decision: t.Fatalf("an exit was chosen while not fenced: %+v", out) @@ -39,13 +62,22 @@ func TestRuntimeHeadFenceChoosesHeadFencedExit(t *testing.T) { if out != (workspaceExit{exitWorkspaceSuperseded, "head_fenced"}) { t.Fatalf("exit %+v, want 78 head_fenced", out) } - case <-time.After(5 * time.Second): + case <-time.After(runtimeFenceWait): t.Fatal("no exit chosen after the runtime fence") } - <-done + select { + case <-done: + case <-time.After(runtimeFenceWait): + t.Fatal("the watcher chose the exit but did not return") + } plain := newProcessExit(context.Background()) - watchChunkRuntimeFence(ctx, plain, flags{volumeID: "v1"}, stub) // returns at once: not a workspace chunk primary + plainDone := startRuntimeFenceWatch(t, plain, flags{volumeID: "v1"}, stub) + select { + case <-plainDone: // not a workspace chunk primary: returns at once + case <-time.After(runtimeFenceWait): + t.Fatal("a non-workspace volume kept watching") + } select { case out := <-plain.decision: t.Fatalf("a non-workspace volume chose %+v", out) diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 220a254251..906620614c 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -262,7 +262,8 @@ type DurableProvider struct { // walstore-chunk: closeCtx ends with Close and cancels in-flight // remote attachment; inflight counts RecoverVolume calls admitted - // before Close, which Close waits for before closing any store. + // before Close, and each attached layer's fence watcher, which Close + // waits for before closing any store. closeCtx context.Context closeCancel context.CancelFunc inflight sync.WaitGroup diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 6818949132..35a45115a8 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -336,6 +336,7 @@ func (p *DurableProvider) attachChunk(ctx context.Context, volumeID string, h *v h.backend.chunkFenced = layer.Fenced h.backend.mu.Unlock() p.startChunkLoop(volumeID, h, layer) + p.inflight.Add(1) // under p.mu with closed false: Close joins the watcher go p.watchChunkFence(volumeID, h, layer) } return nil diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go index fb22ace560..ce9fc929db 100644 --- a/seaweed-block/core/frontend/durable/provider_startup.go +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -73,8 +73,10 @@ const chunkFenceWatchInterval = 50 * time.Millisecond // fenced only on supersede or owner change, never on a clean detach), then // latches the backend not operational with that evidence and marks the // volume runtime-fenced (INV-FE-PRIMARY-READY-OPERATIONAL-001). It ends when -// the provider closes or the layer is no longer this volume's. +// the provider closes or the layer is no longer this volume's; Close joins it +// through p.inflight (counted when it starts) after cancelling closeCtx. func (p *DurableProvider) watchChunkFence(volumeID string, h *volHandle, layer storage.ChunkLayer) { + defer p.inflight.Done() t := time.NewTicker(chunkFenceWatchInterval) defer t.Stop() for { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 40671fdea4..b3f902243a 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -68,7 +68,7 @@ stateDiagram-v2 | Serving | Serving (map prepare refused) | a map preparer (the flusher's checkpoint, the chunk layer's captured-map publication, BASE complete) captured prior and a publication released it before the prepare's live-set snapshot: the prepare reuses no page, writes nothing, refuses with `prior_released` without latching, counts it, and the caller's next cycle prepares from the current root | `core/storage/chunk_lsn_map_v3.go` `prepareLockedV3`; `core/storage/chunk_map_extents_v3.go` `liveSnapshotWithPriorV3` | `INV-WAL-V3-MAP-PRIOR-LIVE-001` | | Serving | FaultLatched | the first failed `fsync` of the store file, or a WAL append whose write failed | `core/storage/walstore.go` `noteFsyncFailure`, `syncFile`; `core/storage/walstore_v3.go` `appendWriteV3` | `INV-WAL-FSYNC-STICKY-001`, `INV-WAL-APPEND-STICKY-001` | | FaultLatched | FaultLatched | every later `Sync`, write, checkpoint and `Recover` on the same open store is refused | `core/storage/walstore.go` `stickyIOFault` | `INV-WAL-FSYNC-STICKY-001` | -| Serving | Closed (process exit 78 `head_fenced`) | workspace chunk primary: the attached layer fenced after startup (HEAD has another publication owner); I/O is refused from the fence, the backend latches not operational with the evidence, and the process owner chooses the no-restart exit | `core/frontend/durable/provider_startup.go` `watchChunkFence`; `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` | `INV-FE-PRIMARY-READY-OPERATIONAL-001` | +| Serving | Closed (process exit 78 `head_fenced`) | workspace chunk primary: the attached layer fenced after startup (HEAD has another publication owner); I/O is refused from the fence, the backend latches not operational with the evidence, and the process owner chooses the no-restart exit | `core/frontend/durable/provider_startup.go` `watchChunkFence`; `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` | `INV-FE-FENCE-EXIT-001` | | any | Closed | `Close`; a store with a latched fault does not write the final superblock | `core/storage/walstore.go` `WALStore.Close` | — | The v2 writer, scanner, checkpoint path, C11 codec/reconciler and in-place converter are retired. Native map and descriptor rules remain enforced; v2 inputs refuse open without mutation. `TestNativeReplacementLegacyBytesRefusedWithoutMutation` and `TestChunkAttachRefusesAnUnmappedNativeStore` cover these admission boundaries. The receiver session bitmap is separate and unchanged. @@ -449,7 +449,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -311 rows: 240 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 296 new. +312 rows: 241 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 297 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -463,7 +463,8 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-001` | A read or write on a successfully recovered chunk volume awaiting attachment waits for attachment readiness, before storage admission, for at most 3 s or until an earlier caller deadline, on the local monotonic clock. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `admitAfterAttachUnqueued`, `awaitAttachAdmission`, `readyCheck` | `TestWALStoreChunk_PendingReadWaitIsBounded`; `TestWALStoreChunk_PendingReadHonoursEarlierDeadline`; `TestWALStoreChunk_TakeoverWriteWaitsForAttach`; `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-STATUS-001` | An NVMe read or write whose attachment-readiness wait times out or is refused completes with Namespace Not Ready (SC 0x82), DNR=0, without reading or mutating storage. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestWALStoreChunk_TakeoverReadBeforeAttachIsRetryable`; `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestWALStoreChunk_PendingAttachBeyondHostRetryBudget` (`core/frontend/durable/takeover_read_ready_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | -| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason; a fence after the target listens ends the process within 5 s. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop`; a runtime HEAD fence: `core/frontend/durable/provider_startup.go` `watchChunkFence` (not operational with the evidence) and `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (exit 78 `head_fenced`) | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`); `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`) | — | ACTIVE | +| `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | +| `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens (lease expiry or a HEAD fence) ends the process within the fence's detection time (HEAD fence: 50 ms) plus the 5 s cleanup bound. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE | | `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/host/volume/status_server.go` `statusProjection` (`NotReadyReason=lease_not_held`); `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (frontends start after the claim); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | @@ -986,6 +987,8 @@ One row per wait in the data and control paths. Guest-visible rows on one path m | `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (from `runVolume`, before any frontend starts) | the backend's first admitted I/O (`StorageBackend.FirstServing`), or the process's stop waiter returning | none of its own: it ends on the stop waiter, which INV-WS-STARTUP-RETRY-001 bounds (a refused or timed-out claim latches exit 75/78) | `runVolume` (`INV-FE-PRIMARY-READY-OPERATIONAL-001`) | no frontend starts; shutdown as after the frontends | none | no (no target listens yet) | | `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched process outcome (startup, or a runtime HEAD fence) | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded or `head_fenced`) | none | no | | `cmd/blockvolume/main.go` `runVolume`, the receive of `stopWait` after the frontends started (when `awaitFrontendStart` released on first serving) | the one result of the `waitWorkspaceStop` goroutine (its only producer, a 1-slot channel it sends to exactly once) | the process lifetime, as `waitWorkspaceStop` | the process exit owner (`superviseProcess`) | shutdown with the handed-back lease drain request | none | no (the targets serve until the stop) | +| `core/frontend/durable/provider_startup.go` `watchChunkFence` (one goroutine per attached chunk layer, started when the layer attaches) | the 50 ms ticker (then reads the layer's latched fence flag) or provider close (`closeCtx`) | the attached layer's lifetime: it returns at provider close, when the layer is no longer the volume's, or after publishing a fence; Close joins it (`p.inflight`) | `DurableProvider.Close` (cancels `closeCtx`, then waits `p.inflight`) | none: the ticker is its poll, not a deadline; a HEAD fence is published at most 50 ms after the layer latches it (I/O is refused from the latch) | none while waiting (`p.mu` only briefly to check the handle and publish) | no | +| `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (one goroutine from `runVolume`, workspace chunk primaries) | the provider's runtime-fence wakeup (1-slot, `ChunkRuntimeFenceUpdates`), the process outcome (`e.done`) or the watch context | the process lifetime: it returns after choosing 78 `head_fenced`, when another outcome is chosen, or when `runVolume` cancels its watch context | the process exit owner (`superviseProcess`) | none | none | no | Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed scan result preserves trusted records, absolute end, highest LSN, contiguous frontier, trusted DurableLSN and stop cause separately. The W/BASE/fence owner (`WALStore.recoverV3`) must check R < W*, fence and publish bounds before readiness or append admission; neither codec nor scan success is readiness. The installed scan begins at max(BaseCursor, retainedTail). No ACTIVE v2 machine/guard is replaced by this step. From c0e243a8882046633f5126a27038477f94292e86 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 02:42:37 -0800 Subject: [PATCH 151/204] docs: INV-FE-FENCE-EXIT-001 statement as ruled (both detection terms named) Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index b3f902243a..ce3bc8c165 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -464,7 +464,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-STATUS-001` | An NVMe read or write whose attachment-readiness wait times out or is refused completes with Namespace Not Ready (SC 0x82), DNR=0, without reading or mutating storage. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestWALStoreChunk_TakeoverReadBeforeAttachIsRetryable`; `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestWALStoreChunk_PendingAttachBeyondHostRetryBudget` (`core/frontend/durable/takeover_read_ready_test.go`) | — | ACTIVE | | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | -| `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens (lease expiry or a HEAD fence) ends the process within the fence's detection time (HEAD fence: 50 ms) plus the 5 s cleanup bound. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE | +| `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens ends the process within detection plus the 5 s cleanup bound: a lease expiry at the guard's own deadline, a HEAD fence within 50 ms. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE | | `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/host/volume/status_server.go` `statusProjection` (`NotReadyReason=lease_not_held`); `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (frontends start after the claim); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | From 50d6d92845c9a0e124754c2a920a36747e839535 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:19:27 -0800 Subject: [PATCH 152/204] blockvolume: one "may serve" function: AdmitsIO for status and the workspace start gate V1-SPEC r2.39: StorageBackend.AdmitsIO is the I/O gate itself (the backend admits I/O AND the guarded projection names this lineage as the healthy primary). /status FrontendPrimaryReady and NotReadyReason read it through the provider (lease_not_held stays first; an unopened volume fails closed). A workspace chunk primary's frontends start once AdmitsIO passes after the backend first admitted I/O (firstAdmitted: a bounded 50 ms re-check until first served, workspace primaries only; the backend has no projection-change signal). Non-chunk volumes and supporting replicas start after open as before (the #410 design condition, V1-SPEC r2.39), now pinned by a test. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/frontend_gate.go | 49 ++++++++++++ .../blockvolume/frontend_start_signal_test.go | 79 +++++++++++++++++++ seaweed-block/cmd/blockvolume/main.go | 2 +- .../core/frontend/durable/admits_io_test.go | 36 +++++++++ .../core/frontend/durable/provider.go | 10 +++ .../core/frontend/durable/storage_adapter.go | 7 ++ .../core/host/volume/status_server.go | 14 ++-- .../core/host/volume/status_server_test.go | 19 ++++- seaweed-block/docs/design/invariants.md | 3 +- 9 files changed, 209 insertions(+), 10 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/frontend_start_signal_test.go create mode 100644 seaweed-block/core/frontend/durable/admits_io_test.go diff --git a/seaweed-block/cmd/blockvolume/frontend_gate.go b/seaweed-block/cmd/blockvolume/frontend_gate.go index 69a5b84bdc..effdac1f93 100644 --- a/seaweed-block/cmd/blockvolume/frontend_gate.go +++ b/seaweed-block/cmd/blockvolume/frontend_gate.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "time" ) // workspaceStopWait is what the process's one stop waiter (waitWorkspaceStop) @@ -21,6 +22,54 @@ type workspaceStopWait struct { // shuts down with exactly as after the frontends. A stop decided meanwhile by // INV-WS-STARTUP-RETRY-001 (exit 75 or 78) ends the stop waiter too, so a // refused claim never starts a frontend. +// servingBackend is the part of the durable backend the start gate reads. +type servingBackend interface { + FirstServing() <-chan struct{} + AdmitsIO() error +} + +// frontendStartSignal is what the frontends wait for. A workspace chunk +// primary (V1-SPEC r2.37/r2.39) starts its targets only once the one "may +// serve" function (AdmitsIO) passes after the backend first admitted I/O; +// any other volume (non-chunk, or a supporting replica) starts right after +// open, as before: it never makes the claim a workspace primary waits for. +func frontendStartSignal(f flags, b servingBackend, stop <-chan struct{}) <-chan struct{} { + if f.workspaceLease && f.durableImpl == "walstore-chunk" { + return firstAdmitted(stop, b.FirstServing(), b.AdmitsIO) + } + return b.FirstServing() +} + +// admitRecheck bounds firstAdmitted's re-check of AdmitsIO after the backend +// first admits I/O (workspace primaries only, until first served): the +// backend has no projection-change signal. +const admitRecheck = 50 * time.Millisecond + +// firstAdmitted is closed once first has closed (the backend first admitted +// I/O) and admits() then passes; it re-checks every admitRecheck until then, +// and ends without closing when stop closes. +func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() error) <-chan struct{} { + out := make(chan struct{}) + go func() { + select { + case <-first: + case <-stop: + return + } + t := time.NewTicker(admitRecheck) + defer t.Stop() + for admits() != nil { + select { + case <-t.C: + case <-stop: + return + } + } + close(out) + }() + return out +} + func awaitFrontendStart(serving <-chan struct{}, stopWait <-chan workspaceStopWait) (stopped *workspaceStopWait, start bool) { if serving == nil { return nil, true diff --git a/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go new file mode 100644 index 0000000000..21956ae9b1 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go @@ -0,0 +1,79 @@ +package main + +import ( + "errors" + "sync/atomic" + "testing" + "time" +) + +type servingStub struct { + first chan struct{} + admits atomic.Bool +} + +func (s *servingStub) FirstServing() <-chan struct{} { return s.first } +func (s *servingStub) AdmitsIO() error { + if s.admits.Load() { + return nil + } + return errors.New("stale primary lineage") +} + +func closedWithin(ch <-chan struct{}, d time.Duration) bool { + select { + case <-ch: + return true + case <-time.After(d): + return false + } +} + +// V1-SPEC r2.37/r2.39: a workspace chunk primary's targets start only once +// AdmitsIO passes after the backend first admitted I/O; the stop ends the +// wait without starting them. +func TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO(t *testing.T) { + f := flags{workspaceLease: true, durableImpl: "walstore-chunk", volumeID: "v1"} + stop := make(chan struct{}) + t.Cleanup(func() { close(stop) }) // ends the re-check goroutine on any path + b := &servingStub{first: make(chan struct{})} + sig := frontendStartSignal(f, b, stop) + if closedWithin(sig, 100*time.Millisecond) { + t.Fatal("started before the backend first admitted I/O") + } + close(b.first) // operational, but the guarded projection does not admit yet + if closedWithin(sig, 4*admitRecheck) { + t.Fatal("started while AdmitsIO refuses") + } + b.admits.Store(true) + if !closedWithin(sig, 5*time.Second) { + t.Fatal("did not start after AdmitsIO passed") + } + + stop2 := make(chan struct{}) + b2 := &servingStub{first: make(chan struct{})} + close(b2.first) + sig2 := frontendStartSignal(f, b2, stop2) + close(stop2) + if closedWithin(sig2, 4*admitRecheck) { + t.Fatal("a stopped wait started the targets") + } +} + +// claude06's #410 design condition: a non-chunk volume or a supporting +// replica starts its frontends right after open, as before: its start +// signal is the backend's first-serving channel itself, not AdmitsIO. +func TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore(t *testing.T) { + stop := make(chan struct{}) + defer close(stop) + for _, f := range []flags{ + {durableImpl: "walstore", volumeID: "v1"}, + {durableImpl: "walstore-chunk", volumeID: "v1"}, // chunk without the workspace lease + } { + b := &servingStub{first: make(chan struct{})} + close(b.first) // open and recovered; AdmitsIO refuses (not the primary) + if !closedWithin(frontendStartSignal(f, b, stop), time.Second) { + t.Fatalf("impl=%s workspace-lease=%v: did not start right after open while AdmitsIO refuses", f.durableImpl, f.workspaceLease) + } + } +} diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 893b2af0c5..36b649d6cf 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -1046,7 +1046,7 @@ func runVolume(f flags, exits *processExit) int { var serving <-chan struct{} // nil: no durable backend, start at once if durableProv != nil { if b := durableProv.Backend(f.volumeID); b != nil { - serving = b.FirstServing() + serving = frontendStartSignal(f, b, exits.done) } } stopped, startFrontends := awaitFrontendStart(serving, stopWait) diff --git a/seaweed-block/core/frontend/durable/admits_io_test.go b/seaweed-block/core/frontend/durable/admits_io_test.go new file mode 100644 index 0000000000..d44227f6a9 --- /dev/null +++ b/seaweed-block/core/frontend/durable/admits_io_test.go @@ -0,0 +1,36 @@ +package durable_test + +import ( + "errors" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend" +) + +// V1-SPEC r2.39: AdmitsIO is the one "may serve" function, the I/O gate +// itself: an operational backend whose guarded projection is not this +// lineage's healthy primary does not admit, nor does a backend that is not +// operational; both together admit. +func TestStorageBackend_AdmitsIOIsTheIOGate(t *testing.T) { + for _, f := range logicalStorageFactories() { + f := f + t.Run(f.name, func(t *testing.T) { + b, view, _ := newTestBackend(t, f, 4, 4096) + if err := b.AdmitsIO(); err != nil { + t.Fatalf("healthy and operational: %v, want nil", err) + } + p := view.Projection() + p.Healthy = false + view.set(p) + if err := b.AdmitsIO(); !errors.Is(err, frontend.ErrStalePrimary) { + t.Fatalf("operational, projection not healthy: %v, want ErrStalePrimary", err) + } + p.Healthy = true + view.set(p) + b.SetOperational(false, "test: attach pending") + if err := b.AdmitsIO(); !errors.Is(err, frontend.ErrNotReady) { + t.Fatalf("healthy, not operational: %v, want ErrNotReady", err) + } + }) + } +} diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 906620614c..bf35f99d7d 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -558,6 +558,16 @@ func (p *DurableProvider) LogicalStorage(volumeID string) storage.LogicalStorage // G5-4 binary wiring to install SetWriteObserver eagerly (before // any frontend bind) — the same backend instance is returned by // the future dp.Open() call when a frontend asks. +// AdmitsIO is StorageBackend.AdmitsIO for an open volume; ErrVolumeNotOpen +// for any other (fail closed). +func (p *DurableProvider) AdmitsIO(volumeID string) error { + b := p.Backend(volumeID) + if b == nil { + return fmt.Errorf("%w: %s", ErrVolumeNotOpen, volumeID) + } + return b.AdmitsIO() +} + func (p *DurableProvider) Backend(volumeID string) *StorageBackend { p.mu.Lock() defer p.mu.Unlock() diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 703b005ad7..47249f558a 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -900,6 +900,13 @@ func (b *StorageBackend) gate() error { return b.lineageCheck() } +// AdmitsIO is the one deciding function for "may serve" (V1-SPEC r2.39): +// nil exactly when a Read, Write or Sync arriving now passes the I/O gate, +// i.e. the backend admits I/O (open, operational, not chunk-fenced, no +// pre-copy pause) AND the guarded projection names this backend's lineage as +// the healthy primary. /status FrontendPrimaryReady reads it. +func (b *StorageBackend) AdmitsIO() error { return b.gate() } + // readyCheck is the gate without the lineage check: closed, then // operational. func (b *StorageBackend) readyCheck() error { diff --git a/seaweed-block/core/host/volume/status_server.go b/seaweed-block/core/host/volume/status_server.go index cbf1286ff5..456b46f1e3 100644 --- a/seaweed-block/core/host/volume/status_server.go +++ b/seaweed-block/core/host/volume/status_server.go @@ -89,6 +89,9 @@ type peerStatusSource interface { type durableStatusSource interface { DurableStatuses() []durable.VolumeStatus + // AdmitsIO is the one deciding function for "may serve" of an open + // volume (StorageBackend.AdmitsIO); an error for any other. + AdmitsIO(volumeID string) error } type nvmeStatusSource interface { @@ -512,18 +515,15 @@ func (s *StatusServer) statusProjection() StatusProjection { // view. Whenever FrontendPrimaryReady is false, NotReadyReason says why. backendReason := "" if src != nil { // outside s.mu: the provider takes its own lock - found := false for _, st := range src.DurableStatuses() { if st.VolumeID == p.VolumeID { - found = true p.Warnings = append(p.Warnings, st.Warnings...) - if !st.Operational { - backendReason = "durable backend not operational: " + st.Evidence - } } } - if !found { - backendReason = "no durable status for volume " + p.VolumeID + // V1-SPEC r2.39: the backend's one "may serve" function decides; an + // unopened volume fails closed. + if err := src.AdmitsIO(p.VolumeID); err != nil { + backendReason = "durable backend admits no I/O: " + err.Error() } } leaseNotHeld := s.view.workspaceLeaseNotHeld() diff --git a/seaweed-block/core/host/volume/status_server_test.go b/seaweed-block/core/host/volume/status_server_test.go index 1e341c9a3d..8310f769fb 100644 --- a/seaweed-block/core/host/volume/status_server_test.go +++ b/seaweed-block/core/host/volume/status_server_test.go @@ -7,6 +7,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "github.com/seaweedfs/seaweed-block/core/storage" "net/http" "net/http/httptest" @@ -16,6 +17,7 @@ import ( "github.com/seaweedfs/seaweed-block/core/adapter" "github.com/seaweedfs/seaweed-block/core/engine" + "github.com/seaweedfs/seaweed-block/core/frontend" "github.com/seaweedfs/seaweed-block/core/frontend/durable" "github.com/seaweedfs/seaweed-block/core/frontend/nvme" "github.com/seaweedfs/seaweed-block/core/frontend/ublk" @@ -957,6 +959,21 @@ func (s stubDurableStatusSource) DurableStatuses() []durable.VolumeStatus { return append([]durable.VolumeStatus(nil), s.vols...) } +// AdmitsIO models StorageBackend.AdmitsIO from the stub's statuses: an open +// operational volume admits; a non-operational one refuses with its evidence; +// an unknown one fails closed. +func (s stubDurableStatusSource) AdmitsIO(volumeID string) error { + for _, v := range s.vols { + if v.VolumeID == volumeID { + if !v.Operational { + return fmt.Errorf("%w: %s", frontend.ErrNotReady, v.Evidence) + } + return nil + } + } + return fmt.Errorf("%w: %s", durable.ErrVolumeNotOpen, volumeID) +} + func TestStatusServer_DurableStatusEndpoint_Disabled_Returns404(t *testing.T) { s := NewStatusServer(NewAdapterProjectionView(stubProjector{}, "v1", "r1", nil)) addr, err := s.Start("127.0.0.1:0") @@ -1235,7 +1252,7 @@ func TestStatusServer_ReadyOnlyWhileBackendOperational(t *testing.T) { // backend's; with only the listener pending, it says so. s.SetNVMeListenerReady(false) s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: false, Evidence: "chunk layer attach refused"}}}) - if body := read(); body.FrontendPrimaryReady || body.NotReadyReason != "durable backend not operational: chunk layer attach refused" { + if body := read(); body.FrontendPrimaryReady || body.NotReadyReason != "durable backend admits no I/O: frontend: volume not ready: chunk layer attach refused" { t.Errorf("listener pending + fenced: ready=%v reason=%q, want the backend's reason", body.FrontendPrimaryReady, body.NotReadyReason) } s.SetDurableStatusSource(stubDurableStatusSource{vols: []durable.VolumeStatus{{VolumeID: "v1", Operational: true}}}) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index ce3bc8c165..792f6be117 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -465,7 +465,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | | `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens ends the process within detection plus the 5 s cleanup bound: a lease expiry at the guard's own deadline, a HEAD fence within 50 ms. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE | -| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/host/volume/status_server.go` `statusProjection` (`NotReadyReason=lease_not_held`); `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (frontends start after the claim); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | +| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/frontend/durable/storage_adapter.go` `AdmitsIO` (the one "may serve" function, the I/O gate: backend admits AND guarded projection names this lineage; V1-SPEC r2.39); `core/host/volume/status_server.go` `statusProjection` (`FrontendPrimaryReady` from `AdmitsIO`; `NotReadyReason=lease_not_held` first); `cmd/blockvolume/frontend_gate.go` `frontendStartSignal` / `awaitFrontendStart` (a workspace primary's frontends start once `AdmitsIO` passes; non-chunk and supporting replicas start after open as before); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); `TestStorageBackend_AdmitsIOIsTheIOGate` (`core/frontend/durable/admits_io_test.go`); `TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO`, `TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore` (`cmd/blockvolume/frontend_start_signal_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | | `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE | @@ -985,6 +985,7 @@ One row per wait in the data and control paths. Guest-visible rows on one path m |---|---|---|---|---|---|---| | `core/storage/chunk_publish_settled.go` `runPublishSettled` (from `unlockCap`, on the cut or detach caller's goroutine) | the `OnPublishSettled` hook to return | the hook's duration: the hook must return without blocking and without remote calls, enqueueing its work to its own worker | the hook implementer | none: a stalled hook stalls its caller, and later reports queue without a bound (a nil hook queues nothing) | none (`capMu` and `stMu` released) | yes on detach (the detach caller delivers before returning) | | `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (from `runVolume`, before any frontend starts) | the backend's first admitted I/O (`StorageBackend.FirstServing`), or the process's stop waiter returning | none of its own: it ends on the stop waiter, which INV-WS-STARTUP-RETRY-001 bounds (a refused or timed-out claim latches exit 75/78) | `runVolume` (`INV-FE-PRIMARY-READY-OPERATIONAL-001`) | no frontend starts; shutdown as after the frontends | none | no (no target listens yet) | +| `cmd/blockvolume/frontend_gate.go` `firstAdmitted` (one goroutine from `runVolume`, workspace chunk primaries only) | the backend's first admitted I/O (`FirstServing`), then `AdmitsIO` passing, re-checked every 50 ms (the backend has no projection-change signal) | until first served or the process outcome (`e.done`), whichever comes first | the process exit owner (`superviseProcess`) through `e.done` | none: it ends without starting the frontends | none | no (no target listens yet) | | `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched process outcome (startup, or a runtime HEAD fence) | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded or `head_fenced`) | none | no | | `cmd/blockvolume/main.go` `runVolume`, the receive of `stopWait` after the frontends started (when `awaitFrontendStart` released on first serving) | the one result of the `waitWorkspaceStop` goroutine (its only producer, a 1-slot channel it sends to exactly once) | the process lifetime, as `waitWorkspaceStop` | the process exit owner (`superviseProcess`) | shutdown with the handed-back lease drain request | none | no (the targets serve until the stop) | | `core/frontend/durable/provider_startup.go` `watchChunkFence` (one goroutine per attached chunk layer, started when the layer attaches) | the 50 ms ticker (then reads the layer's latched fence flag) or provider close (`closeCtx`) | the attached layer's lifetime: it returns at provider close, when the layer is no longer the volume's, or after publishing a fence; Close joins it (`p.inflight`) | `DurableProvider.Close` (cancels `closeCtx`, then waits `p.inflight`) | none: the ticker is its poll, not a deadline; a HEAD fence is published at most 50 ms after the layer latches it (I/O is refused from the latch) | none while waiting (`p.mu` only briefly to check the handle and publish) | no | From 10ce25ee9cbdfe7baaf956d79f31f87d901cdaf3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 03:47:41 -0800 Subject: [PATCH 153/204] blockvolume: firstAdmitted reports its own completion; the exit diagram carries the runtime HEAD fence The stop test now observes the worker's return on its own channel with bounded joins on both paths (a re-check that ignores the stop fails in 12 s); agent-workspace-design.md's supervisor diagram adds Serving -> Exit78 on a runtime HEAD fence (head_fenced), independent of the lease. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/frontend_gate.go | 19 +++++---- .../blockvolume/frontend_start_signal_test.go | 42 +++++++++++++++---- .../docs/design/agent-workspace-design.md | 4 ++ seaweed-block/docs/design/invariants.md | 2 +- 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/frontend_gate.go b/seaweed-block/cmd/blockvolume/frontend_gate.go index effdac1f93..c1d59ac2d2 100644 --- a/seaweed-block/cmd/blockvolume/frontend_gate.go +++ b/seaweed-block/cmd/blockvolume/frontend_gate.go @@ -35,7 +35,8 @@ type servingBackend interface { // open, as before: it never makes the claim a workspace primary waits for. func frontendStartSignal(f flags, b servingBackend, stop <-chan struct{}) <-chan struct{} { if f.workspaceLease && f.durableImpl == "walstore-chunk" { - return firstAdmitted(stop, b.FirstServing(), b.AdmitsIO) + out, _ := firstAdmitted(stop, b.FirstServing(), b.AdmitsIO) + return out } return b.FirstServing() } @@ -45,12 +46,14 @@ func frontendStartSignal(f flags, b servingBackend, stop <-chan struct{}) <-chan // backend has no projection-change signal. const admitRecheck = 50 * time.Millisecond -// firstAdmitted is closed once first has closed (the backend first admitted -// I/O) and admits() then passes; it re-checks every admitRecheck until then, -// and ends without closing when stop closes. -func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() error) <-chan struct{} { - out := make(chan struct{}) +// firstAdmitted's out is closed once first has closed (the backend first +// admitted I/O) and admits() then passes; it re-checks every admitRecheck +// until then, and ends without closing out when stop closes. done is closed +// when its goroutine has returned, on either path. +func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() error) (out, done <-chan struct{}) { + o, d := make(chan struct{}), make(chan struct{}) go func() { + defer close(d) select { case <-first: case <-stop: @@ -65,9 +68,9 @@ func firstAdmitted(stop <-chan struct{}, first <-chan struct{}, admits func() er return } } - close(out) + close(o) }() - return out + return o, d } func awaitFrontendStart(serving <-chan struct{}, stopWait <-chan workspaceStopWait) (stopped *workspaceStopWait, start bool) { diff --git a/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go index 21956ae9b1..919015b454 100644 --- a/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go +++ b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go @@ -50,13 +50,41 @@ func TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO(t *testing.T) { t.Fatal("did not start after AdmitsIO passed") } - stop2 := make(chan struct{}) - b2 := &servingStub{first: make(chan struct{})} - close(b2.first) - sig2 := frontendStartSignal(f, b2, stop2) - close(stop2) - if closedWithin(sig2, 4*admitRecheck) { - t.Fatal("a stopped wait started the targets") +} + +// A stop ends firstAdmitted's worker without starting the targets, both +// while it waits for the first admitted I/O and while it re-checks AdmitsIO: +// its completion is observed on its own channel, and every join is bounded. +func TestFirstAdmittedStopEndsTheWorker(t *testing.T) { + for _, served := range []bool{false, true} { + stop := make(chan struct{}) + b := &servingStub{first: make(chan struct{})} + if served { + close(b.first) // re-checking AdmitsIO, which keeps refusing + } + out, done := firstAdmitted(stop, b.FirstServing(), b.AdmitsIO) + stopped := false + t.Cleanup(func() { + if !stopped { + close(stop) + } + if !closedWithin(done, 5*time.Second) { + t.Errorf("served=%v: the worker did not return within 5s of its stop (cleanup)", served) + } + }) + if closedWithin(done, 2*admitRecheck) { + t.Fatalf("served=%v: the worker returned before any stop", served) + } + close(stop) + stopped = true + if !closedWithin(done, 5*time.Second) { + t.Fatalf("served=%v: the worker did not return within 5s of its stop", served) + } + select { + case <-out: + t.Fatalf("served=%v: a stopped wait started the targets", served) + default: + } } } diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 13ac780750..265cde146c 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -489,6 +489,9 @@ RestartSec=5s. A newer master fact naming another replica or a refused claim pro HEAD holder permits exit 78; RestartPreventExitStatus=78 suppresses automatic restarts until an operator explicitly starts the unit. A higher epoch for the same replica retries. +A HEAD fence after the target listens (the attached chunk layer finds HEAD owned +by another publisher while the lease may still be valid) is independent of the +lease and exits 78 `head_fenced` (INV-FE-FENCE-EXIT-001). An ACKed planned revocation and a signal stop retain their normal exit status. Sealed same-epoch recovery stays non-serving for seal replay after assignment. Local-root, WAL-corruption and I/O diagnostics retain their existing wait. @@ -503,6 +506,7 @@ stateDiagram-v2 Serving --> Exit75: lease fence AwaitingAssignment --> Exit78: newer other-replica fact or exact foreign-holder HEAD claim proof Serving --> Exit78: lease fence and newer other-replica fact + Serving --> Exit78: runtime HEAD fence (another publication owner), head_fenced Exit75 --> AwaitingAssignment: supervisor starts new process Exit78 --> AwaitingAssignment: explicit operator start AwaitingAssignment --> SealedReplay: assigned same-epoch sealed HEAD diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 792f6be117..7fa2d0df4f 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -465,7 +465,7 @@ The "Machine / transition" column refers to Part A. Notes under a table record w | `INV-FE-NVME-READY-ANA-001` | An I/O that ends during the attachment-readiness wait because the backend closed or its lineage went stale keeps its ANA error, and a physical I/O fault keeps Internal Error. | M1 Opened / Recovering → Serving | `core/frontend/durable/storage_adapter.go` `attachReadyTimeout`; `core/frontend/nvme/io.go` `mapBackendError` | `TestSessionReadNotReadyIsRetryable` (`core/frontend/nvme/read_ready_retry_test.go`); `TestReadReadinessWaitDoesNotHoldAdmissionAndCloseWakesIt` (`core/frontend/durable/read_ready_wait_test.go`) | — | ACTIVE | | `INV-FE-PRIMARY-READY-OPERATIONAL-001` | FrontendPrimaryReady is reported only while the local durable backend admits I/O, and the frontend target listens only after it first does; attach-pending, fenced or no durable status reports not ready with the reason. | M1 Opened / Recovering → Serving; M2 process exit | `core/host/volume/status_server.go` `statusProjection`; `core/frontend/durable/storage_adapter.go` `FirstServing`; `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (the iSCSI, NVMe and ublk targets in `cmd/blockvolume/main.go` `runVolume` start after it); `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` | `TestStatusServer_ReadyOnlyWhileBackendOperational`, `TestStatusServer_NotReadyAlwaysHasAReason` (`core/host/volume/status_server_test.go`); `TestFrontendGateWaitsForTheStorageClaim`, `TestFrontendGateStopsWithoutStartingTheFrontends` (`cmd/blockvolume/frontend_gate_test.go`); `TestDurableProvider_NonChunkVolumeServesRightAfterOpen` (`core/frontend/durable/first_serving_test.go`) | — | ACTIVE | | `INV-FE-FENCE-EXIT-001` | A workspace chunk primary whose backend fences after its target listens ends the process within detection plus the 5 s cleanup bound: a lease expiry at the guard's own deadline, a HEAD fence within 50 ms. | M1 Serving → Closed; M2 process exit | `core/frontend/durable/provider_startup.go` `watchChunkFence` (HEAD fence: not operational with the evidence within 50 ms; I/O refused from the fence); `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (78 `head_fenced`) and `waitWorkspaceStop` (lease fence: 75 `lease_expired`); `superviseProcess` (the 5 s cleanup bound from the decision) | `TestWALStoreChunk_RuntimeHeadFenceLatchesNotOperational` (`core/frontend/durable/runtime_fence_test.go`); `TestRuntimeHeadFenceChoosesHeadFencedExit` (`cmd/blockvolume/runtime_fence_exit_test.go`); real-binary case C (lease expiry after listening: exit 75) | — | ACTIVE | -| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/frontend/durable/storage_adapter.go` `AdmitsIO` (the one "may serve" function, the I/O gate: backend admits AND guarded projection names this lineage; V1-SPEC r2.39); `core/host/volume/status_server.go` `statusProjection` (`FrontendPrimaryReady` from `AdmitsIO`; `NotReadyReason=lease_not_held` first); `cmd/blockvolume/frontend_gate.go` `frontendStartSignal` / `awaitFrontendStart` (a workspace primary's frontends start once `AdmitsIO` passes; non-chunk and supporting replicas start after open as before); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); `TestStorageBackend_AdmitsIOIsTheIOGate` (`core/frontend/durable/admits_io_test.go`); `TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO`, `TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore` (`cmd/blockvolume/frontend_start_signal_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | +| `INV-WS-SERVE-LEASE-HELD-001` | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now; without a granted lease it holds at the gate and exits 75 after the start-time wait. | M1 Recovering → Serving; M2 process exit | `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.Held` / `permits` (the one deciding function: the guarded projection gates the chunk claim, the per-I/O admit and `FrontendPrimaryReady`); `core/frontend/durable/storage_adapter.go` `AdmitsIO` (the one "may serve" function, the I/O gate: backend admits AND guarded projection names this lineage; V1-SPEC r2.39); `core/host/volume/status_server.go` `statusProjection` (`FrontendPrimaryReady` from `AdmitsIO`; `NotReadyReason=lease_not_held` first); `cmd/blockvolume/frontend_gate.go` `frontendStartSignal` / `awaitFrontendStart` (a workspace primary's frontends start once `AdmitsIO` passes; non-chunk and supporting replicas start after open as before); `cmd/blockvolume/process_exit.go` (exit 75 `assignment_timeout`) | `TestStatusServer_WorkspacePrimaryNotReadyWithoutHeldLease`, `TestWorkspaceLeaseGrantIsLoggedOnceAfterRefusedRenewals`, `TestWorkspaceLeaseFirstRevokingReplyIsNotLoggedAsAGrant` (`core/host/volume/workspace_lease_held_test.go`); `TestStorageBackend_AdmitsIOIsTheIOGate` (`core/frontend/durable/admits_io_test.go`); `TestFrontendStartSignal_WorkspacePrimaryWaitsForAdmitsIO`, `TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore`, `TestFirstAdmittedStopEndsTheWorker` (`cmd/blockvolume/frontend_start_signal_test.go`); real-binary cases B-late (restart before the forced-move barrier, re-granted inside the wait: no claim, listen or ready before the re-grant), B75 (no grant inside the wait: no claim, listen or ready, exit 75; a restart after the barrier serves) and B0 (restart inside the lease serves at once) | — | ACTIVE | | `INV-WAL-REPLAY-LWW-001` | Replay of the validated native prefix retains the highest admitted LSN per LBA; invalid cursor, nonce or LSN order is refused. | M1 Recovering | `core/storage/dirty_map.go` `putAtIfNewer` | `TestWALLSNOrderV3_RefusesDuplicateAndLower` (`core/storage/wal_lsn_order_v3_test.go`) | `WALRecovery` `ReplayLastWriter` | ACTIVE | | `INV-WAL-REUSE-PERSISTED-TAIL-001` | The WAL writer reuses only bytes that the both durable descriptor slots has already released. | M1 write lifecycle: Checkpointed → Reusable | `core/storage/wal_io_v3.go` `append`; `core/storage/walstore_map_checkpoint_v3.go` `publishCheckpointV3` | `TestWALIOV3_FloorAndPwriteFailureRefuse` (`core/storage/wal_io_v3_test.go`); `TestNativeReplacementCallerPublicationFaults` (`core/storage/legacy_replacement_v3_test.go`) | `WALRecovery` `I1` | ACTIVE | | `INV-WAL-CHECKPOINT-SNAPSHOT-001` | A checkpoint never passes a synced write that is not yet in the extent. | M1 write lifecycle: InExtent → Checkpointed | `core/storage/flusher.go` `flushOnceInternal` | `TestWALStoreV3_FlushMaterializationBoundToRecoveryLifetime` (`core/storage/walstore_map_recovery_lifetime_v3_test.go`); `TestNativeReplacementCheckpointSIGKILL` (`core/storage/legacy_checkpoint_replacement_v3_linux_test.go`) | `WALRecovery` `I1` | ACTIVE | From 870a3d9be010a57d2cd560233ffe564b2a9bcf86 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 06:27:26 -0800 Subject: [PATCH 154/204] docs, test: name the spec row, not a seat; say channel capacity, not slots Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/blockvolume/frontend_start_signal_test.go | 2 +- seaweed-block/docs/design/invariants.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go index 919015b454..2c4f3f646a 100644 --- a/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go +++ b/seaweed-block/cmd/blockvolume/frontend_start_signal_test.go @@ -88,7 +88,7 @@ func TestFirstAdmittedStopEndsTheWorker(t *testing.T) { } } -// claude06's #410 design condition: a non-chunk volume or a supporting +// INV-WS-SERVE-LEASE-HELD-001 scope (V1-SPEC r2.39): a non-chunk volume or a supporting // replica starts its frontends right after open, as before: its start // signal is the backend's first-serving channel itself, not AdmitsIO. func TestFrontendStartSignal_OtherVolumesStartAfterOpenAsBefore(t *testing.T) { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 7fa2d0df4f..a40b33ba70 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -987,9 +987,9 @@ One row per wait in the data and control paths. Guest-visible rows on one path m | `cmd/blockvolume/frontend_gate.go` `awaitFrontendStart` (from `runVolume`, before any frontend starts) | the backend's first admitted I/O (`StorageBackend.FirstServing`), or the process's stop waiter returning | none of its own: it ends on the stop waiter, which INV-WS-STARTUP-RETRY-001 bounds (a refused or timed-out claim latches exit 75/78) | `runVolume` (`INV-FE-PRIMARY-READY-OPERATIONAL-001`) | no frontend starts; shutdown as after the frontends | none | no (no target listens yet) | | `cmd/blockvolume/frontend_gate.go` `firstAdmitted` (one goroutine from `runVolume`, workspace chunk primaries only) | the backend's first admitted I/O (`FirstServing`), then `AdmitsIO` passing, re-checked every 50 ms (the backend has no projection-change signal) | until first served or the process outcome (`e.done`), whichever comes first | the process exit owner (`superviseProcess`) through `e.done` | none: it ends without starting the frontends | none | no (no target listens yet) | | `cmd/blockvolume/process_exit.go` `waitWorkspaceStop` (one goroutine from `runVolume`, started with the workspace lease guard before the frontends) | a signal, the lease guard's drain request or end, or the latched process outcome (startup, or a runtime HEAD fence) | the process lifetime | the process exit owner (`superviseProcess`, `INV-WS-STARTUP-RETRY-001`) | the chosen exit status (0 revoked/signal, 75 retry, 78 superseded or `head_fenced`) | none | no | -| `cmd/blockvolume/main.go` `runVolume`, the receive of `stopWait` after the frontends started (when `awaitFrontendStart` released on first serving) | the one result of the `waitWorkspaceStop` goroutine (its only producer, a 1-slot channel it sends to exactly once) | the process lifetime, as `waitWorkspaceStop` | the process exit owner (`superviseProcess`) | shutdown with the handed-back lease drain request | none | no (the targets serve until the stop) | +| `cmd/blockvolume/main.go` `runVolume`, the receive of `stopWait` after the frontends started (when `awaitFrontendStart` released on first serving) | the one result of the `waitWorkspaceStop` goroutine (its only producer, a channel of capacity one it sends to exactly once) | the process lifetime, as `waitWorkspaceStop` | the process exit owner (`superviseProcess`) | shutdown with the handed-back lease drain request | none | no (the targets serve until the stop) | | `core/frontend/durable/provider_startup.go` `watchChunkFence` (one goroutine per attached chunk layer, started when the layer attaches) | the 50 ms ticker (then reads the layer's latched fence flag) or provider close (`closeCtx`) | the attached layer's lifetime: it returns at provider close, when the layer is no longer the volume's, or after publishing a fence; Close joins it (`p.inflight`) | `DurableProvider.Close` (cancels `closeCtx`, then waits `p.inflight`) | none: the ticker is its poll, not a deadline; a HEAD fence is published at most 50 ms after the layer latches it (I/O is refused from the latch) | none while waiting (`p.mu` only briefly to check the handle and publish) | no | -| `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (one goroutine from `runVolume`, workspace chunk primaries) | the provider's runtime-fence wakeup (1-slot, `ChunkRuntimeFenceUpdates`), the process outcome (`e.done`) or the watch context | the process lifetime: it returns after choosing 78 `head_fenced`, when another outcome is chosen, or when `runVolume` cancels its watch context | the process exit owner (`superviseProcess`) | none | none | no | +| `cmd/blockvolume/process_exit.go` `watchChunkRuntimeFence` (one goroutine from `runVolume`, workspace chunk primaries) | the provider's runtime-fence wakeup (capacity one, `ChunkRuntimeFenceUpdates`), the process outcome (`e.done`) or the watch context | the process lifetime: it returns after choosing 78 `head_fenced`, when another outcome is chosen, or when `runVolume` cancels its watch context | the process exit owner (`superviseProcess`) | none | none | no | Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed scan result preserves trusted records, absolute end, highest LSN, contiguous frontier, trusted DurableLSN and stop cause separately. The W/BASE/fence owner (`WALStore.recoverV3`) must check R < W*, fence and publish bounds before readiness or append admission; neither codec nor scan success is readiness. The installed scan begins at max(BaseCursor, retainedTail). No ACTIVE v2 machine/guard is replaced by this step. From 263fce9fcca5604062507894f6c2b5c1efae8c03 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:16:05 -0800 Subject: [PATCH 155/204] test: the gate's owner-endpoint check rejects when either recipient lacks positive evidence Table for wrongOwnerEndpoints: both positive passes; an unreadable log, a log with no forced-epoch delivery, an empty log, or another host's endpoints in either recipient rejects (#425). Co-Authored-By: Claude Opus 5.5 --- .../owner_endpoints_helper_test.go | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/owner_endpoints_helper_test.go diff --git a/seaweed-block/cmd/blockvolume/owner_endpoints_helper_test.go b/seaweed-block/cmd/blockvolume/owner_endpoints_helper_test.go new file mode 100644 index 0000000000..db7c478960 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/owner_endpoints_helper_test.go @@ -0,0 +1,47 @@ +//go:build subprocess && chunkstore_integration + +package main_test + +import ( + "os" + "path/filepath" + "strings" + "testing" +) + +// #425: the procedure gate's owner-endpoint check rejects when EITHER recipient's evidence is missing, unreadable, +// has no forced-epoch delivery, or carries another host's endpoints; it passes only with positive evidence from both. +func TestWrongOwnerEndpointsNeedsPositiveEvidenceFromEachRecipient(t *testing.T) { + owner := bvHost{id: "s2", data: "127.0.0.1:2001", ctrl: "127.0.0.1:2002"} + dir := t.TempDir() + good := `blockvolume: assignment stream delivery process="X" server="s2" volume="v1" replica="r1" epoch=2 ev=1 data="127.0.0.1:2001" ctrl="127.0.0.1:2002"` + wrong := `blockvolume: assignment stream delivery process="X" server="s2" volume="v1" replica="r1" epoch=2 ev=2 data="127.0.0.1:1001" ctrl="127.0.0.1:1002"` + other := `blockvolume: assignment stream delivery process="X" server="s1" volume="v1" replica="r1" epoch=1 ev=1 data="127.0.0.1:1001" ctrl="127.0.0.1:1002"` + logOf := func(name string, lines ...string) *daemon { + p := filepath.Join(dir, name+".log") + if err := os.WriteFile(p, []byte(strings.Join(lines, "\n")+"\n"), 0o644); err != nil { + t.Fatal(err) + } + return &daemon{name: name, log: p} + } + missing := &daemon{name: "gone", log: filepath.Join(dir, "does-not-exist.log")} + for _, c := range []struct { + name string + ds []*daemon + reject string // "" = must pass + }{ + {"both positive", []*daemon{logOf("a1", good), logOf("b1", other, good)}, ""}, + {"second unreadable", []*daemon{logOf("a2", good), missing}, "log unreadable"}, + {"first has no epoch delivery", []*daemon{logOf("a3", other), logOf("b3", good)}, "no epoch delivery logged"}, + {"second carries another host's endpoints", []*daemon{logOf("a4", good), logOf("b4", good, wrong)}, "127.0.0.1:1001"}, + {"first empty log", []*daemon{logOf("a5"), logOf("b5", good)}, "no epoch delivery logged"}, + } { + bad := wrongOwnerEndpoints(2, owner, c.ds...) + switch { + case c.reject == "" && len(bad) != 0: + t.Errorf("%s: rejected %v, want pass", c.name, bad) + case c.reject != "" && !strings.Contains(strings.Join(bad, "\n"), c.reject): + t.Errorf("%s: got %v, want a rejection naming %q", c.name, bad, c.reject) + } + } +} From 99903f98649c9b35d63a4d7051c5bbb215e48877 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:27:17 -0800 Subject: [PATCH 156/204] fix: preserve typed store faults and retry marked remote short reads --- seaweed-block/core/frontend/error_class.go | 20 +++++++++++++++-- .../iscsi/backend_error_class_test.go | 22 ++++++++++++++++++- .../frontend/nvme/backend_error_class_test.go | 19 +++++++++++----- seaweed-block/docs/design/invariants.md | 6 +++-- 4 files changed, 57 insertions(+), 10 deletions(-) diff --git a/seaweed-block/core/frontend/error_class.go b/seaweed-block/core/frontend/error_class.go index aab910a9c6..89e8a2670e 100644 --- a/seaweed-block/core/frontend/error_class.go +++ b/seaweed-block/core/frontend/error_class.go @@ -3,7 +3,6 @@ package frontend import ( "context" "errors" - "io" "log" "reflect" "sync" @@ -52,10 +51,27 @@ func ClassifyBackendError(ctx context.Context, err error) BackendErrorClass { } func hasPermanentBackendCause(err error) bool { + // M1 permanent precedence: visit every envelope. errors.As alone returns + // the first RecoveryFailure, which may have a non-permanent kind while a + // later sibling or nested envelope carries the latched store fault. + if joined, ok := err.(interface{ Unwrap() []error }); ok { + for _, cause := range joined.Unwrap() { + if hasPermanentBackendCause(cause) { + return true + } + } + } else if cause := errors.Unwrap(err); cause != nil && hasPermanentBackendCause(cause) { + return true + } + var failure *storage.RecoveryFailure + if errors.As(err, &failure) && (failure.Kind == storage.StorageRecoveryFailureSubstrateIO || + failure.Kind == storage.StorageRecoveryFailureWALIntegrity) { + return true + } // errors.Is traverses every child of joins, so neither an outer transient // wrapper nor a sibling deadline can hide a typed storage/media failure. for _, cause := range []error{syscall.EIO, syscall.ENOSPC, syscall.EROFS, - io.ErrUnexpectedEOF, storage.ErrWALIntegrityFault, storage.ErrFsyncFailed, + storage.ErrCounterExhausted, storage.ErrWALIntegrityFault, storage.ErrFsyncFailed, storage.ErrAppendFailed, storage.ErrMapInvalid} { if errors.Is(err, cause) { return true diff --git a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go index 4bbe3324f0..f308b45af7 100644 --- a/seaweed-block/core/frontend/iscsi/backend_error_class_test.go +++ b/seaweed-block/core/frontend/iscsi/backend_error_class_test.go @@ -52,13 +52,33 @@ func TestBackendErrorClassesAcrossFrontends(t *testing.T) { {name: "unknown-with-stale", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrStalePrimary), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x0a, sct: 3, sc: 3}, {name: "unknown-with-closed", err: errors.Join(errors.New("unrecognized backend cause"), frontend.ErrBackendClosed), status: 0x02, key: 0x02, asc: 0x04, ascq: 0x03, sct: 3, sc: 2}, {name: "unknown-with-physical", err: errors.Join(errors.New("unrecognized backend cause"), syscall.EIO), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "latched-arbitrary-io", err: errors.Join(frontend.ErrBackendBusy, storage.NewSubstrateIOFailure(errors.New("map persist failed"), "latched store")), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "latched-arbitrary-integrity", err: errors.Join(frontend.ErrBackendBusy, storage.NewWALIntegrityFailure(errors.New("descriptor corrupt"), "latched store")), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "counter-exhausted", err: errors.Join(frontend.ErrBackendBusy, storage.ErrCounterExhausted), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "local-short-read", err: errors.Join(frontend.ErrBackendBusy, storage.NewWALIntegrityFailure(io.ErrUnexpectedEOF, "local file read")), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "unknown-recovery-kind", err: errors.Join(frontend.ErrBackendBusy, &storage.RecoveryFailure{Kind: storage.StorageRecoveryFailureUnknown, Cause: errors.New("unknown recovery cause")}), + status: 0x08, sct: 0, sc: 0x82}, + {name: "recycled-recovery-kind", err: errors.Join(frontend.ErrBackendBusy, storage.NewWALRecycledFailure(errors.New("recycled"), "history")), + status: 0x08, sct: 0, sc: 0x82}, + {name: "latched-after-nonpermanent-envelope", err: errors.Join(frontend.ErrNotReady, + &storage.RecoveryFailure{Kind: storage.StorageRecoveryFailureUnknown}, + storage.NewSubstrateIOFailure(errors.New("map persistence latched"), "store")), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "latched-under-nonpermanent-envelope", err: errors.Join(frontend.ErrNotReady, + &storage.RecoveryFailure{Kind: storage.StorageRecoveryFailureUnknown, + Cause: storage.NewWALIntegrityFailure(errors.New("descriptor latched"), "store")}), + status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "fsync-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrFsyncFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "append-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrAppendFailed), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "integrity-fault", err: errors.Join(frontend.ErrBackendBusy, storage.ErrWALIntegrityFault), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "invalid-map", err: errors.Join(frontend.ErrBackendBusy, storage.ErrMapInvalid), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "no-space", err: errors.Join(frontend.ErrBackendBusy, syscall.ENOSPC), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, {name: "read-only", err: errors.Join(frontend.ErrBackendBusy, syscall.EROFS), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, - {name: "truncated-io", err: errors.Join(frontend.ErrBackendBusy, io.ErrUnexpectedEOF), status: 0x02, key: 0x03, asc: 0x11, sct: 0, sc: 6}, + {name: "hydration-short-remote-body", err: errors.Join(frontend.ErrBackendBusy, storage.ErrChunkHydrationPending, io.ErrUnexpectedEOF), status: 0x08, sct: 0, sc: 0x82}, {name: "not-ready", err: frontend.ErrNotReady, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x01, sct: 0, sc: 0x82}, {name: "busy", err: frontend.ErrBackendBusy, status: 0x08, sct: 0, sc: 0x82}, {name: "stale", err: frontend.ErrStalePrimary, status: 0x02, key: 0x02, asc: 0x04, ascq: 0x0a, sct: 3, sc: 3}, diff --git a/seaweed-block/core/frontend/nvme/backend_error_class_test.go b/seaweed-block/core/frontend/nvme/backend_error_class_test.go index a5f91031e3..adc453a356 100644 --- a/seaweed-block/core/frontend/nvme/backend_error_class_test.go +++ b/seaweed-block/core/frontend/nvme/backend_error_class_test.go @@ -70,11 +70,20 @@ func (b *durabilityClassBackend) Sync(context.Context) error { // operation's latched permanent cause wins even beneath a deliberate busy marker. func TestSyncAndFUALatchedFaultOverridesBusy(t *testing.T) { for _, fua := range []bool{false, true} { - for _, latched := range []bool{false, true} { - t.Run(fmt.Sprintf("fua=%t/latched=%t", fua, latched), func(t *testing.T) { + for _, fault := range []struct { + name string + err error + }{ + {name: "no-latch"}, + {name: "fsync-sentinel", err: storage.ErrFsyncFailed}, + {name: "arbitrary-substrate-latch", err: storage.NewSubstrateIOFailure(errors.New("map persist failed"), "store")}, + {name: "arbitrary-integrity-latch", err: storage.NewWALIntegrityFailure(errors.New("descriptor corrupt"), "store")}, + {name: "counter-exhausted", err: storage.ErrCounterExhausted}, + } { + t.Run(fmt.Sprintf("fua=%t/%s", fua, fault.name), func(t *testing.T) { cause := errors.Join(frontend.ErrBackendBusy, errors.New("untyped durability cause")) - if latched { - cause = errors.Join(cause, storage.ErrFsyncFailed) + if fault.err != nil { + cause = errors.Join(cause, fault.err) } b := &durabilityClassBackend{Backend: testback.NewRecordingBackend(frontend.Identity{VolumeID: "v"}), err: cause} cmd := IOCommand{Opcode: ioFlush, NSID: 1} @@ -83,7 +92,7 @@ func TestSyncAndFUALatchedFaultOverridesBusy(t *testing.T) { } got := NewIOHandler(HandlerConfig{Backend: b}).Handle(context.Background(), cmd) want := MakeStatusField(SCTGeneric, SCNamespaceNotReady, false) - if latched { + if fault.err != nil { want = MakeStatusField(SCTGeneric, SCInternalError, true) } if got.completionStatus() != want { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 52b4d4aad2..cbd89a0413 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -414,8 +414,10 @@ snapshot lifetime; local persistence does not bypass it. deadline; the broader budget gap is tracked separately in issue221. - Every frontend I/O error completion uses one shared retry class (`INV-FE-ERROR-RETRY-CLASS-001`, amended V1-SPEC r2.42): (a) a known permanent - cause anywhere in the wrapped/joined tree wins: EIO, ENOSPC, EROFS, unexpected - EOF, WAL integrity, prior fsync/append failure, or invalid chunk maps; + cause anywhere in the wrapped/joined tree wins: EIO, ENOSPC, EROFS, counter + exhaustion, WAL integrity, prior fsync/append failure, invalid chunk maps, or + RecoveryFailure with SubstrateIO/WALIntegrity kind (any cause). Bare short-read + EOF is not permanent evidence; local faults carry an integrity/I/O envelope; (b) otherwise a deliberate busy, not-ready, stale, closed or pure expired command-deadline marker decides. Unknown causes under markers do not override them; pressure/hydration/observer causes are not frontend classification atoms; From 339932cb6171cc798ebe8aad55b1365402d7e606 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:33:12 -0800 Subject: [PATCH 157/204] test: fold the procedure gate's test-tier review - The old host returning after a forced move: the absence checks run only while it is alive; it must exit 75 and log a refusal; a supervised restart and a start on a fresh local root (a control: no stale root to refuse) must do the same. The refusal text that the product never prints is dropped. - The same-host restart is the page's systemctl restart (SIGTERM, a start within RestartSec); the crash restart is its own test. Both must serve within 15 s, as s1/r1 at the same epoch. - The barrier wait requires at least one barrier refusal, compares with one second of log resolution, and requires the re-grant line. - Too early: the exit reason assignment_timeout, and the same serving predicate as the barrier wait. - The planned hand-over runs the page's step 1 and reads a never-written block as zero (a control). - The lapsed-lease return must serve within its 30 s authority wait, as s1/r1. Comments match the order of the revoke-without-ACK steps. - Harness ports come from 10000-19999, below weed's range; sw-block output can be captured to HANDOFF_CAPTURE_DIR for the fixtures. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_integration_test.go | 51 ++++- .../procedure_gate_integration_test.go | 190 ++++++++++++++---- 2 files changed, 190 insertions(+), 51 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 24efa719f2..651b9521d9 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -17,6 +17,7 @@ import ( "path/filepath" "strings" "sync" + "syscall" "testing" "time" @@ -237,8 +238,12 @@ func startHandoffEnv(t *testing.T, n int, masterArgs ...string) *handoffEnv { } // volArgs is the chapter's blockvolume command for one host. -func (env *handoffEnv) volArgs(id string) []string { - b := env.hosts[id] +func (env *handoffEnv) volArgs(id string) []string { return env.volArgsFor(env.hosts[id]) } + +// volArgsFor is the chapter's blockvolume command for b. The default +// scheduled snapshot (daily:7, at a per-volume offset) stays on, as the page +// says; a snapshot inside a test could only make a test fail, never pass. +func (env *handoffEnv) volArgsFor(b bvHost) []string { return []string{"--master", env.h.masterAddr, "--server-id", b.id, "--volume-id", "v1", "--replica-id", "r1", "--data-addr", b.data, "--ctrl-addr", b.ctrl, "--status-addr", b.status, "--durable-root", b.root, "--durable-impl", "walstore-chunk", @@ -303,15 +308,30 @@ func newPlannedHandoffHarness(t *testing.T) *plannedHandoffHarness { return h } +// captureOutput writes each sw-block answer to $HANDOFF_CAPTURE_DIR, when set, +// as --.stdout/.stderr: the source of testdata/planned-handoff. +func captureOutput(t *testing.T, args []string, stdout, stderr string) { + dir := os.Getenv("HANDOFF_CAPTURE_DIR") + if dir == "" || len(args) < 3 { + return + } + captureSeq++ + base := filepath.Join(dir, fmt.Sprintf("%s-%02d-%s-%s", t.Name(), captureSeq, args[1], args[2])) + _ = os.WriteFile(base+".stdout", []byte(stdout), 0o644) + _ = os.WriteFile(base+".stderr", []byte(stderr), 0o644) +} + +var captureSeq int + var handoffPorts struct { sync.Mutex used map[int]bool } -// handoffAddress returns a free loopback address below the kernel's -// ephemeral range (32768 and up on Linux). A daemon restarted minutes later -// binds it again, and an outgoing connection may take any ephemeral port in -// between; ports below the range are never handed out that way. +// handoffAddress returns a free loopback address in 10000-19999: below the +// kernel's ephemeral range (32768 and up on Linux), where an outgoing +// connection can take a port while a restarted daemon waits to bind it +// again, and below the 20000-49999 range startWorkspaceWeed draws from. func handoffAddress(t *testing.T) string { t.Helper() handoffPorts.Lock() @@ -320,7 +340,7 @@ func handoffAddress(t *testing.T) string { handoffPorts.used = map[int]bool{} } for i := 0; i < 500; i++ { - p := 21000 + rand.Intn(11000) + p := 10000 + rand.Intn(10000) if handoffPorts.used[p] { continue } @@ -341,6 +361,21 @@ type daemon struct { done chan struct{} err error cancel context.CancelFunc + proc *os.Process +} + +// term sends SIGTERM, as systemctl stop or restart does, and waits for the +// child to exit. +func (d *daemon) term(t *testing.T, timeout time.Duration) { + t.Helper() + if err := d.proc.Signal(syscall.SIGTERM); err != nil { + t.Fatalf("SIGTERM %s: %v", d.name, err) + } + select { + case <-d.done: + case <-time.After(timeout): + t.Fatalf("%s did not exit within %s of SIGTERM", d.name, timeout) + } } // kill kills the child (no ACK is sent on a signal) and waits for it. @@ -392,6 +427,7 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. t.Fatalf("start %s: %v", name, err) } started = true + d.proc = cmd.Process go func() { d.err = cmd.Wait(); close(d.done) }() return d } @@ -468,6 +504,7 @@ func (h *plannedHandoffHarness) run(t *testing.T, args ...string) (string, strin var stdout, stderr strings.Builder cmd.Stdout, cmd.Stderr = &stdout, &stderr err := cmd.Run() + captureOutput(t, args, stdout.String(), stderr.String()) var exit *exec.ExitError switch { case err == nil: diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index eec3f8d1bf..1b1aacec6e 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -17,9 +17,11 @@ import ( ) // The procedure gate: every operator procedure of docs/volume-lifecycle.md -// runs as written, with real binaries, on two blockvolume processes with -// distinct server ids (s1 and s2) sharing one blockmaster and one SeaweedFS. -// The planned return to the same host is TestStandalonePlannedHandoffToTheSameHost. +// runs as written, with real binaries, on blockvolume processes with distinct +// server ids (s1, and s2 where a procedure moves the volume) sharing one +// blockmaster and one SeaweedFS. The two start-time tests and the same-host +// restarts use s1 only. The planned return to the same host is +// TestStandalonePlannedHandoffToTheSameHost. // TestProcedurePlannedHandoffToAnotherHost: the planned hand-over from s1 to // s2. The new holder starts with no local copy, claims the sealed HEAD at the @@ -34,6 +36,9 @@ func TestProcedurePlannedHandoffToAnotherHost(t *testing.T) { block := pattern("to-another-host!") env.writeBlock(t, "s1", 0, block) + // Step 1: read the holder; the lease must be granted. + out, _ := h.command(t, env.show...) + must(checkShowGranted(out, e)) g := env.seal(t, "s1", e) l := env.sealedLSN(t, e, g) env.revoke(t, e, g) @@ -49,7 +54,7 @@ func TestProcedurePlannedHandoffToAnotherHost(t *testing.T) { if got := env.adopt(t, nw, "s2"); got != e2 { t.Fatalf("s2 adopted at epoch %d; want %d", got, e2) } - out, _ := h.command(t, env.show...) + out, _ = h.command(t, env.show...) must(wantLines(out, fmt.Sprintf("holder: r1@%d (logical replica)", e2), fmt.Sprintf("move: request=move-v1-1 kind=clean issued=true s1/r1@%d -> s2/r1@%d HEAD generation %d remote LSN %d", e, e2, g, l))) out, _ = h.command(t, env.chunkShow()...) @@ -57,27 +62,59 @@ func TestProcedurePlannedHandoffToAnotherHost(t *testing.T) { if !bytes.Equal(env.readBlock(t, "s2", 0), block) { t.Fatal("the block written on s1 does not read back on s2") } + // Control: a block never written reads zero, so the comparison above can + // fail. + if !bytes.Equal(env.readBlock(t, "s2", 8), make([]byte, 4096)) { + t.Fatal("a block never written does not read zero on s2") + } } -// TestProcedureSameHostRestartInsideTheLease: the holder's process dies and is -// started again on its host within the 30 s lease. It keeps holder and epoch -// and serves again at once from its local WAL. +// TestProcedureSameHostRestartInsideTheLease: the page's restart without a +// hand-over, `systemctl restart`: the holder gets SIGTERM, exits, and is +// started again on its host within the unit's RestartSec (5 s), inside the +// 30 s lease. It keeps holder and epoch and serves again at once from its +// local WAL. func TestProcedureSameHostRestartInsideTheLease(t *testing.T) { - env := startHandoffEnv(t, 2) - must, _ := fatalOn(t) - + env := startHandoffEnv(t, 1) first := env.start(t, "blockvolume-s1", "s1") e := env.adopt(t, first, "s1") block := pattern("restart-in-lease") env.writeBlock(t, "s1", 0, block) - first.kill(t) + first.term(t, 30*time.Second) + env.restartServesAtOnce(t, "blockvolume-s1-again", e, block) +} - again := env.start(t, "blockvolume-s1-again", "s1") +// TestProcedureSameHostCrashRestartInsideTheLease: the page's "the holder +// comes back within the lease" after a crash: the process is killed and +// started again within the unit's RestartSec (5 s). The same outcome as a +// restart. +func TestProcedureSameHostCrashRestartInsideTheLease(t *testing.T) { + env := startHandoffEnv(t, 1) + first := env.start(t, "blockvolume-s1", "s1") + e := env.adopt(t, first, "s1") + block := pattern("crash-in-lease!!") + env.writeBlock(t, "s1", 0, block) + first.kill(t) + env.restartServesAtOnce(t, "blockvolume-s1-again", e, block) +} + +// restartServesAtOnce starts s1 again within 5 s of its exit and requires it +// to serve within 15 s ("at once"), as s1/r1 at the same epoch, with the +// written block. +func (env *handoffEnv) restartServesAtOnce(t *testing.T, name string, e uint64, block []byte) { + t.Helper() + must, _ := fatalOn(t) + started := time.Now() + again := env.start(t, name, "s1") if got := env.adopt(t, again, "s1"); got != e { t.Fatalf("the restarted holder adopted epoch %d; want the same epoch %d", got, e) } + if took := time.Since(started); took > 15*time.Second { + t.Fatalf("the restarted holder served after %s; the page says at once", took.Round(time.Second)) + } out, _ := env.h.command(t, env.show...) must(checkShowGranted(out, e)) + env.requireHeadHolder(t, e, "s1") if !bytes.Equal(env.readBlock(t, "s1", 0), block) { t.Fatal("the block written before the restart does not read back") } @@ -99,15 +136,20 @@ func TestProcedureReturnAfterALapsedLease(t *testing.T) { stopped := time.Now() time.Sleep(time.Until(stopped.Add(65 * time.Second))) + started := time.Now() back := env.start(t, "blockvolume-s1-back", "s1") if got := env.adopt(t, back, "s1"); got != e { t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) } + if took := time.Since(started); took > 30*time.Second { + t.Fatalf("the returning holder served after %s, past its 30 s authority wait", took.Round(time.Second)) + } if back.has("assignment unavailable, not serving") { t.Fatal("started 65 s after the stop, the holder still logged the not-serving line") } out, _ := env.h.command(t, env.show...) must(checkShowGranted(out, e)) + env.requireHeadHolder(t, e, "s1") if !bytes.Equal(env.readBlock(t, "s1", 0), block) { t.Fatal("the block written before the lapse does not read back") } @@ -153,40 +195,30 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { t.Fatal("the block written after the last cut reads back on s2; the page says it is lost") } - // The old host returns with its old local root. It must not take s2's - // line as its own (a holder is server and replica), report its frontend - // ready, or listen for I/O; the page says it does not serve. - back := env.start(t, "blockvolume-s1-back", "s1") - var failures []string - end := time.Now().Add(40 * time.Second) - for time.Now().Before(end) && len(failures) == 0 { - if l := back.line(fmt.Sprintf("adopted as PRIMARY at r1@%d", e2)); l != "" { - failures = append(failures, "it adopted s2's line: "+l) - } - if env.frontendReadyAt("s1") { - failures = append(failures, "its status reports FrontendPrimaryReady") - } - if listening(env.hosts["s1"].nvme) { - failures = append(failures, "its NVMe/TCP target listens") - } - time.Sleep(time.Second) - } - if !back.has("refusing to attach volume=v1") && !back.has("workspace lease: stale authority") && !back.has("is not this process") && !back.has("foreign assignment") { - failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") - } - if len(failures) > 0 { - t.Errorf("the returning old host after the forced move: %s", strings.Join(failures, "; ")) - } + // The old host returns with its old local root, and a supervisor starts + // it again after it exits. Each time it must not take s2's line as its + // own (a holder is server and replica), report its frontend ready or + // listen for I/O, and it must log a refusal and exit with status 75. + env.oldHostRefuses(t, "blockvolume-s1-back", env.hosts["s1"], e2) + time.Sleep(5 * time.Second) // RestartSec of the example unit + env.oldHostRefuses(t, "blockvolume-s1-restarted", env.hosts["s1"], e2) + // Control: on a fresh local root there is no stale root to refuse, and + // it must still refuse s2's line. + fresh := env.hosts["s1"] + fresh.root = fresh.root + "-fresh" + env.oldHostRefuses(t, "blockvolume-s1-fresh-root", fresh, e2) env.h.waitPrimaryAt(t, env.hosts["s2"].status, e2) if !bytes.Equal(env.readBlock(t, "s2", 0), kept) { t.Fatal("s2 no longer serves the kept block after the old host returned") } } -// TestProcedureRevokeWithoutACKThenForcedMove: the volume is sealed and -// revoked, but its process dies before it sends the ACK. The clean move is -// refused; only a forced move to another node remains, and since HEAD is -// sealed, nothing acknowledged is lost. +// TestProcedureRevokeWithoutACKThenForcedMove: the volume is sealed, its +// process is gone before the revoke (so no process ever sends the ACK), and +// the lease is revoked with the sealed generation. The clean move is refused; +// only a forced move to another node remains, and since HEAD is sealed, +// nothing acknowledged is lost. Killing before the revoke makes the missing +// ACK certain; the page's row "Revoked, but no ACK" has the same outcome. func TestProcedureRevokeWithoutACKThenForcedMove(t *testing.T) { env := startHandoffEnv(t, 2) must, mustU := fatalOn(t) @@ -236,7 +268,7 @@ func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { var ready []time.Time end := time.Now().Add(90 * time.Second) for time.Now().Before(end) { - if env.frontendReadyAt("s1") || listening(env.hosts["s1"].nvme) { + if env.servingNow("s1") { ready = append(ready, time.Now()) if len(ready) >= 5 { break @@ -247,10 +279,19 @@ func TestProcedureStartInsideTheBarrierWaitIsReGranted(t *testing.T) { if len(ready) == 0 { t.Fatal("the returning holder never served within 90 s") } - if last := lastLogTime(back, "clock-skew margin has not elapsed"); !last.IsZero() && ready[0].Before(last) { - t.Errorf("the returning holder served at %s, before its renewal was still refused for the barrier at %s: it served without a lease", + // Started before the barrier, its renewals must have been refused for it + // at least once; log times have 1 s resolution. + last := lastLogTime(back, "clock-skew margin has not elapsed") + if last.IsZero() { + t.Fatal("started 40 s after the stop, the returning holder logged no renewal refused for the barrier") + } + if ready[0].Before(last.Add(time.Second)) { + t.Errorf("the returning holder served at %s, while its renewal was still refused for the barrier at %s: it served without a lease", ready[0].Format("15:04:05.000"), last.Format("15:04:05")) } + if !back.has("workspace lease: re-granted after ") { + t.Error("the returning holder served without logging its re-grant") + } if got := env.adopt(t, back, "s1"); got != e { t.Fatalf("the returning holder adopted epoch %d; want the same epoch %d", got, e) } @@ -274,12 +315,15 @@ func TestProcedureStartTooEarlyExitsAndARestartServes(t *testing.T) { first.kill(t) time.Sleep(31 * time.Second) + // Attempt 2 starts about 66 s after the stop and its wait ends about + // 96 s after it, against a barrier of at most 95 s, so attempt 2 normally + // serves; up to 4 attempts allow for scheduling on a loaded host. for attempt := 1; ; attempt++ { d := env.start(t, fmt.Sprintf("blockvolume-s1-try%d", attempt), "s1") served := false end := time.Now().Add(45 * time.Second) for time.Now().Before(end) { - if env.frontendReadyAt("s1") { + if env.servingNow("s1") { served = true break } @@ -302,6 +346,9 @@ func TestProcedureStartTooEarlyExitsAndARestartServes(t *testing.T) { if err := d.wait(5 * time.Second); exitCode(err) != 75 { t.Fatalf("attempt %d did not serve and did not exit 75: %v", attempt, err) } + if !d.has("blockvolume: exiting status=75 reason=assignment_timeout") { + t.Fatalf("attempt %d exited 75 without the reason assignment_timeout", attempt) + } if attempt == 4 { t.Fatal("four supervised starts never served") } @@ -339,6 +386,61 @@ func exitCode(err error) int { return -1 } +// oldHostRefuses starts the old holder b after the volume moved to epoch e2 +// on another host. While it runs it must not adopt the new line, report its +// frontend ready or listen; it must log a refusal and exit with status 75 +// (a later change may give a stale local root its own status). +func (env *handoffEnv) oldHostRefuses(t *testing.T, name string, b bvHost, e2 uint64) { + t.Helper() + d := env.h.start(t, name, env.h.volume, env.volArgsFor(b)...) + var failures []string + end := time.Now().Add(60 * time.Second) + for alive := true; alive && time.Now().Before(end); { + if l := d.line(fmt.Sprintf("adopted as PRIMARY at r1@%d", e2)); l != "" { + failures = append(failures, "it adopted the new holder's line: "+l) + } + if env.frontendReadyAt("s1") { + failures = append(failures, "its status reports FrontendPrimaryReady") + } + if listening(b.nvme) { + failures = append(failures, "its NVMe/TCP target listens") + } + select { + case <-d.done: + alive = false + case <-time.After(500 * time.Millisecond): + } + } + if err := d.wait(5 * time.Second); exitCode(err) != 75 { + failures = append(failures, fmt.Sprintf("it did not exit with status 75: %v", err)) + } + if !d.has("refusing to attach volume=v1") && !d.has("workspace lease: stale authority") && !d.has("foreign assignment") { + failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") + } + if len(failures) > 0 { + t.Errorf("%s after the forced move: %s", name, strings.Join(failures, "; ")) + } +} + +// servingNow reports whether the host serves: its frontend is ready or its +// NVMe/TCP target accepts connections. +func (env *handoffEnv) servingNow(id string) bool { + return env.frontendReadyAt(id) || listening(env.hosts[id].nvme) +} + +// requireHeadHolder checks that HEAD is active, held by host/r1 at epoch e. +func (env *handoffEnv) requireHeadHolder(t *testing.T, e uint64, host string) { + t.Helper() + out, _ := env.h.command(t, env.chunkShow()...) + head, err := parseHead(out) + if err != nil { + t.Fatal(err) + } + if head.State != "active" || head.Epoch != e || head.Holder != host+"/r1" { + t.Fatalf("HEAD %+v; want active at epoch %d held by %s/r1", head, e, host) + } +} + func pattern(s string) []byte { return bytes.Repeat([]byte(s), 4096/len(s)) } func (env *handoffEnv) start(t *testing.T, name, id string) *daemon { From 4098abca8283613f85bcce08ac5b405f8984ae4f Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 07:46:41 -0800 Subject: [PATCH 158/204] test: the procedure gate's captured outputs as fixtures The move to s2, HEAD reclaimed by s2, the forced move, its dry-run previews (refused with an admissible time, then admitted) and lost-range, captured from a passing gate run, are read by the default-build check test; each check also refuses a neighbouring output. Co-Authored-By: Claude Opus 5.5 --- .../planned_handoff_checks_test.go | 35 +++++++++++++++++-- .../force-move-dry-run-admitted.stdout | 4 +++ .../force-move-dry-run-refused.stdout | 3 ++ .../planned-handoff/force-move.stdout | 3 ++ .../planned-handoff/head-reopened-s2.stdout | 1 + .../planned-handoff/lost-range.stdout | 2 ++ .../planned-handoff/move-clean-s2.stdout | 2 ++ 7 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-admitted.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-refused.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened-s2.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/lost-range.stdout create mode 100644 seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean-s2.stdout diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go index af534928eb..1a64651a8d 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_checks_test.go @@ -229,9 +229,10 @@ func matchUint(re *regexp.Regexp, s string) (uint64, error) { // TestPlannedHandoffChecksReadCapturedProductOutput runs every check on the // output the real binaries printed in one passing hand-over (E=1, G=3, L=1, -// E2=2) and in the refused clean move without an ACK (move-refused, -// show-revoked), and each check on an output of another step, which it must -// refuse. +// E2=2), in the refused clean move without an ACK (move-refused, +// show-revoked), and in the procedure gate's move to s2 and forced move +// (move-clean-s2, head-reopened-s2, force-move*, lost-range), and each check +// on an output of another step, which it must refuse. func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { read := func(name string) string { b, err := os.ReadFile(filepath.Join("testdata", "planned-handoff", name)) @@ -302,6 +303,34 @@ func TestPlannedHandoffChecksReadCapturedProductOutput(t *testing.T) { if r := read("show-revoked.stdout"); showsAck(r, e, g) || !hasLine(r, "recorded ACK: none") { t.Error("the revoked show without an ACK is read as acknowledged") } + // The procedure gate's two-host outputs (a planned move to s2, a forced + // move s1 -> s2 at E=1 -> E2=2 keeping gen 3, LSN 1). + if got, err := movedEpochTo(read("move-clean-s2.stdout"), e, g, l, "s2"); err != nil || got != e2 { + t.Errorf("moved epoch to s2 %d, %v; want %d", got, err, e2) + } + _, err = movedEpochTo(read("move-clean-s2.stdout"), e, g, l, "s1") + refused("clean move to s2 read as a move to s1", err) + ok("HEAD reopened by s2", checkHeadReopenedBy(read("head-reopened-s2.stdout"), e2, g, l, "s2")) + refused("HEAD reopened by s2 read as s1's", checkHeadReopenedBy(read("head-reopened-s2.stdout"), e2, g, l, "s1")) + if got, err := forcedEpoch(read("force-move.stdout"), e, "s1", "s2"); err != nil || got != e2 { + t.Errorf("forced epoch %d, %v; want %d", got, err, e2) + } + _, err = forcedEpoch(read("force-move.stdout"), e, "s2", "s1") + refused("forced move read the other way round", err) + _, err = forcedEpoch(read("move-clean-s2.stdout"), e, "s1", "s2") + refused("forced epoch", err) + if got, err := forcedKeptLSN(read("force-move.stdout")); err != nil || got != l { + t.Errorf("forced kept LSN %d, %v; want %d", got, err, l) + } + if !previewAdmitted(read("force-move-dry-run-admitted.stdout")) || previewAdmitted(read("force-move-dry-run-refused.stdout")) { + t.Error("the dry-run preview is not told admitted from not admitted") + } + if !strings.Contains(read("force-move-dry-run-refused.stdout"), "admissible at ") { + t.Error("the refused preview has no admissible time") + } + if !strings.Contains(read("lost-range.stdout"), "range 1 of 1: request force-v1-1, r1@") { + t.Error("lost-range does not show the forced move") + } if !frontendReady([]byte(read("status-primary.json"))) || frontendReady([]byte(`{"FrontendPrimaryReady":false,"Healthy":true}`)) { t.Error("the frontend-ready check does not read FrontendPrimaryReady") } diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-admitted.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-admitted.stdout new file mode 100644 index 0000000000..9442ec483d --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-admitted.stdout @@ -0,0 +1,4 @@ +preview (advisory): at master time 2026-11-22T15:36:16.705621624Z, may change; admission is re-checked at the move. Nothing was written; this is not a confirmation. +forced move admitted +HEAD now: gen 3, epoch 1, holder s1/r1, remote LSN 1, published at 2026-11-22T15:35:12Z (publishing host clock as recorded in the filer, 1 s resolution) +if moved now: writes with LSN <= 1 are kept; writes acknowledged after that and before 2026-11-22T15:36:16.617154582Z, master clock, may be lost diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-refused.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-refused.stdout new file mode 100644 index 0000000000..082cfcc755 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move-dry-run-refused.stdout @@ -0,0 +1,3 @@ +preview (advisory): at master time 2026-11-22T15:35:12.107989752Z, may change; admission is re-checked at the move. Nothing was written; this is not a confirmation. +forced move not admitted: workspace forced move lease expiry plus clock-skew margin has not elapsed +admissible at 2026-11-22T15:36:16.617154582Z, master clock diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move.stdout new file mode 100644 index 0000000000..0484f10cbc --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/force-move.stdout @@ -0,0 +1,3 @@ +forced move issued: volume v1 request force-v1-1: r1@1 on s1 -> r1@2 on s2 (kept HEAD gen 3, remote LSN 1) +volume v1 restored to the last published image at 2026-11-22T15:35:12Z (publishing host clock as recorded in the filer, 1 s resolution) (gen 3, LSN 1): writes with LSN <= 1 are preserved; writes acknowledged by r1@1 after that and before 2026-11-22T15:36:16.617154582Z, master clock, may be lost; the upper bound is a time, not an LSN. +next: start volume v1 on s2 (this command moved authority only) diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened-s2.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened-s2.stdout new file mode 100644 index 0000000000..8bcafeb22b --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/head-reopened-s2.stdout @@ -0,0 +1 @@ +{"volumeID":"v1","volume":{"origin":"create","numBlocks":65536,"blockSize":4096,"chunkBlocks":1024,"createdNs":1795361693554515613,"parent":null},"head":{"gen":4,"epoch":2,"holder":"s2/r1","remoteLSN":1,"state":"active","detachedBy":null,"chunkCount":1}} diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/lost-range.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/lost-range.stdout new file mode 100644 index 0000000000..6da93bf717 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/lost-range.stdout @@ -0,0 +1,2 @@ +range 1 of 1: request force-v1-1, r1@1 -> epoch 2, lost after LSN 1, until 2026-11-22T15:36:16.617154582Z (master clock) + volume v1 restored to the last published image at 2026-11-22T15:35:12Z (publishing host clock as recorded in the filer, 1 s resolution) (gen 3, LSN 1): writes with LSN <= 1 are preserved; writes acknowledged by r1@1 after that and before 2026-11-22T15:36:16.617154582Z, master clock, may be lost; the upper bound is a time, not an LSN. diff --git a/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean-s2.stdout b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean-s2.stdout new file mode 100644 index 0000000000..829f37454f --- /dev/null +++ b/seaweed-block/cmd/blockvolume/testdata/planned-handoff/move-clean-s2.stdout @@ -0,0 +1,2 @@ +clean move issued: volume v1 request move-v1-1: r1@1 -> r1@2 on s2 (sealed HEAD gen 3, remote LSN 1) +next: start volume v1 on s2 (this command moved authority only) From 376e40c91ee72de6ed4bbe95d03771113e8a340b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:38:18 -0800 Subject: [PATCH 159/204] test(deploy): expose unbounded blockvolume startup retries --- .../testops/blockvolume_systemd_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 seaweed-block/internal/testops/blockvolume_systemd_test.go diff --git a/seaweed-block/internal/testops/blockvolume_systemd_test.go b/seaweed-block/internal/testops/blockvolume_systemd_test.go new file mode 100644 index 0000000000..134971291d --- /dev/null +++ b/seaweed-block/internal/testops/blockvolume_systemd_test.go @@ -0,0 +1,41 @@ +package testops + +import ( + "strings" + "testing" +) + +// M2 restart: the shipped supervisor bounds retries after exit 75. +func TestBlockvolumeUnitsBoundStartupRetries(t *testing.T) { + for _, name := range []string{"sw-blockvolume.service", "sw-blockvolume-ublk.service"} { + t.Run(name, func(t *testing.T) { + body := readRepoFile(t, "deploy", "systemd", name) + section := "" + seen := map[string]bool{} + for _, line := range strings.Split(body, "\n") { + line = strings.TrimSpace(line) + if strings.HasPrefix(line, "[") { + section = line + continue + } + key, value, ok := strings.Cut(line, "=") + if !ok { + continue + } + want, checked := map[string]string{"StartLimitIntervalSec": "600", "StartLimitBurst": "10"}[key] + if !checked { + continue + } + if seen[key] || section != "[Unit]" || value != want { + t.Errorf("%s: %s=%s in %s (duplicate=%t), want %s=%s once in [Unit]", name, key, value, section, seen[key], key, want) + } + seen[key] = true + } + for _, key := range []string{"StartLimitIntervalSec", "StartLimitBurst"} { + if !seen[key] { + t.Errorf("%s: missing [Unit] %s", name, key) + } + } + }) + } +} From 3dc1bac4c9bb7d84e06299c7aef4e03ca26240cb Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:38:34 -0800 Subject: [PATCH 160/204] fix(deploy): bound blockvolume supervisor retries --- .../deploy/systemd/sw-blockvolume-ublk.service | 2 ++ seaweed-block/deploy/systemd/sw-blockvolume.service | 2 ++ seaweed-block/docs/design/invariants.md | 1 + seaweed-block/docs/standalone-deployment.md | 10 ++++++++++ 4 files changed, 15 insertions(+) diff --git a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service index ee1904fa86..6819f4d9d6 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service @@ -9,6 +9,8 @@ # # Load the module at boot: echo ublk_drv | sudo tee /etc/modules-load.d/ublk.conf [Unit] +StartLimitIntervalSec=600 +StartLimitBurst=10 Description=Seaweed Block volume over ublk (one replica, root) Documentation=https://github.com/seaweedfs/seaweed-block After=network-online.target sw-blockmaster.service diff --git a/seaweed-block/deploy/systemd/sw-blockvolume.service b/seaweed-block/deploy/systemd/sw-blockvolume.service index 7ad8a3ed5e..30a69d729c 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume.service @@ -7,6 +7,8 @@ # For ublk (needs root) do not edit this unit: use # sw-blockvolume-ublk.service, which has its own state directory. [Unit] +StartLimitIntervalSec=600 +StartLimitBurst=10 Description=Seaweed Block volume (one replica) Documentation=https://github.com/seaweedfs/seaweed-block After=network-online.target sw-blockmaster.service diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index a40b33ba70..8ee4057e95 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1011,6 +1011,7 @@ Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed sc |---|---|---|---|---| | Workspace revocation ACK closeout | M2 Revoking → Revoked; `INV-WS-STARTUP-RETRY-001` | Existing `workspaceLeaseCloseoutTimeout` (3 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 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` | 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. | | Plain seal remote proof | M5 RemoteProof; `INV-WS-SEAL-REPLAY-001` | Earlier caller context or existing 2 s HEAD-operation bound for the filer read; attachment serialization retains its owner's cooperative caller bound | Provider registers with Close; closeBoundRemote cancels the read, and Close joins it. Failure keeps frontend admission closed. | Attachment mutex serializes against recover/detach; no backend/store/map lock spans the filer read. | | Frontend pre-copy admission | M5 tentative admission -> resume; `INV-CUT-PRECOPY-001` (not reachable in this release) | Earlier of caller deadline and this command arrival + 5 s; one bound across retries, no inherited pause clock | Owner `finishPrecopyLocked`: resume or terminal Close clears the pause and grants all waiters in FIFO arrival order under one `b.mu` hold; each rechecks the ordinary gate. Expiry removes only its waiter and refuses with typed `ErrBackendBusy` + deadline cause (guest-visible: yes). Only a typed pause refusal requeues a granted waiter under the original command deadline; already-observed stale-primary and other gate errors are returned unchanged. Grant versus queue expiry is decided under the same lock; timely grants survive later queue-timer expiry but never caller expiry or a terminal gate. No dependency on another command's completion. | No `ioMu`, store lock, or remote call while queued. Admitted I/O retains normal per-LBA serialization and lifecycle accounting. | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index 041aada217..10dd3ef822 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -79,6 +79,16 @@ The binaries take command-line flags. The `SWB_*` variables are read only by the example units, which turn them into flags. blockvolume itself reads only `SW_BLOCK_ISCSI_CHAP_USERNAME` and `SW_BLOCK_ISCSI_CHAP_SECRET`. +Both blockvolume units restart failed processes after 5 seconds, except exit 78 +(superseded). Exit 75 retries through the ordinary lease and HEAD-claim gates. +`StartLimitIntervalSec=600` and `StartLimitBurst=10` in `[Unit]` allow at most +10 starts in a 10-minute window; another start in that window is refused and +the unit enters `failed` (`start-limit-hit`). This bounds retries on a host +that no longer holds the volume. After correcting the assignment or disabling +the obsolete unit, an operator can use `systemctl reset-failed ` and +`systemctl start ` to resume attempts. An ACKed planned stop exits 0 +and is not automatically restarted. + ## Required setup: make the volume known to blockmaster blockmaster gives a blockvolume an assignment only for a volume and replica From e082155232468da23ff4406a01226064e82dae00 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:48:38 -0800 Subject: [PATCH 161/204] docs(deploy): explain no-restart outcomes and retry window --- seaweed-block/docs/design/invariants.md | 2 +- seaweed-block/docs/standalone-deployment.md | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 8ee4057e95..caab17aee9 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1011,7 +1011,7 @@ Format v3 row 4 runs in production recovery (`WALStore.recoverV3`). Its typed sc |---|---|---|---|---| | Workspace revocation ACK closeout | M2 Revoking → Revoked; `INV-WS-STARTUP-RETRY-001` | Existing `workspaceLeaseCloseoutTimeout` (3 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 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` | 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. | +| Workspace primary supervisor retries | M2 restart; `INV-WS-STARTUP-RETRY-001` | Shipped systemd units: `StartLimitIntervalSec=600`, `StartLimitBurst=10`, `RestartSec=5s`. Each cycle is the assignment wait (default 30 s) + 5 s, reaching the limit in about 6 minutes. 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. | | Plain seal remote proof | M5 RemoteProof; `INV-WS-SEAL-REPLAY-001` | Earlier caller context or existing 2 s HEAD-operation bound for the filer read; attachment serialization retains its owner's cooperative caller bound | Provider registers with Close; closeBoundRemote cancels the read, and Close joins it. Failure keeps frontend admission closed. | Attachment mutex serializes against recover/detach; no backend/store/map lock spans the filer read. | | Frontend pre-copy admission | M5 tentative admission -> resume; `INV-CUT-PRECOPY-001` (not reachable in this release) | Earlier of caller deadline and this command arrival + 5 s; one bound across retries, no inherited pause clock | Owner `finishPrecopyLocked`: resume or terminal Close clears the pause and grants all waiters in FIFO arrival order under one `b.mu` hold; each rechecks the ordinary gate. Expiry removes only its waiter and refuses with typed `ErrBackendBusy` + deadline cause (guest-visible: yes). Only a typed pause refusal requeues a granted waiter under the original command deadline; already-observed stale-primary and other gate errors are returned unchanged. Grant versus queue expiry is decided under the same lock; timely grants survive later queue-timer expiry but never caller expiry or a terminal gate. No dependency on another command's completion. | No `ioMu`, store lock, or remote call while queued. Admitted I/O retains normal per-LBA serialization and lifecycle accounting. | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index 10dd3ef822..6a4fd485fa 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -80,11 +80,16 @@ the example units, which turn them into flags. blockvolume itself reads only `SW_BLOCK_ISCSI_CHAP_USERNAME` and `SW_BLOCK_ISCSI_CHAP_SECRET`. Both blockvolume units restart failed processes after 5 seconds, except exit 78 -(superseded). Exit 75 retries through the ordinary lease and HEAD-claim gates. +(a no-restart outcome; the final log line names the reason). Exit 75 retries +through the ordinary lease and HEAD-claim gates. `StartLimitIntervalSec=600` and `StartLimitBurst=10` in `[Unit]` allow at most 10 starts in a 10-minute window; another start in that window is refused and the unit enters `failed` (`start-limit-hit`). This bounds retries on a host -that no longer holds the volume. After correcting the assignment or disabling +that no longer holds the volume. Each retry cycle is the assignment wait +(default 30 seconds) plus `RestartSec=5s`, so the retries reach the limit in +about 6 minutes, inside 600 seconds. Raising the assignment wait above about +55 seconds prevents this window from filling; raise `StartLimitIntervalSec` +with it to retain the bound. After correcting the assignment or disabling the obsolete unit, an operator can use `systemctl reset-failed ` and `systemctl start ` to resume attempts. An ACKed planned stop exits 0 and is not automatically restarted. From be1337aeaa1026948c36d72c41369efbb8e5bdcc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:40:46 -0800 Subject: [PATCH 162/204] test(workspace): expose divergent lease validity decisions --- .../core/authority/workspace_validity_test.go | 43 +++++++++++++++++++ .../core/host/master/workspace_skew_test.go | 27 ++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 seaweed-block/core/authority/workspace_validity_test.go diff --git a/seaweed-block/core/authority/workspace_validity_test.go b/seaweed-block/core/authority/workspace_validity_test.go new file mode 100644 index 0000000000..dcce84f5b4 --- /dev/null +++ b/seaweed-block/core/authority/workspace_validity_test.go @@ -0,0 +1,43 @@ +package authority + +import ( + "context" + "testing" + "time" +) + +func TestWorkspaceAckUsesGrantedHalfSkewBoundary(t *testing.T) { + for _, tc := range []struct { + name string + elapsed time.Duration + allowed bool + }{ + {"before", 28*time.Second - time.Nanosecond, true}, + {"at", 28 * time.Second, false}, + {"after", 29 * time.Second, false}, + } { + t.Run(tc.name, func(t *testing.T) { + disk, _ := newTempStore(t) + now := time.Unix(1000, 0) + p := NewPublisher(nil, WithStore(disk), WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return now }), WithWorkspaceMaxClockSkew(4*time.Second)) + if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind}); err != nil { + t.Fatal(err) + } + ctx := context.Background() + if _, err := p.RenewWorkspaceLease(ctx, "v", "r", 1); err != nil { + t.Fatal(err) + } + if err := p.BeginWorkspaceRevocation(ctx, "v", "r", 1); err != nil { + t.Fatal(err) + } + now = now.Add(tc.elapsed) + err := p.AckWorkspaceRevocation(ctx, "v", WorkspaceRevokeAck{ReplicaID: "r", Epoch: 1, HeadGen: 7}) + if (err == nil) != tc.allowed { + t.Fatalf("ACK allowed=%t, want %t: %v", err == nil, tc.allowed, err) + } + if (p.WorkspaceState("v").Ack != nil) != tc.allowed { + t.Fatal("ACK persistence differs from admission") + } + }) + } +} diff --git a/seaweed-block/core/host/master/workspace_skew_test.go b/seaweed-block/core/host/master/workspace_skew_test.go index a2db589ec8..a26ec75701 100644 --- a/seaweed-block/core/host/master/workspace_skew_test.go +++ b/seaweed-block/core/host/master/workspace_skew_test.go @@ -145,3 +145,30 @@ func TestWorkspaceClockSkewConfigReachesLeaseReply(t *testing.T) { t.Fatal("configuration not applied to host validity", lease, reply) } } + +// The lease reply uses the publisher clock even when it differs from this +// process's wall clock; configured skew also covers legacy leases with no bound. +func TestWorkspaceLeaseFactUsesPublisherClockAndSkew(t *testing.T) { + now := time.Unix(1000, 0) + p := authority.NewPublisher(nil, authority.WithWorkspaceLeaseConfig(12*time.Second, func() time.Time { return now }), authority.WithWorkspaceMaxClockSkew(4*time.Second)) + _ = p + for _, tc := range []struct { + name string + expiry time.Duration + skew int64 + want time.Duration + }{ + {"legacy-configured-bound", 10 * time.Second, 0, 8 * time.Second}, + {"persisted-larger-bound", 10 * time.Second, int64(6 * time.Second), 7 * time.Second}, + {"configured-ttl-cap", 40 * time.Second, 0, 12 * time.Second}, + {"expired", time.Second, 0, 0}, + } { + t.Run(tc.name, func(t *testing.T) { + l := authority.WorkspaceLease{ReplicaID: "r", Epoch: 1, ExpiresAtNS: now.Add(tc.expiry).UnixNano(), MaxClockSkewNS: tc.skew} + fact := leaseFact("v", l) + if fact.ValidForNs != int64(tc.want) { + t.Fatalf("validity=%s, want %s", time.Duration(fact.ValidForNs), tc.want) + } + }) + } +} From b528a0c9ecd3e11135c9b3daf68bc1b67e2e2156 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:42:32 -0800 Subject: [PATCH 163/204] fix(workspace): share detached proof and lease validity decisions --- .../cmd/blockvolume/workspace_lease.go | 6 +- .../cmd/blockvolume/workspace_proof_test.go | 58 +++++++++++++++++++ seaweed-block/core/authority/workspace.go | 5 +- .../core/authority/workspace_lease_view.go | 14 ++++- .../workspace_renewal_slowstore_test.go | 2 +- .../core/host/master/workspace_service.go | 26 ++------- .../core/host/master/workspace_skew_test.go | 5 +- seaweed-block/docs/design/invariants.md | 10 ++-- 8 files changed, 89 insertions(+), 37 deletions(-) create mode 100644 seaweed-block/cmd/blockvolume/workspace_proof_test.go diff --git a/seaweed-block/cmd/blockvolume/workspace_lease.go b/seaweed-block/cmd/blockvolume/workspace_lease.go index b0724b8288..4362b51e82 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease.go @@ -60,13 +60,9 @@ func workspaceDetachedGeneration(ctx context.Context, remoteFor func(string) (st if err != nil { return 0, err } - head, err := remote.GetHead(ctx) + head, err := storage.ReadDetachedChunkHead(ctx, remote, id.Epoch, holder) if err != nil { return 0, err } - proof := head.DetachedBy - if head.Gen == 0 || head.Epoch != id.Epoch || head.Holder != holder || head.State != storage.ChunkHeadDetached || proof == nil || proof.Gen != head.Gen || proof.Epoch != head.Epoch || proof.Holder != head.Holder { - return 0, fmt.Errorf("workspace shutdown has no matching stored detached HEAD") - } return head.Gen, nil } diff --git a/seaweed-block/cmd/blockvolume/workspace_proof_test.go b/seaweed-block/cmd/blockvolume/workspace_proof_test.go new file mode 100644 index 0000000000..6bbbf4e56d --- /dev/null +++ b/seaweed-block/cmd/blockvolume/workspace_proof_test.go @@ -0,0 +1,58 @@ +package main + +import ( + "context" + "errors" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "github.com/seaweedfs/seaweed-block/core/storage" + "testing" +) + +type workspaceProofRemote struct { + storage.ChunkRemote + head storage.ChunkHead + err error + reads int +} + +func (r *workspaceProofRemote) GetHead(context.Context) (storage.ChunkHead, error) { + r.reads++ + return r.head, r.err +} + +func TestWorkspaceRevocationUsesExactStoredSeal(t *testing.T) { + for _, name := range []string{"valid", "zero-epoch", "empty-holder", "active", "proof-gen", "foreign-holder", "read-error"} { + t.Run(name, func(t *testing.T) { + h := storage.ChunkHead{Gen: 7, Epoch: 2, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Gen: 7, Epoch: 2, Holder: "s/r"}} + id := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 2} + holder := "s/r" + r := &workspaceProofRemote{head: h} + switch name { + case "zero-epoch": + id.Epoch = 0 + r.head.Epoch = 0 + r.head.DetachedBy.Epoch = 0 + case "empty-holder": + holder = "" + r.head.Holder = "" + r.head.DetachedBy.Holder = "" + case "active": + r.head.State = storage.ChunkHeadActive + case "proof-gen": + r.head.DetachedBy.Gen = 6 + case "foreign-holder": + r.head.Holder = "other/r" + case "read-error": + r.err = errors.New("HEAD answer lost") + } + gen, err := workspaceDetachedGeneration(context.Background(), func(string) (storage.ChunkRemote, error) { return r, nil }, id, holder) + if name == "valid" { + if err != nil || gen != 7 || r.reads != 1 { + t.Fatalf("stored seal: gen%d reads%d err%v", gen, r.reads, err) + } + } else if err == nil || gen != 0 { + t.Fatalf("unproven ACK gen%d err%v", gen, err) + } + }) + } +} diff --git a/seaweed-block/core/authority/workspace.go b/seaweed-block/core/authority/workspace.go index adae4867fa..8382c23230 100644 --- a/seaweed-block/core/authority/workspace.go +++ b/seaweed-block/core/authority/workspace.go @@ -277,8 +277,9 @@ func (p *Publisher) AckWorkspaceRevocation(ctx context.Context, volume string, a if !ok || line.info.ReplicaID != ack.ReplicaID || line.info.Epoch != ack.Epoch || ack.HeadGen == 0 || s == nil || s.Lease == nil || !s.Lease.Revoking { return fmt.Errorf("workspace revoke ACK: stale or unsolicited") } - now := p.workspaceNow() - if now.UnixNano() >= s.Lease.ExpiresAtNS || !now.Before(p.leaseDeadlineLocked(volume)) { + lease := *s.Lease + lease.ExpiresAtNS = min(lease.ExpiresAtNS, p.leaseDeadlineLocked(volume).UnixNano()) + if p.WorkspaceLeaseValidity(lease) == 0 { return fmt.Errorf("workspace revoke ACK: lease expired; forced move required") } if s.Ack != nil && *s.Ack != ack { diff --git a/seaweed-block/core/authority/workspace_lease_view.go b/seaweed-block/core/authority/workspace_lease_view.go index 354aff74bd..b4c08095cf 100644 --- a/seaweed-block/core/authority/workspace_lease_view.go +++ b/seaweed-block/core/authority/workspace_lease_view.go @@ -144,6 +144,18 @@ func (p *Publisher) WorkspaceLeaseReply(volume string) (WorkspaceLease, bool) { return l, true } +// WorkspaceLeaseValidity reports host validity on the publisher clock, with +// the configured TTL and the larger configured/persisted skew bound. +// M2 grant/revoke ACK; INV-WS-FORCED-MOVE-HALF-SKEW-001. +func (p *Publisher) WorkspaceLeaseValidity(l WorkspaceLease) time.Duration { + return p.workspaceLeaseValidityAt(l, p.workspaceNow()) +} + +func (p *Publisher) workspaceLeaseValidityAt(l WorkspaceLease, now time.Time) time.Duration { + remaining := time.Unix(0, l.ExpiresAtNS).Add(-p.workspaceSkew(&l) / 2).Sub(now) + return max(0, min(remaining, p.workspaceTTL)) +} + // PublishedLine is a volume's committed authority line as the lease view // publishes it. type PublishedLine struct { @@ -261,7 +273,7 @@ func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder stri // A grant without positive host validity (expiry minus half the skew // bound, leaseFact) would make the host fence on an invalid reply and lose // its remaining validity; refuse with an error instead. - if grant-lv.d.maxSkewNS/2 <= now.UnixNano() { + if p.workspaceLeaseValidityAt(WorkspaceLease{ExpiresAtNS: grant, MaxClockSkewNS: lv.d.maxSkewNS}, now) == 0 { horizon := lv.d.horizon // the view is leaseMu's: read it before the unlock (#242) summary := p.leaseStats.summaryDue(now) p.leaseMu.Unlock() diff --git a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go index a9c488dbcb..c02ed5a927 100644 --- a/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go +++ b/seaweed-block/core/host/master/workspace_renewal_slowstore_test.go @@ -112,7 +112,7 @@ func (c deadlineLeaseClient) RenewWorkspaceLease(ctx context.Context, id *contro done <- result{err: err} return } - done <- result{fact: leaseFact(id.VolumeId, l)} + done <- result{fact: leaseFact(c.p, id.VolumeId, l)} }() select { case r := <-done: diff --git a/seaweed-block/core/host/master/workspace_service.go b/seaweed-block/core/host/master/workspace_service.go index 2a84382c6a..04981c09fa 100644 --- a/seaweed-block/core/host/master/workspace_service.go +++ b/seaweed-block/core/host/master/workspace_service.go @@ -78,23 +78,9 @@ func workspaceError(err error) error { return status.Error(codes.FailedPrecondition, err.Error()) } -func leaseFact(volume string, l authority.WorkspaceLease) *control.WorkspaceLeaseFact { - // Client anchors this duration to its request START, not response arrival. - // The host fences half a skew bound before the stored master expiry. - // Never grant more than the server's configured 30s TTL after a restart. - skew := time.Duration(l.MaxClockSkewNS) - // Older persisted leases predate the bound; use the production default. - if skew <= 0 { - skew = 20 * time.Second - } - remaining := time.Until(time.Unix(0, l.ExpiresAtNS).Add(-skew / 2)) - if remaining > 30*time.Second { - remaining = 30 * time.Second - } - if remaining < 0 { - remaining = 0 - } - return &control.WorkspaceLeaseFact{VolumeId: volume, ReplicaId: l.ReplicaID, Epoch: l.Epoch, ExpiresAtNs: l.ExpiresAtNS, ValidForNs: int64(remaining), Revoking: l.Revoking} +func leaseFact(p *authority.Publisher, volume string, l authority.WorkspaceLease) *control.WorkspaceLeaseFact { + // The client anchors this duration to its request START, not response arrival. + return &control.WorkspaceLeaseFact{VolumeId: volume, ReplicaId: l.ReplicaID, Epoch: l.Epoch, ExpiresAtNs: l.ExpiresAtNS, ValidForNs: int64(p.WorkspaceLeaseValidity(l)), Revoking: l.Revoking} } // holderMatches implements INV-AUTH-HOLDER-IDENTITY-001 for both holder RPCs. @@ -125,7 +111,7 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace if err != nil { return nil, workspaceError(err) } - return leaseFact(q.GetVolumeId(), l), nil + return leaseFact(s.host.Publisher(), q.GetVolumeId(), l), nil } func (s *services) RevokeWorkspace(ctx context.Context, q *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) { @@ -140,7 +126,7 @@ func (s *services) RevokeWorkspace(ctx context.Context, q *control.WorkspaceIden if !ok { return nil, status.Error(codes.FailedPrecondition, "workspace moved during revocation") } - return leaseFact(q.GetVolumeId(), lease), nil + return leaseFact(s.host.Publisher(), q.GetVolumeId(), lease), nil } func (s *services) AckWorkspaceRevoked(ctx context.Context, q *control.WorkspaceRevocationAck) (*control.WorkspaceEmpty, error) { @@ -416,7 +402,7 @@ func (s *services) QueryWorkspace(ctx context.Context, q *control.WorkspaceVolum return out, nil } if lease, ok := s.host.Publisher().WorkspaceLeaseReply(q.GetVolumeId()); ok { - out.Lease = leaseFact(q.GetVolumeId(), lease) // granted expiry, not the durable horizon + out.Lease = leaseFact(s.host.Publisher(), q.GetVolumeId(), lease) // granted expiry, not the durable horizon } if state.Ack != nil { out.RevocationAck = &control.WorkspaceRevocationAck{Identity: &control.WorkspaceIdentity{VolumeId: q.GetVolumeId(), ReplicaId: state.Ack.ReplicaID, Epoch: state.Ack.Epoch}, HeadGen: state.Ack.HeadGen} diff --git a/seaweed-block/core/host/master/workspace_skew_test.go b/seaweed-block/core/host/master/workspace_skew_test.go index a26ec75701..e6a3317d2d 100644 --- a/seaweed-block/core/host/master/workspace_skew_test.go +++ b/seaweed-block/core/host/master/workspace_skew_test.go @@ -19,7 +19,7 @@ func (c skewLeaseClient) RenewWorkspaceLease(ctx context.Context, id *control.Wo if err != nil { return nil, err } - return leaseFact(id.VolumeId, l), nil + return leaseFact(c.p, id.VolumeId, l), nil } func (skewLeaseClient) AckWorkspaceRevoked(context.Context, *control.WorkspaceRevocationAck, ...grpc.CallOption) (*control.WorkspaceEmpty, error) { panic("expiry must not ACK clean") @@ -151,7 +151,6 @@ func TestWorkspaceClockSkewConfigReachesLeaseReply(t *testing.T) { func TestWorkspaceLeaseFactUsesPublisherClockAndSkew(t *testing.T) { now := time.Unix(1000, 0) p := authority.NewPublisher(nil, authority.WithWorkspaceLeaseConfig(12*time.Second, func() time.Time { return now }), authority.WithWorkspaceMaxClockSkew(4*time.Second)) - _ = p for _, tc := range []struct { name string expiry time.Duration @@ -165,7 +164,7 @@ func TestWorkspaceLeaseFactUsesPublisherClockAndSkew(t *testing.T) { } { t.Run(tc.name, func(t *testing.T) { l := authority.WorkspaceLease{ReplicaID: "r", Epoch: 1, ExpiresAtNS: now.Add(tc.expiry).UnixNano(), MaxClockSkewNS: tc.skew} - fact := leaseFact("v", l) + fact := leaseFact(p, "v", l) if fact.ValidForNs != int64(tc.want) { t.Fatalf("validity=%s, want %s", time.Duration(fact.ValidForNs), tc.want) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 19bb6ca18b..3d06edcae3 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -134,7 +134,7 @@ a pre-issued publication. | none | Granted | `RenewWorkspaceLease` from the current primary (server id, replica id) at the current epoch; a missing/foreign server is refused by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`); no move pending; the first grant is written synchronously and persists the durable horizon now + 1.5·TTL (an epoch issued by a move already has its lease) | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `firstWorkspaceGrant`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Granted | Granted | current primary server/replica/epoch required by RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) (missing server refused); renew from memory (the lease view, leaf lock only) before the durable horizon and the granted deadline; the grant is min(now + TTL, horizon), refused with an error when it would leave no host validity (grant − skew/2 ≤ now); an extender, an ordinary writer under the publisher lock, raises the horizon to trigger + 1.5·TTL | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `extendWorkspaceLease`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-LEASE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LEASE-HORIZON-MONO-001`, `INV-WS-RENEW-NONBLOCKING-001`, `INV-LEASE-VIEW-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Granted | Revoking | `BeginWorkspaceRevocation` for the matching lease; a renew now returns the revoking lease with the granted expiry, min(horizon, deadline), without extending it | `core/authority/workspace.go` `BeginWorkspaceRevocation`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `WorkspaceLeaseReply` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001` | -| Revoking | Acked | `AckWorkspaceRevocation` from the primary server/replica at the current epoch, validated by the same RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) (missing/foreign server refused), a nonzero HEAD generation, the lease still valid; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001`, `INV-AUTH-HOLDER-IDENTITY-001` | +| Revoking | Acked | `AckWorkspaceRevocation` from the primary server/replica at the current epoch, validated by the same RPC holderMatches (registered server id, gRPC peer on its registered host: `refuseWorkspaceHolderHost`) (missing/foreign server refused), a nonzero HEAD generation, positive granted validity after half the configured/persisted skew on the publisher clock; a different second acknowledgement is refused | `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/master/workspace_service.go` `holderMatches` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-REVOKE-ACK-001`, `INV-AUTH-HOLDER-IDENTITY-001` | | Acked | Moved (clean) | HEAD detached by the expected holder at the expected epoch, and the acknowledgement names that HEAD generation; the target may be the same host, with a newly issued epoch and every binding/collision/isolation check retained | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `validateWorkspaceMoveRequest`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-SAME-HOST-CLEAN-MOVE-001` | | Acked or Expired | (move refused, nothing written) | blockmaster admits a move only with valid target endpoints (host:port, port 1..65535, data and ctrl distinct), a known source host, a registered target node (the source itself only for a clean, non-force move), and target endpoints that either match a live per-volume binding or, for a volume without bindings, lie on the target node's registered hosts (any port) and are not owned by another assignment or binding, and, under strict journal isolation, a target node whose durable root does not share the authority store's file system (the retry of an issued move excepted); each refusal names its condition and is logged | `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked`; `core/host/master/journal_isolation.go` `colocatedTargetRefused` | `INV-WS-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-MASTER-JOURNAL-ISOLATION-001` | | Granted or Revoking | Expired | the durable horizon or the granted deadline passes | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/authority/workspace.go` `AckWorkspaceRevocation` | `INV-WS-FORCED-MOVE-001` | @@ -722,7 +722,7 @@ Notes: | `INV-WS-CLEAN-MOVE-001` | A clean move is granted only with a detached HEAD from the expected holder and a matching revocation acknowledgement at the current epoch. | M2 lease: Acked → Moved | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `AckWorkspaceRevocation` | `TestWorkspaceCleanMoveNeedsDetachedHEADAndRevocationAck` (`core/authority/workspace_test.go`) | `WorkspaceTakeover` `CleanNoLoss` | ACTIVE | | `INV-WS-FORCED-MOVE-001` | A forced move is admitted only after the persisted lease horizon and the granted or restart deadline, each plus the clock-skew bound, have passed for the lease the last move issue started (never a predecessor's): see M2 Expired → Moved (forced). | M2 lease: Expired → Moved (forced) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveAdmissionLocked`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`; `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked` | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`); `TestWorkspaceClockSkewPersistsAndProtectsRestart` (`core/authority/workspace_skew_test.go`); `TestWorkspaceForcedMoveRequiresExplicitForceAndLeaseExpiry` (`core/authority/workspace_test.go`); `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignAfterExpiry`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceLateClaimThenUnclaimedGrantForcedReassign` (`core/authority/workspace_unclaimed_grant_test.go`); `TestWorkspaceForcedMoveAdmittedMatchesMoveAdmission` (`core/authority/workspace_forced_admission_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignOverRPC` (`core/host/master/workspace_unclaimed_grant_test.go`); `TestWorkspacePausedGranteeRefusedAtAttach` (`core/host/master/workspace_paused_grantee_test.go`) | — | ACTIVE | | `INV-WS-FORCED-MOVE-REPLY-001` | The lease expiry the master reports to a host is the granted expiry, never the persisted horizon. | M2 Granted → Granted; Granted → Revoking | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `WorkspaceLeaseReply`, `replyExpiryNS`; `core/host/master/workspace_service.go` `RevokeWorkspace` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceSameVolumeRenewalDuringHeldWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignAfterExpiry` (`core/authority/workspace_unclaimed_grant_test.go`) | — | ACTIVE | -| `INV-WS-FORCED-MOVE-HALF-SKEW-001` | The validity the master gives a host with a lease ends half the clock-skew bound before the reported lease expiry. | M2 Granted → Granted (reply); M4 NoLease, Valid → Valid | `core/host/master/workspace_service.go` `leaseFact`; `core/host/volume/workspace_lease.go` `Refresh` | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`) | — | ACTIVE | +| `INV-WS-FORCED-MOVE-HALF-SKEW-001` | The validity the master gives a host with a lease ends half the clock-skew bound before the reported lease expiry. | M2 Granted → Granted (reply); M4 NoLease, Valid → Valid | `core/authority/workspace_lease_view.go` `WorkspaceLeaseValidity`, `workspaceLeaseValidityAt`; `core/host/master/workspace_service.go` `leaseFact`; `core/authority/workspace.go` `AckWorkspaceRevocation`; `core/host/volume/workspace_lease.go` `Refresh` | `TestWorkspaceLeaseFactUsesPublisherClockAndSkew` (`core/host/master/workspace_skew_test.go`); `TestWorkspaceAckUsesGrantedHalfSkewBoundary` (`core/authority/workspace_validity_test.go`); `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`) | — | ACTIVE | | `INV-WS-LOST-RANGE-READOUT-001` | Every issued forced grant the master returns, also on a replay and after a restart, carries the lost range stored in the authority store before the issue, never a recomputed one: see M2 Moved → epoch issued. | M2 lease: Expired → Moved (forced); Moved → epoch issued | `core/authority/workspace_lost_range.go` `recordLostRangeLocked`, `WorkspaceLostRangeReadouts`, `encodeLostRangeEnvelope`; `core/authority/workspace.go` `prepareWorkspaceMoveLocked`; `core/host/master/workspace_head.go` `headFilerMtimeNS`; `core/host/master/workspace_service.go` `grantWithLostRange`, `issuedRecord`; `core/rpc/wsclient/wsclient.go` `Readout` | `TestWorkspaceForcedMoveRecordsTheLostRange`, `TestWorkspaceForcedMoveLostRangeOrdering`, `TestWorkspaceForcedReservationResumeNeedsItsRange` (`core/authority/workspace_lost_range_test.go`); `TestWorkspaceForcedMoveStoresHeadFilerTime` (`core/authority/workspace_lost_range_readout_test.go`); `TestWorkspaceForcedMoveLostRangeOverRPC`, `TestWorkspaceHEADReadsFilerMtime` (`core/host/master/workspace_lost_range_readout_test.go`); `TestReadoutWording` (`core/rpc/wsclient/wsclient_test.go`); `TestWorkspaceForceMove_Row3and4_SentAndGranted` (`cmd/sw-block/workspace_test.go`); `TestWorkspaceForceMoveAgainstRealMaster` (`cmd/sw-block/workspace_master_test.go`) | — | ACTIVE | | `INV-WS-LOST-RANGE-QUERY-001` | `QueryWorkspaceLostRange` returns the stored ranges unchanged: every issued forced move's range in issue order, or the single range of a given request id. | M2 lease: Moved → epoch issued (readout) | `core/authority/workspace_lost_range.go` `WorkspaceLostRangeReadouts`; `core/host/master/workspace_service.go` `QueryWorkspaceLostRange`; `core/rpc/wsclient/wsclient.go` `LostRanges`; `cmd/sw-block/workspace.go` `runWorkspaceLostRange` | `TestWorkspaceLostRangeAccumulatesInIssueOrder` (`core/authority/workspace_lost_range_readout_test.go`); `TestLostRangesBindsTheAnswer` (`core/rpc/wsclient/wsclient_test.go`); `TestWorkspaceLostRangeListsAllInOrder` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | | `INV-WS-LOST-RANGE-FAILCLOSED-001` | If an issued forced move's range record is missing or fails its range or HEAD-time checksum, the readout fails: the grant carries no range but the reason, the query returns `DataLoss`, the CLI exits 4; none reports the move as no loss. | M2 lease: Moved → epoch issued | `core/authority/workspace_lost_range.go` `LoadWorkspaceLostRanges`, `decodeLostRangeHeadTimes`, `WorkspaceLostRangeReadouts`; `core/host/master/workspace_service.go` `grantWithLostRange`, `QueryWorkspaceLostRange`; `core/rpc/wsclient/wsclient.go` `classify`, `checkRange`; `cmd/sw-block/workspace.go` `runWorkspaceForceMove`, `runWorkspaceLostRange` | `TestWorkspaceLostRangeReadoutFailsClosed`, `TestWorkspaceLostRangeHeadTimeTamperFailsClosed`, `TestWorkspaceLostRangeSkippedWriteIsDetected` (`core/authority/workspace_lost_range_readout_test.go`); `TestForceMoveGrantWithoutRangeIsUnproven` (`core/rpc/wsclient/wsclient_test.go`); `TestWorkspaceForceMove_Row7_ReadoutUnproven` (`cmd/sw-block/workspace_test.go`) | — | ACTIVE | @@ -755,7 +755,7 @@ Notes: - `INV-WS-FORCED-MOVE-001`: TLA+: `W4_drift` found the gap before #158; the skew margin itself is not in the model. Extended for a new holder that dies between its grant and its HEAD claim: the move issue starts its lease, admission uses that grant's lease, HEAD is read after admission, an older-epoch HEAD is accepted (its generation and remote LSN may have moved by an earlier holder's late claim), and a returning holder is refused by two fences, its lease-gated attach and the higher HEAD epoch. `WorkspaceTakeover` models one move from A to B and does not cover a second move away from an unclaimed grant; that model check is open and not claimed here. - `INV-WS-LOST-RANGE-READOUT-001`: The HEAD time is the HEAD filer entry's mtime from the filer's `Last-Modified` header on the same read as the HEAD content (1 s resolution). chunkstore writes that mtime from the clock of the host that wrote the entry (the cut); the readout labels it "(publishing host clock as recorded in the filer, 1 s resolution)", and it is not a master time; there is no HEAD format change. The HEAD times sit beside the v1 ranges in the lost-range file with their own checksum, so a binary that predates them still verifies the file; a record without one reads as unknown. The readout reads the ranges loaded at startup: damage after startup shows at the next load. The no-HEAD form ("no remote image exists") is defensive: the master refuses a forced move without a published HEAD. The header is checked against test HTTP servers only; the `chunkstore_integration` test does not assert it. Not in the TLA+ models. - `INV-WS-FORCED-CONFIRM-001`: A client-side rule: the master's own guards (explicit force, admission, expected epoch) are `INV-WS-FORCED-MOVE-001`. The holder's logical replica id is read from `QueryWorkspace` (the lease, or the journal on a rerun). The holder check (`INV-WS-FORCED-CONFIRM-HOLDER-001`) sends that one `QueryWorkspace` RPC; only the move is withheld. -- `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`: the persisted lease horizon is at least every grant (`INV-WS-LEASE-HORIZON-001`). blockmaster reads HEAD only after the forced admission holds; HEAD must be the expected holder's at the expected epoch, or any HEAD at an older epoch; the lost range starts at that HEAD's remote LSN: see M2 Expired → Moved (forced) (tests `TestWorkspaceUnclaimedGrantForcedReassignOverRPC`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceForcedMoveRecordsTheLostRange`). The publisher checks the admission again when it issues the move. The host counts its validity from the start of its renewal request: see M4 NoLease, Valid → Valid. The validity is a duration computed on the master's wall clock (`time.Until`); `leaseFact` also caps it at 30 s and uses a 20 s bound when an older persisted lease carries none. +- `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`: the persisted lease horizon is at least every grant (`INV-WS-LEASE-HORIZON-001`). blockmaster reads HEAD only after the forced admission holds; HEAD must be the expected holder's at the expected epoch, or any HEAD at an older epoch; the lost range starts at that HEAD's remote LSN: see M2 Expired → Moved (forced) (tests `TestWorkspaceUnclaimedGrantForcedReassignOverRPC`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceForcedMoveRecordsTheLostRange`). The publisher checks the admission again when it issues the move. The host counts its validity from the start of its renewal request: see M4 NoLease, Valid → Valid. The authority-owned `WorkspaceLeaseValidity` computes duration on the publisher clock with its configured TTL and the larger configured/persisted skew, including legacy leases with no stored bound. Renewal admission, RPC replies and revocation ACK admission share that calculation; ACK uses the granted deadline clamped to the durable horizon. `workspaceDetachedGeneration` reads its exact stored seal through `ReadDetachedChunkHead`; `TestWorkspaceRevocationUsesExactStoredSeal` (`cmd/blockvolume/workspace_proof_test.go`) covers valid and refused proofs without publishing. - `INV-WS-LOST-RANGE-READOUT-001`: a stored range holds the kept HEAD's remote LSN; the forced-move barrier as LostUntil, in master time; the kept HEAD's generation (via the move record); and the HEAD entry's filer mtime read with that HEAD, or "unknown". A missing or damaged record is `INV-WS-LOST-RANGE-FAILCLOSED-001`. A failure after the issue (for example the binding reconciliation) is answered `Internal` naming the move ISSUED, never as a refusal: see M2 Moved → epoch issued. `PreviewWorkspaceMove` runs the forced admission, reads HEAD only once admitted, and writes nothing: see M2 Expired → Moved (forced) (tests `TestWorkspaceForcedMovePreviewWritesNothing`, `TestWorkspaceForceMove_Row2_DryRunPreview`). - `INV-WS-LOST-RANGE-UNCERTAIN-001`, `INV-WS-LOST-RANGE-PRE-ISSUE-001`: on a volume already uncertain, every failed move, an admission refusal or a HEAD-read error included, is answered as an unknown outcome and logged as unknown; only the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see `INV-AUTH-UNCERTAIN-001` and M2 Uncertain → Uncertain (move answer). - Enforced by reading (no test asserts it): the publisher's second admission check when it issues a forced move (`prepareWorkspaceMoveLocked` calls `forcedMoveAdmissionLocked`). @@ -1060,13 +1060,13 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| | `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines (through `PublishedLine.Owner`, which the snapshot builder's `expectOwnerForLine` also calls). The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | -| `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, at most 30 s. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `Publisher.AckWorkspaceRevocation` (`core/authority/workspace.go`) checks expiry again inline, without the skew term: open. `leaseFact` (`core/host/master/workspace_service.go`) recomputes the host validity with `time.Now` instead of the publisher's clock, with a 20 s skew fallback, while `RenewWorkspaceLease` refuses a grant on the same term inline: open (one helper for both). `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The 30 s TTL is written three times: the publisher's default TTL (`core/authority/authority.go`), the cap in `leaseFact`, and the reply bound in `Refresh`: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | +| `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, capped by the configured TTL. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.WorkspaceLeaseValidity` / `workspaceLeaseValidityAt` is shared by renewal admission, `leaseFact` and `AckWorkspaceRevocation`. `WorkspaceLeaseValidity` reads the publisher clock; its leaf calculation uses the larger configured/persisted skew and configured TTL. `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The host reply sanity bound in `Refresh` still repeats the publisher's default 30 s TTL: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | | `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | | `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host | -| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | +| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) delegates revocation ACK proof to `ReadDetachedChunkHead`, with `TestWorkspaceRevocationUsesExactStoredSeal` coverage. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | | `TERM-ONE-PROCESS-001` One live process per holder | At most one blockvolume process serves a holder at a time. Today a second process is refused only when it opens the same store file. A local-root nonce in the holder identity is to close the other cases (pending). | The store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); its exclusive OS file lock; the HEAD `Holder` | Volume: `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the lock's limit: it covers one file. A second process is not refused when it uses another `--durable-root`, runs on another host with the same server id, or runs on a copied root. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open, pending the local-root nonce. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | From 402a0d747966a0b76a11d2c95cc882114a13a127 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:49:11 -0800 Subject: [PATCH 164/204] refactor(workspace): defer seal proof integration until holder update --- .../cmd/blockvolume/workspace_lease.go | 6 +- .../cmd/blockvolume/workspace_proof_test.go | 58 ------------------- seaweed-block/docs/design/invariants.md | 4 +- 3 files changed, 7 insertions(+), 61 deletions(-) delete mode 100644 seaweed-block/cmd/blockvolume/workspace_proof_test.go diff --git a/seaweed-block/cmd/blockvolume/workspace_lease.go b/seaweed-block/cmd/blockvolume/workspace_lease.go index 4362b51e82..b0724b8288 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease.go @@ -60,9 +60,13 @@ func workspaceDetachedGeneration(ctx context.Context, remoteFor func(string) (st if err != nil { return 0, err } - head, err := storage.ReadDetachedChunkHead(ctx, remote, id.Epoch, holder) + head, err := remote.GetHead(ctx) if err != nil { return 0, err } + proof := head.DetachedBy + if head.Gen == 0 || head.Epoch != id.Epoch || head.Holder != holder || head.State != storage.ChunkHeadDetached || proof == nil || proof.Gen != head.Gen || proof.Epoch != head.Epoch || proof.Holder != head.Holder { + return 0, fmt.Errorf("workspace shutdown has no matching stored detached HEAD") + } return head.Gen, nil } diff --git a/seaweed-block/cmd/blockvolume/workspace_proof_test.go b/seaweed-block/cmd/blockvolume/workspace_proof_test.go deleted file mode 100644 index 6bbbf4e56d..0000000000 --- a/seaweed-block/cmd/blockvolume/workspace_proof_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package main - -import ( - "context" - "errors" - control "github.com/seaweedfs/seaweed-block/core/rpc/control" - "github.com/seaweedfs/seaweed-block/core/storage" - "testing" -) - -type workspaceProofRemote struct { - storage.ChunkRemote - head storage.ChunkHead - err error - reads int -} - -func (r *workspaceProofRemote) GetHead(context.Context) (storage.ChunkHead, error) { - r.reads++ - return r.head, r.err -} - -func TestWorkspaceRevocationUsesExactStoredSeal(t *testing.T) { - for _, name := range []string{"valid", "zero-epoch", "empty-holder", "active", "proof-gen", "foreign-holder", "read-error"} { - t.Run(name, func(t *testing.T) { - h := storage.ChunkHead{Gen: 7, Epoch: 2, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Gen: 7, Epoch: 2, Holder: "s/r"}} - id := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 2} - holder := "s/r" - r := &workspaceProofRemote{head: h} - switch name { - case "zero-epoch": - id.Epoch = 0 - r.head.Epoch = 0 - r.head.DetachedBy.Epoch = 0 - case "empty-holder": - holder = "" - r.head.Holder = "" - r.head.DetachedBy.Holder = "" - case "active": - r.head.State = storage.ChunkHeadActive - case "proof-gen": - r.head.DetachedBy.Gen = 6 - case "foreign-holder": - r.head.Holder = "other/r" - case "read-error": - r.err = errors.New("HEAD answer lost") - } - gen, err := workspaceDetachedGeneration(context.Background(), func(string) (storage.ChunkRemote, error) { return r, nil }, id, holder) - if name == "valid" { - if err != nil || gen != 7 || r.reads != 1 { - t.Fatalf("stored seal: gen%d reads%d err%v", gen, r.reads, err) - } - } else if err == nil || gen != 0 { - t.Fatalf("unproven ACK gen%d err%v", gen, err) - } - }) - } -} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 3d06edcae3..532ac12870 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -755,7 +755,7 @@ Notes: - `INV-WS-FORCED-MOVE-001`: TLA+: `W4_drift` found the gap before #158; the skew margin itself is not in the model. Extended for a new holder that dies between its grant and its HEAD claim: the move issue starts its lease, admission uses that grant's lease, HEAD is read after admission, an older-epoch HEAD is accepted (its generation and remote LSN may have moved by an earlier holder's late claim), and a returning holder is refused by two fences, its lease-gated attach and the higher HEAD epoch. `WorkspaceTakeover` models one move from A to B and does not cover a second move away from an unclaimed grant; that model check is open and not claimed here. - `INV-WS-LOST-RANGE-READOUT-001`: The HEAD time is the HEAD filer entry's mtime from the filer's `Last-Modified` header on the same read as the HEAD content (1 s resolution). chunkstore writes that mtime from the clock of the host that wrote the entry (the cut); the readout labels it "(publishing host clock as recorded in the filer, 1 s resolution)", and it is not a master time; there is no HEAD format change. The HEAD times sit beside the v1 ranges in the lost-range file with their own checksum, so a binary that predates them still verifies the file; a record without one reads as unknown. The readout reads the ranges loaded at startup: damage after startup shows at the next load. The no-HEAD form ("no remote image exists") is defensive: the master refuses a forced move without a published HEAD. The header is checked against test HTTP servers only; the `chunkstore_integration` test does not assert it. Not in the TLA+ models. - `INV-WS-FORCED-CONFIRM-001`: A client-side rule: the master's own guards (explicit force, admission, expected epoch) are `INV-WS-FORCED-MOVE-001`. The holder's logical replica id is read from `QueryWorkspace` (the lease, or the journal on a rerun). The holder check (`INV-WS-FORCED-CONFIRM-HOLDER-001`) sends that one `QueryWorkspace` RPC; only the move is withheld. -- `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`: the persisted lease horizon is at least every grant (`INV-WS-LEASE-HORIZON-001`). blockmaster reads HEAD only after the forced admission holds; HEAD must be the expected holder's at the expected epoch, or any HEAD at an older epoch; the lost range starts at that HEAD's remote LSN: see M2 Expired → Moved (forced) (tests `TestWorkspaceUnclaimedGrantForcedReassignOverRPC`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceForcedMoveRecordsTheLostRange`). The publisher checks the admission again when it issues the move. The host counts its validity from the start of its renewal request: see M4 NoLease, Valid → Valid. The authority-owned `WorkspaceLeaseValidity` computes duration on the publisher clock with its configured TTL and the larger configured/persisted skew, including legacy leases with no stored bound. Renewal admission, RPC replies and revocation ACK admission share that calculation; ACK uses the granted deadline clamped to the durable horizon. `workspaceDetachedGeneration` reads its exact stored seal through `ReadDetachedChunkHead`; `TestWorkspaceRevocationUsesExactStoredSeal` (`cmd/blockvolume/workspace_proof_test.go`) covers valid and refused proofs without publishing. +- `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-REPLY-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001`: the persisted lease horizon is at least every grant (`INV-WS-LEASE-HORIZON-001`). blockmaster reads HEAD only after the forced admission holds; HEAD must be the expected holder's at the expected epoch, or any HEAD at an older epoch; the lost range starts at that HEAD's remote LSN: see M2 Expired → Moved (forced) (tests `TestWorkspaceUnclaimedGrantForcedReassignOverRPC`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceForcedMoveRecordsTheLostRange`). The publisher checks the admission again when it issues the move. The host counts its validity from the start of its renewal request: see M4 NoLease, Valid → Valid. The authority-owned `WorkspaceLeaseValidity` computes duration on the publisher clock with its configured TTL and the larger configured/persisted skew, including legacy leases with no stored bound. Renewal admission, RPC replies and revocation ACK admission share that calculation; ACK uses the granted deadline clamped to the durable horizon. - `INV-WS-LOST-RANGE-READOUT-001`: a stored range holds the kept HEAD's remote LSN; the forced-move barrier as LostUntil, in master time; the kept HEAD's generation (via the move record); and the HEAD entry's filer mtime read with that HEAD, or "unknown". A missing or damaged record is `INV-WS-LOST-RANGE-FAILCLOSED-001`. A failure after the issue (for example the binding reconciliation) is answered `Internal` naming the move ISSUED, never as a refusal: see M2 Moved → epoch issued. `PreviewWorkspaceMove` runs the forced admission, reads HEAD only once admitted, and writes nothing: see M2 Expired → Moved (forced) (tests `TestWorkspaceForcedMovePreviewWritesNothing`, `TestWorkspaceForceMove_Row2_DryRunPreview`). - `INV-WS-LOST-RANGE-UNCERTAIN-001`, `INV-WS-LOST-RANGE-PRE-ISSUE-001`: on a volume already uncertain, every failed move, an admission refusal or a HEAD-read error included, is answered as an unknown outcome and logged as unknown; only the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see `INV-AUTH-UNCERTAIN-001` and M2 Uncertain → Uncertain (move answer). - Enforced by reading (no test asserts it): the publisher's second admission check when it issues a forced move (`prepareWorkspaceMoveLocked` calls `forcedMoveAdmissionLocked`). @@ -1066,7 +1066,7 @@ A row that names a function existing only on an open pull request says so ("on # | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | | `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | | `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host | -| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) delegates revocation ACK proof to `ReadDetachedChunkHead`, with `TestWorkspaceRevocationUsesExactStoredSeal` coverage. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | +| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | | `TERM-ONE-PROCESS-001` One live process per holder | At most one blockvolume process serves a holder at a time. Today a second process is refused only when it opens the same store file. A local-root nonce in the holder identity is to close the other cases (pending). | The store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); its exclusive OS file lock; the HEAD `Holder` | Volume: `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the lock's limit: it covers one file. A second process is not refused when it uses another `--durable-root`, runs on another host with the same server id, or runs on a copied root. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open, pending the local-root nonce. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | From 115ae3651a95ea4d0ca5430291c7e8e686672183 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 08:59:22 -0800 Subject: [PATCH 165/204] test(workspace): document ACK validity edge and horizon controls --- .../core/authority/workspace_validity_test.go | 28 +++++++++++++++---- .../core/host/master/workspace_skew_test.go | 1 + .../docs/design/agent-workspace-design.md | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/seaweed-block/core/authority/workspace_validity_test.go b/seaweed-block/core/authority/workspace_validity_test.go index dcce84f5b4..96e8e74a47 100644 --- a/seaweed-block/core/authority/workspace_validity_test.go +++ b/seaweed-block/core/authority/workspace_validity_test.go @@ -11,14 +11,19 @@ func TestWorkspaceAckUsesGrantedHalfSkewBoundary(t *testing.T) { name string elapsed time.Duration allowed bool + restart bool }{ - {"before", 28*time.Second - time.Nanosecond, true}, - {"at", 28 * time.Second, false}, - {"after", 29 * time.Second, false}, + {"before", 28*time.Second - time.Nanosecond, true, false}, + {"at", 28 * time.Second, false, false}, + {"after", 29 * time.Second, false, false}, + {"horizon-before", 43*time.Second - time.Nanosecond, true, true}, + {"horizon-at", 43 * time.Second, false, true}, + {"horizon-after", 44 * time.Second, false, true}, } { t.Run(tc.name, func(t *testing.T) { disk, _ := newTempStore(t) - now := time.Unix(1000, 0) + start := time.Unix(1000, 0) + now := start p := NewPublisher(nil, WithStore(disk), WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return now }), WithWorkspaceMaxClockSkew(4*time.Second)) if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind}); err != nil { t.Fatal(err) @@ -30,7 +35,20 @@ func TestWorkspaceAckUsesGrantedHalfSkewBoundary(t *testing.T) { if err := p.BeginWorkspaceRevocation(ctx, "v", "r", 1); err != nil { t.Fatal(err) } - now = now.Add(tc.elapsed) + if tc.restart { + // Reopening at +20s gives a restart deadline of +50s, beyond + // the persisted +45s horizon. ACK must stop at +43s. + now = start.Add(20 * time.Second) + p = NewPublisher(nil, WithStore(disk), WithWorkspaceLeaseConfig(30*time.Second, func() time.Time { return now }), WithWorkspaceMaxClockSkew(4*time.Second)) + p.mu.Lock() + deadline := p.leaseDeadlineLocked("v") + horizon := p.workspace["v"].Lease.ExpiresAtNS + p.mu.Unlock() + if !deadline.After(time.Unix(0, horizon)) { + t.Fatal("fixture deadline does not exceed persisted horizon") + } + } + now = start.Add(tc.elapsed) err := p.AckWorkspaceRevocation(ctx, "v", WorkspaceRevokeAck{ReplicaID: "r", Epoch: 1, HeadGen: 7}) if (err == nil) != tc.allowed { t.Fatalf("ACK allowed=%t, want %t: %v", err == nil, tc.allowed, err) diff --git a/seaweed-block/core/host/master/workspace_skew_test.go b/seaweed-block/core/host/master/workspace_skew_test.go index e6a3317d2d..129667348c 100644 --- a/seaweed-block/core/host/master/workspace_skew_test.go +++ b/seaweed-block/core/host/master/workspace_skew_test.go @@ -158,6 +158,7 @@ func TestWorkspaceLeaseFactUsesPublisherClockAndSkew(t *testing.T) { want time.Duration }{ {"legacy-configured-bound", 10 * time.Second, 0, 8 * time.Second}, + {"persisted-smaller-bound", 10 * time.Second, int64(2 * time.Second), 8 * time.Second}, {"persisted-larger-bound", 10 * time.Second, int64(6 * time.Second), 7 * time.Second}, {"configured-ttl-cap", 40 * time.Second, 0, 12 * time.Second}, {"expired", time.Second, 0, 0}, diff --git a/seaweed-block/docs/design/agent-workspace-design.md b/seaweed-block/docs/design/agent-workspace-design.md index 265cde146c..ef5d1db91a 100644 --- a/seaweed-block/docs/design/agent-workspace-design.md +++ b/seaweed-block/docs/design/agent-workspace-design.md @@ -358,7 +358,7 @@ stateDiagram-v2 [*] --> Granted: move issue starts the new holder's lease Granted --> Granted: Renew before horizon and deadline (from memory; registered server id, from its registered host) Granted --> Revoking: BeginWorkspaceRevocation - Revoking --> Acked: host acks detached HEAD gen while the lease is valid (from its registered host) + Revoking --> Acked: registered host acks detached HEAD gen; publisher-clock validity after half max(configured, persisted) skew is positive Acked --> Moved: CLEAN move, including same host, new epoch Granted --> Expired: horizon or deadline passes Expired --> Granted: unchanged holder from its registered host, no move/revocation, MAX expiry + skew passed; durable re-grant From f0662dd31f4152fc3a54fdeebec0ac2c95d91178 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:08:31 -0800 Subject: [PATCH 166/204] test: an old host on its stale local root exits 78; on a fresh root, 75 Co-Authored-By: Claude Opus 5.5 --- .../procedure_gate_integration_test.go | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 5b41a4a7a7..2b65e12024 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -195,22 +195,22 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { t.Fatal("the block written after the last cut reads back on s2; the page says it is lost") } - // The old host returns with its old local root, and a supervisor starts - // it again after it exits. Each time it must not take s2's line as its - // own (a holder is server and replica), report its frontend ready or - // listen for I/O, and it must log a refusal and exit with status 75. - back := env.oldHostRefuses(t, "blockvolume-s1-back", env.hosts["s1"], e2) - time.Sleep(5 * time.Second) // RestartSec of the example unit - restarted := env.oldHostRefuses(t, "blockvolume-s1-restarted", env.hosts["s1"], e2) - // Control: on a fresh local root there is no stale root to refuse, and - // it must still refuse s2's line. + // The old host returns with its old local root. It must not take s2's + // line as its own (a holder is server and replica), report its frontend + // ready or listen for I/O; it logs a refusal and exits with status 78, the + // no-restart class for a local root older than HEAD (the example unit + // does not restart on 78). Started again by hand, it does the same. + back := env.oldHostRefuses(t, "blockvolume-s1-back", env.hosts["s1"], e2, 78) + again := env.oldHostRefuses(t, "blockvolume-s1-started-again", env.hosts["s1"], e2, 78) + // Control: on a fresh local root there is no stale root, so its refusal + // is the identity check alone; it exits 75, the retry class. fresh := env.hosts["s1"] fresh.root = fresh.root + "-fresh" - freshRoot := env.oldHostRefuses(t, "blockvolume-s1-fresh-root", fresh, e2) + freshRoot := env.oldHostRefuses(t, "blockvolume-s1-fresh-root", fresh, e2, 75) // A line carries its owner and that owner's endpoints: every line // delivered at the forced epoch, to the new owner and to each returning // old host alike, carries s2's own endpoints, never another host's. - if bad := wrongOwnerEndpoints(e2, env.hosts["s2"], nw, back, restarted, freshRoot); len(bad) > 0 { + if bad := wrongOwnerEndpoints(e2, env.hosts["s2"], nw, back, again, freshRoot); len(bad) > 0 { t.Errorf("epoch-%d deliveries not proven to carry s2's endpoints (want data=%s ctrl=%s in every recipient's lines):\n%s", e2, env.hosts["s2"].data, env.hosts["s2"].ctrl, strings.Join(bad, "\n")) } @@ -394,10 +394,10 @@ func exitCode(err error) int { } // oldHostRefuses starts the old holder b after the volume moved to epoch e2 -// on another host, and returns it. While it runs it must not adopt the new line, report its -// frontend ready or listen; it must log a refusal and exit with status 75 -// (a later change may give a stale local root its own status). -func (env *handoffEnv) oldHostRefuses(t *testing.T, name string, b bvHost, e2 uint64) *daemon { +// on another host, and returns it. While it runs it must not adopt the new +// line, report its frontend ready or listen; it must log a refusal and exit +// with wantExit. +func (env *handoffEnv) oldHostRefuses(t *testing.T, name string, b bvHost, e2 uint64, wantExit int) *daemon { t.Helper() d := env.h.start(t, name, env.h.volume, env.volArgsFor(b)...) var failures []string @@ -418,8 +418,8 @@ func (env *handoffEnv) oldHostRefuses(t *testing.T, name string, b bvHost, e2 ui case <-time.After(500 * time.Millisecond): } } - if err := d.wait(5 * time.Second); exitCode(err) != 75 { - failures = append(failures, fmt.Sprintf("it did not exit with status 75: %v", err)) + if err := d.wait(5 * time.Second); exitCode(err) != wantExit { + failures = append(failures, fmt.Sprintf("it did not exit with status %d: %v", wantExit, err)) } if !d.has("refusing to attach volume=v1") && !d.has("workspace lease: stale authority") && !d.has("foreign assignment") { failures = append(failures, "it logged no refusal (stale root, stale authority, or another server's assignment)") From 440f9eff3cff3d7b0fc0708c06ecfb4d13a4a45c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:26:58 -0800 Subject: [PATCH 167/204] test: the returning old host exits 75 on its old root and on a fresh root, and the unit restarts it Co-Authored-By: Claude Opus 5.5 --- .../procedure_gate_integration_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go index 2b65e12024..640bb67930 100644 --- a/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go +++ b/seaweed-block/cmd/blockvolume/procedure_gate_integration_test.go @@ -195,15 +195,16 @@ func TestProcedureForcedMoveWithTheOldHostReturning(t *testing.T) { t.Fatal("the block written after the last cut reads back on s2; the page says it is lost") } - // The old host returns with its old local root. It must not take s2's - // line as its own (a holder is server and replica), report its frontend - // ready or listen for I/O; it logs a refusal and exits with status 78, the - // no-restart class for a local root older than HEAD (the example unit - // does not restart on 78). Started again by hand, it does the same. - back := env.oldHostRefuses(t, "blockvolume-s1-back", env.hosts["s1"], e2, 78) - again := env.oldHostRefuses(t, "blockvolume-s1-started-again", env.hosts["s1"], e2, 78) + // The old host returns with its old local root, and the example unit + // (Restart=on-failure, RestartSec=5s) starts it again after it exits, + // until its start limit. Each time it must not take s2's line as its own + // (a holder is server and replica), report its frontend ready or listen + // for I/O; it logs a refusal and exits with status 75. + back := env.oldHostRefuses(t, "blockvolume-s1-back", env.hosts["s1"], e2, 75) + time.Sleep(5 * time.Second) // RestartSec of the example unit + again := env.oldHostRefuses(t, "blockvolume-s1-restarted", env.hosts["s1"], e2, 75) // Control: on a fresh local root there is no stale root, so its refusal - // is the identity check alone; it exits 75, the retry class. + // is the identity check alone; it also exits 75. fresh := env.hosts["s1"] fresh.root = fresh.root + "-fresh" freshRoot := env.oldHostRefuses(t, "blockvolume-s1-fresh-root", fresh, e2, 75) From 34f5c7656c167b9084e9771e7dc89da5a985c2d6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:21:33 -0800 Subject: [PATCH 168/204] test: reproduce node inventory loss at publication rename --- .../core/lifecycle/node_inventory.go | 15 ++- .../lifecycle/node_inventory_crash_test.go | 100 ++++++++++++++++++ 2 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 seaweed-block/core/lifecycle/node_inventory_crash_test.go diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index c241b644da..f5bd801584 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -64,10 +64,11 @@ type NodeRegistration struct { // NodeInventoryStore persists one JSON registration record per server. type NodeInventoryStore struct { - mu sync.Mutex - dir string - records map[string]NodeRegistration - published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) + mu sync.Mutex + dir string + records map[string]NodeRegistration + published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) + persistHookForTest func(string) // nil in production; crash injection at publication boundaries } // OpenNodeInventoryStore opens or creates a node inventory store. @@ -222,9 +223,15 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("lifecycle: replace node %s: %w", rec.ServerID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("before-rename") + } if err := os.Rename(tmpName, path); err != nil { return fmt.Errorf("lifecycle: rename node %s: %w", rec.ServerID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("after-rename") + } return nil } diff --git a/seaweed-block/core/lifecycle/node_inventory_crash_test.go b/seaweed-block/core/lifecycle/node_inventory_crash_test.go new file mode 100644 index 0000000000..4463d1f1be --- /dev/null +++ b/seaweed-block/core/lifecycle/node_inventory_crash_test.go @@ -0,0 +1,100 @@ +//go:build linux + +package lifecycle + +import ( + "context" + "encoding/json" + "errors" + "os" + "os/exec" + "path/filepath" + "reflect" + "strings" + "testing" + "time" +) + +func crashNodeRegistration(updated bool) NodeRegistration { + value := "old" + if updated { + value = "new" + } + return NodeRegistration{ + ServerID: "node-a", Addr: "127.0.0.1:9100", + SeenAt: time.Unix(1, 0).UTC(), + Labels: map[string]string{"payload": strings.Repeat(value, 4096)}, + } +} + +// RegisterNode must leave a complete old or new registration across a process +// crash at either side of the publication rename (V1-SPEC r2.46). +func TestNodeInventoryCrashKeepsCompleteRegistration(t *testing.T) { + for _, phase := range []string{"before-rename", "after-rename"} { + t.Run(phase, func(t *testing.T) { + dir := t.TempDir() + s, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + old, next := crashNodeRegistration(false), crashNodeRegistration(true) + if _, err := s.RegisterNode(old); err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestNodeInventoryCrashChild$", "-test.timeout=8s") + cmd.Env = append(os.Environ(), "NODE_INVENTORY_CRASH_DIR="+dir, "NODE_INVENTORY_CRASH_PHASE="+phase) + out, err := cmd.CombinedOutput() + var exit *exec.ExitError + if ctx.Err() != nil || !errors.As(err, &exit) || exit.ExitCode() != 73 { + t.Fatalf("crash point not reached: err=%v context=%v output=%s", err, ctx.Err(), out) + } + raw, err := os.ReadFile(filepath.Join(dir, "node-a.json")) + if err != nil { + t.Fatalf("crash lost the committed registration: %v", err) + } + var got NodeRegistration + if err := json.Unmarshal(raw, &got); err != nil { + t.Fatalf("crash left a partial registration: %v", err) + } + if !reflect.DeepEqual(got, old) && !reflect.DeepEqual(got, next) { + t.Fatal("crash left neither the complete old nor the complete new registration") + } + want := old + if phase == "after-rename" { + want = next + } + if !reflect.DeepEqual(got, want) { + t.Fatalf("wrong generation at %s", phase) + } + reopened, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + if got, ok := reopened.GetNodeSnapshot("node-a"); !ok || !reflect.DeepEqual(got, want) { + t.Fatal("reopened snapshot lost the complete registration") + } + }) + } +} + +func TestNodeInventoryCrashChild(t *testing.T) { + dir := os.Getenv("NODE_INVENTORY_CRASH_DIR") + if dir == "" { + t.Skip("subprocess crash injector") + } + s, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + s.persistHookForTest = func(phase string) { + if phase == os.Getenv("NODE_INVENTORY_CRASH_PHASE") { + os.Exit(73) // abrupt exit: no deferred cleanup or close + } + } + if _, err := s.RegisterNode(crashNodeRegistration(true)); err != nil { + t.Fatal(err) + } + t.Fatal("write returned without reaching the crash point") +} From ba6574c87b3bb1a60b74915273c603d782929c79 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:21:57 -0800 Subject: [PATCH 169/204] fix: atomically sync node inventory replacements --- seaweed-block/core/lifecycle/node_inventory.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index f5bd801584..da5b90d81b 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -217,12 +217,15 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write node temp %s: %w", rec.ServerID, err) } + if err := tmp.Sync(); err != nil { + _ = tmp.Close() + return fmt.Errorf("lifecycle: sync node temp %s: %w", rec.ServerID, err) + } if err := tmp.Close(); err != nil { return fmt.Errorf("lifecycle: close node temp %s: %w", rec.ServerID, err) } - if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { - return fmt.Errorf("lifecycle: replace node %s: %w", rec.ServerID, err) - } + // V1-SPEC r2.46: replace without an absent-file window; acknowledge only + // after both the complete candidate and its directory entry are synced. if s.persistHookForTest != nil { s.persistHookForTest("before-rename") } @@ -232,6 +235,9 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } + if err := syncBindingParent(s.dir); err != nil { + return fmt.Errorf("lifecycle: sync node directory %s: %w", rec.ServerID, err) + } return nil } From 5ea7c6a006416602a228bb372cd732e9e713ec30 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:26:32 -0800 Subject: [PATCH 170/204] docs: bind node inventory crash safety to durability invariant --- seaweed-block/core/lifecycle/node_inventory.go | 2 +- seaweed-block/core/lifecycle/node_inventory_crash_test.go | 2 +- seaweed-block/docs/design/invariants.md | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index da5b90d81b..b18d6cbd1e 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -224,7 +224,7 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { if err := tmp.Close(); err != nil { return fmt.Errorf("lifecycle: close node temp %s: %w", rec.ServerID, err) } - // V1-SPEC r2.46: replace without an absent-file window; acknowledge only + // INV-LIFECYCLE-STORE-DURABLE-001: replace without an absent-file window; acknowledge only // after both the complete candidate and its directory entry are synced. if s.persistHookForTest != nil { s.persistHookForTest("before-rename") diff --git a/seaweed-block/core/lifecycle/node_inventory_crash_test.go b/seaweed-block/core/lifecycle/node_inventory_crash_test.go index 4463d1f1be..c84c43142a 100644 --- a/seaweed-block/core/lifecycle/node_inventory_crash_test.go +++ b/seaweed-block/core/lifecycle/node_inventory_crash_test.go @@ -28,7 +28,7 @@ func crashNodeRegistration(updated bool) NodeRegistration { } // RegisterNode must leave a complete old or new registration across a process -// crash at either side of the publication rename (V1-SPEC r2.46). +// crash at either side of the publication rename (INV-LIFECYCLE-STORE-DURABLE-001). func TestNodeInventoryCrashKeepsCompleteRegistration(t *testing.T) { for _, phase := range []string{"before-rename", "after-rename"} { t.Run(phase, func(t *testing.T) { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 19bb6ca18b..96ea82b964 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -465,7 +465,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -313 rows: 242 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 298 new. +314 rows: 243 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 299 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -650,6 +650,7 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the node file is the complete old or the complete new record, never absent or partial; a put that returned nil has fsynced the file and its directory. | M2 node registration publication | `core/lifecycle/node_inventory.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | From 4bc0d302c6251657e3cb2bce372bf30dfe65421b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:28:04 -0800 Subject: [PATCH 171/204] docs: generalize lifecycle durability row and record open gaps --- seaweed-block/docs/design/invariants.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 96ea82b964..a1e1dc0686 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -650,13 +650,14 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the node file is the complete old or the complete new record, never absent or partial; a put that returned nil has fsynced the file and its directory. | M2 node registration publication | `core/lifecycle/node_inventory.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 node registration publication | `core/lifecycle/node_inventory.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | Notes: +- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `FileStore.putLocked` (`core/lifecycle/store.go`) and `PlacementIntentStore.putLocked` (`core/lifecycle/placement_intent.go`) still remove the previous file before rename and do not fsync the replacement or its directory. The current enforcement and crash controls cover node inventory only; the other stores require separate fixes. - `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`: a failed write's durable outcome may be unknown (the record may have landed); for a workspace volume the failure latches uncertainty (`INV-AUTH-UNCERTAIN-001`). The cited test covers the non-workspace in-memory rollback. - `INV-AUTH-UNCERTAIN-001`: The cited test asserts the refusal after an unknown-outcome lease extension (rename landed, directory sync failed): the next renewal, a revocation and an endpoint change are all refused. The TLA+ configuration `S5_red_noUncertain` violates `UniqueEpoch` without it. A Revoking lease still gets its bounded drain reply, min(horizon, deadline), never extended: see M2 any (workspace) → Uncertain. A failed move on an uncertain volume is answered as an unknown outcome before any admission refusal, the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see M2 Uncertain → Uncertain (move answer). The renewal path reads uncertainty from the lease view (`INV-LEASE-VIEW-001`), not from `persistWorkspaceLocked`. - `INV-WS-LEASE-HORIZON-001`: The forced-barrier argument (a renewal that reads its clock after the barrier has read the deadline is refused) assumes nondecreasing master time. That is an assumption of the current `WorkspaceTakeover` model, whose `Tick` and `SlowTick` actions only advance `now`; it is not a consequence of `time.Now` carrying a monotonic reading, because persisted `UnixNano` deadlines are compared as wall-clock values. The existing deadline check stays alongside the horizon. The model still renews with `exp = deadline = now + TTL`; the horizon/grant split is a pending specification update (Part C rule 2). From 956a5f86eb49ffe1b9801ac64643f64714fa430d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:29:06 -0800 Subject: [PATCH 172/204] docs: disclose lifecycle failed-put and delete durability gaps --- seaweed-block/docs/design/invariants.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index a1e1dc0686..00695c83b4 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -657,7 +657,7 @@ Notes: Notes: -- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `FileStore.putLocked` (`core/lifecycle/store.go`) and `PlacementIntentStore.putLocked` (`core/lifecycle/placement_intent.go`) still remove the previous file before rename and do not fsync the replacement or its directory. The current enforcement and crash controls cover node inventory only; the other stores require separate fixes. +- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `FileStore.putLocked` (`core/lifecycle/store.go`) and `PlacementIntentStore.putLocked` (`core/lifecycle/placement_intent.go`) still remove the previous file before rename and do not fsync the replacement or its directory. The current enforcement and crash controls cover node inventory puts only; the other stores require separate fixes. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record. `NodeInventoryStore.RemoveNode` does not fsync its directory after deletion, so a removed node can reappear after a crash. - `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`: a failed write's durable outcome may be unknown (the record may have landed); for a workspace volume the failure latches uncertainty (`INV-AUTH-UNCERTAIN-001`). The cited test covers the non-workspace in-memory rollback. - `INV-AUTH-UNCERTAIN-001`: The cited test asserts the refusal after an unknown-outcome lease extension (rename landed, directory sync failed): the next renewal, a revocation and an endpoint change are all refused. The TLA+ configuration `S5_red_noUncertain` violates `UniqueEpoch` without it. A Revoking lease still gets its bounded drain reply, min(horizon, deadline), never extended: see M2 any (workspace) → Uncertain. A failed move on an uncertain volume is answered as an unknown outcome before any admission refusal, the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see M2 Uncertain → Uncertain (move answer). The renewal path reads uncertainty from the lease view (`INV-LEASE-VIEW-001`), not from `persistWorkspaceLocked`. - `INV-WS-LEASE-HORIZON-001`: The forced-barrier argument (a renewal that reads its clock after the barrier has read the deadline is refused) assumes nondecreasing master time. That is an assumption of the current `WorkspaceTakeover` model, whose `Tick` and `SlowTick` actions only advance `now`; it is not a consequence of `time.Now` carrying a monotonic reading, because persisted `UnixNano` deadlines are compared as wall-clock values. The existing deadline check stays alongside the horizon. The model still renews with `exp = deadline = now + TTL`; the horizon/grant split is a pending specification update (Part C rule 2). From 16ea488a0bbb825ff376826efd3485306e38a3b8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:30:55 -0800 Subject: [PATCH 173/204] test: reproduce volume and placement record loss across rename --- .../core/lifecycle/placement_intent.go | 15 +- seaweed-block/core/lifecycle/store.go | 9 +- .../core/lifecycle/store_crash_test.go | 136 ++++++++++++++++++ 3 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 seaweed-block/core/lifecycle/store_crash_test.go diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index 7d4a58ef8a..d93fc07d19 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -35,10 +35,11 @@ type PlacementIntent struct { // PlacementIntentStore persists one placement intent per volume. type PlacementIntentStore struct { - mu sync.Mutex - dir string - records map[string]PlacementIntent - published sync.Map // committed immutable PlacementIntent values; renewal never takes mu + mu sync.Mutex + dir string + records map[string]PlacementIntent + published sync.Map // committed immutable PlacementIntent values; renewal never takes mu + persistHookForTest func(string) // nil in production; crash injection at publication boundaries } // OpenPlacementIntentStore opens or creates a placement intent store. @@ -200,9 +201,15 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("lifecycle: replace placement intent %s: %w", rec.VolumeID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("before-rename") + } if err := os.Rename(tmpName, path); err != nil { return fmt.Errorf("lifecycle: rename placement intent %s: %w", rec.VolumeID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("after-rename") + } return nil } diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index 89b1e6ae66..5c3c130115 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -57,7 +57,8 @@ type FileStore struct { records map[string]VolumeRecord // snap mirrors records as an immutable copy, republished at every change // of records, for lock-free renewal-path reads. - snap atomic.Pointer[map[string]VolumeRecord] + snap atomic.Pointer[map[string]VolumeRecord] + persistHookForTest func(string) // nil in production; crash injection at publication boundaries } // publishLocked republishes the immutable snapshot of records. Caller holds @@ -311,9 +312,15 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { return fmt.Errorf("lifecycle: replace %s: %w", rec.Spec.VolumeID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("before-rename") + } if err := os.Rename(tmpName, path); err != nil { return fmt.Errorf("lifecycle: rename %s: %w", rec.Spec.VolumeID, err) } + if s.persistHookForTest != nil { + s.persistHookForTest("after-rename") + } return nil } diff --git a/seaweed-block/core/lifecycle/store_crash_test.go b/seaweed-block/core/lifecycle/store_crash_test.go new file mode 100644 index 0000000000..0f65092de7 --- /dev/null +++ b/seaweed-block/core/lifecycle/store_crash_test.go @@ -0,0 +1,136 @@ +//go:build linux + +package lifecycle + +import ( + "context" + "encoding/json" + "errors" + "os" + "os/exec" + "path/filepath" + "reflect" + "strings" + "testing" + "time" +) + +// INV-LIFECYCLE-STORE-DURABLE-001: each public write retains the complete +// old/new record across abrupt process exit at both rename boundaries. +func TestFileStoreCrashKeepsCompleteRecord(t *testing.T) { checkStoreCrash(t, "volume") } +func TestPlacementStoreCrashKeepsCompleteRecord(t *testing.T) { checkStoreCrash(t, "placement") } + +type recordCrashFixture struct { + old, next any + put func(bool) error + get func() (any, bool) +} + +func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) recordCrashFixture { + t.Helper() + if kind == "volume" { + s, err := OpenFileStore(dir) + if err != nil { + t.Fatal(err) + } + s.persistHookForTest = hook + old := VolumeRecord{Spec: VolumeSpec{VolumeID: "vol-a", SizeBytes: 1 << 20, ReplicationFactor: 1, Protocol: "iscsi", PVCName: strings.Repeat("payload", 1024)}} + next := old + next.AttachedTo = "node-b" + return recordCrashFixture{old: old, next: next, + put: func(updated bool) error { + if updated { + _, err := s.AttachVolume("vol-a", "node-b") + return err + } + _, err := s.CreateVolume(old.Spec) + return err + }, get: func() (any, bool) { r, ok := s.GetVolumeSnapshot("vol-a"); return r, ok }, + } + } + if kind != "placement" { + t.Fatalf("unknown fixture %q", kind) + } + s, err := OpenPlacementIntentStore(dir) + if err != nil { + t.Fatal(err) + } + s.persistHookForTest = hook + old := PlacementIntent{VolumeID: "vol-a", DesiredRF: 1, Slots: []PlacementSlotIntent{{ServerID: "node-a", PoolID: strings.Repeat("old", 4096), Source: PlacementSourceBlankPool}}} + next := copyPlacementIntent(old) + next.Slots[0].PoolID = strings.Repeat("new", 4096) + return recordCrashFixture{old: old, next: next, + put: func(updated bool) error { + r := old + if updated { + r = next + } + _, err := s.ApplyPlan(PlacementPlan{VolumeID: "vol-a", DesiredRF: 1, Candidates: []PlacementCandidate{{VolumeID: "vol-a", ServerID: "node-a", PoolID: r.Slots[0].PoolID, Source: PlacementSourceBlankPool}}}) + return err + }, get: func() (any, bool) { r, ok := s.GetPlacementSnapshot("vol-a"); return r, ok }, + } +} + +func checkStoreCrash(t *testing.T, kind string) { + t.Helper() + for _, phase := range []string{"before-rename", "after-rename"} { + t.Run(phase, func(t *testing.T) { + dir := t.TempDir() + f := openRecordCrashFixture(t, kind, dir, nil) + if err := f.put(false); err != nil { + t.Fatal(err) + } + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestRecordStoreCrashChild$", "-test.timeout=8s") + cmd.Env = append(os.Environ(), "RECORD_STORE_CRASH_DIR="+dir, "RECORD_STORE_CRASH_KIND="+kind, "RECORD_STORE_CRASH_PHASE="+phase) + out, err := cmd.CombinedOutput() + var exit *exec.ExitError + if ctx.Err() != nil || !errors.As(err, &exit) || exit.ExitCode() != 73 { + t.Fatalf("crash point not reached: %v context=%v output=%s", err, ctx.Err(), out) + } + raw, err := os.ReadFile(filepath.Join(dir, "vol-a.json")) + if err != nil { + t.Fatalf("crash lost the committed record: %v", err) + } + want := f.old + if phase == "after-rename" { + want = f.next + } + wantRaw, err := json.Marshal(want) + if err != nil { + t.Fatal(err) + } + var gotJSON, wantJSON any + if err := json.Unmarshal(raw, &gotJSON); err != nil { + t.Fatalf("partial record: %v", err) + } + if err := json.Unmarshal(wantRaw, &wantJSON); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(gotJSON, wantJSON) { + t.Fatalf("wrong or incomplete record at %s", phase) + } + reopened := openRecordCrashFixture(t, kind, dir, nil) + if got, ok := reopened.get(); !ok || !reflect.DeepEqual(got, want) { + t.Fatal("reopened snapshot differs from the complete record") + } + }) + } +} + +func TestRecordStoreCrashChild(t *testing.T) { + dir := os.Getenv("RECORD_STORE_CRASH_DIR") + if dir == "" { + t.Skip("subprocess crash injector") + } + f := openRecordCrashFixture(t, os.Getenv("RECORD_STORE_CRASH_KIND"), dir, func(phase string) { + if phase == os.Getenv("RECORD_STORE_CRASH_PHASE") { + os.Exit(73) + } + }) + if err := f.put(true); err != nil { + t.Fatal(err) + } + t.Fatal("write returned without reaching the crash point") +} From 33097cb79769b39e51dc0e25150b56b6a9a541be Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:31:31 -0800 Subject: [PATCH 174/204] fix: durably replace volume and placement lifecycle records --- seaweed-block/core/lifecycle/placement_intent.go | 12 +++++++++--- seaweed-block/core/lifecycle/store.go | 15 +++++++++------ seaweed-block/docs/design/invariants.md | 4 ++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index d93fc07d19..bcd9253cea 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -195,12 +195,15 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write placement intent temp %s: %w", rec.VolumeID, err) } + if err := tmp.Sync(); err != nil { + _ = tmp.Close() + return fmt.Errorf("lifecycle: sync placement intent temp %s: %w", rec.VolumeID, err) + } if err := tmp.Close(); err != nil { return fmt.Errorf("lifecycle: close placement intent temp %s: %w", rec.VolumeID, err) } - if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { - return fmt.Errorf("lifecycle: replace placement intent %s: %w", rec.VolumeID, err) - } + // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. + if s.persistHookForTest != nil { s.persistHookForTest("before-rename") } @@ -210,6 +213,9 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } + if err := syncBindingParent(s.dir); err != nil { + return fmt.Errorf("lifecycle: sync placement intent directory %s: %w", rec.VolumeID, err) + } return nil } diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index 5c3c130115..54cacf328a 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -303,15 +303,15 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write temp %s: %w", rec.Spec.VolumeID, err) } + if err := tmp.Sync(); err != nil { + _ = tmp.Close() + return fmt.Errorf("lifecycle: sync record temp %s: %w", rec.Spec.VolumeID, err) + } if err := tmp.Close(); err != nil { return fmt.Errorf("lifecycle: close temp %s: %w", rec.Spec.VolumeID, err) } - // Windows os.Rename does not replace existing files. Remove first; - // lifecycle records are intent metadata, and the in-memory state is - // updated only after this write succeeds. - if err := os.Remove(path); err != nil && !errors.Is(err, os.ErrNotExist) { - return fmt.Errorf("lifecycle: replace %s: %w", rec.Spec.VolumeID, err) - } + // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. + if s.persistHookForTest != nil { s.persistHookForTest("before-rename") } @@ -321,6 +321,9 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } + if err := syncBindingParent(s.dir); err != nil { + return fmt.Errorf("lifecycle: sync record directory %s: %w", rec.Spec.VolumeID, err) + } return nil } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 00695c83b4..6563b4a00b 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -650,14 +650,14 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 node registration publication | `core/lifecycle/node_inventory.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord` (`core/lifecycle/store_crash_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | Notes: -- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `FileStore.putLocked` (`core/lifecycle/store.go`) and `PlacementIntentStore.putLocked` (`core/lifecycle/placement_intent.go`) still remove the previous file before rename and do not fsync the replacement or its directory. The current enforcement and crash controls cover node inventory puts only; the other stores require separate fixes. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record. `NodeInventoryStore.RemoveNode` does not fsync its directory after deletion, so a removed node can reappear after a crash. +- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `NodeInventoryStore.RemoveNode` does not fsync its directory after deletion, so a removed node can reappear after a crash. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record. - `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`: a failed write's durable outcome may be unknown (the record may have landed); for a workspace volume the failure latches uncertainty (`INV-AUTH-UNCERTAIN-001`). The cited test covers the non-workspace in-memory rollback. - `INV-AUTH-UNCERTAIN-001`: The cited test asserts the refusal after an unknown-outcome lease extension (rename landed, directory sync failed): the next renewal, a revocation and an endpoint change are all refused. The TLA+ configuration `S5_red_noUncertain` violates `UniqueEpoch` without it. A Revoking lease still gets its bounded drain reply, min(horizon, deadline), never extended: see M2 any (workspace) → Uncertain. A failed move on an uncertain volume is answered as an unknown outcome before any admission refusal, the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see M2 Uncertain → Uncertain (move answer). The renewal path reads uncertainty from the lease view (`INV-LEASE-VIEW-001`), not from `persistWorkspaceLocked`. - `INV-WS-LEASE-HORIZON-001`: The forced-barrier argument (a renewal that reads its clock after the barrier has read the deadline is refused) assumes nondecreasing master time. That is an assumption of the current `WorkspaceTakeover` model, whose `Tick` and `SlowTick` actions only advance `now`; it is not a consequence of `time.Now` carrying a monotonic reading, because persisted `UnixNano` deadlines are compared as wall-clock values. The existing deadline check stays alongside the horizon. The model still renews with `exp = deadline = now + TTL`; the horizon/grant split is a pending specification update (Part C rule 2). From d0626bdfcdb737a5fd82073ceb7b0c07c4d4d459 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:35:08 -0800 Subject: [PATCH 175/204] fix: sync lifecycle parent entries and pin sync failure publication --- .../core/lifecycle/node_inventory.go | 23 +++- .../core/lifecycle/placement_intent.go | 24 +++- seaweed-block/core/lifecycle/store.go | 22 +++- .../core/lifecycle/store_crash_test.go | 110 +++++++++++++++++- seaweed-block/docs/design/invariants.md | 2 +- 5 files changed, 165 insertions(+), 16 deletions(-) diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index b18d6cbd1e..ae615a2754 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -67,8 +67,10 @@ type NodeInventoryStore struct { mu sync.Mutex dir string records map[string]NodeRegistration - published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) - persistHookForTest func(string) // nil in production; crash injection at publication boundaries + published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) + persistHookForTest func(string) // nil in production; crash injection at publication boundaries + fileSyncForTest func(*os.File) error // nil uses the real file Sync + dirSyncForTest func(string) error // nil uses syncBindingParent } // OpenNodeInventoryStore opens or creates a node inventory store. @@ -79,6 +81,11 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) { if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir node inventory %q: %w", dir, err) } + // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. + if err := syncBindingParent(filepath.Dir(dir)); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + s := &NodeInventoryStore{ dir: dir, records: make(map[string]NodeRegistration), @@ -217,7 +224,11 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write node temp %s: %w", rec.ServerID, err) } - if err := tmp.Sync(); err != nil { + fileSync := tmp.Sync + if s.fileSyncForTest != nil { + fileSync = func() error { return s.fileSyncForTest(tmp) } + } + if err := fileSync(); err != nil { _ = tmp.Close() return fmt.Errorf("lifecycle: sync node temp %s: %w", rec.ServerID, err) } @@ -235,7 +246,11 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } - if err := syncBindingParent(s.dir); err != nil { + dirSync := syncBindingParent + if s.dirSyncForTest != nil { + dirSync = s.dirSyncForTest + } + if err := dirSync(s.dir); err != nil { return fmt.Errorf("lifecycle: sync node directory %s: %w", rec.ServerID, err) } return nil diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index bcd9253cea..8927a73a9b 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -38,8 +38,10 @@ type PlacementIntentStore struct { mu sync.Mutex dir string records map[string]PlacementIntent - published sync.Map // committed immutable PlacementIntent values; renewal never takes mu - persistHookForTest func(string) // nil in production; crash injection at publication boundaries + published sync.Map // committed immutable PlacementIntent values; renewal never takes mu + persistHookForTest func(string) // nil in production; crash injection at publication boundaries + fileSyncForTest func(*os.File) error // nil uses the real file Sync + dirSyncForTest func(string) error // nil uses syncBindingParent } // OpenPlacementIntentStore opens or creates a placement intent store. @@ -50,6 +52,11 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) { if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir placement intent %q: %w", dir, err) } + // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. + if err := syncBindingParent(filepath.Dir(dir)); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + s := &PlacementIntentStore{ dir: dir, records: make(map[string]PlacementIntent), @@ -195,7 +202,11 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write placement intent temp %s: %w", rec.VolumeID, err) } - if err := tmp.Sync(); err != nil { + fileSync := tmp.Sync + if s.fileSyncForTest != nil { + fileSync = func() error { return s.fileSyncForTest(tmp) } + } + if err := fileSync(); err != nil { _ = tmp.Close() return fmt.Errorf("lifecycle: sync placement intent temp %s: %w", rec.VolumeID, err) } @@ -203,7 +214,6 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { return fmt.Errorf("lifecycle: close placement intent temp %s: %w", rec.VolumeID, err) } // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. - if s.persistHookForTest != nil { s.persistHookForTest("before-rename") } @@ -213,7 +223,11 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } - if err := syncBindingParent(s.dir); err != nil { + dirSync := syncBindingParent + if s.dirSyncForTest != nil { + dirSync = s.dirSyncForTest + } + if err := dirSync(s.dir); err != nil { return fmt.Errorf("lifecycle: sync placement intent directory %s: %w", rec.VolumeID, err) } return nil diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index 54cacf328a..9a18faa8a2 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -58,7 +58,9 @@ type FileStore struct { // snap mirrors records as an immutable copy, republished at every change // of records, for lock-free renewal-path reads. snap atomic.Pointer[map[string]VolumeRecord] - persistHookForTest func(string) // nil in production; crash injection at publication boundaries + persistHookForTest func(string) // nil in production; crash injection at publication boundaries + fileSyncForTest func(*os.File) error // nil uses the real file Sync + dirSyncForTest func(string) error // nil uses syncBindingParent } // publishLocked republishes the immutable snapshot of records. Caller holds @@ -91,6 +93,11 @@ func OpenFileStore(dir string) (*FileStore, error) { if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir %q: %w", dir, err) } + // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. + if err := syncBindingParent(filepath.Dir(dir)); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + s := &FileStore{ dir: dir, records: make(map[string]VolumeRecord), @@ -303,7 +310,11 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { _ = tmp.Close() return fmt.Errorf("lifecycle: write temp %s: %w", rec.Spec.VolumeID, err) } - if err := tmp.Sync(); err != nil { + fileSync := tmp.Sync + if s.fileSyncForTest != nil { + fileSync = func() error { return s.fileSyncForTest(tmp) } + } + if err := fileSync(); err != nil { _ = tmp.Close() return fmt.Errorf("lifecycle: sync record temp %s: %w", rec.Spec.VolumeID, err) } @@ -311,7 +322,6 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { return fmt.Errorf("lifecycle: close temp %s: %w", rec.Spec.VolumeID, err) } // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. - if s.persistHookForTest != nil { s.persistHookForTest("before-rename") } @@ -321,7 +331,11 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { if s.persistHookForTest != nil { s.persistHookForTest("after-rename") } - if err := syncBindingParent(s.dir); err != nil { + dirSync := syncBindingParent + if s.dirSyncForTest != nil { + dirSync = s.dirSyncForTest + } + if err := dirSync(s.dir); err != nil { return fmt.Errorf("lifecycle: sync record directory %s: %w", rec.Spec.VolumeID, err) } return nil diff --git a/seaweed-block/core/lifecycle/store_crash_test.go b/seaweed-block/core/lifecycle/store_crash_test.go index 0f65092de7..c0d86a3dcc 100644 --- a/seaweed-block/core/lifecycle/store_crash_test.go +++ b/seaweed-block/core/lifecycle/store_crash_test.go @@ -24,10 +24,30 @@ type recordCrashFixture struct { old, next any put func(bool) error get func() (any, bool) + setSync func(func(*os.File) error, func(string) error) } func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) recordCrashFixture { t.Helper() + if kind == "node" { + s, err := OpenNodeInventoryStore(dir) + if err != nil { + t.Fatal(err) + } + s.persistHookForTest = hook + return recordCrashFixture{old: crashNodeRegistration(false), next: crashNodeRegistration(true), + put: func(updated bool) error { _, err := s.RegisterNode(crashNodeRegistration(updated)); return err }, + get: func() (any, bool) { + r, ok := s.GetNodeSnapshot("node-a") + memory, exists := s.GetNode("node-a") + if exists != ok || !reflect.DeepEqual(memory, r) { + t.Fatal("node records and snapshot diverged") + } + return r, ok + }, + setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, + } + } if kind == "volume" { s, err := OpenFileStore(dir) if err != nil { @@ -45,7 +65,15 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r } _, err := s.CreateVolume(old.Spec) return err - }, get: func() (any, bool) { r, ok := s.GetVolumeSnapshot("vol-a"); return r, ok }, + }, get: func() (any, bool) { + r, ok := s.GetVolumeSnapshot("vol-a") + memory, exists := s.GetVolume("vol-a") + if exists != ok || !reflect.DeepEqual(memory, r) { + t.Fatal("volume records and snapshot diverged") + } + return r, ok + }, + setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, } } if kind != "placement" { @@ -67,7 +95,15 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r } _, err := s.ApplyPlan(PlacementPlan{VolumeID: "vol-a", DesiredRF: 1, Candidates: []PlacementCandidate{{VolumeID: "vol-a", ServerID: "node-a", PoolID: r.Slots[0].PoolID, Source: PlacementSourceBlankPool}}}) return err - }, get: func() (any, bool) { r, ok := s.GetPlacementSnapshot("vol-a"); return r, ok }, + }, get: func() (any, bool) { + r, ok := s.GetPlacementSnapshot("vol-a") + memory, exists := s.GetPlacement("vol-a") + if exists != ok || !reflect.DeepEqual(memory, r) { + t.Fatal("placement records and snapshot diverged") + } + return r, ok + }, + setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, } } @@ -134,3 +170,73 @@ func TestRecordStoreCrashChild(t *testing.T) { } t.Fatal("write returned without reaching the crash point") } + +// The injected operations delegate to real fsync, so omitting either call +// loses its event or fails to surface the injected error. +func TestLifecyclePutSyncOrderAndFailure(t *testing.T) { + for _, kind := range []string{"node", "volume", "placement"} { + for _, failure := range []string{"none", "file", "directory", "nil-hooks"} { + t.Run(kind+"/"+failure, func(t *testing.T) { + dir := t.TempDir() + f := openRecordCrashFixture(t, kind, dir, nil) + if err := f.put(false); err != nil { + t.Fatal(err) + } + fault := errors.New("injected sync failure") + var events []string + if failure != "nil-hooks" { + f.setSync(func(file *os.File) error { + events = append(events, "file") + if filepath.Ext(file.Name()) != ".tmp" { + t.Fatal("sync must target the candidate file") + } + if failure == "file" { + return fault + } + return file.Sync() + }, func(path string) error { + events = append(events, "directory") + if path != dir { + t.Fatal("sync must target the record directory") + } + if failure == "directory" { + return fault + } + return syncBindingParent(path) + }) + } + err := f.put(true) + want := f.next + if failure == "file" || failure == "directory" { + if !errors.Is(err, fault) { + t.Fatalf("sync failure hidden: %v", err) + } + want = f.old + } else if err != nil { + t.Fatal(err) + } + if got, ok := f.get(); !ok || !reflect.DeepEqual(got, want) { + t.Fatal("memory published before successful sync") + } + wantEvents := []string{"file", "directory"} + if failure == "file" { + wantEvents = []string{"file"} + } + if failure == "nil-hooks" { + wantEvents = nil + } + if !reflect.DeepEqual(events, wantEvents) { + t.Fatalf("sync events %v want %v", events, wantEvents) + } + reopened := openRecordCrashFixture(t, kind, dir, nil) + diskWant := f.next + if failure == "file" { + diskWant = f.old + } + if got, ok := reopened.get(); !ok || !reflect.DeepEqual(got, diskWant) { + t.Fatal("wrong durable record after sync outcome") + } + }) + } + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 6563b4a00b..008bb61eae 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -650,7 +650,7 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | A lifecycle store write is atomic and durable: after a crash at any point the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord` (`core/lifecycle/store_crash_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | From 3c3ba23a638725586ba1f0dc23c5b046c35fe6b8 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:51:01 -0800 Subject: [PATCH 176/204] durable: red test, a rolled-back copy of a root attaches under a newer HEAD V1-SPEC r2.45 (2): an existing root whose HEAD names this holder must reach HEAD's remote_lsn with its local durable LSN. A copy taken before a later cut attaches today. Co-Authored-By: Claude Opus 5.5 --- .../frontend/durable/rolled_back_copy_test.go | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 seaweed-block/core/frontend/durable/rolled_back_copy_test.go diff --git a/seaweed-block/core/frontend/durable/rolled_back_copy_test.go b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go new file mode 100644 index 0000000000..c62ffb1127 --- /dev/null +++ b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go @@ -0,0 +1,107 @@ +package durable_test + +import ( + "context" + "errors" + "io" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// copyRootFiles copies a provider's storage root (files only) to dst. +func copyRootFiles(t *testing.T, src, dst string) { + t.Helper() + err := filepath.Walk(src, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + rel, _ := filepath.Rel(src, path) + target := filepath.Join(dst, rel) + if info.IsDir() { + return os.MkdirAll(target, 0o755) + } + in, err := os.Open(path) + if err != nil { + return err + } + defer in.Close() + out, err := os.OpenFile(target, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()) + if err != nil { + return err + } + if _, err := io.Copy(out, in); err != nil { + out.Close() + return err + } + return out.Close() + }) + if err != nil { + t.Fatal(err) + } +} + +// V1-SPEC r2.45 (2): an existing root whose HEAD names this holder attaches +// only if its local durable LSN reaches HEAD's remote_lsn. A rolled-back +// copy of the root (a backup taken before the last cut) is refused with the +// stale-root refusal, as a no-retry (superseded) startup outcome, with the +// operator's cure; the root's own restart is accepted. +func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { + ctx := context.Background() + remote := storage.NewMemChunkRemote() + root := t.TempDir() + a := chunkProvider(t, root, remote, v1View(), 0) + s := openRecovered(t, a) + if _, err := s.Write(1, block(1)); err != nil { + t.Fatal(err) + } + if _, err := a.CaptureVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + if err := a.Close(); err != nil { + t.Fatal(err) + } + backup := t.TempDir() + copyRootFiles(t, root, backup) // durable LSN at the first cut + + a = chunkProvider(t, root, remote, v1View(), 0) + s = openRecovered(t, a) // the root's own restart + if _, err := s.Write(2, block(2)); err != nil { + t.Fatal(err) + } + if _, err := a.CaptureVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + if err := a.Close(); err != nil { + t.Fatal(err) + } + head, _ := remote.GetHead(ctx) + + b := chunkProvider(t, backup, remote, v1View(), 0) + if _, err := b.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + _, err := b.RecoverVolume(ctx, "v1") + if !errors.Is(err, durable.ErrChunkStaleLocalRoot) || !strings.Contains(err.Error(), "remove or quarantine the local root") { + t.Fatalf("a rolled-back copy attached under HEAD remote_lsn %d: %v; want the stale-root refusal", head.RemoteLSN, err) + } + gen, ended := b.ChunkStartupOutcome("v1") + if !ended || !b.ChunkStartupSuperseded("v1", gen) { + t.Fatalf("the rolled-back copy's startup: ended=%t superseded=%t, want a no-retry outcome", ended, b.ChunkStartupSuperseded("v1", gen)) + } + if after, _ := remote.GetHead(ctx); after.Gen != head.Gen { + t.Fatalf("HEAD moved under the refused copy: gen %d -> %d", head.Gen, after.Gen) + } + + c := chunkProvider(t, root, remote, v1View(), 0) + if _, err := c.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + if _, err := c.RecoverVolume(ctx, "v1"); err != nil { + t.Fatalf("the root's own restart after its last cut was refused: %v", err) + } +} From 9d58ce6b828dbeb344e68835f60901d12ac01f2d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:51:16 -0800 Subject: [PATCH 177/204] test: red, one live process per volume per host (V1-SPEC r2.45 (1)) A second provider for the same volume on one host (another storage root, the same host lock directory) must be refused before its store opens; a missing lock directory, the default one included, refuses the provider; blockvolume's test-only lock directory is hidden from --help and refused under systemd. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/volume_lock_flag_test.go | 45 ++++++++++ .../durable/one_process_per_volume_test.go | 90 +++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/volume_lock_flag_test.go create mode 100644 seaweed-block/core/frontend/durable/one_process_per_volume_test.go diff --git a/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go b/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go new file mode 100644 index 0000000000..907cd45126 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go @@ -0,0 +1,45 @@ +package main + +import ( + "io" + "os" + "strings" + "testing" +) + +// V1-SPEC r2.45: the test lock directory override is refused under systemd +// (INVOCATION_ID set), so it cannot reach a shipped unit. +func TestVolumeLockDirTestOnlyRefusedUnderSystemd(t *testing.T) { + args := append(phase150RequiredBlockvolumeArgs(), "--durable-root="+t.TempDir(), "--durable-impl=walstore", "--volume-lock-dir-test-only="+t.TempDir()) + t.Setenv("INVOCATION_ID", "") + f, err := parseFlags(args) + if err != nil || f.volumeLockDirTestOnly == "" { + t.Fatalf("the test override outside systemd: %+v %v", f.volumeLockDirTestOnly, err) + } + t.Setenv("INVOCATION_ID", "0123456789abcdef") + if _, err := parseFlags(args); err == nil || !strings.Contains(err.Error(), "refused under systemd") { + t.Fatalf("the test override was accepted under systemd: %v", err) + } +} + +// The test override is hidden from --help. +func TestVolumeLockDirTestOnlyHiddenFromHelp(t *testing.T) { + r, w, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + read := make(chan []byte) + go func() { b, _ := io.ReadAll(r); read <- b }() // usage exceeds a pipe buffer + saved := os.Stderr + os.Stderr = w + _, parseErr := parseFlags([]string{"-h"}) + os.Stderr = saved + _ = w.Close() + out := <-read + if parseErr == nil || !strings.Contains(string(out), "-durable-root") { + t.Fatalf("no usage printed: %v %q", parseErr, out) + } + if strings.Contains(string(out), volumeLockDirTestOnlyFlag) { + t.Fatalf("--help lists the test override:\n%s", out) + } +} diff --git a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go new file mode 100644 index 0000000000..8b002a0c3f --- /dev/null +++ b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go @@ -0,0 +1,90 @@ +package durable_test + +import ( + "errors" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// lockedProvider is a chunk provider whose host volume-lock directory is dir. +func lockedProvider(t *testing.T, root, lockDir string, remote storage.ChunkRemote) *durable.DurableProvider { + t.Helper() + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStoreChunk, StorageRoot: root, + HostVolumeLock: true, VolumeLockDirTestOnly: lockDir, + BlockSize: 4096, NumBlocks: pcBlocks, ChunkBlocks: pcChunkBlocks, + ChunkRemoteFor: func(string) (storage.ChunkRemote, error) { return remote, nil }, + }, v1View()) + if err != nil { + t.Fatalf("NewDurableProvider: %v", err) + } + t.Cleanup(func() { _ = p.Close() }) + return p +} + +// V1-SPEC r2.45 (1): one live process per volume per host. A second +// provider for the same volume id on the same host (another storage root, +// the same host lock directory) is refused before its store opens; once the +// first closes, the volume can be opened again. +func TestOneLiveProcessPerVolumePerHost(t *testing.T) { + remote := storage.NewMemChunkRemote() + lockDir := t.TempDir() + a := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := a.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + b := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := b.EnsureStorage("v1"); !errors.Is(err, storage.ErrWALStoreLocked) { + t.Fatalf("a second provider for the same volume on this host opened: %v; want %v", err, storage.ErrWALStoreLocked) + } + other := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := other.EnsureStorage("v2"); err != nil { + t.Fatalf("another volume was refused by v1's lock: %v", err) + } + if err := a.Close(); err != nil { + t.Fatal(err) + } + c := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := c.EnsureStorage("v1"); err != nil { + t.Fatalf("the volume could not be opened after its first owner closed: %v", err) + } +} + +// V1-SPEC r2.45 (1): without its host lock directory the provider refuses +// to start, with the operator's cure; it never creates the directory. The +// default path is checked where the host lacks it. +func TestHostVolumeLockRefusesMissingDirectory(t *testing.T) { + dirs := []string{filepath.Join(t.TempDir(), "locks")} + if _, err := os.Stat(durable.HostVolumeLockDir); errors.Is(err, os.ErrNotExist) { + dirs = append(dirs, "") // the default path + } else { + t.Logf("this host has %s: default path not exercised", durable.HostVolumeLockDir) + } + for _, dir := range dirs { + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks, + HostVolumeLock: true, VolumeLockDirTestOnly: dir, + }, v1View()) + if err == nil { + _ = p.Close() + } + if !errors.Is(err, durable.ErrVolumeLockDirMissing) || !strings.Contains(err.Error(), "install the tmpfiles.d entry or create the directory") { + t.Fatalf("lock dir %q: a provider without its lock directory started: %v", dir, err) + } + want := dir + if want == "" { + want = durable.HostVolumeLockDir + } + if !strings.Contains(err.Error(), want) { + t.Fatalf("the refusal does not name %s: %v", want, err) + } + if _, statErr := os.Stat(want); !errors.Is(statErr, os.ErrNotExist) { + t.Fatalf("the provider created its lock directory %s: %v", want, statErr) + } + } +} From bd8afb0aea156f5cbaa50730962a7df11634360e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:51:27 -0800 Subject: [PATCH 178/204] blockvolume: one live process per volume per host; refuse a rolled-back root V1-SPEC r2.45. (1) The provider takes an exclusive, non-blocking lock on /run/sw-block/locks/.lock before the volume's store opens and releases it after the store closes (HostVolumeLock, set by blockvolume). A missing directory refuses the provider with the cure; the tmpfiles.d entry ships in deploy/systemd and both units may write it under ProtectSystem=strict. --volume-lock-dir-test-only (hidden, refused under systemd, warned at start) is for plain subprocess tests and harnesses. (2) An existing root whose HEAD names this holder attaches only if its local durable LSN reaches HEAD's remote_lsn; otherwise the existing stale-root refusal, no retry (78 superseded), with the cure. (3) docs/releases/one-process-per-volume.md: the lifecycle do-not list. No HEAD change, no format bump, no new persisted file, no new exit reason. Co-Authored-By: Claude Opus 5.5 --- .../blockvolume/g5_4_l2_replication_test.go | 3 + seaweed-block/cmd/blockvolume/main.go | 30 ++++++++ .../planned_handoff_integration_test.go | 4 +- .../replication_ingress_binary_test.go | 2 +- .../startup_systemd_integration_test.go | 5 ++ .../workspace_lease_binary_test.go | 2 +- .../core/frontend/durable/provider.go | 74 ++++++++++++++++++- .../core/frontend/durable/provider_chunk.go | 9 +++ .../deploy/systemd/sw-block.tmpfiles.conf | 9 +++ .../systemd/sw-blockvolume-ublk.service | 3 + .../deploy/systemd/sw-blockvolume.service | 3 + seaweed-block/docs/design/invariants.md | 10 +-- seaweed-block/docs/releases/README.md | 1 + .../docs/releases/one-process-per-volume.md | 53 +++++++++++++ seaweed-block/docs/standalone-deployment.md | 3 + 15 files changed, 202 insertions(+), 9 deletions(-) create mode 100644 seaweed-block/deploy/systemd/sw-block.tmpfiles.conf create mode 100644 seaweed-block/docs/releases/one-process-per-volume.md diff --git a/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go b/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go index 496bf6fbaa..dfc51048cd 100644 --- a/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go +++ b/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go @@ -196,7 +196,10 @@ func startG54Volume(t *testing.T, bins l2bins, art string, o volOpts) *proc { t.Fatalf("volume log: %v", err) } _ = os.MkdirAll(o.durableRoot, 0o755) + lockDir := o.durableRoot + ".locks" // one simulated host + _ = os.MkdirAll(lockDir, 0o700) cmd := exec.Command(bins.volume, + "--volume-lock-dir-test-only", lockDir, "--master", o.masterAddr, "--server-id", o.serverID, "--volume-id", "v1", diff --git a/seaweed-block/cmd/blockvolume/main.go b/seaweed-block/cmd/blockvolume/main.go index 36b649d6cf..95ed4242c9 100644 --- a/seaweed-block/cmd/blockvolume/main.go +++ b/seaweed-block/cmd/blockvolume/main.go @@ -121,6 +121,9 @@ type flags struct { durableBlockSize uint durableWALMultiBlockRecords bool durableWALRecoveryTestDisableFlusher bool + // volumeLockDirTestOnly replaces durable.HostVolumeLockDir (hidden, + // test-only; refused under systemd). + volumeLockDirTestOnly string // WAL retention window past checkpoint LSN. Zero = strict // checkpoint-driven recycle. Non-zero = walstore relaxes the @@ -155,6 +158,22 @@ type flags struct { version bool } +// volumeLockDirTestOnlyFlag is hidden from --help (printVisibleUsage). +const volumeLockDirTestOnlyFlag = "volume-lock-dir-test-only" + +// printVisibleUsage is the default usage without the hidden test flag. +func printVisibleUsage(fs *flag.FlagSet) { + visible := flag.NewFlagSet(fs.Name(), flag.ContinueOnError) + visible.SetOutput(fs.Output()) + fs.VisitAll(func(fl *flag.Flag) { + if fl.Name != volumeLockDirTestOnlyFlag { + visible.Var(fl.Value, fl.Name, fl.Usage) + } + }) + fmt.Fprintf(fs.Output(), "Usage of %s:\n", fs.Name()) + visible.PrintDefaults() +} + func parseFlags(args []string) (flags, error) { var f flags fs := flag.NewFlagSet("blockvolume", flag.ContinueOnError) @@ -245,7 +264,9 @@ func parseFlags(args []string) (flags, error) { "replication acknowledgement profile: \"best-effort\" (default), \"sync-quorum\", or \"sync-all\". "+ "sync-* modes fail foreground writes when required replica acknowledgement is unavailable.") fs.BoolVar(&f.version, "version", false, "print build provenance and exit") + fs.StringVar(&f.volumeLockDirTestOnly, volumeLockDirTestOnlyFlag, "", "") fs.SetOutput(os.Stderr) + fs.Usage = func() { printVisibleUsage(fs) } if err := fs.Parse(args); err != nil { return flags{}, err } @@ -272,6 +293,9 @@ func parseFlags(args []string) (flags, error) { if f.version { return f, nil } + if f.volumeLockDirTestOnly != "" && os.Getenv("INVOCATION_ID") != "" { + return flags{}, fmt.Errorf("--%s is test-only and refused under systemd (INVOCATION_ID is set): the one-process-per-host guarantee needs %s", volumeLockDirTestOnlyFlag, durable.HostVolumeLockDir) + } if f.recoveryMode != "legacy" && f.recoveryMode != "dual-lane" { return flags{}, fmt.Errorf("--recovery-mode=%q invalid; want \"legacy\" or \"dual-lane\"", f.recoveryMode) } @@ -655,6 +679,12 @@ func runVolume(f flags, exits *processExit) int { WALRetentionLSNs: f.walRetentionLSNs, WALMultiBlockRecords: f.durableWALMultiBlockRecords, WALRecoveryTestDisableFlusher: f.durableWALRecoveryTestDisableFlusher, + // V1-SPEC r2.45: one live process per volume per host. + HostVolumeLock: true, + VolumeLockDirTestOnly: f.volumeLockDirTestOnly, + } + if f.volumeLockDirTestOnly != "" { + fmt.Fprintf(os.Stderr, "blockvolume: volume lock directory %s is a test override: the one-process-per-host guarantee does not hold\n", f.volumeLockDirTestOnly) } var chunkErr error var chunk chunkWiring diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 651b9521d9..04dec7d25a 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -244,7 +244,9 @@ func (env *handoffEnv) volArgs(id string) []string { return env.volArgsFor(env.h // scheduled snapshot (daily:7, at a per-volume offset) stays on, as the page // says; a snapshot inside a test could only make a test fail, never pass. func (env *handoffEnv) volArgsFor(b bvHost) []string { - return []string{"--master", env.h.masterAddr, "--server-id", b.id, "--volume-id", "v1", "--replica-id", "r1", + lockDir := b.root + ".locks" // each simulated host has its own + _ = os.MkdirAll(lockDir, 0o700) + return []string{"--volume-lock-dir-test-only", lockDir, "--master", env.h.masterAddr, "--server-id", b.id, "--volume-id", "v1", "--replica-id", "r1", "--data-addr", b.data, "--ctrl-addr", b.ctrl, "--status-addr", b.status, "--durable-root", b.root, "--durable-impl", "walstore-chunk", "--durable-blocks", "65536", "--durable-blocksize", "4096", diff --git a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go index 150b08ce9e..cc51198a64 100644 --- a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go +++ b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go @@ -117,7 +117,7 @@ func TestBinaryReplicationIngressFollowsAssignedSlots(t *testing.T) { if e != nil { t.Fatal(e) } - child := exec.Command(exe, "--master", ln.Addr().String(), "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", "--data-addr", data, "--ctrl-addr", ctrl, "--status-addr", status, "--t1-readiness", "--durable-root", root, "--durable-impl", "walstore", "--durable-blocks", "64", "--heartbeat-interval", "50ms", "--recovery-mode", mode) + child := exec.Command(exe, "--master", ln.Addr().String(), "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", "--data-addr", data, "--ctrl-addr", ctrl, "--status-addr", status, "--t1-readiness", "--durable-root", root, "--volume-lock-dir-test-only", t.TempDir(), "--durable-impl", "walstore", "--durable-blocks", "64", "--heartbeat-interval", "50ms", "--recovery-mode", mode) child.Stdout, child.Stderr = log, log if e = child.Start(); e != nil { t.Fatal(e) diff --git a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go index baeb17f0ea..95263837fa 100644 --- a/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go +++ b/seaweed-block/cmd/blockvolume/startup_systemd_integration_test.go @@ -44,6 +44,11 @@ func TestSystemdExpiredStartupExits75ThenRegrantServes(t *testing.T) { if out, err := exec.CommandContext(probeCtx, "systemctl", "show", "--property=Version").CombinedOutput(); err != nil { t.Fatalf("real systemd unavailable: %v %s", err, out) } + // Under systemd the test lock override is refused: the units use the + // real host lock directory, which the shipped tmpfiles.d entry makes. + if err := os.MkdirAll(durable.HostVolumeLockDir, 0o700); err != nil { + t.Fatalf("host volume lock directory: %v", err) + } fixture := newGAP1Fixture(t) root := fixture.root bin := filepath.Join(root, "bin") diff --git a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go index 1e6b284a3d..1a2591548b 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go @@ -106,7 +106,7 @@ func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { if err != nil { t.Fatal(err) } - cmd := exec.Command(exe, "--master", h.Addr(), "--server-id", "node-a", "--volume-id", "vol-a", "--replica-id", "r1", "--data-addr", dataAddr, "--ctrl-addr", ctrlAddr, "--t1-readiness", "--status-addr", statusAddr, "--durable-root", t.TempDir(), "--durable-impl", "walstore-chunk", "--durable-blocks", "64", "--chunk-filer", cluster.filerGRPC, "--chunk-path", base, "--chunk-control-endpoint", "--workspace-lease", "--nvme-listen", nvmeAddr, "--nvme-subsysnqn", "nqn.2026-11.test:workspace-lease") + cmd := exec.Command(exe, "--master", h.Addr(), "--server-id", "node-a", "--volume-id", "vol-a", "--replica-id", "r1", "--data-addr", dataAddr, "--ctrl-addr", ctrlAddr, "--t1-readiness", "--status-addr", statusAddr, "--durable-root", t.TempDir(), "--volume-lock-dir-test-only", t.TempDir(), "--durable-impl", "walstore-chunk", "--durable-blocks", "64", "--chunk-filer", cluster.filerGRPC, "--chunk-path", base, "--chunk-control-endpoint", "--workspace-lease", "--nvme-listen", nvmeAddr, "--nvme-subsysnqn", "nqn.2026-11.test:workspace-lease") cmd.Stdout, cmd.Stderr = log, log if err = cmd.Start(); err != nil { t.Fatal(err) diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index bf35f99d7d..3b7a44577c 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -159,6 +159,17 @@ type ProviderConfig struct { // ChunkHolder names this node in HEAD; blockvolume sets // /. Zero: the replica ID (tests). ChunkHolder string + // HostVolumeLock makes the provider hold an exclusive, nonblocking lock + // on HostVolumeLockDir/.lock from before the volume's store + // opens until Close: one host runs at most one live process per volume + // (V1-SPEC r2.45). The directory must exist (a tmpfiles.d entry ships in + // deploy/systemd); NewDurableProvider refuses without it. blockvolume + // sets this. + HostVolumeLock bool + // VolumeLockDirTestOnly replaces HostVolumeLockDir for tests and test + // harnesses (blockvolume --volume-lock-dir-test-only); the one-process- + // per-host guarantee then holds only among processes sharing it. + VolumeLockDirTestOnly string // Zero uses immediate HEAD confirmation for the supported single-filer // topology. Nonzero cooling is reserved for explicit topology experiments. ChunkHeadCoolingWindow time.Duration @@ -275,6 +286,9 @@ type volHandle struct { path string impl ImplName // the resolved implementation, never ImplAuto + // hostLock is the volume's host lock (HostVolumeLock), held while open. + hostLock *os.File + // ImplWALStoreChunk. fresh: the local volume is new and starts from // the remote HEAD. It mirrors the durable fresh marker beside the // volume file, written before the file is created and removed only @@ -384,6 +398,17 @@ func NewDurableProvider(cfg ProviderConfig, view frontend.ProjectionView) (*Dura if cfg.ChunkSnapshotPeriod < 0 || (cfg.ChunkSnapshotPeriod > 0 && cfg.ChunkScheduledSnapshot == nil) { return nil, fmt.Errorf("durable: a chunk snapshot period must not be negative and requires its callback") } + if cfg.HostVolumeLock { + if cfg.VolumeLockDirTestOnly == "" { + cfg.VolumeLockDirTestOnly = HostVolumeLockDir + } + if fi, err := os.Stat(cfg.VolumeLockDirTestOnly); err != nil || !fi.IsDir() { + if err == nil { + err = fmt.Errorf("not a directory") + } + return nil, fmt.Errorf("%w %s: %w; install the tmpfiles.d entry or create the directory", ErrVolumeLockDirMissing, cfg.VolumeLockDirTestOnly, err) + } + } if cfg.ChunkBlocks == 0 { cfg.ChunkBlocks = defaultChunkBlocks } @@ -497,25 +522,71 @@ func (p *DurableProvider) ensureHandle(volumeID string) (*volHandle, error) { } p.mu.Unlock() - h, err := p.openOrCreate(volumeID) + // V1-SPEC r2.45: the host lock is taken before the store opens. + hostLock, err := p.lockVolumeOnHost(volumeID) if err != nil { return nil, err } + h, err := p.openOrCreate(volumeID) + if err != nil { + closeHostLock(hostLock) + return nil, err + } + h.hostLock = hostLock p.mu.Lock() defer p.mu.Unlock() if p.closed { _ = h.storage.Close() + closeHostLock(h.hostLock) return nil, fmt.Errorf("durable: provider closed") } if existing, ok := p.volumes[volumeID]; ok { _ = h.storage.Close() + closeHostLock(h.hostLock) return existing, nil } p.volumes[volumeID] = h return h, nil } +// HostVolumeLockDir is the one fixed host-local directory of the volume +// host locks (HostVolumeLock). +const HostVolumeLockDir = "/run/sw-block/locks" + +// ErrVolumeLockDirMissing refuses a provider with HostVolumeLock whose lock +// directory does not exist. +var ErrVolumeLockDirMissing = errors.New("durable: host volume lock directory missing") + +// lockVolumeOnHost takes the volume's host lock (nil without +// HostVolumeLock). A second live process for the volume on this host gets +// storage.ErrWALStoreLocked. +func (p *DurableProvider) lockVolumeOnHost(volumeID string) (*os.File, error) { + if !p.cfg.HostVolumeLock { + return nil, nil + } + dir := p.cfg.VolumeLockDirTestOnly + if volumeID == "" || volumeID == "." || volumeID == ".." || strings.ContainsAny(volumeID, "/\\") { + return nil, fmt.Errorf("durable: volume id %q is not a plain path element", volumeID) + } + path := filepath.Join(dir, volumeID+".lock") + f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o600) + if err != nil { + return nil, fmt.Errorf("durable: volume lock %s: %w", path, err) + } + if err := storage.LockWALStoreFile(f); err != nil { + _ = f.Close() + return nil, fmt.Errorf("durable: volume %s already has a live process on this host (lock %s held): %w", volumeID, path, err) + } + return f, nil +} + +func closeHostLock(f *os.File) { + if f != nil { + _ = f.Close() + } +} + // EnsureStorage opens (or creates) the on-disk LogicalStorage for // volumeID WITHOUT waiting for the projection to flip Healthy. This // is the binary-path entry point used by G5-4 to construct per-volume @@ -1024,6 +1095,7 @@ func (p *DurableProvider) Close() error { if err := h.storage.Close(); err != nil && firstErr == nil { firstErr = fmt.Errorf("durable: close storage: %w", err) } + closeHostLock(h.hostLock) // after the store closes } return firstErr } diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 35a45115a8..6c92535c3b 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -462,6 +462,15 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h volumeID, h.path, head.Holder, head.Gen, head.Epoch, holder) return err } + // V1-SPEC r2.45: HEAD names this holder, but a root whose local + // durable LSN is below HEAD's remote_lsn is a rolled-back copy + // (a backup taken before a later cut). Restarting cannot cure it. + if durableLSN, _, _ := ws.Boundaries(); head.Gen != 0 && durableLSN < head.RemoteLSN { + log.Printf("durable: refusing to attach volume=%s root=%s: local durable LSN %d is below HEAD gen=%d remote_lsn=%d (remove or quarantine the local root)", + volumeID, h.path, durableLSN, head.Gen, head.RemoteLSN) + return fmt.Errorf("%w: %w: %w: volume %s local root %s, local durable LSN %d below HEAD gen %d remote_lsn %d; remove or quarantine the local root to attach fresh from HEAD", + ErrChunkStaleLocalRoot, storage.ErrChunkLayerFenced, errChunkForeignClaim, volumeID, h.path, durableLSN, head.Gen, head.RemoteLSN) + } return nil } if err := cfg.PrepareRestore(head); err != nil { diff --git a/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf b/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf new file mode 100644 index 0000000000..cbe5109956 --- /dev/null +++ b/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf @@ -0,0 +1,9 @@ +# tmpfiles.d entry for the blockvolume host volume locks. Install as +# /etc/tmpfiles.d/sw-block.conf, then run `systemd-tmpfiles --create`. +# blockvolume refuses to start without this directory. Each volume takes an +# exclusive lock on /run/sw-block/locks/.lock, so one host runs at +# most one live blockvolume per volume. The directory is owned by the +# unprivileged units' user (sw-block) and is 0700, so no other local user can +# create or hold a volume's lock. The root ublk unit reaches it as root. +d /run/sw-block 0755 root root - +d /run/sw-block/locks 0700 sw-block sw-block - diff --git a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service index 6819f4d9d6..fe10fad22a 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service @@ -76,6 +76,9 @@ RestartSec=5s NoNewPrivileges=true ProtectSystem=strict +# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf); blockvolume +# refuses to start without the directory. +ReadWritePaths=-/run/sw-block/locks ProtectHome=true PrivateTmp=true # PrivateDevices= is off: the server needs /dev/ublk-control and /dev/ublkcN. diff --git a/seaweed-block/deploy/systemd/sw-blockvolume.service b/seaweed-block/deploy/systemd/sw-blockvolume.service index 30a69d729c..79f1046a56 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume.service @@ -75,6 +75,9 @@ RestartSec=5s NoNewPrivileges=true ProtectSystem=strict +# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf); blockvolume +# refuses to start without the directory. +ReadWritePaths=-/run/sw-block/locks ProtectHome=true PrivateTmp=true PrivateDevices=true diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index dc3b63053e..52eeec78eb 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -234,7 +234,7 @@ stateDiagram-v2 | 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` | -| Attaching | Refused | an existing local root whose HEAD another holder has published (`ErrChunkStaleLocalRoot`) | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `INV-WS-STALE-LOCAL-ROOT-001` | +| Attaching | Refused | an existing local root whose HEAD another holder has published, or whose durable LSN is below HEAD's `remote_lsn` (`ErrChunkStaleLocalRoot`) | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `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` | | Claiming | Holder | HEAD epoch not above the master-issued epoch, no other holder at the same epoch; fresh roots seed from HEAD before the CAS; existing roots retain local WAL; active incarnations replace the generation (or exclusive-create HEAD); a sealed same-owner incarnation remains detached; I/O opens only after the configured cooling window (zero at one serialization point) and an exact generation/epoch/holder readback | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-WS-HEAD-CAS-001`, `INV-WS-REOPEN-FENCE-001` | | Claiming | Detached (non-serving) | same epoch/holder HEAD is already detached: refuse with ErrChunkLayerDetached before restore preparation or CAS; a higher-epoch takeover still consumes the sealed image | `core/storage/chunk_restore.go` `ClaimChunkHead` | `INV-WS-SEALED-REOPEN-001` | @@ -712,7 +712,7 @@ Notes: | `INV-WS-SEAL-REPLAY-001` | A repeated plain seal, also after restart, succeeds only from a fresh filer HEAD with exact owner/epoch and detachedBy proof. It returns that original HEAD/frontier without a CAS or new generation. An unreadable or mismatched proof cannot be answered from process memory. | M5 PlainStop -> RemoteProof -> SealedReply | `core/frontend/durable/provider_seal_replay.go` `replayPlainSeal`; `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead` | `TestPlainSealLostAnswerRestartReplaysFilerProof`, `TestPlainSealReplayNeverUsesProcessMemory`, `TestPlainSealReplayDuringDeferredAuthorityStartup` (`core/frontend/durable/provider_plain_seal_replay_test.go`) | `PlainSealReplay` `SuccessNeedsFreshExactProof`, `ValidProofDoesNotNeedProcessMemory` | ACTIVE | | `INV-WS-CAS-UNKNOWN-001` | An unknown HEAD CAS outcome is settled by re-reading HEAD, never by a blind retry; until it is settled the proposal stays pending and its intents stay. | M5 CAS → Pending | `core/storage/chunk_layer.go` `captureLocked`, `resolvePending`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestChunkRemote_UncertainCASIsNotPrecondition` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_UnknownNotAppliedNeverClaimsSuccess` (`core/storage/chunk_layer_contract_test.go`); `TestClaimChunkHeadSettlesUnknownWithoutReplay` (`core/storage/chunk_restore_test.go`); `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | — | ACTIVE | | `INV-WS-CLAIM-BEFORE-SERVE-001` | A new holder claims HEAD at its master-issued epoch before I/O opens; a HEAD with a higher epoch, or another holder at the same epoch, fences the claim. | M4 Claiming → Holder \| Fenced | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestClaimChunkHeadRefusesStaleAuthorityAndAdmissionDrift` (`core/storage/chunk_restore_test.go`); `TestRestoreSeedPrecedesTakeoverCAS` (`core/frontend/durable/provider_seed_order_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | `WorkspaceTakeover` `SeedMatchesTakeover` | ACTIVE | -| `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`) | — | ACTIVE | +| `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn` (a rolled-back copy), is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`); `TestRolledBackCopyBelowHeadLSNIsRefused` (`core/frontend/durable/one_process_per_volume_test.go`) | — | ACTIVE | | `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: same holder and epoch only, no move pending or issued, not revoking, store certain, one durable write, and only once max(horizon, deadline) + skew bound has passed; the new process claims HEAD with a new generation before any I/O, so no older incarnation writes or CASes after. | M2 lease: Expired → Granted | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut`, `TestWorkspaceLeaseRegrantCannotUnsealSameEpoch`, `TestWorkspaceLeaseRegrantEmptyRootClaimsOnlyHEAD` (`core/authority/workspace_regrant_storage_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory` | 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 | @@ -1060,16 +1060,16 @@ A row that names a function existing only on an open pull request says so ("on # | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| -| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. A local-root nonce joins the pair later (pending). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines (through `PublishedLine.Owner`, which the snapshot builder's `expectOwnerForLine` also calls). The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | +| `TERM-HOLDER-001` Holder identity (the primary of a single-copy workspace volume only; supporting replicas are not holders) | The process that may act as primary of a single-copy workspace volume at an epoch is the pair (server id, replica id) at that epoch. A matching replica id or endpoint alone never names it, and a missing server id is refused. No local-root nonce joins it (V1-SPEC r2.45); one live process per volume on a host is the host lock (`TERM-ONE-PROCESS-001`). | `AssignmentFact` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/control.proto`; `server_id` on [#411](https://github.com/seaweedfs/seaweed-block/pull/411)); `WorkspaceIdentity` `server_id`, `replica_id`, `epoch` (`core/rpc/proto/workspace.proto`; `server_id` on #411); the published line's `PublishedLine.IssuedHost` (`core/authority/workspace_lease_view.go`) and the move journal's `WorkspaceMoveRecord.NewHost` (`core/authority/workspace.go`); the volume's `Config.ServerID`, `Config.ReplicaID` (`core/host/volume/host.go`, from `--server-id`, `--replica-id`); the HEAD `Holder`, written as `/` (`cmd/blockvolume/chunk_remote.go` `chunkHolder`) | Master: `core/host/master/workspace_service.go` `services.holderMatches(volume, replica, server, epoch)`, on #411; it gates `RenewWorkspaceLease` and `AckWorkspaceRevoked`, after the host check of #416, and takes the line's owner server from `core/host/master/workspace_binding.go` `Host.workspaceLineOwner`, on #423, the one owner decision for current and historical lines (through `PublishedLine.Owner`, which the snapshot builder's `expectOwnerForLine` also calls). The line's owner server is carried in the published line; a move's line names the move's new host; placement names the owner only for the initial line; an unknown owner is sent empty and never adopted. A volume that has seen an epoch owned by one server never adopts that epoch for another (this covers replays). The safety rule is the refusal to adopt a line naming another server; fencing on a foreign line is defence in depth, and only a process that has adopted a lineage fences, on a strictly newer foreign line. Volume: `core/host/volume/assignment_holder.go` `Host.assignmentNamesSelf`, on #411; called by `applyFact` and `IsSuperseded`. | `Host.applyFact` adopts a fact on the replica id alone. `Host.IsSuperseded` ignores a same-replica line from another server. `Host.recordOtherLine` lets an older line overwrite a newer one. Lease renewals and revocation ACKs carry no server id. All four are removed by #411. The master's status frontends and CSI publish target take the freshest same-replica heartbeat from any server (`ObservationStore.SlotFact` via `statusFrontendsForAssignedVolume`), and the operator's primary node is the placement slot (`serverForReplica`). Both are removed by [#416](https://github.com/seaweedfs/seaweed-block/pull/416), stacked on #411. The master computed the line's owner server twice; #423 makes it one function. | authority (master side); volume host (volume side) | | `TERM-LEASE-NOW-001` Lease valid now | The holder may act on its workspace lease at this instant only while the guard has not fenced and host monotonic time is before the start of its last successful renewal plus the granted validity. The granted validity is the master expiry less half the clock-skew bound, capped by the configured TTL. | `WorkspaceLease` `ExpiresAtNS`, `MaxClockSkewNS`, and the lease view's durable horizon and granted deadline (`core/authority/workspace_lease_view.go`); `WorkspaceLeaseFact` `valid_for_ns`, `expires_at_ns`, `revoking` (`core/rpc/proto/workspace.proto`); `WorkspaceLeaseGuard` `until`, `fenced` (`core/host/volume/workspace_lease.go`) | Holder: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.permits`. Master: `core/authority/workspace_lease_view.go` `Publisher.WorkspaceLeaseValidity` / `workspaceLeaseValidityAt` is shared by renewal admission, `leaseFact` and `AckWorkspaceRevocation`. `WorkspaceLeaseValidity` reads the publisher clock; its leaf calculation uses the larger configured/persisted skew and configured TTL. `Publisher.RenewWorkspaceLease`. `firstWorkspaceGrant` and `regrantWorkspaceLease` are reached only from it, and only it starts the extender `extendWorkspaceLease`. | `WorkspaceLeaseGuard.drain` checks `now < until` again inline before the ACK, and `WorkspaceLeaseGuard.Refresh` repeats the expiry check of `permits`: open (both should call one predicate). The host reply sanity bound in `Refresh` still repeats the publisher's default 30 s TTL: open. Not a duplicate: `Publisher.forcedMoveBarrierLocked` decides the opposite term, "the lease is over for the master" (the horizon and the deadline each plus the full skew bound), which a forced move and a re-grant need. | authority (grant); volume host (guard) | | `TERM-SERVING-001` Serving / ready | A workspace primary claims HEAD, listens, reports ready and admits I/O only while its lease guard permits now and its durable backend is operational. Without a granted lease it holds at the gate and exits 75 after the start-time wait. | `frontend.Projection.Healthy`; the `StorageBackend` operational flag and its evidence, reported as `VolumeStatus.Operational` (`core/frontend/durable`); `StatusProjection.FrontendPrimaryReady` (and `NotReadyReason`, on [#410](https://github.com/seaweedfs/seaweed-block/pull/410)); the ALUA and ANA state; `HeartbeatSlot.frontends` | Authority side: `core/host/volume/projection_bridge.go` `AdapterProjectionView.projectionWithSupersede`, which ANDs in `WorkspaceLeaseGuard.permits` for workspace volumes. Storage side: the `StorageBackend` operational flag (`core/frontend/durable/storage_adapter.go`), written only by `SetOperational` and read by `readyCheck`. The one decision of both sides together is `StorageBackend.AdmitsIO` (the guarded AND), read by the status, the frontend start gate and every I/O: on #410 (today `StorageBackend.gate` on `main`). | `StatusServer.authorityProjection` derives `FrontendPrimaryReady` from the authority view alone, and it repeats the supersede and supporting tests that `Healthy` already contains. #410 adds the backend half in `statusProjection`; the repeated tests remain open. The frontends listen whether or not the backend admits I/O: #410 holds them in `awaitBackendAdmitsIO` until it does. #410 replaces its earlier `backendAdmitsIO` (which read only `VolumeStatus.Operational`) with `StorageBackend.AdmitsIO`. A later lease fence ends the process on [#409](https://github.com/seaweedfs/seaweed-block/pull/409). `projectionALUAProvider.ALUAState` and `projectionANAProvider.ANAState` (`cmd/blockvolume`) follow the projection only: open. The start-time wait (`chunkAuthorityWait`; `ProviderConfig.ChunkAssignmentTimeout`, 30 s by default) ends once, and the process then stays up without serving: #409 makes it exit 75. iSCSI reports a not-ready or busy backend as a medium error, while NVMe retries the same error: [#415](https://github.com/seaweedfs/seaweed-block/pull/415) (`frontend.ClassifyBackendError`). The heartbeat `Frontends` are set when the listeners start and cleared only at shutdown: open. | volume host | | `TERM-STOP-SUPERSEDED-001` Superseded | A newer published line for this volume names another holder (another replica, or the same replica on another server) at or above this process's epoch and endpoint version. From then on the process is not healthy. | `Host.lastOther` (an `AssignmentFact`); the process's own epoch and endpoint version | Volume: `core/host/volume/host.go` `Host.IsSuperseded`. Its same-replica branch, and the ordered `recordOtherLine` it reads, are on #411. | The status repeat listed under `TERM-SERVING-001`. `Host.IsCurrentReplicaSuperseded` (on #409) and `Host.promotionReady` call `IsSuperseded` with other lineages. They are wrappers, not second derivations. | volume host | | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | | `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | -| `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published is refused before the claim and never served. The process stays up without serving. | HEAD `Holder`; `ProviderConfig.ChunkHolder` | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | It compares the holder only, so a rolled-back root of the same holder passes: pending the local-root nonce. | volume host | +| `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn`, is refused before the claim and never served. A rolled-back copy exits 78; a foreign holder below the assignment's epoch stays up without serving. | HEAD `Holder`, `RemoteLSN`; `ProviderConfig.ChunkHolder`; the store's durable LSN (`WALStore.Boundaries`) | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | A copy of the root taken after its last cut has HEAD's LSN and passes: no local check sees it (never restore a root from a copy). | volume host | | `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | -| `TERM-ONE-PROCESS-001` One live process per holder | At most one blockvolume process serves a holder at a time. Today a second process is refused only when it opens the same store file. A local-root nonce in the holder identity is to close the other cases (pending). | The store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); its exclusive OS file lock; the HEAD `Holder` | Volume: `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the lock's limit: it covers one file. A second process is not refused when it uses another `--durable-root`, runs on another host with the same server id, or runs on a copied root. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open, pending the local-root nonce. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | +| `TERM-ONE-PROCESS-001` One live process per volume per host | At most one blockvolume process serves a volume on one host: each holds `/run/sw-block/locks/.lock` from before its store opens, whatever its `--durable-root`. Across hosts the assignment and the workspace lease keep holders apart. | The host lock file (`durable.HostVolumeLockDir`, `deploy/systemd/sw-block.tmpfiles.conf`); the store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); their exclusive OS file locks; the HEAD `Holder` | Volume: `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (`ProviderConfig.HostVolumeLock`, set by blockvolume; a missing directory refuses the provider), taken in `ensureHandle` before the store opens and released after it closes. `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the locks' limit: they cover one host. A second process is not refused when it runs on another host with the same server id, in a container without the host's `/run/sw-block/locks` (the Kubernetes renderer does not mount it: open), or on a copied root on another host. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | Notes: diff --git a/seaweed-block/docs/releases/README.md b/seaweed-block/docs/releases/README.md index 17c155376d..528ea41d80 100644 --- a/seaweed-block/docs/releases/README.md +++ b/seaweed-block/docs/releases/README.md @@ -5,6 +5,7 @@ what a user or reviewer can actually run, what QA evidence backs it, and what is still outside the supported boundary. - [Holder identity and pre-release upgrades](holder-identity.md) +- [One live process per volume per host](one-process-per-volume.md) - [v0.1 Alpha — Kubernetes Block Foundation](v0.1-alpha.md) - [v0.2 Alpha — Day-1 Activation And First Volume](v0.2-alpha.md) - [v0.3 Alpha — Helm Install And Observable First Volume](v0.3-alpha.md) diff --git a/seaweed-block/docs/releases/one-process-per-volume.md b/seaweed-block/docs/releases/one-process-per-volume.md new file mode 100644 index 0000000000..1589261848 --- /dev/null +++ b/seaweed-block/docs/releases/one-process-per-volume.md @@ -0,0 +1,53 @@ +# One live process per volume per host + +A blockvolume with a durable root takes an exclusive, non-blocking lock on +`/run/sw-block/locks/.lock` before it opens the volume's store, and +holds it until the volume closes. A second blockvolume for the same volume on +the same host is refused before it opens anything, whatever its +`--durable-root`. The lock is released when the process exits, including on +a crash or kill. + +The directory is not created by blockvolume. Install the tmpfiles.d entry +shipped in [`deploy/systemd/sw-block.tmpfiles.conf`](../../deploy/systemd/sw-block.tmpfiles.conf): + +```bash +sudo install -m 0644 deploy/systemd/sw-block.tmpfiles.conf /etc/tmpfiles.d/sw-block.conf +sudo systemd-tmpfiles --create /etc/tmpfiles.d/sw-block.conf +``` + +It creates `/run/sw-block/locks` as `0700`, owned by `sw-block`, at every +boot. Without it blockvolume exits at start with `host volume lock directory +missing ... install the tmpfiles.d entry or create the directory`. Both +shipped units allow writes to it (`ReadWritePaths=-/run/sw-block/locks`) +under `ProtectSystem=strict`. If you run blockvolume as another user, give +that user the directory instead. + +## A rolled-back copy of a root is refused + +An existing local root attaches only if its local durable LSN reaches the +`remote_lsn` of the HEAD it attaches under. A copy of a root taken before +a later cut (a backup, a snapshot of the disk, an older replica of the +directory) is below that HEAD: it is refused with `ErrChunkStaleLocalRoot`, +never serves, and its process exits 78 (no automatic restart) with the root +kept. Remove or quarantine the local root to attach fresh from HEAD. + +## Do not + +- Do not start a second blockvolume for a volume on any host while one runs. + The lock covers one host only. Two hosts are kept apart by the master's + assignment and the workspace lease, not by this lock. +- Do not restore a local root from a copy. A copy taken after the root's last + cut has the same LSN as HEAD, attaches, and loses the writes the original + acknowledged after the copy was taken (in its local WAL, not yet cut). No + local check can see that. Restore from the remote image (the sealed or + latest HEAD). +- Do not copy or move a local root to another host or another + `--durable-root` and start it there while the original may still run. +- Do not delete `/run/sw-block/locks` or its lock files while blockvolume + runs: a new process would then get a different lock file and not see the + running one. +- Do not run blockvolume in containers that do not share the host's + `/run/sw-block/locks`. In a container the lock is per host only if that + directory is the host's (a hostPath mount). The Kubernetes renderer + (`core/launcher/k8s_renderer.go`) and `deploy/k8s` manifests do not mount + it yet: there, the lock is per pod. diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index 6a4fd485fa..183466fc4d 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -52,6 +52,7 @@ added), do not mix revisions: build the binaries from your checkout instead | [`deploy/systemd/sw-blockmaster.service`](../deploy/systemd/sw-blockmaster.service) | `/etc/systemd/system/` | blockmaster, as `sw-block`; state in `/var/lib/sw-block-master` | | [`deploy/systemd/sw-blockvolume.service`](../deploy/systemd/sw-blockvolume.service) | `/etc/systemd/system/` | One blockvolume over NVMe/TCP or iSCSI, as `sw-block`; state in `/var/lib/sw-block-volume` | | [`deploy/systemd/sw-blockvolume-ublk.service`](../deploy/systemd/sw-blockvolume-ublk.service) | `/etc/systemd/system/` | The same volume over ublk, as root; state in `/var/lib/sw-block-volume-ublk` | +| [`deploy/systemd/sw-block.tmpfiles.conf`](../deploy/systemd/sw-block.tmpfiles.conf) | `/etc/tmpfiles.d/sw-block.conf` | `/run/sw-block/locks`, the host volume locks; blockvolume refuses to start without it ([one process per volume](releases/one-process-per-volume.md)) | Each unit has its own `StateDirectory=`, so the root ublk unit can never take ownership of blockmaster's or the unprivileged volume's files. Run either @@ -70,6 +71,8 @@ sudo install -m 0755 blockmaster blockvolume sw-block /usr/local/bin/ sudo install -d -m 0750 -g sw-block /etc/sw-block sudo install -m 0640 -g sw-block deploy/config/*.env deploy/config/topology.yaml /etc/sw-block/ sudo install -m 0644 deploy/systemd/*.service /etc/systemd/system/ +sudo install -m 0644 deploy/systemd/sw-block.tmpfiles.conf /etc/tmpfiles.d/sw-block.conf +sudo systemd-tmpfiles --create /etc/tmpfiles.d/sw-block.conf sudo systemctl daemon-reload sudo systemctl enable --now sw-blockmaster sw-blockvolume journalctl -u sw-blockvolume -f # wait for "adopted as PRIMARY" (see the required setup below) From 3a0dcd9d64cc881d10d53dddf86ec17b9e48ce95 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 09:52:21 -0800 Subject: [PATCH 179/204] docs: invariants count the host lock's deciding function (#439) Co-Authored-By: Claude Opus 5.5 --- seaweed-block/docs/design/invariants.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 52eeec78eb..de070b7852 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -1056,7 +1056,7 @@ A reviewer applies the rule to every pull request: A row that names a function existing only on an open pull request says so ("on #N"). The qualifier is dropped when that pull request merges. Code references name a file and a function, as in the rest of this document. A checker will later verify that every deciding function named here exists on `main`. -10 rows for 5 terms. They name 13 deciding functions: 10 on `main` and 3 only on open pull requests (2 on #411, 1 on #409). One row (`TERM-STOP-STALE-ROOT-001`) has no named function yet. +10 rows for 5 terms. They name 14 deciding functions: 10 on `main` and 4 only on open pull requests (2 on #411, 1 on #409, 1 on #439). One row (`TERM-STOP-STALE-ROOT-001`) has no named function yet. | Term | Meaning | Field(s) | Deciding function (one per side) | Known second derivations to remove | Owner role | |---|---|---|---|---|---| @@ -1069,7 +1069,7 @@ A row that names a function existing only on an open pull request says so ("on # | `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn`, is refused before the claim and never served. A rolled-back copy exits 78; a foreign holder below the assignment's epoch stays up without serving. | HEAD `Holder`, `RemoteLSN`; `ProviderConfig.ChunkHolder`; the store's durable LSN (`WALStore.Boundaries`) | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | A copy of the root taken after its last cut has HEAD's LSN and passes: no local check sees it (never restore a root from a copy). | volume host | | `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | -| `TERM-ONE-PROCESS-001` One live process per volume per host | At most one blockvolume process serves a volume on one host: each holds `/run/sw-block/locks/.lock` from before its store opens, whatever its `--durable-root`. Across hosts the assignment and the workspace lease keep holders apart. | The host lock file (`durable.HostVolumeLockDir`, `deploy/systemd/sw-block.tmpfiles.conf`); the store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); their exclusive OS file locks; the HEAD `Holder` | Volume: `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (`ProviderConfig.HostVolumeLock`, set by blockvolume; a missing directory refuses the provider), taken in `ensureHandle` before the store opens and released after it closes. `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the locks' limit: they cover one host. A second process is not refused when it runs on another host with the same server id, in a container without the host's `/run/sw-block/locks` (the Kubernetes renderer does not mount it: open), or on a copied root on another host. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | +| `TERM-ONE-PROCESS-001` One live process per volume per host | At most one blockvolume process serves a volume on one host: each holds `/run/sw-block/locks/.lock` from before its store opens, whatever its `--durable-root`. Across hosts the assignment and the workspace lease keep holders apart. | The host lock file (`durable.HostVolumeLockDir`, `deploy/systemd/sw-block.tmpfiles.conf`); the store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); their exclusive OS file locks; the HEAD `Holder` | Volume: `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (on #439; `ProviderConfig.HostVolumeLock`, set by blockvolume; a missing directory refuses the provider), taken in `ensureHandle` before the store opens and released after it closes. `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the locks' limit: they cover one host. A second process is not refused when it runs on another host with the same server id, in a container without the host's `/run/sw-block/locks` (the Kubernetes renderer does not mount it: open), or on a copied root on another host. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | Notes: From 83f8507d3b1814881eeb7ff5268043164abc4bf4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:01:32 -0800 Subject: [PATCH 180/204] durable, blockvolume: review fold for the host lock and the rolled-back root - The lock directory is created (0700) when missing; only a directory or lock file that cannot be created or opened refuses, with the cure (install the tmpfiles.d entry, or chown the directory and its lock files to the unit's user). - The lock file is opened read-only (an existing file first, created 0644 only when missing), so a lock file another user created stays lockable; it is never unlinked, and the next owner locks the same file. - A stale-root startup end carries its cure into the final exit line: exiting status=78 reason=superseded cure="...". - Tests: a cut's remote_lsn is locally durable at its HEAD CAS, and the root's crash image at the CAS reattaches and serves; the rolled-back copy makes no claim or PUT, admits no I/O, keeps its data and durable LSN; an exact copy at HEAD attaches; a read-only lock file is taken. - Invariants: INV-WS-ONE-PROCESS-PER-HOST-001 and its M4 edge; the rollback row names its test file. Co-Authored-By: Claude Opus 5.5 --- seaweed-block/cmd/blockvolume/process_exit.go | 19 +++-- .../cmd/blockvolume/process_exit_test.go | 16 ++-- .../blockvolume/runtime_fence_exit_test.go | 2 +- .../durable/cut_durable_before_cas_test.go | 78 ++++++++++++++++++ .../durable/one_process_per_volume_test.go | 80 ++++++++++++------- .../core/frontend/durable/provider.go | 33 +++++--- .../core/frontend/durable/provider_chunk.go | 3 + .../core/frontend/durable/provider_startup.go | 19 +++++ .../frontend/durable/rolled_back_copy_test.go | 49 ++++++++++-- .../deploy/systemd/sw-block.tmpfiles.conf | 3 +- .../systemd/sw-blockvolume-ublk.service | 4 +- .../deploy/systemd/sw-blockvolume.service | 4 +- seaweed-block/docs/design/invariants.md | 11 ++- .../docs/releases/one-process-per-volume.md | 35 +++++--- seaweed-block/docs/standalone-deployment.md | 2 +- 15 files changed, 278 insertions(+), 80 deletions(-) create mode 100644 seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go diff --git a/seaweed-block/cmd/blockvolume/process_exit.go b/seaweed-block/cmd/blockvolume/process_exit.go index c264aea4bd..9fdcb53767 100644 --- a/seaweed-block/cmd/blockvolume/process_exit.go +++ b/seaweed-block/cmd/blockvolume/process_exit.go @@ -23,6 +23,8 @@ const ( type workspaceExit struct { code int reason string + // detail is the operator's cure, printed on the final exit line. + detail string } // INV-WS-STARTUP-RETRY-001: the first outcome is immutable. The channel is a @@ -113,7 +115,11 @@ func finishWorkspaceExit(out workspaceExit, finished <-chan int, deadline <-chan func reportWorkspaceExit(out workspaceExit) int { if out.code != 0 { - fmt.Fprintf(os.Stderr, "blockvolume: exiting status=%d reason=%s\n", out.code, out.reason) + if out.detail != "" { + fmt.Fprintf(os.Stderr, "blockvolume: exiting status=%d reason=%s cure=%q\n", out.code, out.reason, out.detail) + } else { + fmt.Fprintf(os.Stderr, "blockvolume: exiting status=%d reason=%s\n", out.code, out.reason) + } } return out.code } @@ -122,9 +128,9 @@ func reportWorkspaceExit(out workspaceExit) int { // authority fact and the provider's generation-bound foreign-HEAD proof. func workspaceRetryOutcome(reason string, h *volume.Host, claimSuperseded bool) workspaceExit { if claimSuperseded || h.IsCurrentReplicaSuperseded() { - return workspaceExit{exitWorkspaceSuperseded, "superseded"} + return workspaceExit{code: exitWorkspaceSuperseded, reason: "superseded"} } - return workspaceExit{exitWorkspaceRetry, reason} + return workspaceExit{code: exitWorkspaceRetry, reason: reason} } // M2 startup outcome; INV-WS-STARTUP-RETRY-001. Workspace chunk primaries only. @@ -165,7 +171,7 @@ func watchChunkRuntimeFence(ctx context.Context, e *processExit, f flags, p chun } for { if p.ChunkRuntimeFenced(f.volumeID) { - e.choose(workspaceExit{exitWorkspaceSuperseded, "head_fenced"}) + e.choose(workspaceExit{code: exitWorkspaceSuperseded, reason: "head_fenced"}) return } select { @@ -222,7 +228,7 @@ func finishWorkspaceLease(e *processExit, f flags, h *volume.Host, done <-chan e case <-time.After(workspaceLeaseCloseoutTimeout): fmt.Fprintln(os.Stderr, "blockvolume: workspace lease closeout deadline") } - e.choose(workspaceExit{exitWorkspaceRetry, "revoke_ack_unconfirmed"}) + e.choose(workspaceExit{code: exitWorkspaceRetry, reason: "revoke_ack_unconfirmed"}) } // The provider publishes only a generation-bound outcome and an atomic choice. @@ -243,5 +249,8 @@ func chooseChunkStartupExit(e *processExit, f flags, h *volume.Host, p chunkStar // INV-WS-STARTUP-RETRY-001: one exit decision consumes both proof // sources; the provider rechecks the claim generation below. out := workspaceRetryOutcome("assignment_timeout", h, p.ChunkStartupSuperseded(f.volumeID, gen)) + if c, ok := p.(interface{ ChunkStartupCure(string, uint64) string }); ok { + out.detail = c.ChunkStartupCure(f.volumeID, gen) + } return p.ChooseChunkStartupExit(f.volumeID, gen, func() { e.chooseChunkStartup(out) }) } diff --git a/seaweed-block/cmd/blockvolume/process_exit_test.go b/seaweed-block/cmd/blockvolume/process_exit_test.go index 444d13caa0..ac6d56dfea 100644 --- a/seaweed-block/cmd/blockvolume/process_exit_test.go +++ b/seaweed-block/cmd/blockvolume/process_exit_test.go @@ -10,15 +10,15 @@ import ( ) func TestWorkspaceExitFirstOutcomeIsLatched(t *testing.T) { - for _, first := range []workspaceExit{{75, "lease_expired"}, {78, "superseded"}, {0, "revoked"}} { + for _, first := range []workspaceExit{{code: 75, reason: "lease_expired"}, {code: 78, reason: "superseded"}, {code: 0, reason: "revoked"}} { e := newProcessExit(context.Background()) e.choose(first) - e.choose(workspaceExit{75, "assignment_timeout"}) + e.choose(workspaceExit{code: 75, reason: "assignment_timeout"}) <-e.done if got := <-e.decision; got != first { t.Fatalf("first=%+v changed to %+v", first, got) } - e.choose(workspaceExit{78, "superseded"}) + e.choose(workspaceExit{code: 78, reason: "superseded"}) select { case got := <-e.decision: t.Fatalf("later outcome published: %+v", got) @@ -28,7 +28,7 @@ func TestWorkspaceExitFirstOutcomeIsLatched(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() e := newProcessExit(ctx) - e.choose(workspaceExit{78, "superseded"}) + e.choose(workspaceExit{code: 78, reason: "superseded"}) if got := <-e.decision; got.code != 0 || got.reason != "signal" { t.Fatalf("observed signal lost: %+v", got) } @@ -38,13 +38,13 @@ func TestWorkspaceExitDoesNotWaitForBlockedFrontendClose(t *testing.T) { finished := make(chan int) // a frontend Close that never returns deadline := make(chan time.Time, 1) deadline <- time.Time{} - if code := finishWorkspaceExit(workspaceExit{75, "lease_expired"}, finished, deadline); code != 75 { + if code := finishWorkspaceExit(workspaceExit{code: 75, reason: "lease_expired"}, finished, deadline); code != 75 { t.Fatalf("code=%d", code) } // Cleanup errors do not overwrite an already selected retry/no-retry status. done := make(chan int, 1) done <- 1 - if code := finishWorkspaceExit(workspaceExit{78, "superseded"}, done, make(chan time.Time)); code != 78 { + if code := finishWorkspaceExit(workspaceExit{code: 78, reason: "superseded"}, done, make(chan time.Time)); code != 78 { t.Fatalf("code=%d", code) } } @@ -64,7 +64,7 @@ func TestWorkspacePlannedStopKeepsSuccess(t *testing.T) { func TestWorkspaceRetryProcessExitsWhenCloseBlocks(t *testing.T) { if os.Getenv("GAP1_BLOCKED_CLOSE_CHILD") == "1" { code := superviseProcess(context.Background(), func(e *processExit) int { - e.choose(workspaceExit{75, "lease_expired"}) + e.choose(workspaceExit{code: 75, reason: "lease_expired"}) select {} // the frontend/resource owner's Close never returns }) os.Exit(code) @@ -84,7 +84,7 @@ func TestWorkspaceSignalFirstKeepsZeroAfterLaterFailure(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() code := superviseProcess(ctx, func(e *processExit) int { - e.choose(workspaceExit{78, "superseded"}) + e.choose(workspaceExit{code: 78, reason: "superseded"}) return 1 // a later cleanup error cannot replace the chosen signal status }) if code != 0 { diff --git a/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go index 48e9d3bbe3..f0dec17775 100644 --- a/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go +++ b/seaweed-block/cmd/blockvolume/runtime_fence_exit_test.go @@ -59,7 +59,7 @@ func TestRuntimeHeadFenceChoosesHeadFencedExit(t *testing.T) { stub.updates <- struct{}{} select { case out := <-e.decision: - if out != (workspaceExit{exitWorkspaceSuperseded, "head_fenced"}) { + if out != (workspaceExit{code: exitWorkspaceSuperseded, reason: "head_fenced"}) { t.Fatalf("exit %+v, want 78 head_fenced", out) } case <-time.After(runtimeFenceWait): diff --git a/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go b/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go new file mode 100644 index 0000000000..8004ce71ee --- /dev/null +++ b/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go @@ -0,0 +1,78 @@ +package durable_test + +import ( + "bytes" + "context" + "runtime" + "testing" + + "github.com/seaweedfs/seaweed-block/core/storage" +) + +// casObservedRemote runs onCAS right after each successful HEAD CAS. +type casObservedRemote struct { + storage.ChunkRemote + onCAS func(next storage.ChunkHead) +} + +func (r *casObservedRemote) CASHead(ctx context.Context, expected storage.ChunkHeadVersion, next storage.ChunkHead) (uint64, error) { + gen, err := r.ChunkRemote.CASHead(ctx, expected, next) + if err == nil && r.onCAS != nil { + r.onCAS(next) + } + return gen, err +} + +// V1-SPEC r2.45 (2) rests on this: a cut publishes only an LSN its root has +// already made durable (the barrier sync before the HEAD CAS), so a crash +// right after the CAS leaves a root at or above HEAD's remote_lsn. The +// root's crash image taken at the CAS reattaches under that HEAD and serves +// the cut's data. +func TestCutPublishesOnlyLocallyDurableLSN(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("the open store's byte-range lock keeps its files unreadable for the crash image") + } + ctx := context.Background() + inner := storage.NewMemChunkRemote() + root, crash := t.TempDir(), t.TempDir() + var ws *storage.WALStore + var images int + remote := &casObservedRemote{ChunkRemote: inner} + remote.onCAS = func(next storage.ChunkHead) { + if ws == nil || next.RemoteLSN == 0 { + return + } + if durable, _, _ := ws.Boundaries(); durable < next.RemoteLSN { + t.Errorf("HEAD CAS published remote_lsn %d above the root's durable LSN %d", next.RemoteLSN, durable) + } + copyRootFiles(t, root, crash) // the root as a crash right after this CAS leaves it + images++ + } + a := chunkProvider(t, root, remote, v1View(), 0) + s := openRecovered(t, a) + ws = s.(*storage.WALStore) + for lba := uint32(0); lba < 3; lba++ { + if _, err := s.Write(lba, block(byte(lba+1))); err != nil { + t.Fatal(err) + } + } + if _, err := a.CaptureVolume(ctx, "v1"); err != nil { + t.Fatal(err) + } + if images == 0 { + t.Fatal("no cut published a HEAD") + } + head, _ := inner.GetHead(ctx) + + b := chunkProvider(t, crash, inner, v1View(), 0) + got := openRecovered(t, b) // the refusal must not fire on the crash image + for lba := uint32(0); lba < 3; lba++ { + buf, err := got.Read(lba) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(buf, block(byte(lba+1))) { + t.Fatalf("crash image under HEAD remote_lsn %d lost block %d", head.RemoteLSN, lba) + } + } +} diff --git a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go index 8b002a0c3f..5e784bf284 100644 --- a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go +++ b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go @@ -38,6 +38,10 @@ func TestOneLiveProcessPerVolumePerHost(t *testing.T) { if _, err := a.EnsureStorage("v1"); err != nil { t.Fatal(err) } + held, err := os.Stat(filepath.Join(lockDir, "v1.lock")) + if err != nil { + t.Fatal(err) + } b := lockedProvider(t, t.TempDir(), lockDir, remote) if _, err := b.EnsureStorage("v1"); !errors.Is(err, storage.ErrWALStoreLocked) { t.Fatalf("a second provider for the same volume on this host opened: %v; want %v", err, storage.ErrWALStoreLocked) @@ -53,38 +57,58 @@ func TestOneLiveProcessPerVolumePerHost(t *testing.T) { if _, err := c.EnsureStorage("v1"); err != nil { t.Fatalf("the volume could not be opened after its first owner closed: %v", err) } + // Released, never unlinked: the next owner locks the same file. + if again, err := os.Stat(filepath.Join(lockDir, "v1.lock")); err != nil || !os.SameFile(held, again) { + t.Fatalf("the lock file was replaced between owners: %v", err) + } } -// V1-SPEC r2.45 (1): without its host lock directory the provider refuses -// to start, with the operator's cure; it never creates the directory. The -// default path is checked where the host lacks it. -func TestHostVolumeLockRefusesMissingDirectory(t *testing.T) { - dirs := []string{filepath.Join(t.TempDir(), "locks")} - if _, err := os.Stat(durable.HostVolumeLockDir); errors.Is(err, os.ErrNotExist) { - dirs = append(dirs, "") // the default path - } else { - t.Logf("this host has %s: default path not exercised", durable.HostVolumeLockDir) - } - for _, dir := range dirs { - p, err := durable.NewDurableProvider(durable.ProviderConfig{ +// V1-SPEC r2.45 (1): the provider creates a missing lock directory (0700) +// and refuses, with the operator's cure, only when it cannot create it. +func TestHostVolumeLockDirectoryCreatedOrRefused(t *testing.T) { + newProvider := func(dir string) (*durable.DurableProvider, error) { + return durable.NewDurableProvider(durable.ProviderConfig{ Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks, HostVolumeLock: true, VolumeLockDirTestOnly: dir, }, v1View()) - if err == nil { - _ = p.Close() - } - if !errors.Is(err, durable.ErrVolumeLockDirMissing) || !strings.Contains(err.Error(), "install the tmpfiles.d entry or create the directory") { - t.Fatalf("lock dir %q: a provider without its lock directory started: %v", dir, err) - } - want := dir - if want == "" { - want = durable.HostVolumeLockDir - } - if !strings.Contains(err.Error(), want) { - t.Fatalf("the refusal does not name %s: %v", want, err) - } - if _, statErr := os.Stat(want); !errors.Is(statErr, os.ErrNotExist) { - t.Fatalf("the provider created its lock directory %s: %v", want, statErr) - } + } + missing := filepath.Join(t.TempDir(), "sw-block", "locks") + p, err := newProvider(missing) + if err != nil { + t.Fatalf("a missing lock directory was not created: %v", err) + } + _ = p.Close() + if fi, err := os.Stat(missing); err != nil || !fi.IsDir() { + t.Fatalf("lock directory %s: %v", missing, err) + } + blocked := filepath.Join(t.TempDir(), "file") + if err := os.WriteFile(blocked, nil, 0o600); err != nil { + t.Fatal(err) + } + p, err = newProvider(filepath.Join(blocked, "locks")) + if err == nil { + _ = p.Close() + } + if !errors.Is(err, durable.ErrVolumeLockDirUnavailable) || !strings.Contains(err.Error(), "install the tmpfiles.d entry") || !strings.Contains(err.Error(), "chown the directory and its lock files") { + t.Fatalf("an uncreatable lock directory: %v; want the refusal with its cure", err) + } +} + +// A lock file this process cannot write (one another user created, as the +// root ublk unit does) is still taken: the lock opens it read-only. +func TestHostVolumeLockTakesReadOnlyLockFile(t *testing.T) { + remote := storage.NewMemChunkRemote() + lockDir := t.TempDir() + path := filepath.Join(lockDir, "v1.lock") + if err := os.WriteFile(path, nil, 0o444); err != nil { + t.Fatal(err) + } + a := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := a.EnsureStorage("v1"); err != nil { + t.Fatalf("a read-only lock file refused the volume: %v", err) + } + b := lockedProvider(t, t.TempDir(), lockDir, remote) + if _, err := b.EnsureStorage("v1"); !errors.Is(err, storage.ErrWALStoreLocked) { + t.Fatalf("a second provider on a read-only lock file: %v; want %v", err, storage.ErrWALStoreLocked) } } diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 3b7a44577c..eb391db3d8 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -162,8 +162,9 @@ type ProviderConfig struct { // HostVolumeLock makes the provider hold an exclusive, nonblocking lock // on HostVolumeLockDir/.lock from before the volume's store // opens until Close: one host runs at most one live process per volume - // (V1-SPEC r2.45). The directory must exist (a tmpfiles.d entry ships in - // deploy/systemd); NewDurableProvider refuses without it. blockvolume + // (V1-SPEC r2.45). NewDurableProvider creates the directory (0700) when + // missing and refuses when it cannot create or use it; the tmpfiles.d + // entry in deploy/systemd creates it for the unit's user. blockvolume // sets this. HostVolumeLock bool // VolumeLockDirTestOnly replaces HostVolumeLockDir for tests and test @@ -288,6 +289,8 @@ type volHandle struct { // hostLock is the volume's host lock (HostVolumeLock), held while open. hostLock *os.File + // startupCure is the operator's cure of a stale-root startup end. + startupCure string // ImplWALStoreChunk. fresh: the local volume is new and starts from // the remote HEAD. It mirrors the durable fresh marker beside the @@ -402,11 +405,8 @@ func NewDurableProvider(cfg ProviderConfig, view frontend.ProjectionView) (*Dura if cfg.VolumeLockDirTestOnly == "" { cfg.VolumeLockDirTestOnly = HostVolumeLockDir } - if fi, err := os.Stat(cfg.VolumeLockDirTestOnly); err != nil || !fi.IsDir() { - if err == nil { - err = fmt.Errorf("not a directory") - } - return nil, fmt.Errorf("%w %s: %w; install the tmpfiles.d entry or create the directory", ErrVolumeLockDirMissing, cfg.VolumeLockDirTestOnly, err) + if err := os.MkdirAll(cfg.VolumeLockDirTestOnly, 0o700); err != nil { + return nil, fmt.Errorf("%w %s: %w; %s", ErrVolumeLockDirUnavailable, cfg.VolumeLockDirTestOnly, err, volumeLockCure) } } if cfg.ChunkBlocks == 0 { @@ -554,9 +554,13 @@ func (p *DurableProvider) ensureHandle(volumeID string) (*volHandle, error) { // host locks (HostVolumeLock). const HostVolumeLockDir = "/run/sw-block/locks" -// ErrVolumeLockDirMissing refuses a provider with HostVolumeLock whose lock -// directory does not exist. -var ErrVolumeLockDirMissing = errors.New("durable: host volume lock directory missing") +// ErrVolumeLockDirUnavailable refuses a provider with HostVolumeLock whose +// lock directory or lock file it cannot create or open. +var ErrVolumeLockDirUnavailable = errors.New("durable: host volume lock directory unavailable") + +// volumeLockCure names the operator's cure. A directory or lock file a root +// process created is root-owned: an unprivileged unit then cannot use it. +const volumeLockCure = "install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), or chown the directory and its lock files to this process's user" // lockVolumeOnHost takes the volume's host lock (nil without // HostVolumeLock). A second live process for the volume on this host gets @@ -570,9 +574,14 @@ func (p *DurableProvider) lockVolumeOnHost(volumeID string) (*os.File, error) { return nil, fmt.Errorf("durable: volume id %q is not a plain path element", volumeID) } path := filepath.Join(dir, volumeID+".lock") - f, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0o600) + // Read-only, 0644: a lock file another user created (the root ublk unit) + // stays lockable by the plain unit; the 0700 directory keeps others out. + f, err := os.Open(path) + if errors.Is(err, os.ErrNotExist) { + f, err = os.OpenFile(path, os.O_CREATE|os.O_RDONLY, 0o644) + } if err != nil { - return nil, fmt.Errorf("durable: volume lock %s: %w", path, err) + return nil, fmt.Errorf("%w: volume lock %s: %w; %s", ErrVolumeLockDirUnavailable, path, err, volumeLockCure) } if err := storage.LockWALStoreFile(f); err != nil { _ = f.Close() diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 6c92535c3b..e356da62a4 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -465,6 +465,9 @@ func (p *DurableProvider) newChunkLayer(ctx context.Context, volumeID string, h // V1-SPEC r2.45: HEAD names this holder, but a root whose local // durable LSN is below HEAD's remote_lsn is a rolled-back copy // (a backup taken before a later cut). Restarting cannot cure it. + // A crash cannot cause it: a cut syncs its LSN locally before the + // HEAD CAS publishes it (storage chunkLayer capture: the barrier + // syncWithPhases result is next.RemoteLSN). if durableLSN, _, _ := ws.Boundaries(); head.Gen != 0 && durableLSN < head.RemoteLSN { log.Printf("durable: refusing to attach volume=%s root=%s: local durable LSN %d is below HEAD gen=%d remote_lsn=%d (remove or quarantine the local root)", volumeID, h.path, durableLSN, head.Gen, head.RemoteLSN) diff --git a/seaweed-block/core/frontend/durable/provider_startup.go b/seaweed-block/core/frontend/durable/provider_startup.go index ce9fc929db..c2050d25e4 100644 --- a/seaweed-block/core/frontend/durable/provider_startup.go +++ b/seaweed-block/core/frontend/durable/provider_startup.go @@ -42,12 +42,31 @@ func (p *DurableProvider) endChunkStartup(h *volHandle, gen uint64, cause error) } h.startupEnded = gen h.startupSuperseded = errors.Is(cause, errChunkForeignClaim) + h.startupCure = "" + if errors.Is(cause, ErrChunkStaleLocalRoot) { + h.startupCure = ChunkStaleLocalRootCure + } select { case p.startupUpdates <- struct{}{}: default: } } +// ChunkStaleLocalRootCure is the operator's cure of a stale local root. +const ChunkStaleLocalRootCure = "remove or quarantine the local root to attach fresh from HEAD" + +// ChunkStartupCure is the operator's cure of this exact recovery's startup +// end ("" when none), for the process's final exit line. +func (p *DurableProvider) ChunkStartupCure(volumeID string, gen uint64) string { + p.mu.Lock() + defer p.mu.Unlock() + h := p.volumes[volumeID] + if p.closed || h == nil || gen == 0 || h.recoverGen != gen || h.startupEnded != gen { + return "" + } + return h.startupCure +} + // ChooseChunkStartupExit validates and selects an outcome in one provider-lock // section, so recovery cannot change generation between observation and choice. // choose must only latch the process outcome; it must not block or call back diff --git a/seaweed-block/core/frontend/durable/rolled_back_copy_test.go b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go index c62ffb1127..bfaff18e25 100644 --- a/seaweed-block/core/frontend/durable/rolled_back_copy_test.go +++ b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go @@ -1,6 +1,7 @@ package durable_test import ( + "bytes" "context" "errors" "io" @@ -49,7 +50,8 @@ func copyRootFiles(t *testing.T, src, dst string) { // only if its local durable LSN reaches HEAD's remote_lsn. A rolled-back // copy of the root (a backup taken before the last cut) is refused with the // stale-root refusal, as a no-retry (superseded) startup outcome, with the -// operator's cure; the root's own restart is accepted. +// operator's cure; it makes no claim, never serves and is left as it was. An +// exact copy of the root at HEAD, and the root's own restart, attach. func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { ctx := context.Background() remote := storage.NewMemChunkRemote() @@ -62,6 +64,7 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { if _, err := a.CaptureVolume(ctx, "v1"); err != nil { t.Fatal(err) } + copyLSN, _, _ := s.(*storage.WALStore).Boundaries() if err := a.Close(); err != nil { t.Fatal(err) } @@ -80,12 +83,16 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { t.Fatal(err) } head, _ := remote.GetHead(ctx) + exact := t.TempDir() + copyRootFiles(t, root, exact) // durable LSN at HEAD + puts := remote.Puts() b := chunkProvider(t, backup, remote, v1View(), 0) - if _, err := b.EnsureStorage("v1"); err != nil { + bs, err := b.EnsureStorage("v1") + if err != nil { t.Fatal(err) } - _, err := b.RecoverVolume(ctx, "v1") + _, err = b.RecoverVolume(ctx, "v1") if !errors.Is(err, durable.ErrChunkStaleLocalRoot) || !strings.Contains(err.Error(), "remove or quarantine the local root") { t.Fatalf("a rolled-back copy attached under HEAD remote_lsn %d: %v; want the stale-root refusal", head.RemoteLSN, err) } @@ -93,8 +100,40 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { if !ended || !b.ChunkStartupSuperseded("v1", gen) { t.Fatalf("the rolled-back copy's startup: ended=%t superseded=%t, want a no-retry outcome", ended, b.ChunkStartupSuperseded("v1", gen)) } - if after, _ := remote.GetHead(ctx); after.Gen != head.Gen { - t.Fatalf("HEAD moved under the refused copy: gen %d -> %d", head.Gen, after.Gen) + if cure := b.ChunkStartupCure("v1", gen); cure != durable.ChunkStaleLocalRootCure { + t.Fatalf("the startup end carries cure %q, want %q for the final exit line", cure, durable.ChunkStaleLocalRootCure) + } + if after, _ := remote.GetHead(ctx); after.Gen != head.Gen || after.Epoch != head.Epoch || after.Holder != head.Holder || remote.Puts() != puts { + t.Fatalf("the refused copy claimed or wrote: HEAD gen %d -> %d, PUTs %d -> %d", head.Gen, after.Gen, puts, remote.Puts()) + } + if err := b.Backend("v1").AdmitsIO(); err == nil { + t.Fatal("the refused copy admits I/O") + } + // The refused root is left as it was: its data and durable LSN are those + // of the copy (no seed, replay or rewrite toward HEAD). + ws := bs.(*storage.WALStore) + if r, _, _ := ws.Boundaries(); r != copyLSN { + t.Fatalf("the refused root's durable LSN moved: %d -> %d", copyLSN, r) + } + for lba, want := range map[uint32][]byte{1: block(1), 2: make([]byte, 4096)} { + got, err := ws.Read(lba) + if err != nil || !bytes.Equal(got, want) { + t.Fatalf("the refused root's block %d changed: %v", lba, err) + } + } + if err := b.Close(); err != nil { + t.Fatal(err) + } + + x := chunkProvider(t, exact, remote, v1View(), 0) + if _, err := x.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + if _, err := x.RecoverVolume(ctx, "v1"); err != nil { + t.Fatalf("an exact copy at HEAD remote_lsn %d was refused: %v", head.RemoteLSN, err) + } + if err := x.Close(); err != nil { + t.Fatal(err) } c := chunkProvider(t, root, remote, v1View(), 0) diff --git a/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf b/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf index cbe5109956..c75d451863 100644 --- a/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf +++ b/seaweed-block/deploy/systemd/sw-block.tmpfiles.conf @@ -1,6 +1,7 @@ # tmpfiles.d entry for the blockvolume host volume locks. Install as # /etc/tmpfiles.d/sw-block.conf, then run `systemd-tmpfiles --create`. -# blockvolume refuses to start without this directory. Each volume takes an +# blockvolume creates the directory when it can and refuses to start when it +# cannot (the shipped units cannot: ProtectSystem=strict). Each volume takes an # exclusive lock on /run/sw-block/locks/.lock, so one host runs at # most one live blockvolume per volume. The directory is owned by the # unprivileged units' user (sw-block) and is 0700, so no other local user can diff --git a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service index fe10fad22a..0e9727f5b7 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume-ublk.service @@ -76,8 +76,8 @@ RestartSec=5s NoNewPrivileges=true ProtectSystem=strict -# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf); blockvolume -# refuses to start without the directory. +# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf). Under +# ProtectSystem=strict blockvolume cannot create the directory itself. ReadWritePaths=-/run/sw-block/locks ProtectHome=true PrivateTmp=true diff --git a/seaweed-block/deploy/systemd/sw-blockvolume.service b/seaweed-block/deploy/systemd/sw-blockvolume.service index 79f1046a56..d0b66668ed 100644 --- a/seaweed-block/deploy/systemd/sw-blockvolume.service +++ b/seaweed-block/deploy/systemd/sw-blockvolume.service @@ -75,8 +75,8 @@ RestartSec=5s NoNewPrivileges=true ProtectSystem=strict -# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf); blockvolume -# refuses to start without the directory. +# The host volume locks (deploy/systemd/sw-block.tmpfiles.conf). Under +# ProtectSystem=strict blockvolume cannot create the directory itself. ReadWritePaths=-/run/sw-block/locks ProtectHome=true PrivateTmp=true diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index de070b7852..9a07e8cd70 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -213,9 +213,10 @@ stateDiagram-v2 Drained --> Acked: revocation acknowledged with the HEAD gen } state "HEAD holder" as H { - [*] --> Attaching + [*] --> Attaching: this process took the volume's host lock + [*] --> Refused: another live process holds the volume's host lock Attaching --> Claiming: fresh or same-holder local root - Attaching --> Refused: existing root, HEAD published by another holder + Attaching --> Refused: existing root, HEAD published by another holder or above its durable LSN Claiming --> Cooling: replace generation (or exclusive create), same image Cooling --> Holder: configured window elapsed (zero for single filer), exact HEAD reread Cooling --> HolderFenced: publication displaced @@ -234,6 +235,7 @@ stateDiagram-v2 | 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` | +| (start) | Attaching, Refused | the volume's host lock `/run/sw-block/locks/.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 | an existing local root whose HEAD another holder has published, or whose durable LSN is below HEAD's `remote_lsn` (`ErrChunkStaleLocalRoot`) | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `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` | | Claiming | Holder | HEAD epoch not above the master-issued epoch, no other holder at the same epoch; fresh roots seed from HEAD before the CAS; existing roots retain local WAL; active incarnations replace the generation (or exclusive-create HEAD); a sealed same-owner incarnation remains detached; I/O opens only after the configured cooling window (zero at one serialization point) and an exact generation/epoch/holder readback | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `INV-WS-CLAIM-BEFORE-SERVE-001`, `INV-WS-HEAD-CAS-001`, `INV-WS-REOPEN-FENCE-001` | @@ -465,7 +467,7 @@ Tests: `TestSnapshotSchedule_SlotsAreOffsetPerVolume`, `_FailureIsTypedAndBacksO ## Part B. Invariant ledger -313 rows: 242 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 298 new. +314 rows: 243 ACTIVE, 68 STUB, 3 ARCHIVED; 15 kept from the internal ledger, 299 new. The "Machine / transition" column refers to Part A. Notes under a table record what a row does not cover and, for kept rows, what was narrowed from the internal ledger. @@ -712,7 +714,8 @@ Notes: | `INV-WS-SEAL-REPLAY-001` | A repeated plain seal, also after restart, succeeds only from a fresh filer HEAD with exact owner/epoch and detachedBy proof. It returns that original HEAD/frontier without a CAS or new generation. An unreadable or mismatched proof cannot be answered from process memory. | M5 PlainStop -> RemoteProof -> SealedReply | `core/frontend/durable/provider_seal_replay.go` `replayPlainSeal`; `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead` | `TestPlainSealLostAnswerRestartReplaysFilerProof`, `TestPlainSealReplayNeverUsesProcessMemory`, `TestPlainSealReplayDuringDeferredAuthorityStartup` (`core/frontend/durable/provider_plain_seal_replay_test.go`) | `PlainSealReplay` `SuccessNeedsFreshExactProof`, `ValidProofDoesNotNeedProcessMemory` | ACTIVE | | `INV-WS-CAS-UNKNOWN-001` | An unknown HEAD CAS outcome is settled by re-reading HEAD, never by a blind retry; until it is settled the proposal stays pending and its intents stay. | M5 CAS → Pending | `core/storage/chunk_layer.go` `captureLocked`, `resolvePending`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestChunkRemote_UncertainCASIsNotPrecondition` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_UnknownNotAppliedNeverClaimsSuccess` (`core/storage/chunk_layer_contract_test.go`); `TestClaimChunkHeadSettlesUnknownWithoutReplay` (`core/storage/chunk_restore_test.go`); `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | — | ACTIVE | | `INV-WS-CLAIM-BEFORE-SERVE-001` | A new holder claims HEAD at its master-issued epoch before I/O opens; a HEAD with a higher epoch, or another holder at the same epoch, fences the claim. | M4 Claiming → Holder \| Fenced | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestClaimChunkHeadRefusesStaleAuthorityAndAdmissionDrift` (`core/storage/chunk_restore_test.go`); `TestRestoreSeedPrecedesTakeoverCAS` (`core/frontend/durable/provider_seed_order_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | `WorkspaceTakeover` `SeedMatchesTakeover` | ACTIVE | -| `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn` (a rolled-back copy), is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`); `TestRolledBackCopyBelowHeadLSNIsRefused` (`core/frontend/durable/one_process_per_volume_test.go`) | — | ACTIVE | +| `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn` (a rolled-back copy), is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`); `TestRolledBackCopyBelowHeadLSNIsRefused` (`core/frontend/durable/rolled_back_copy_test.go`); `TestCutPublishesOnlyLocallyDurableLSN` (`core/frontend/durable/cut_durable_before_cas_test.go`) | — | ACTIVE | +| `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | | `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: same holder and epoch only, no move pending or issued, not revoking, store certain, one durable write, and only once max(horizon, deadline) + skew bound has passed; the new process claims HEAD with a new generation before any I/O, so no older incarnation writes or CASes after. | M2 lease: Expired → Granted | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut`, `TestWorkspaceLeaseRegrantCannotUnsealSameEpoch`, `TestWorkspaceLeaseRegrantEmptyRootClaimsOnlyHEAD` (`core/authority/workspace_regrant_storage_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory` | 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 | diff --git a/seaweed-block/docs/releases/one-process-per-volume.md b/seaweed-block/docs/releases/one-process-per-volume.md index 1589261848..e2604748c5 100644 --- a/seaweed-block/docs/releases/one-process-per-volume.md +++ b/seaweed-block/docs/releases/one-process-per-volume.md @@ -7,8 +7,10 @@ the same host is refused before it opens anything, whatever its `--durable-root`. The lock is released when the process exits, including on a crash or kill. -The directory is not created by blockvolume. Install the tmpfiles.d entry -shipped in [`deploy/systemd/sw-block.tmpfiles.conf`](../../deploy/systemd/sw-block.tmpfiles.conf): +blockvolume creates the directory (`0700`) when it is missing and it may, and +refuses to start when it cannot create or open the directory or a volume's +lock file. The shipped units cannot create it (`ProtectSystem=strict`), so +install the tmpfiles.d entry shipped in [`deploy/systemd/sw-block.tmpfiles.conf`](../../deploy/systemd/sw-block.tmpfiles.conf): ```bash sudo install -m 0644 deploy/systemd/sw-block.tmpfiles.conf /etc/tmpfiles.d/sw-block.conf @@ -16,11 +18,16 @@ sudo systemd-tmpfiles --create /etc/tmpfiles.d/sw-block.conf ``` It creates `/run/sw-block/locks` as `0700`, owned by `sw-block`, at every -boot. Without it blockvolume exits at start with `host volume lock directory -missing ... install the tmpfiles.d entry or create the directory`. Both -shipped units allow writes to it (`ReadWritePaths=-/run/sw-block/locks`) -under `ProtectSystem=strict`. If you run blockvolume as another user, give -that user the directory instead. +boot. Both shipped units allow writes to it +(`ReadWritePaths=-/run/sw-block/locks`). Without it, or when it is not +usable, blockvolume exits at start with `host volume lock directory +unavailable ... install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), +or chown the directory and its lock files to this process's user`. A +directory created by a root process (the root ublk unit, or blockvolume run +by hand as root) is root-owned, and an unprivileged unit on that host then +cannot use it: install the tmpfiles.d entry, or chown the directory to the +unit's user. Lock files are opened read-only, so a lock file another user +created stays lockable. ## A rolled-back copy of a root is refused @@ -29,7 +36,13 @@ An existing local root attaches only if its local durable LSN reaches the a later cut (a backup, a snapshot of the disk, an older replica of the directory) is below that HEAD: it is refused with `ErrChunkStaleLocalRoot`, never serves, and its process exits 78 (no automatic restart) with the root -kept. Remove or quarantine the local root to attach fresh from HEAD. +kept; its last line is `exiting status=78 reason=superseded cure="remove or +quarantine the local root to attach fresh from HEAD"`. + +A power loss does not trigger this refusal on a correct root: a cut makes its +LSN durable on the local root (the barrier sync, an fsync or fdatasync of the +WAL) before the HEAD update that publishes it as `remote_lsn`, so the root is +never below the HEAD it published. ## Do not @@ -46,8 +59,8 @@ kept. Remove or quarantine the local root to attach fresh from HEAD. - Do not delete `/run/sw-block/locks` or its lock files while blockvolume runs: a new process would then get a different lock file and not see the running one. -- Do not run blockvolume in containers that do not share the host's - `/run/sw-block/locks`. In a container the lock is per host only if that - directory is the host's (a hostPath mount). The Kubernetes renderer +- Do not run blockvolume in containers or mount namespaces that do not + share the host's `/run/sw-block/locks`. `/run` is per mount namespace: the + lock is per host only if that directory is the host's (a hostPath mount). The Kubernetes renderer (`core/launcher/k8s_renderer.go`) and `deploy/k8s` manifests do not mount it yet: there, the lock is per pod. diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index 183466fc4d..8a9ca99431 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -52,7 +52,7 @@ added), do not mix revisions: build the binaries from your checkout instead | [`deploy/systemd/sw-blockmaster.service`](../deploy/systemd/sw-blockmaster.service) | `/etc/systemd/system/` | blockmaster, as `sw-block`; state in `/var/lib/sw-block-master` | | [`deploy/systemd/sw-blockvolume.service`](../deploy/systemd/sw-blockvolume.service) | `/etc/systemd/system/` | One blockvolume over NVMe/TCP or iSCSI, as `sw-block`; state in `/var/lib/sw-block-volume` | | [`deploy/systemd/sw-blockvolume-ublk.service`](../deploy/systemd/sw-blockvolume-ublk.service) | `/etc/systemd/system/` | The same volume over ublk, as root; state in `/var/lib/sw-block-volume-ublk` | -| [`deploy/systemd/sw-block.tmpfiles.conf`](../deploy/systemd/sw-block.tmpfiles.conf) | `/etc/tmpfiles.d/sw-block.conf` | `/run/sw-block/locks`, the host volume locks; blockvolume refuses to start without it ([one process per volume](releases/one-process-per-volume.md)) | +| [`deploy/systemd/sw-block.tmpfiles.conf`](../deploy/systemd/sw-block.tmpfiles.conf) | `/etc/tmpfiles.d/sw-block.conf` | `/run/sw-block/locks`, the host volume locks; the units cannot create it and blockvolume refuses to start without it ([one process per volume](releases/one-process-per-volume.md)) | Each unit has its own `StateDirectory=`, so the root ublk unit can never take ownership of blockmaster's or the unprivileged volume's files. Run either From f9383c5e486739dfe0b37eb3f6edbe996079443a Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:10:01 -0800 Subject: [PATCH 181/204] test: zero HEAD CAS on the refused copy; same-epoch HEAD advance before the claim recheck - The rolled-back copy makes no HEAD CAS attempt (counted at the remote, not inferred from PUTs). - Control: an exact copy passes the preliminary HEAD read; HEAD then advances at the same epoch and holder before the claim's own read; the claim-image recheck refuses it as stale, with no CAS. - The refused second provider leaves its storage root empty. - The --help capture registers stderr restoration and pipe closes first, closes the writer before joining the reader, and bounds the join. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/volume_lock_flag_test.go | 15 +++++-- .../durable/cut_durable_before_cas_test.go | 17 ++++++- .../durable/one_process_per_volume_test.go | 6 ++- .../frontend/durable/rolled_back_copy_test.go | 44 ++++++++++++++++++- 4 files changed, 74 insertions(+), 8 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go b/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go index 907cd45126..ead0e331d9 100644 --- a/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go +++ b/seaweed-block/cmd/blockvolume/volume_lock_flag_test.go @@ -5,6 +5,7 @@ import ( "os" "strings" "testing" + "time" ) // V1-SPEC r2.45: the test lock directory override is refused under systemd @@ -28,14 +29,20 @@ func TestVolumeLockDirTestOnlyHiddenFromHelp(t *testing.T) { if err != nil { t.Fatal(err) } - read := make(chan []byte) - go func() { b, _ := io.ReadAll(r); read <- b }() // usage exceeds a pipe buffer saved := os.Stderr + t.Cleanup(func() { os.Stderr = saved; _ = w.Close(); _ = r.Close() }) + read := make(chan []byte, 1) + go func() { b, _ := io.ReadAll(r); read <- b }() // usage exceeds a pipe buffer os.Stderr = w _, parseErr := parseFlags([]string{"-h"}) os.Stderr = saved - _ = w.Close() - out := <-read + _ = w.Close() // release the reader before joining it + var out []byte + select { + case out = <-read: + case <-time.After(10 * time.Second): + t.Fatal("usage reader did not finish") + } if parseErr == nil || !strings.Contains(string(out), "-durable-root") { t.Fatalf("no usage printed: %v %q", parseErr, out) } diff --git a/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go b/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go index 8004ce71ee..3cbc0f5b1b 100644 --- a/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go +++ b/seaweed-block/core/frontend/durable/cut_durable_before_cas_test.go @@ -9,13 +9,26 @@ import ( "github.com/seaweedfs/seaweed-block/core/storage" ) -// casObservedRemote runs onCAS right after each successful HEAD CAS. +// casObservedRemote counts HEAD reads and CAS attempts; onGetHead runs +// before each HEAD read (n counts from 1), onCAS right after each successful +// HEAD CAS. type casObservedRemote struct { storage.ChunkRemote - onCAS func(next storage.ChunkHead) + onCAS func(next storage.ChunkHead) + onGetHead func(n int) + reads, cass int +} + +func (r *casObservedRemote) GetHead(ctx context.Context) (storage.ChunkHead, error) { + r.reads++ + if r.onGetHead != nil { + r.onGetHead(r.reads) + } + return r.ChunkRemote.GetHead(ctx) } func (r *casObservedRemote) CASHead(ctx context.Context, expected storage.ChunkHeadVersion, next storage.ChunkHead) (uint64, error) { + r.cass++ gen, err := r.ChunkRemote.CASHead(ctx, expected, next) if err == nil && r.onCAS != nil { r.onCAS(next) diff --git a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go index 5e784bf284..55af4a8d40 100644 --- a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go +++ b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go @@ -42,10 +42,14 @@ func TestOneLiveProcessPerVolumePerHost(t *testing.T) { if err != nil { t.Fatal(err) } - b := lockedProvider(t, t.TempDir(), lockDir, remote) + bRoot := t.TempDir() + b := lockedProvider(t, bRoot, lockDir, remote) if _, err := b.EnsureStorage("v1"); !errors.Is(err, storage.ErrWALStoreLocked) { t.Fatalf("a second provider for the same volume on this host opened: %v; want %v", err, storage.ErrWALStoreLocked) } + if left, err := os.ReadDir(bRoot); err != nil || len(left) != 0 { + t.Fatalf("the refused second provider touched its root: %v %v", left, err) + } other := lockedProvider(t, t.TempDir(), lockDir, remote) if _, err := other.EnsureStorage("v2"); err != nil { t.Fatalf("another volume was refused by v1's lock: %v", err) diff --git a/seaweed-block/core/frontend/durable/rolled_back_copy_test.go b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go index bfaff18e25..b35f390871 100644 --- a/seaweed-block/core/frontend/durable/rolled_back_copy_test.go +++ b/seaweed-block/core/frontend/durable/rolled_back_copy_test.go @@ -87,7 +87,8 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { copyRootFiles(t, root, exact) // durable LSN at HEAD puts := remote.Puts() - b := chunkProvider(t, backup, remote, v1View(), 0) + observed := &casObservedRemote{ChunkRemote: remote} + b := chunkProvider(t, backup, observed, v1View(), 0) bs, err := b.EnsureStorage("v1") if err != nil { t.Fatal(err) @@ -106,6 +107,9 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { if after, _ := remote.GetHead(ctx); after.Gen != head.Gen || after.Epoch != head.Epoch || after.Holder != head.Holder || remote.Puts() != puts { t.Fatalf("the refused copy claimed or wrote: HEAD gen %d -> %d, PUTs %d -> %d", head.Gen, after.Gen, puts, remote.Puts()) } + if observed.cass != 0 { + t.Fatalf("the refused copy attempted %d HEAD CASes, want none", observed.cass) + } if err := b.Backend("v1").AdmitsIO(); err == nil { t.Fatal("the refused copy admits I/O") } @@ -143,4 +147,42 @@ func TestRolledBackCopyBelowHeadLSNIsRefused(t *testing.T) { if _, err := c.RecoverVolume(ctx, "v1"); err != nil { t.Fatalf("the root's own restart after its last cut was refused: %v", err) } + + // The recheck on the exact claim image: HEAD advances at the same epoch + // and holder between the preliminary HEAD read and the claim's read + // (the original root cut again). An exact copy that passed the first + // read is then below HEAD and refused, with no CAS. + race := t.TempDir() + copyRootFiles(t, exact, race) + raced := &casObservedRemote{ChunkRemote: remote} + var advanced storage.ChunkHead + raced.onGetHead = func(n int) { + if n != 2 { + return + } + cur, err := remote.GetHead(ctx) + if err != nil { + t.Error(err) + return + } + next := cur + next.RemoteLSN = cur.RemoteLSN + 1 + if _, err := remote.CASHead(ctx, storage.ChunkHeadVersion{Gen: cur.Gen, Epoch: cur.Epoch}, next); err != nil { + t.Error(err) + } + advanced, _ = remote.GetHead(ctx) + } + y := chunkProvider(t, race, raced, v1View(), 0) + if _, err := y.EnsureStorage("v1"); err != nil { + t.Fatal(err) + } + if _, err := y.RecoverVolume(ctx, "v1"); !errors.Is(err, durable.ErrChunkStaleLocalRoot) { + t.Fatalf("HEAD advanced to remote_lsn %d (epoch %d) after the preliminary read; the claim recheck attached: %v", advanced.RemoteLSN, advanced.Epoch, err) + } + if advanced.Gen == 0 || advanced.Epoch != head.Epoch || advanced.Holder != head.Holder || raced.cass != 0 { + t.Fatalf("race control: advanced HEAD %+v (want same epoch %d, holder %q), CAS attempts %d (want 0)", advanced, head.Epoch, head.Holder, raced.cass) + } + if err := y.Close(); err != nil { + t.Fatal(err) + } } From f865a8e21f475fdf44970e60365a35d08cc65aee Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:43:23 -0800 Subject: [PATCH 182/204] test: expose unsynced lifecycle ancestors and trailing separator --- .../core/lifecycle/store_parent_sync_test.go | 82 +++++++++++++++++++ .../core/lifecycle/workspace_bindings.go | 4 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 seaweed-block/core/lifecycle/store_parent_sync_test.go diff --git a/seaweed-block/core/lifecycle/store_parent_sync_test.go b/seaweed-block/core/lifecycle/store_parent_sync_test.go new file mode 100644 index 0000000000..3828af708a --- /dev/null +++ b/seaweed-block/core/lifecycle/store_parent_sync_test.go @@ -0,0 +1,82 @@ +//go:build linux + +package lifecycle + +import ( + "context" + "os" + "os/exec" + "path/filepath" + "reflect" + "testing" + "time" +) + +// INV-LIFECYCLE-STORE-DURABLE-001: creation syncs every new directory's +// parent, including a new ancestor; a trailing separator changes no target. +func TestLifecycleStoreParentSync(t *testing.T) { + for _, kind := range []string{"node", "volume", "placement"} { + for _, shape := range []string{"nested", "trailing-slash"} { + t.Run(kind+"/"+shape, func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestLifecycleStoreParentSyncChild$", "-test.timeout=8s") + cmd.Env = append(os.Environ(), "LIFECYCLE_PARENT_ROOT="+t.TempDir(), "LIFECYCLE_PARENT_KIND="+kind, "LIFECYCLE_PARENT_SHAPE="+shape) + if out, err := cmd.CombinedOutput(); err != nil { + t.Fatalf("parent sync control: %v context=%v\n%s", err, ctx.Err(), out) + } + }) + } + } +} + +func TestLifecycleStoreParentSyncChild(t *testing.T) { + root := os.Getenv("LIFECYCLE_PARENT_ROOT") + if root == "" { + t.Skip("isolated syscall-boundary control") + } + dir := filepath.Join(root, "store") + want := []string{root} + if os.Getenv("LIFECYCLE_PARENT_SHAPE") == "nested" { + dir = filepath.Join(root, "new-parent", "store") + want = []string{filepath.Dir(dir), root} + } else { + dir += string(os.PathSeparator) + } + var calls []string + realSync := syncBindingParent + syncBindingParent = func(path string) error { + calls = append(calls, path) + return realSync(path) + } + open := func() error { + switch os.Getenv("LIFECYCLE_PARENT_KIND") { + case "node": + _, err := OpenNodeInventoryStore(dir) + return err + case "volume": + _, err := OpenFileStore(dir) + return err + case "placement": + _, err := OpenPlacementIntentStore(dir) + return err + default: + t.Fatal("unknown store kind") + return nil + } + } + if err := open(); err != nil { + t.Fatal(err) + } + if !reflect.DeepEqual(calls, want) { + t.Fatalf("parent syncs %v want %v", calls, want) + } + calls = nil + if err := open(); err != nil { + t.Fatal(err) + } + want = []string{filepath.Dir(filepath.Clean(dir))} + if !reflect.DeepEqual(calls, want) { + t.Fatalf("existing-store retry syncs %v want %v", calls, want) + } +} diff --git a/seaweed-block/core/lifecycle/workspace_bindings.go b/seaweed-block/core/lifecycle/workspace_bindings.go index d3fbefd8e9..1d6270d41f 100644 --- a/seaweed-block/core/lifecycle/workspace_bindings.go +++ b/seaweed-block/core/lifecycle/workspace_bindings.go @@ -36,7 +36,9 @@ func OpenWorkspaceBindingStore(dir string) (*WorkspaceBindingStore, error) { return openWorkspaceBindingStore(dir, syncBindingParent) } -func syncBindingParent(dir string) error { +// Isolated subprocess tests may replace this syscall boundary; production +// always uses the real directory Sync below. +var syncBindingParent = func(dir string) error { f, err := os.Open(dir) if err != nil { return err From aaedc618551fa203ac4da10a48a719b334d24082 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:44:01 -0800 Subject: [PATCH 183/204] fix: sync every created lifecycle ancestor from cleaned paths --- .../core/lifecycle/node_inventory.go | 28 +++++++++++++++++-- .../core/lifecycle/placement_intent.go | 28 +++++++++++++++++-- seaweed-block/core/lifecycle/store.go | 28 +++++++++++++++++-- .../core/lifecycle/store_parent_sync_test.go | 4 +-- seaweed-block/docs/design/invariants.md | 2 +- 5 files changed, 78 insertions(+), 12 deletions(-) diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index ae615a2754..6e0f959c4a 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -78,12 +78,34 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidNodeRegistration) } + dir = filepath.Clean(dir) + ancestor := dir + for { + if _, err := os.Stat(ancestor); err == nil { + break + } else if !errors.Is(err, os.ErrNotExist) { + return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) + } + parent := filepath.Dir(ancestor) + if parent == ancestor { + return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) + } + ancestor = parent + } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir node inventory %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. - if err := syncBindingParent(filepath.Dir(dir)); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, + // deepest first. Existing-store retries still sync the store's parent. + for current := dir; ; { + parent := filepath.Dir(current) + if err := syncBindingParent(parent); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + if current == ancestor || parent == ancestor { + break + } + current = parent } s := &NodeInventoryStore{ diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index 8927a73a9b..a9034b8fa6 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -49,12 +49,34 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec) } + dir = filepath.Clean(dir) + ancestor := dir + for { + if _, err := os.Stat(ancestor); err == nil { + break + } else if !errors.Is(err, os.ErrNotExist) { + return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) + } + parent := filepath.Dir(ancestor) + if parent == ancestor { + return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) + } + ancestor = parent + } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir placement intent %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. - if err := syncBindingParent(filepath.Dir(dir)); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, + // deepest first. Existing-store retries still sync the store's parent. + for current := dir; ; { + parent := filepath.Dir(current) + if err := syncBindingParent(parent); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + if current == ancestor || parent == ancestor { + break + } + current = parent } s := &PlacementIntentStore{ diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index 9a18faa8a2..e8cd453504 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -90,12 +90,34 @@ func OpenFileStore(dir string) (*FileStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec) } + dir = filepath.Clean(dir) + ancestor := dir + for { + if _, err := os.Stat(ancestor); err == nil { + break + } else if !errors.Is(err, os.ErrNotExist) { + return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) + } + parent := filepath.Dir(ancestor) + if parent == ancestor { + return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) + } + ancestor = parent + } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry. - if err := syncBindingParent(filepath.Dir(dir)); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, + // deepest first. Existing-store retries still sync the store's parent. + for current := dir; ; { + parent := filepath.Dir(current) + if err := syncBindingParent(parent); err != nil { + return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + } + if current == ancestor || parent == ancestor { + break + } + current = parent } s := &FileStore{ diff --git a/seaweed-block/core/lifecycle/store_parent_sync_test.go b/seaweed-block/core/lifecycle/store_parent_sync_test.go index 3828af708a..7290dfe63a 100644 --- a/seaweed-block/core/lifecycle/store_parent_sync_test.go +++ b/seaweed-block/core/lifecycle/store_parent_sync_test.go @@ -38,8 +38,8 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { dir := filepath.Join(root, "store") want := []string{root} if os.Getenv("LIFECYCLE_PARENT_SHAPE") == "nested" { - dir = filepath.Join(root, "new-parent", "store") - want = []string{filepath.Dir(dir), root} + dir = filepath.Join(root, "new-parent", "deeper", "store") + want = []string{filepath.Dir(dir), filepath.Join(root, "new-parent"), root} } else { dir += string(os.PathSeparator) } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 008bb61eae..109348b90c 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -650,7 +650,7 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | From b87fea473b09b6c13b78466b877e00b01a3d424c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:50:31 -0800 Subject: [PATCH 184/204] test: reproduce incomplete ancestor sync after failed first open --- .../core/lifecycle/store_parent_sync_test.go | 52 +++++++++++++++---- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/seaweed-block/core/lifecycle/store_parent_sync_test.go b/seaweed-block/core/lifecycle/store_parent_sync_test.go index 7290dfe63a..c1fef0d8e0 100644 --- a/seaweed-block/core/lifecycle/store_parent_sync_test.go +++ b/seaweed-block/core/lifecycle/store_parent_sync_test.go @@ -4,19 +4,21 @@ package lifecycle import ( "context" + "errors" "os" "os/exec" "path/filepath" "reflect" + "strings" "testing" "time" ) -// INV-LIFECYCLE-STORE-DURABLE-001: creation syncs every new directory's -// parent, including a new ancestor; a trailing separator changes no target. +// INV-LIFECYCLE-STORE-DURABLE-001: every open syncs the full ancestor chain, +// including a retry after failed creation; a trailing separator changes no target. func TestLifecycleStoreParentSync(t *testing.T) { for _, kind := range []string{"node", "volume", "placement"} { - for _, shape := range []string{"nested", "trailing-slash"} { + for _, shape := range []string{"nested", "trailing-slash", "failed-parent-sync", "relative-path"} { t.Run(kind+"/"+shape, func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -35,18 +37,38 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { if root == "" { t.Skip("isolated syscall-boundary control") } - dir := filepath.Join(root, "store") - want := []string{root} - if os.Getenv("LIFECYCLE_PARENT_SHAPE") == "nested" { - dir = filepath.Join(root, "new-parent", "deeper", "store") - want = []string{filepath.Dir(dir), filepath.Join(root, "new-parent"), root} - } else { - dir += string(os.PathSeparator) + shape := os.Getenv("LIFECYCLE_PARENT_SHAPE") + dir := filepath.Join(root, "new-parent", "deeper", "store") + if shape == "trailing-slash" { + dir = filepath.Join(root, "store") + string(os.PathSeparator) } + if shape == "relative-path" { + if err := os.Chdir(root); err != nil { + t.Fatal(err) + } + dir = filepath.Join("new-parent", "deeper", "store") + } + abs, err := filepath.Abs(filepath.Clean(dir)) + if err != nil { + t.Fatal(err) + } + // Independently enumerate absolute path prefixes, deepest first, down to /. + parts := strings.Split(strings.TrimPrefix(filepath.Dir(abs), "/"), "/") + var want []string + for n := len(parts); n > 0; n-- { + want = append(want, "/"+strings.Join(parts[:n], "/")) + } + want = append(want, "/") var calls []string realSync := syncBindingParent + failFirst := shape == "failed-parent-sync" + fault := &os.PathError{Op: "open", Path: want[0], Err: os.ErrPermission} syncBindingParent = func(path string) error { calls = append(calls, path) + if failFirst { + failFirst = false + return fault + } return realSync(path) } open := func() error { @@ -65,6 +87,15 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { return nil } } + if shape == "failed-parent-sync" { + if err := open(); !errors.Is(err, os.ErrPermission) { + t.Fatalf("ancestor sync failure hidden: %v", err) + } + if !reflect.DeepEqual(calls, want[:1]) { + t.Fatalf("failed syncs %v want %v", calls, want[:1]) + } + calls = nil + } if err := open(); err != nil { t.Fatal(err) } @@ -75,7 +106,6 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { if err := open(); err != nil { t.Fatal(err) } - want = []string{filepath.Dir(filepath.Clean(dir))} if !reflect.DeepEqual(calls, want) { t.Fatalf("existing-store retry syncs %v want %v", calls, want) } From f9038ca88d1dd54998bf8b13fc2abd85fea54312 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:51:03 -0800 Subject: [PATCH 185/204] fix: sync the full lifecycle ancestor chain on every open --- .../core/lifecycle/node_inventory.go | 28 ++++++------------- .../core/lifecycle/placement_intent.go | 28 ++++++------------- seaweed-block/core/lifecycle/store.go | 28 ++++++------------- 3 files changed, 24 insertions(+), 60 deletions(-) diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index 6e0f959c4a..6975c64330 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -78,34 +78,22 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidNodeRegistration) } - dir = filepath.Clean(dir) - ancestor := dir - for { - if _, err := os.Stat(ancestor); err == nil { - break - } else if !errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) - } - parent := filepath.Dir(ancestor) - if parent == ancestor { - return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) - } - ancestor = parent + dir, err := filepath.Abs(filepath.Clean(dir)) + if err != nil { + return nil, fmt.Errorf("lifecycle: resolve store path: %w", err) } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir node inventory %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, - // deepest first. Existing-store retries still sync the store's parent. - for current := dir; ; { - parent := filepath.Dir(current) + // INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability. + // Every open syncs the full ancestor chain, also after a failed first open. + for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) } - if current == ancestor || parent == ancestor { + if parent == filepath.Dir(parent) { break } - current = parent } s := &NodeInventoryStore{ diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index a9034b8fa6..dcca42190b 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -49,34 +49,22 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec) } - dir = filepath.Clean(dir) - ancestor := dir - for { - if _, err := os.Stat(ancestor); err == nil { - break - } else if !errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) - } - parent := filepath.Dir(ancestor) - if parent == ancestor { - return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) - } - ancestor = parent + dir, err := filepath.Abs(filepath.Clean(dir)) + if err != nil { + return nil, fmt.Errorf("lifecycle: resolve store path: %w", err) } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir placement intent %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, - // deepest first. Existing-store retries still sync the store's parent. - for current := dir; ; { - parent := filepath.Dir(current) + // INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability. + // Every open syncs the full ancestor chain, also after a failed first open. + for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) } - if current == ancestor || parent == ancestor { + if parent == filepath.Dir(parent) { break } - current = parent } s := &PlacementIntentStore{ diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index e8cd453504..e7b4eb752c 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -90,34 +90,22 @@ func OpenFileStore(dir string) (*FileStore, error) { if dir == "" { return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec) } - dir = filepath.Clean(dir) - ancestor := dir - for { - if _, err := os.Stat(ancestor); err == nil { - break - } else if !errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err) - } - parent := filepath.Dir(ancestor) - if parent == ancestor { - return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir) - } - ancestor = parent + dir, err := filepath.Abs(filepath.Clean(dir)) + if err != nil { + return nil, fmt.Errorf("lifecycle: resolve store path: %w", err) } if err := os.MkdirAll(dir, 0o755); err != nil { return nil, fmt.Errorf("lifecycle: mkdir %q: %w", dir, err) } - // INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent, - // deepest first. Existing-store retries still sync the store's parent. - for current := dir; ; { - parent := filepath.Dir(current) + // INV-LIFECYCLE-STORE-DURABLE-001: existence does not prove durability. + // Every open syncs the full ancestor chain, also after a failed first open. + for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store parent: %w", err) + return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) } - if current == ancestor || parent == ancestor { + if parent == filepath.Dir(parent) { break } - current = parent } s := &FileStore{ From ef9ec6bba63aa8fee5ac7c0fc82066af842ad214 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:13:20 -0800 Subject: [PATCH 186/204] docs: lifecycle setup, register nodes by the address they reach blockmaster from Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/volume-lifecycle.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index 0d3f3b4bc7..47c27b9555 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -75,6 +75,12 @@ volumes: replica_id: r1 ``` +In a multi-host cluster, register each node by the address it connects to +blockmaster from, never loopback. One server id names one host: a volume host whose +server id is registered on `127.0.0.1` is refused with `server id s1 is registered on +host 127.0.0.1; refused from
: one server id names one host`. The loopback +addresses above fit only when blockmaster and blockvolume run on the same machine. + **3. blockmaster flags.** `--cluster-spec` replaces `--topology` (setting both stops blockmaster). `--workspace-head-base-url` is the filer HTTP address plus blockvolume's `--chunk-path`: From 07bbe359c157de75c8dc42f1dec3b611086f537b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:13:48 -0800 Subject: [PATCH 187/204] test: require registration cure in holder host refusal --- seaweed-block/core/host/master/server_host_identity_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 645103f1a2..5a2357a4c4 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -244,6 +244,9 @@ func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T) if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1; refused from 127.0.0.2") { t.Fatalf("%s from 127.0.0.2 as node-a: %v, want the host refusal", what, err) } + if !strings.Contains(status.Convert(err).Message(), "register the node by the address it connects from (not loopback) in the cluster spec") { + t.Fatalf("%s refusal has no registration cure: %v", what, err) + } } _, err := wsOther.RenewWorkspaceLease(r.ctx, id) refusedFrom2("renew", err) From 8829b693127d0ba7492ee1ed267531885bc5abf4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:14:17 -0800 Subject: [PATCH 188/204] fix: explain how to correct a workspace holder host mismatch --- seaweed-block/core/host/master/server_host_identity.go | 2 +- seaweed-block/core/host/master/server_host_identity_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index 0ed05e436e..e401a085a5 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -85,7 +85,7 @@ func (h *Host) refuseWorkspaceHolderHost(ctx context.Context, rpc, server string if ph == "" { ph = "an unknown peer" } - err = fmt.Errorf("%s: server id %s is registered on host %s; refused from %s: one server id names one host", rpc, server, named, ph) + err = fmt.Errorf("%s: server id %s is registered on host %s but connects from %s: register the node by the address it connects from (not loopback) in the cluster spec", rpc, server, named, ph) } if err != nil { h.log.Print(err) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 5a2357a4c4..4a343973b2 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -241,7 +241,7 @@ func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T) wsOther, asnOther := control.NewWorkspaceServiceClient(other), control.NewAssignmentServiceClient(other) refusedFrom2 := func(what string, err error) { t.Helper() - if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1; refused from 127.0.0.2") { + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1 but connects from 127.0.0.2") { t.Fatalf("%s from 127.0.0.2 as node-a: %v, want the host refusal", what, err) } if !strings.Contains(status.Convert(err).Message(), "register the node by the address it connects from (not loopback) in the cluster spec") { @@ -257,7 +257,7 @@ func TestWorkspaceHolderRefusedFromAnotherHostAtRenewAckAndStream(t *testing.T) _, err = stream.Recv() } refusedFrom2("assignment stream", err) - if n := strings.Count(r.logs.String(), "refused from 127.0.0.2"); n < 3 { + if n := strings.Count(r.logs.String(), "connects from 127.0.0.2"); n < 3 { t.Fatalf("refusals logged %d times, want 3:\n%s", n, r.logs.String()) } // the registered host is unaffected: it renews and receives the line @@ -396,7 +396,7 @@ func TestDeletionReservedWorkspaceVolumeKeepsTheStreamHostCheck(t *testing.T) { if err == nil { _, err = stream.Recv() } - if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "refused from 127.0.0.2") { + if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "connects from 127.0.0.2") { t.Fatalf("deletion-reserved workspace volume, stream from another host: %v, want the host refusal", err) } } From 85c2ec33640c8116b996f140dd1223f917dae71d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:22:48 -0800 Subject: [PATCH 189/204] docs: lifecycle setup, quote the refusal text with its cure Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/volume-lifecycle.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index 47c27b9555..c6be7a1d72 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -78,7 +78,8 @@ volumes: In a multi-host cluster, register each node by the address it connects to blockmaster from, never loopback. One server id names one host: a volume host whose server id is registered on `127.0.0.1` is refused with `server id s1 is registered on -host 127.0.0.1; refused from
: one server id names one host`. The loopback +host 127.0.0.1 but connects from
: register the node by the address it +connects from (not loopback) in the cluster spec`. The loopback addresses above fit only when blockmaster and blockvolume run on the same machine. **3. blockmaster flags.** `--cluster-spec` replaces `--topology` (setting both From badc7f959622fe901fe0ac7d36e9d3e20ce52e00 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:23:55 -0800 Subject: [PATCH 190/204] test: start test-lock-dir children without INVOCATION_ID A test runner that is itself a systemd service (the CI runner unit) passes its INVOCATION_ID to every child, and blockvolume rightly refuses --volume-lock-dir-test-only under systemd. Every subprocess start that passes the flag now builds the child's environment without INVOCATION_ID (one helper per test package). The product rule is unchanged. Co-Authored-By: Claude Opus 5.5 --- .../blockvolume/g5_4_l2_replication_test.go | 1 + .../planned_handoff_integration_test.go | 2 +- .../replication_ingress_binary_test.go | 1 + .../blockvolume/volume_lock_env_ext_test.go | 37 +++++++++++++++++++ .../cmd/blockvolume/volume_lock_env_test.go | 37 +++++++++++++++++++ .../workspace_lease_binary_test.go | 1 + 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 seaweed-block/cmd/blockvolume/volume_lock_env_ext_test.go create mode 100644 seaweed-block/cmd/blockvolume/volume_lock_env_test.go diff --git a/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go b/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go index dfc51048cd..bb03d55c8a 100644 --- a/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go +++ b/seaweed-block/cmd/blockvolume/g5_4_l2_replication_test.go @@ -223,6 +223,7 @@ func startG54Volume(t *testing.T, bins l2bins, art string, o volOpts) *proc { if o.replicationAck != "" { cmd.Args = append(cmd.Args, "--replication-ack", o.replicationAck) } + stripSystemdForTestLockDir(cmd) cmd.Stdout = lf cmd.Stderr = lf if err := cmd.Start(); err != nil { diff --git a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go index 04dec7d25a..b679961e0e 100644 --- a/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go +++ b/seaweed-block/cmd/blockvolume/planned_handoff_integration_test.go @@ -402,7 +402,7 @@ func (h *plannedHandoffHarness) start(t *testing.T, name, binary string, args .. t.Fatal(err) } ctx, cancel := context.WithCancel(context.Background()) - cmd := exec.CommandContext(ctx, binary, args...) + cmd := stripSystemdForTestLockDir(exec.CommandContext(ctx, binary, args...)) cmd.Dir, cmd.Stdout, cmd.Stderr = h.dir, log, log cmd.WaitDelay = 5 * time.Second d := &daemon{name: name, log: log.Name(), done: make(chan struct{}), cancel: cancel} diff --git a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go index cc51198a64..6dadcde110 100644 --- a/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go +++ b/seaweed-block/cmd/blockvolume/replication_ingress_binary_test.go @@ -118,6 +118,7 @@ func TestBinaryReplicationIngressFollowsAssignedSlots(t *testing.T) { t.Fatal(e) } child := exec.Command(exe, "--master", ln.Addr().String(), "--server-id", "s1", "--volume-id", "v1", "--replica-id", "r1", "--data-addr", data, "--ctrl-addr", ctrl, "--status-addr", status, "--t1-readiness", "--durable-root", root, "--volume-lock-dir-test-only", t.TempDir(), "--durable-impl", "walstore", "--durable-blocks", "64", "--heartbeat-interval", "50ms", "--recovery-mode", mode) + stripSystemdForTestLockDir(child) child.Stdout, child.Stderr = log, log if e = child.Start(); e != nil { t.Fatal(e) diff --git a/seaweed-block/cmd/blockvolume/volume_lock_env_ext_test.go b/seaweed-block/cmd/blockvolume/volume_lock_env_ext_test.go new file mode 100644 index 0000000000..0f08caa197 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/volume_lock_env_ext_test.go @@ -0,0 +1,37 @@ +package main_test + +import ( + "os" + "os/exec" + "strings" +) + +// stripSystemdForTestLockDir is the external test package's copy of the +// helper in volume_lock_env_test.go (package main_test cannot use it): a +// child started with --volume-lock-dir-test-only gets an environment without +// INVOCATION_ID, which a systemd-run test runner would otherwise pass on. +func stripSystemdForTestLockDir(cmd *exec.Cmd) *exec.Cmd { + const flag = "--volume-lock-dir-test-only" + hasFlag := false + for _, a := range cmd.Args[1:] { + if a == flag || strings.HasPrefix(a, flag+"=") { + hasFlag = true + break + } + } + if !hasFlag { + return cmd + } + env := cmd.Env + if env == nil { + env = os.Environ() + } + kept := make([]string, 0, len(env)) + for _, kv := range env { + if !strings.HasPrefix(kv, "INVOCATION_ID=") { + kept = append(kept, kv) + } + } + cmd.Env = kept + return cmd +} diff --git a/seaweed-block/cmd/blockvolume/volume_lock_env_test.go b/seaweed-block/cmd/blockvolume/volume_lock_env_test.go new file mode 100644 index 0000000000..7aa93a3144 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/volume_lock_env_test.go @@ -0,0 +1,37 @@ +package main + +import ( + "os" + "os/exec" + "strings" +) + +// stripSystemdForTestLockDir gives a blockvolume child started with +// --volume-lock-dir-test-only an environment without INVOCATION_ID. +// blockvolume refuses the test override under systemd; a test runner that is +// itself a systemd service (a CI runner unit) would otherwise pass its +// INVOCATION_ID to every child. Other children are left as they are. +func stripSystemdForTestLockDir(cmd *exec.Cmd) *exec.Cmd { + hasFlag := false + for _, a := range cmd.Args[1:] { + if a == "--"+volumeLockDirTestOnlyFlag || strings.HasPrefix(a, "--"+volumeLockDirTestOnlyFlag+"=") { + hasFlag = true + break + } + } + if !hasFlag { + return cmd + } + env := cmd.Env + if env == nil { + env = os.Environ() + } + kept := make([]string, 0, len(env)) + for _, kv := range env { + if !strings.HasPrefix(kv, "INVOCATION_ID=") { + kept = append(kept, kv) + } + } + cmd.Env = kept + return cmd +} diff --git a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go index 1a2591548b..0ae40371a6 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease_binary_test.go @@ -107,6 +107,7 @@ func TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown(t *testing.T) { t.Fatal(err) } cmd := exec.Command(exe, "--master", h.Addr(), "--server-id", "node-a", "--volume-id", "vol-a", "--replica-id", "r1", "--data-addr", dataAddr, "--ctrl-addr", ctrlAddr, "--t1-readiness", "--status-addr", statusAddr, "--durable-root", t.TempDir(), "--volume-lock-dir-test-only", t.TempDir(), "--durable-impl", "walstore-chunk", "--durable-blocks", "64", "--chunk-filer", cluster.filerGRPC, "--chunk-path", base, "--chunk-control-endpoint", "--workspace-lease", "--nvme-listen", nvmeAddr, "--nvme-subsysnqn", "nqn.2026-11.test:workspace-lease") + stripSystemdForTestLockDir(cmd) cmd.Stdout, cmd.Stderr = log, log if err = cmd.Start(); err != nil { t.Fatal(err) From c775b752afde45cf8304f68a138b19b929df77b1 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:24:34 -0800 Subject: [PATCH 191/204] test: require heartbeat registration cure and slot detail --- seaweed-block/core/host/master/server_host_identity_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 4a343973b2..11a6319cb3 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -145,6 +145,10 @@ func TestServerIDRefusedFromAHostOtherThanItsRegisteredOne(t *testing.T) { if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1") { t.Fatalf("same --server-id from a second host: %v, want FailedPrecondition naming the registered host", err) } + want := "registered on host 127.0.0.1 but connects from 127.0.0.2: register the node by the address it connects from (not loopback) in the cluster spec (volume hb-node-a replica r-node-a)" + if !strings.Contains(status.Convert(err).Message(), want) { + t.Fatalf("heartbeat refusal lacks the cure or slot detail: %v", err) + } if slot, ok := r.m.ObservationHost().Store().SlotFactOnServer("node-a", "hb-node-a", "r-node-a"); !ok || !strings.HasPrefix(slot.DataAddr, "127.0.0.1:") { t.Fatalf("refused heartbeat reached the observations: %+v ok=%v", slot, ok) } From 7928b4d2571207c2b316ee45827bb0a541244604 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:24:50 -0800 Subject: [PATCH 192/204] fix: give heartbeat host mismatch the registration cure --- seaweed-block/core/host/master/server_host_identity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index e401a085a5..99d2f63733 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -54,7 +54,7 @@ func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { for _, s := range r.Slots { for _, a := range []string{s.DataAddr, s.CtrlAddr} { if a != "" && !hosts[addrHost(a)] { - return fmt.Errorf("heartbeat: server id %s is registered on host %s; refused from %s (volume %s replica %s): one server id names one host", + return fmt.Errorf("heartbeat: server id %s is registered on host %s but connects from %s: register the node by the address it connects from (not loopback) in the cluster spec (volume %s replica %s)", r.ServerId, named, addrHost(a), s.VolumeId, s.ReplicaId) } } From 8f98eb3caabd2c89f5004956b5169c296b6c636e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:27:48 -0800 Subject: [PATCH 193/204] test: keep lifecycle opens available under ancestor sync failures --- .../core/lifecycle/store_parent_sync_test.go | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/seaweed-block/core/lifecycle/store_parent_sync_test.go b/seaweed-block/core/lifecycle/store_parent_sync_test.go index c1fef0d8e0..9897d3ed98 100644 --- a/seaweed-block/core/lifecycle/store_parent_sync_test.go +++ b/seaweed-block/core/lifecycle/store_parent_sync_test.go @@ -3,8 +3,9 @@ package lifecycle import ( + "bytes" "context" - "errors" + "log" "os" "os/exec" "path/filepath" @@ -18,7 +19,7 @@ import ( // including a retry after failed creation; a trailing separator changes no target. func TestLifecycleStoreParentSync(t *testing.T) { for _, kind := range []string{"node", "volume", "placement"} { - for _, shape := range []string{"nested", "trailing-slash", "failed-parent-sync", "relative-path"} { + for _, shape := range []string{"nested", "trailing-slash", "failed-parent-sync", "ancestor-permission", "relative-path"} { t.Run(kind+"/"+shape, func(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() @@ -60,11 +61,16 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { } want = append(want, "/") var calls []string + var warnings bytes.Buffer + log.SetOutput(&warnings) realSync := syncBindingParent failFirst := shape == "failed-parent-sync" fault := &os.PathError{Op: "open", Path: want[0], Err: os.ErrPermission} syncBindingParent = func(path string) error { calls = append(calls, path) + if shape == "ancestor-permission" && path == want[len(want)-2] { + return &os.PathError{Op: "open", Path: path, Err: os.ErrPermission} + } if failFirst { failFirst = false return fault @@ -88,20 +94,31 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) { } } if shape == "failed-parent-sync" { - if err := open(); !errors.Is(err, os.ErrPermission) { - t.Fatalf("ancestor sync failure hidden: %v", err) + if err := open(); err != nil { + t.Fatalf("best-effort ancestor sync blocked Open: %v", err) } - if !reflect.DeepEqual(calls, want[:1]) { - t.Fatalf("failed syncs %v want %v", calls, want[:1]) + if !reflect.DeepEqual(calls, want) { + t.Fatalf("failed-first syncs %v want %v", calls, want) + } + if strings.Count(warnings.String(), "lifecycle: could not sync ") != 1 || !strings.Contains(warnings.String(), "the store directory entry may not survive a crash right after its creation") { + t.Fatalf("missing ancestor durability warning: %s", warnings.String()) } calls = nil + warnings.Reset() } + if err := open(); err != nil { t.Fatal(err) } if !reflect.DeepEqual(calls, want) { t.Fatalf("parent syncs %v want %v", calls, want) } + if shape == "ancestor-permission" { + if strings.Count(warnings.String(), "lifecycle: could not sync ") != 1 || !strings.Contains(warnings.String(), "permission denied") || !strings.Contains(warnings.String(), "the store directory entry may not survive a crash right after its creation") { + t.Fatalf("missing permission warning: %s", warnings.String()) + } + warnings.Reset() + } calls = nil if err := open(); err != nil { t.Fatal(err) From 3c50b14e8d40f8f534d86db2d559bd9add35f23d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:29:31 -0800 Subject: [PATCH 194/204] refactor: share lifecycle record durability and warn on ancestor sync failures --- .../core/lifecycle/node_inventory.go | 56 +------ .../lifecycle/node_inventory_crash_test.go | 4 +- .../core/lifecycle/placement_intent.go | 55 +------ seaweed-block/core/lifecycle/record_file.go | 61 ++++++++ seaweed-block/core/lifecycle/store.go | 49 +----- .../core/lifecycle/store_crash_test.go | 142 ++++++++++-------- seaweed-block/docs/design/invariants.md | 4 +- 7 files changed, 160 insertions(+), 211 deletions(-) create mode 100644 seaweed-block/core/lifecycle/record_file.go diff --git a/seaweed-block/core/lifecycle/node_inventory.go b/seaweed-block/core/lifecycle/node_inventory.go index 6975c64330..798569ef4b 100644 --- a/seaweed-block/core/lifecycle/node_inventory.go +++ b/seaweed-block/core/lifecycle/node_inventory.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "os" "path/filepath" "sort" @@ -64,13 +65,10 @@ type NodeRegistration struct { // NodeInventoryStore persists one JSON registration record per server. type NodeInventoryStore struct { - mu sync.Mutex - dir string - records map[string]NodeRegistration - published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) - persistHookForTest func(string) // nil in production; crash injection at publication boundaries - fileSyncForTest func(*os.File) error // nil uses the real file Sync - dirSyncForTest func(string) error // nil uses syncBindingParent + mu sync.Mutex + dir string + records map[string]NodeRegistration + published sync.Map // committed NodeRegistration values; holder host checks never take mu (INV-WS-RENEW-NONBLOCKING-001) } // OpenNodeInventoryStore opens or creates a node inventory store. @@ -89,7 +87,7 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) { // Every open syncs the full ancestor chain, also after a failed first open. for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) + log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err) } if parent == filepath.Dir(parent) { break @@ -223,47 +221,7 @@ func (s *NodeInventoryStore) putLocked(rec NodeRegistration) error { if err != nil { return fmt.Errorf("lifecycle: marshal node %s: %w", rec.ServerID, err) } - path := s.path(rec.ServerID) - tmp, err := os.CreateTemp(s.dir, rec.ServerID+".*.tmp") - if err != nil { - return fmt.Errorf("lifecycle: temp node %s: %w", rec.ServerID, err) - } - tmpName := tmp.Name() - defer func() { _ = os.Remove(tmpName) }() - if _, err := tmp.Write(raw); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: write node temp %s: %w", rec.ServerID, err) - } - fileSync := tmp.Sync - if s.fileSyncForTest != nil { - fileSync = func() error { return s.fileSyncForTest(tmp) } - } - if err := fileSync(); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: sync node temp %s: %w", rec.ServerID, err) - } - if err := tmp.Close(); err != nil { - return fmt.Errorf("lifecycle: close node temp %s: %w", rec.ServerID, err) - } - // INV-LIFECYCLE-STORE-DURABLE-001: replace without an absent-file window; acknowledge only - // after both the complete candidate and its directory entry are synced. - if s.persistHookForTest != nil { - s.persistHookForTest("before-rename") - } - if err := os.Rename(tmpName, path); err != nil { - return fmt.Errorf("lifecycle: rename node %s: %w", rec.ServerID, err) - } - if s.persistHookForTest != nil { - s.persistHookForTest("after-rename") - } - dirSync := syncBindingParent - if s.dirSyncForTest != nil { - dirSync = s.dirSyncForTest - } - if err := dirSync(s.dir); err != nil { - return fmt.Errorf("lifecycle: sync node directory %s: %w", rec.ServerID, err) - } - return nil + return writeRecordDurably(s.dir, rec.ServerID+".json", raw) } func (s *NodeInventoryStore) path(serverID string) string { diff --git a/seaweed-block/core/lifecycle/node_inventory_crash_test.go b/seaweed-block/core/lifecycle/node_inventory_crash_test.go index c84c43142a..aba4ef1e86 100644 --- a/seaweed-block/core/lifecycle/node_inventory_crash_test.go +++ b/seaweed-block/core/lifecycle/node_inventory_crash_test.go @@ -88,11 +88,11 @@ func TestNodeInventoryCrashChild(t *testing.T) { if err != nil { t.Fatal(err) } - s.persistHookForTest = func(phase string) { + durableRecordHooksForTest.Store(&durableRecordHooks{crash: func(phase string) { if phase == os.Getenv("NODE_INVENTORY_CRASH_PHASE") { os.Exit(73) // abrupt exit: no deferred cleanup or close } - } + }}) if _, err := s.RegisterNode(crashNodeRegistration(true)); err != nil { t.Fatal(err) } diff --git a/seaweed-block/core/lifecycle/placement_intent.go b/seaweed-block/core/lifecycle/placement_intent.go index dcca42190b..69216ae01c 100644 --- a/seaweed-block/core/lifecycle/placement_intent.go +++ b/seaweed-block/core/lifecycle/placement_intent.go @@ -4,6 +4,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "os" "path/filepath" "sort" @@ -35,13 +36,10 @@ type PlacementIntent struct { // PlacementIntentStore persists one placement intent per volume. type PlacementIntentStore struct { - mu sync.Mutex - dir string - records map[string]PlacementIntent - published sync.Map // committed immutable PlacementIntent values; renewal never takes mu - persistHookForTest func(string) // nil in production; crash injection at publication boundaries - fileSyncForTest func(*os.File) error // nil uses the real file Sync - dirSyncForTest func(string) error // nil uses syncBindingParent + mu sync.Mutex + dir string + records map[string]PlacementIntent + published sync.Map // committed immutable PlacementIntent values; renewal never takes mu } // OpenPlacementIntentStore opens or creates a placement intent store. @@ -60,7 +58,7 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) { // Every open syncs the full ancestor chain, also after a failed first open. for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) + log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err) } if parent == filepath.Dir(parent) { break @@ -201,46 +199,7 @@ func (s *PlacementIntentStore) putLocked(rec PlacementIntent) error { if err != nil { return fmt.Errorf("lifecycle: marshal placement intent %s: %w", rec.VolumeID, err) } - path := s.path(rec.VolumeID) - tmp, err := os.CreateTemp(s.dir, rec.VolumeID+".*.tmp") - if err != nil { - return fmt.Errorf("lifecycle: temp placement intent %s: %w", rec.VolumeID, err) - } - tmpName := tmp.Name() - defer func() { _ = os.Remove(tmpName) }() - if _, err := tmp.Write(raw); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: write placement intent temp %s: %w", rec.VolumeID, err) - } - fileSync := tmp.Sync - if s.fileSyncForTest != nil { - fileSync = func() error { return s.fileSyncForTest(tmp) } - } - if err := fileSync(); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: sync placement intent temp %s: %w", rec.VolumeID, err) - } - if err := tmp.Close(); err != nil { - return fmt.Errorf("lifecycle: close placement intent temp %s: %w", rec.VolumeID, err) - } - // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. - if s.persistHookForTest != nil { - s.persistHookForTest("before-rename") - } - if err := os.Rename(tmpName, path); err != nil { - return fmt.Errorf("lifecycle: rename placement intent %s: %w", rec.VolumeID, err) - } - if s.persistHookForTest != nil { - s.persistHookForTest("after-rename") - } - dirSync := syncBindingParent - if s.dirSyncForTest != nil { - dirSync = s.dirSyncForTest - } - if err := dirSync(s.dir); err != nil { - return fmt.Errorf("lifecycle: sync placement intent directory %s: %w", rec.VolumeID, err) - } - return nil + return writeRecordDurably(s.dir, rec.VolumeID+".json", raw) } func (s *PlacementIntentStore) path(volumeID string) string { diff --git a/seaweed-block/core/lifecycle/record_file.go b/seaweed-block/core/lifecycle/record_file.go new file mode 100644 index 0000000000..04e5b5e772 --- /dev/null +++ b/seaweed-block/core/lifecycle/record_file.go @@ -0,0 +1,61 @@ +package lifecycle + +import ( + "fmt" + "os" + "path/filepath" + "sync/atomic" +) + +// Hooks are installed only in isolated subprocess tests. Production uses +// the real filesystem operations; one helper owns all publication seams. +type durableRecordHooks struct { + crash func(string) + fileSync func(*os.File) error + dirSync func(string) error +} + +var durableRecordHooksForTest atomic.Pointer[durableRecordHooks] + +// writeRecordDurably implements INV-LIFECYCLE-STORE-DURABLE-001 for puts and +// replacements. A post-rename error may leave the new record on disk. +func writeRecordDurably(dir, name string, raw []byte) error { + f, err := os.CreateTemp(dir, name+".*.tmp") + if err != nil { + return fmt.Errorf("lifecycle: temp record %s: %w", name, err) + } + defer os.Remove(f.Name()) + if _, err := f.Write(raw); err != nil { + _ = f.Close() + return fmt.Errorf("lifecycle: write record %s: %w", name, err) + } + hooks := durableRecordHooksForTest.Load() + fileSync := f.Sync + if hooks != nil && hooks.fileSync != nil { + fileSync = func() error { return hooks.fileSync(f) } + } + if err := fileSync(); err != nil { + _ = f.Close() + return fmt.Errorf("lifecycle: sync record %s: %w", name, err) + } + if err := f.Close(); err != nil { + return fmt.Errorf("lifecycle: close record %s: %w", name, err) + } + if hooks != nil && hooks.crash != nil { + hooks.crash("before-rename") + } + if err := os.Rename(f.Name(), filepath.Join(dir, name)); err != nil { + return fmt.Errorf("lifecycle: rename record %s: %w", name, err) + } + if hooks != nil && hooks.crash != nil { + hooks.crash("after-rename") + } + dirSync := syncBindingParent + if hooks != nil && hooks.dirSync != nil { + dirSync = hooks.dirSync + } + if err := dirSync(dir); err != nil { + return fmt.Errorf("lifecycle: sync record directory %s: %w", name, err) + } + return nil +} diff --git a/seaweed-block/core/lifecycle/store.go b/seaweed-block/core/lifecycle/store.go index e7b4eb752c..01f297c9d4 100644 --- a/seaweed-block/core/lifecycle/store.go +++ b/seaweed-block/core/lifecycle/store.go @@ -10,6 +10,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "os" "path/filepath" "regexp" @@ -57,10 +58,7 @@ type FileStore struct { records map[string]VolumeRecord // snap mirrors records as an immutable copy, republished at every change // of records, for lock-free renewal-path reads. - snap atomic.Pointer[map[string]VolumeRecord] - persistHookForTest func(string) // nil in production; crash injection at publication boundaries - fileSyncForTest func(*os.File) error // nil uses the real file Sync - dirSyncForTest func(string) error // nil uses syncBindingParent + snap atomic.Pointer[map[string]VolumeRecord] } // publishLocked republishes the immutable snapshot of records. Caller holds @@ -101,7 +99,7 @@ func OpenFileStore(dir string) (*FileStore, error) { // Every open syncs the full ancestor chain, also after a failed first open. for parent := filepath.Dir(dir); ; parent = filepath.Dir(parent) { if err := syncBindingParent(parent); err != nil { - return nil, fmt.Errorf("lifecycle: sync store ancestor %q: %w", parent, err) + log.Printf("lifecycle: could not sync %s (%v): the store directory entry may not survive a crash right after its creation", parent, err) } if parent == filepath.Dir(parent) { break @@ -309,46 +307,7 @@ func (s *FileStore) putLocked(rec VolumeRecord) error { if err != nil { return fmt.Errorf("lifecycle: marshal %s: %w", rec.Spec.VolumeID, err) } - path := s.path(rec.Spec.VolumeID) - tmp, err := os.CreateTemp(s.dir, rec.Spec.VolumeID+".*.tmp") - if err != nil { - return fmt.Errorf("lifecycle: temp %s: %w", rec.Spec.VolumeID, err) - } - tmpName := tmp.Name() - defer func() { _ = os.Remove(tmpName) }() - if _, err := tmp.Write(raw); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: write temp %s: %w", rec.Spec.VolumeID, err) - } - fileSync := tmp.Sync - if s.fileSyncForTest != nil { - fileSync = func() error { return s.fileSyncForTest(tmp) } - } - if err := fileSync(); err != nil { - _ = tmp.Close() - return fmt.Errorf("lifecycle: sync record temp %s: %w", rec.Spec.VolumeID, err) - } - if err := tmp.Close(); err != nil { - return fmt.Errorf("lifecycle: close temp %s: %w", rec.Spec.VolumeID, err) - } - // INV-LIFECYCLE-STORE-DURABLE-001: retain the old file until atomic replacement. - if s.persistHookForTest != nil { - s.persistHookForTest("before-rename") - } - if err := os.Rename(tmpName, path); err != nil { - return fmt.Errorf("lifecycle: rename %s: %w", rec.Spec.VolumeID, err) - } - if s.persistHookForTest != nil { - s.persistHookForTest("after-rename") - } - dirSync := syncBindingParent - if s.dirSyncForTest != nil { - dirSync = s.dirSyncForTest - } - if err := dirSync(s.dir); err != nil { - return fmt.Errorf("lifecycle: sync record directory %s: %w", rec.Spec.VolumeID, err) - } - return nil + return writeRecordDurably(s.dir, rec.Spec.VolumeID+".json", raw) } func (s *FileStore) path(volumeID string) string { diff --git a/seaweed-block/core/lifecycle/store_crash_test.go b/seaweed-block/core/lifecycle/store_crash_test.go index c0d86a3dcc..c28e073981 100644 --- a/seaweed-block/core/lifecycle/store_crash_test.go +++ b/seaweed-block/core/lifecycle/store_crash_test.go @@ -24,17 +24,19 @@ type recordCrashFixture struct { old, next any put func(bool) error get func() (any, bool) - setSync func(func(*os.File) error, func(string) error) } func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) recordCrashFixture { t.Helper() + durableRecordHooksForTest.Store(nil) + if hook != nil { + durableRecordHooksForTest.Store(&durableRecordHooks{crash: hook}) + } if kind == "node" { s, err := OpenNodeInventoryStore(dir) if err != nil { t.Fatal(err) } - s.persistHookForTest = hook return recordCrashFixture{old: crashNodeRegistration(false), next: crashNodeRegistration(true), put: func(updated bool) error { _, err := s.RegisterNode(crashNodeRegistration(updated)); return err }, get: func() (any, bool) { @@ -45,7 +47,6 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r } return r, ok }, - setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, } } if kind == "volume" { @@ -53,7 +54,6 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r if err != nil { t.Fatal(err) } - s.persistHookForTest = hook old := VolumeRecord{Spec: VolumeSpec{VolumeID: "vol-a", SizeBytes: 1 << 20, ReplicationFactor: 1, Protocol: "iscsi", PVCName: strings.Repeat("payload", 1024)}} next := old next.AttachedTo = "node-b" @@ -73,7 +73,6 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r } return r, ok }, - setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, } } if kind != "placement" { @@ -83,7 +82,6 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r if err != nil { t.Fatal(err) } - s.persistHookForTest = hook old := PlacementIntent{VolumeID: "vol-a", DesiredRF: 1, Slots: []PlacementSlotIntent{{ServerID: "node-a", PoolID: strings.Repeat("old", 4096), Source: PlacementSourceBlankPool}}} next := copyPlacementIntent(old) next.Slots[0].PoolID = strings.Repeat("new", 4096) @@ -103,7 +101,6 @@ func openRecordCrashFixture(t *testing.T, kind, dir string, hook func(string)) r } return r, ok }, - setSync: func(f func(*os.File) error, d func(string) error) { s.fileSyncForTest, s.dirSyncForTest = f, d }, } } @@ -177,66 +174,81 @@ func TestLifecyclePutSyncOrderAndFailure(t *testing.T) { for _, kind := range []string{"node", "volume", "placement"} { for _, failure := range []string{"none", "file", "directory", "nil-hooks"} { t.Run(kind+"/"+failure, func(t *testing.T) { - dir := t.TempDir() - f := openRecordCrashFixture(t, kind, dir, nil) - if err := f.put(false); err != nil { - t.Fatal(err) - } - fault := errors.New("injected sync failure") - var events []string - if failure != "nil-hooks" { - f.setSync(func(file *os.File) error { - events = append(events, "file") - if filepath.Ext(file.Name()) != ".tmp" { - t.Fatal("sync must target the candidate file") - } - if failure == "file" { - return fault - } - return file.Sync() - }, func(path string) error { - events = append(events, "directory") - if path != dir { - t.Fatal("sync must target the record directory") - } - if failure == "directory" { - return fault - } - return syncBindingParent(path) - }) - } - err := f.put(true) - want := f.next - if failure == "file" || failure == "directory" { - if !errors.Is(err, fault) { - t.Fatalf("sync failure hidden: %v", err) - } - want = f.old - } else if err != nil { - t.Fatal(err) - } - if got, ok := f.get(); !ok || !reflect.DeepEqual(got, want) { - t.Fatal("memory published before successful sync") - } - wantEvents := []string{"file", "directory"} - if failure == "file" { - wantEvents = []string{"file"} - } - if failure == "nil-hooks" { - wantEvents = nil - } - if !reflect.DeepEqual(events, wantEvents) { - t.Fatalf("sync events %v want %v", events, wantEvents) - } - reopened := openRecordCrashFixture(t, kind, dir, nil) - diskWant := f.next - if failure == "file" { - diskWant = f.old - } - if got, ok := reopened.get(); !ok || !reflect.DeepEqual(got, diskWant) { - t.Fatal("wrong durable record after sync outcome") + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestLifecyclePutSyncChild$", "-test.timeout=8s") + cmd.Env = append(os.Environ(), "LIFECYCLE_SYNC_KIND="+kind, "LIFECYCLE_SYNC_FAILURE="+failure) + if out, err := cmd.CombinedOutput(); err != nil { + t.Fatalf("sync control: %v context=%v\n%s", err, ctx.Err(), out) } }) } } } + +func TestLifecyclePutSyncChild(t *testing.T) { + kind := os.Getenv("LIFECYCLE_SYNC_KIND") + if kind == "" { + t.Skip("isolated sync control") + } + failure := os.Getenv("LIFECYCLE_SYNC_FAILURE") + dir := t.TempDir() + f := openRecordCrashFixture(t, kind, dir, nil) + if err := f.put(false); err != nil { + t.Fatal(err) + } + fault := errors.New("injected sync failure") + var events []string + if failure != "nil-hooks" { + durableRecordHooksForTest.Store(&durableRecordHooks{fileSync: func(file *os.File) error { + events = append(events, "file") + if filepath.Ext(file.Name()) != ".tmp" { + t.Fatal("sync must target the candidate file") + } + if failure == "file" { + return fault + } + return file.Sync() + }, dirSync: func(path string) error { + events = append(events, "directory") + if path != dir { + t.Fatal("sync must target the record directory") + } + if failure == "directory" { + return fault + } + return syncBindingParent(path) + }}) + } + err := f.put(true) + want := f.next + if failure == "file" || failure == "directory" { + if !errors.Is(err, fault) { + t.Fatalf("sync failure hidden: %v", err) + } + want = f.old + } else if err != nil { + t.Fatal(err) + } + if got, ok := f.get(); !ok || !reflect.DeepEqual(got, want) { + t.Fatal("memory published before successful sync") + } + wantEvents := []string{"file", "directory"} + if failure == "file" { + wantEvents = []string{"file"} + } + if failure == "nil-hooks" { + wantEvents = nil + } + if !reflect.DeepEqual(events, wantEvents) { + t.Fatalf("sync events %v want %v", events, wantEvents) + } + reopened := openRecordCrashFixture(t, kind, dir, nil) + diskWant := f.next + if failure == "file" { + diskWant = f.old + } + if got, ok := reopened.get(); !ok || !reflect.DeepEqual(got, diskWant) { + t.Fatal("wrong durable record after sync outcome") + } +} diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 109348b90c..572e39b719 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -650,14 +650,14 @@ Notes: | `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE | | `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE | | `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE | -| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | — | ACTIVE | +| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/record_file.go` `writeRecordDurably`; `node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | — | ACTIVE | | `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE | | `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE | | `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE | Notes: -- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: `NodeInventoryStore.RemoveNode` does not fsync its directory after deletion, so a removed node can reappear after a crash. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record. +- `INV-LIFECYCLE-STORE-DURABLE-001` open gaps: Store-directory ancestor sync on Open is best-effort: failures are logged and do not block startup; a new directory entry may not survive an immediate crash when an ancestor cannot be synced. Record-file and store-directory sync after a put remain mandatory. `NodeInventoryStore.RemoveNode` does not fsync its directory after deletion, so a removed node can reappear after a crash. A failed put may still be on disk: if directory fsync fails after rename, restart can load the new record. - `INV-AUTH-PERSIST-BEFORE-PUBLISH-001`: a failed write's durable outcome may be unknown (the record may have landed); for a workspace volume the failure latches uncertainty (`INV-AUTH-UNCERTAIN-001`). The cited test covers the non-workspace in-memory rollback. - `INV-AUTH-UNCERTAIN-001`: The cited test asserts the refusal after an unknown-outcome lease extension (rename landed, directory sync failed): the next renewal, a revocation and an endpoint change are all refused. The TLA+ configuration `S5_red_noUncertain` violates `UniqueEpoch` without it. A Revoking lease still gets its bounded drain reply, min(horizon, deadline), never extended: see M2 any (workspace) → Uncertain. A failed move on an uncertain volume is answered as an unknown outcome before any admission refusal, the request's own cancellation or deadline stays typed, and an issued move's replay still returns its stored grant: see M2 Uncertain → Uncertain (move answer). The renewal path reads uncertainty from the lease view (`INV-LEASE-VIEW-001`), not from `persistWorkspaceLocked`. - `INV-WS-LEASE-HORIZON-001`: The forced-barrier argument (a renewal that reads its clock after the barrier has read the deadline is refused) assumes nondecreasing master time. That is an assumption of the current `WorkspaceTakeover` model, whose `Tick` and `SlowTick` actions only advance `now`; it is not a consequence of `time.Now` carrying a monotonic reading, because persisted `UnixNano` deadlines are compared as wall-clock values. The existing deadline check stays alongside the horizon. The model still renews with `exp = deadline = now + TTL`; the horizon/grant split is a pending specification update (Part C rule 2). From 286f5ebeb8f4df7465fde5eeca356c4391ddd893 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:46:10 -0800 Subject: [PATCH 195/204] durable: red test, a created lock directory's parent must be 0755 V1-SPEC r2.45 (1): MkdirAll(locks, 0700) also makes a missing parent /run/sw-block 0700; created by root, it keeps the unit's user out even after the locks directory is chowned. The tmpfiles.d layout is parent 0755, locks 0700. Co-Authored-By: Claude Opus 5.5 --- .../durable/volume_lock_parent_mode_test.go | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go diff --git a/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go b/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go new file mode 100644 index 0000000000..3890219402 --- /dev/null +++ b/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go @@ -0,0 +1,40 @@ +//go:build unix + +package durable_test + +import ( + "os" + "path/filepath" + "syscall" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/durable" +) + +// V1-SPEC r2.45 (1), as the tmpfiles.d entry lays it out: a lock directory +// the provider creates gets a traversable parent (0755) and is itself 0700, +// whatever the umask. A 0700 parent created by root would keep the unit's +// user out even after the locks directory is chowned to it. +func TestHostVolumeLockCreatesParent0755AndLocks0700(t *testing.T) { + old := syscall.Umask(0o077) // a strict umask must not narrow the parent + defer syscall.Umask(old) + parent := filepath.Join(t.TempDir(), "sw-block") + locks := filepath.Join(parent, "locks") + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks, + HostVolumeLock: true, VolumeLockDirTestOnly: locks, + }, v1View()) + if err != nil { + t.Fatal(err) + } + _ = p.Close() + for path, want := range map[string]os.FileMode{parent: 0o755, locks: 0o700} { + fi, err := os.Stat(path) + if err != nil { + t.Fatal(err) + } + if got := fi.Mode().Perm(); got != want { + t.Fatalf("%s created %v, want %v", path, got, want) + } + } +} From 4c36f1f8614b80bcea97e47569ae38d370b11c9b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 10:46:38 -0800 Subject: [PATCH 196/204] durable: lay out a created lock directory as tmpfiles.d does A missing /run/sw-block is created 0755 and the locks directory 0700, with the modes set explicitly (the umask cannot narrow them); existing directories are left alone. The cure line also names the parent. Co-Authored-By: Claude Opus 5.5 --- .../core/frontend/durable/provider.go | 27 +++++++++++++++++-- .../docs/releases/one-process-per-volume.md | 14 +++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index eb391db3d8..00ac1bb722 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -405,7 +405,7 @@ func NewDurableProvider(cfg ProviderConfig, view frontend.ProjectionView) (*Dura if cfg.VolumeLockDirTestOnly == "" { cfg.VolumeLockDirTestOnly = HostVolumeLockDir } - if err := os.MkdirAll(cfg.VolumeLockDirTestOnly, 0o700); err != nil { + if err := makeVolumeLockDir(cfg.VolumeLockDirTestOnly); err != nil { return nil, fmt.Errorf("%w %s: %w; %s", ErrVolumeLockDirUnavailable, cfg.VolumeLockDirTestOnly, err, volumeLockCure) } } @@ -560,7 +560,30 @@ var ErrVolumeLockDirUnavailable = errors.New("durable: host volume lock director // volumeLockCure names the operator's cure. A directory or lock file a root // process created is root-owned: an unprivileged unit then cannot use it. -const volumeLockCure = "install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), or chown the directory and its lock files to this process's user" +const volumeLockCure = "install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), or make its parent directory traversable (0755) and chown the directory and its lock files to this process's user" + +// makeVolumeLockDir lays out a missing lock directory as the tmpfiles.d +// entry does: its parent 0755 (traversable by the unit's user even when root +// created it) and the directory itself 0700. Existing directories are left +// as they are. Modes are set explicitly, so the umask cannot narrow them. +func makeVolumeLockDir(dir string) error { + parent := filepath.Dir(dir) + if _, err := os.Stat(parent); errors.Is(err, os.ErrNotExist) { + if err := os.MkdirAll(parent, 0o755); err != nil { + return err + } + if err := os.Chmod(parent, 0o755); err != nil { + return err + } + } + if err := os.Mkdir(dir, 0o700); err != nil { + if errors.Is(err, os.ErrExist) { + return nil + } + return err + } + return os.Chmod(dir, 0o700) +} // lockVolumeOnHost takes the volume's host lock (nil without // HostVolumeLock). A second live process for the volume on this host gets diff --git a/seaweed-block/docs/releases/one-process-per-volume.md b/seaweed-block/docs/releases/one-process-per-volume.md index e2604748c5..93ed89b56b 100644 --- a/seaweed-block/docs/releases/one-process-per-volume.md +++ b/seaweed-block/docs/releases/one-process-per-volume.md @@ -7,7 +7,8 @@ the same host is refused before it opens anything, whatever its `--durable-root`. The lock is released when the process exits, including on a crash or kill. -blockvolume creates the directory (`0700`) when it is missing and it may, and +blockvolume creates the directory when it is missing and it may, laid out as +the tmpfiles.d entry does (`/run/sw-block` `0755`, `/run/sw-block/locks` `0700`), and refuses to start when it cannot create or open the directory or a volume's lock file. The shipped units cannot create it (`ProtectSystem=strict`), so install the tmpfiles.d entry shipped in [`deploy/systemd/sw-block.tmpfiles.conf`](../../deploy/systemd/sw-block.tmpfiles.conf): @@ -22,11 +23,12 @@ boot. Both shipped units allow writes to it (`ReadWritePaths=-/run/sw-block/locks`). Without it, or when it is not usable, blockvolume exits at start with `host volume lock directory unavailable ... install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), -or chown the directory and its lock files to this process's user`. A -directory created by a root process (the root ublk unit, or blockvolume run -by hand as root) is root-owned, and an unprivileged unit on that host then -cannot use it: install the tmpfiles.d entry, or chown the directory to the -unit's user. Lock files are opened read-only, so a lock file another user +or make its parent directory traversable (0755) and chown the directory and +its lock files to this process's user`. A directory created by a root +process (the root ublk unit, or blockvolume run by hand as root) is +root-owned, and an unprivileged unit on that host then cannot use it: +install the tmpfiles.d entry, or chown the locks directory to the unit's +user and make sure `/run/sw-block` is `0755`. Lock files are opened read-only, so a lock file another user created stays lockable. ## A rolled-back copy of a root is refused From 8edb6b128e52560f104badbd09e371a653956ad9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 12:15:41 -0800 Subject: [PATCH 197/204] test: distinguish heartbeat advertised address from RPC peer --- .../core/host/master/server_host_identity_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/seaweed-block/core/host/master/server_host_identity_test.go b/seaweed-block/core/host/master/server_host_identity_test.go index 11a6319cb3..1067bda980 100644 --- a/seaweed-block/core/host/master/server_host_identity_test.go +++ b/seaweed-block/core/host/master/server_host_identity_test.go @@ -141,11 +141,14 @@ func TestServerIDRefusedFromAHostOtherThanItsRegisteredOne(t *testing.T) { if err := r.heartbeatFrom("node-a", "127.0.0.1"); err != nil { t.Fatalf("heartbeat from node-a's registered host refused: %v", err) } - err := r.heartbeatFrom("node-a", "127.0.0.2") + // The peer is the registered host; only the advertised slot address is wrong. + obs := control.NewObservationServiceClient(r.dialFrom(t, "127.0.0.1")) + _, err := obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, + Slots: []*control.HeartbeatSlot{{VolumeId: "hb-node-a", ReplicaId: "r-node-a", DataAddr: "127.0.0.2:19611", CtrlAddr: "127.0.0.2:19612"}}}) if status.Code(err) != codes.FailedPrecondition || !strings.Contains(status.Convert(err).Message(), "registered on host 127.0.0.1") { t.Fatalf("same --server-id from a second host: %v, want FailedPrecondition naming the registered host", err) } - want := "registered on host 127.0.0.1 but connects from 127.0.0.2: register the node by the address it connects from (not loopback) in the cluster spec (volume hb-node-a replica r-node-a)" + want := "registered on host 127.0.0.1 but advertises 127.0.0.2 (volume hb-node-a replica r-node-a): advertise the registered address, or register the node by the address it uses, in the cluster spec" if !strings.Contains(status.Convert(err).Message(), want) { t.Fatalf("heartbeat refusal lacks the cure or slot detail: %v", err) } From a777189b7f69b5b34f7abd9c3b8333529cb6e5a3 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 12:15:53 -0800 Subject: [PATCH 198/204] fix: diagnose advertised heartbeat addresses accurately --- seaweed-block/core/host/master/server_host_identity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seaweed-block/core/host/master/server_host_identity.go b/seaweed-block/core/host/master/server_host_identity.go index 99d2f63733..d3ab7afa29 100644 --- a/seaweed-block/core/host/master/server_host_identity.go +++ b/seaweed-block/core/host/master/server_host_identity.go @@ -54,7 +54,7 @@ func (h *Host) refuseServerIDFromOtherHost(r *control.HeartbeatReport) error { for _, s := range r.Slots { for _, a := range []string{s.DataAddr, s.CtrlAddr} { if a != "" && !hosts[addrHost(a)] { - return fmt.Errorf("heartbeat: server id %s is registered on host %s but connects from %s: register the node by the address it connects from (not loopback) in the cluster spec (volume %s replica %s)", + return fmt.Errorf("heartbeat: server id %s is registered on host %s but advertises %s (volume %s replica %s): advertise the registered address, or register the node by the address it uses, in the cluster spec", r.ServerId, named, addrHost(a), s.VolumeId, s.ReplicaId) } } From 5c84520d48f1fedc3fac3d8e3c79b5d45f74e7d6 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 12:22:36 -0800 Subject: [PATCH 199/204] durable: red test, a regular file as the lock directory is accepted The new helper treats any existing lock path as the directory; the old constructor refused a non-directory. Controls: an existing parent and an existing lock directory keep their modes. Co-Authored-By: Claude Opus 5.5 --- .../durable/one_process_per_volume_test.go | 19 ++++++++ .../durable/volume_lock_parent_mode_test.go | 48 +++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go index 55af4a8d40..98b3329fe1 100644 --- a/seaweed-block/core/frontend/durable/one_process_per_volume_test.go +++ b/seaweed-block/core/frontend/durable/one_process_per_volume_test.go @@ -98,6 +98,25 @@ func TestHostVolumeLockDirectoryCreatedOrRefused(t *testing.T) { } } +// A lock path that exists but is not a directory refuses, as before the +// lock directory was laid out by the provider. +func TestHostVolumeLockRefusesNonDirectoryLockPath(t *testing.T) { + locks := filepath.Join(t.TempDir(), "locks") + if err := os.WriteFile(locks, nil, 0o600); err != nil { + t.Fatal(err) + } + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks, + HostVolumeLock: true, VolumeLockDirTestOnly: locks, + }, v1View()) + if err == nil { + _ = p.Close() + } + if !errors.Is(err, durable.ErrVolumeLockDirUnavailable) { + t.Fatalf("a regular file as the lock directory was accepted: %v", err) + } +} + // A lock file this process cannot write (one another user created, as the // root ublk unit does) is still taken: the lock opens it read-only. func TestHostVolumeLockTakesReadOnlyLockFile(t *testing.T) { diff --git a/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go b/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go index 3890219402..ba85f454d9 100644 --- a/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go +++ b/seaweed-block/core/frontend/durable/volume_lock_parent_mode_test.go @@ -38,3 +38,51 @@ func TestHostVolumeLockCreatesParent0755AndLocks0700(t *testing.T) { } } } + +// newLockProvider opens a provider whose host lock directory is locks. +func newLockProvider(t *testing.T, locks string) { + t.Helper() + p, err := durable.NewDurableProvider(durable.ProviderConfig{ + Impl: durable.ImplWALStore, StorageRoot: t.TempDir(), BlockSize: 4096, NumBlocks: pcBlocks, + HostVolumeLock: true, VolumeLockDirTestOnly: locks, + }, v1View()) + if err != nil { + t.Fatal(err) + } + _ = p.Close() +} + +func wantPerm(t *testing.T, path string, want os.FileMode) { + t.Helper() + fi, err := os.Stat(path) + if err != nil { + t.Fatal(err) + } + if got := fi.Mode().Perm(); got != want { + t.Fatalf("%s is %v, want %v", path, got, want) + } +} + +// Directories the provider did not create keep their modes: an existing +// parent with a missing lock directory, and both existing. +func TestHostVolumeLockKeepsExistingDirectoryModes(t *testing.T) { + parent := filepath.Join(t.TempDir(), "sw-block") + if err := os.Mkdir(parent, 0o711); err != nil { + t.Fatal(err) + } + if err := os.Chmod(parent, 0o711); err != nil { + t.Fatal(err) + } + locks := filepath.Join(parent, "locks") + newLockProvider(t, locks) + wantPerm(t, parent, 0o711) + wantPerm(t, locks, 0o700) + + if err := os.Chmod(locks, 0o750); err != nil { + t.Fatal(err) + } + newLockProvider(t, locks) + wantPerm(t, parent, 0o711) + wantPerm(t, locks, 0o750) +} + From dc393ba380532f21052a865df2f76087629518dc Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 12:22:51 -0800 Subject: [PATCH 200/204] durable: refuse a non-directory lock path; chmod only what this call created The lock directory and its parent are chmod'ed only when this call's own Mkdir created them, so an existing or concurrently created directory keeps its mode; an existing lock path that is not a directory refuses (Lstat), as the constructor did before. The invariant row links the mode tests. Co-Authored-By: Claude Opus 5.5 --- .../core/frontend/durable/provider.go | 34 ++++++++++++------- seaweed-block/docs/design/invariants.md | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 00ac1bb722..e99ada32b2 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -564,25 +564,35 @@ const volumeLockCure = "install the tmpfiles.d entry (deploy/systemd/sw-block.tm // makeVolumeLockDir lays out a missing lock directory as the tmpfiles.d // entry does: its parent 0755 (traversable by the unit's user even when root -// created it) and the directory itself 0700. Existing directories are left -// as they are. Modes are set explicitly, so the umask cannot narrow them. +// created it) and the directory itself 0700. Only a directory this call +// creates is chmod'ed (the umask cannot narrow it); one that exists, or that +// another process creates meanwhile, keeps its mode. An existing lock path +// that is not a directory refuses. func makeVolumeLockDir(dir string) error { parent := filepath.Dir(dir) - if _, err := os.Stat(parent); errors.Is(err, os.ErrNotExist) { - if err := os.MkdirAll(parent, 0o755); err != nil { - return err - } + if err := os.MkdirAll(filepath.Dir(parent), 0o755); err != nil { + return err + } + if err := os.Mkdir(parent, 0o755); err == nil { if err := os.Chmod(parent, 0o755); err != nil { return err } - } - if err := os.Mkdir(dir, 0o700); err != nil { - if errors.Is(err, os.ErrExist) { - return nil - } + } else if !errors.Is(err, os.ErrExist) { return err } - return os.Chmod(dir, 0o700) + if err := os.Mkdir(dir, 0o700); err == nil { + return os.Chmod(dir, 0o700) + } else if !errors.Is(err, os.ErrExist) { + return err + } + fi, err := os.Lstat(dir) + if err != nil { + return err + } + if !fi.IsDir() { + return fmt.Errorf("%s exists and is not a directory", dir) + } + return nil } // lockVolumeOnHost takes the volume's host lock (nil without diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 9a07e8cd70..8d2d96542f 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -715,7 +715,7 @@ Notes: | `INV-WS-CAS-UNKNOWN-001` | An unknown HEAD CAS outcome is settled by re-reading HEAD, never by a blind retry; until it is settled the proposal stays pending and its intents stay. | M5 CAS → Pending | `core/storage/chunk_layer.go` `captureLocked`, `resolvePending`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestChunkRemote_UncertainCASIsNotPrecondition` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_UnknownNotAppliedNeverClaimsSuccess` (`core/storage/chunk_layer_contract_test.go`); `TestClaimChunkHeadSettlesUnknownWithoutReplay` (`core/storage/chunk_restore_test.go`); `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | — | ACTIVE | | `INV-WS-CLAIM-BEFORE-SERVE-001` | A new holder claims HEAD at its master-issued epoch before I/O opens; a HEAD with a higher epoch, or another holder at the same epoch, fences the claim. | M4 Claiming → Holder \| Fenced | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestClaimChunkHeadRefusesStaleAuthorityAndAdmissionDrift` (`core/storage/chunk_restore_test.go`); `TestRestoreSeedPrecedesTakeoverCAS` (`core/frontend/durable/provider_seed_order_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | `WorkspaceTakeover` `SeedMatchesTakeover` | ACTIVE | | `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn` (a rolled-back copy), is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`); `TestRolledBackCopyBelowHeadLSNIsRefused` (`core/frontend/durable/rolled_back_copy_test.go`); `TestCutPublishesOnlyLocallyDurableLSN` (`core/frontend/durable/cut_durable_before_cas_test.go`) | — | ACTIVE | -| `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | +| `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | | `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: same holder and epoch only, no move pending or issued, not revoking, store certain, one durable write, and only once max(horizon, deadline) + skew bound has passed; the new process claims HEAD with a new generation before any I/O, so no older incarnation writes or CASes after. | M2 lease: Expired → Granted | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut`, `TestWorkspaceLeaseRegrantCannotUnsealSameEpoch`, `TestWorkspaceLeaseRegrantEmptyRootClaimsOnlyHEAD` (`core/authority/workspace_regrant_storage_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory` | 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 | From bdbe601e4c75d8b52904055628e29e16362c6ca9 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:23:42 -0800 Subject: [PATCH 201/204] test(workspace): refuse unassigned stored seal proofs --- .../cmd/blockvolume/workspace_proof_test.go | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 seaweed-block/cmd/blockvolume/workspace_proof_test.go diff --git a/seaweed-block/cmd/blockvolume/workspace_proof_test.go b/seaweed-block/cmd/blockvolume/workspace_proof_test.go new file mode 100644 index 0000000000..3ecf940654 --- /dev/null +++ b/seaweed-block/cmd/blockvolume/workspace_proof_test.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "errors" + control "github.com/seaweedfs/seaweed-block/core/rpc/control" + "github.com/seaweedfs/seaweed-block/core/storage" + "testing" +) + +type workspaceProofRemote struct { + storage.ChunkRemote + head storage.ChunkHead + err error + reads int +} + +func (r *workspaceProofRemote) GetHead(context.Context) (storage.ChunkHead, error) { + r.reads++ + return r.head, r.err +} + +func TestWorkspaceRevocationUsesExactStoredSeal(t *testing.T) { + for _, name := range []string{"valid", "zero-epoch", "empty-holder", "active", "missing-proof", "proof-gen", "proof-epoch", "proof-holder", "foreign-holder", "foreign-epoch", "zero-gen", "read-error"} { + t.Run(name, func(t *testing.T) { + h := storage.ChunkHead{Gen: 7, Epoch: 2, Holder: "s/r", State: storage.ChunkHeadDetached, DetachedBy: &storage.ChunkDetachedBy{Gen: 7, Epoch: 2, Holder: "s/r"}} + id := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r", Epoch: 2} + holder := "s/r" + r := &workspaceProofRemote{head: h} + switch name { + case "zero-epoch": + id.Epoch = 0 + r.head.Epoch = 0 + r.head.DetachedBy.Epoch = 0 + case "empty-holder": + holder = "" + r.head.Holder = "" + r.head.DetachedBy.Holder = "" + case "active": + r.head.State = storage.ChunkHeadActive + case "missing-proof": + r.head.DetachedBy = nil + case "zero-gen": + r.head.Gen = 0 + r.head.DetachedBy.Gen = 0 + case "proof-epoch": + r.head.DetachedBy.Epoch = 1 + case "proof-holder": + r.head.DetachedBy.Holder = "other/r" + case "foreign-epoch": + r.head.Epoch = 1 + case "proof-gen": + r.head.DetachedBy.Gen = 6 + case "foreign-holder": + r.head.Holder = "other/r" + case "read-error": + r.err = errors.New("HEAD answer lost") + } + gen, err := workspaceDetachedGeneration(context.Background(), func(string) (storage.ChunkRemote, error) { return r, nil }, id, holder) + if name == "valid" { + if err != nil || gen != 7 || r.reads != 1 { + t.Fatalf("stored seal: gen%d reads%d err%v", gen, r.reads, err) + } + } else if err == nil || gen != 0 { + t.Fatalf("unproven ACK gen%d err%v", gen, err) + } + }) + } +} From b4daad80d1554d9107dc98b67003c6fd56b0b92b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 11:24:07 -0800 Subject: [PATCH 202/204] fix(workspace): delegate revocation ACK to stored seal proof --- seaweed-block/cmd/blockvolume/workspace_lease.go | 6 +----- seaweed-block/docs/design/invariants.md | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/workspace_lease.go b/seaweed-block/cmd/blockvolume/workspace_lease.go index b0724b8288..4362b51e82 100644 --- a/seaweed-block/cmd/blockvolume/workspace_lease.go +++ b/seaweed-block/cmd/blockvolume/workspace_lease.go @@ -60,13 +60,9 @@ func workspaceDetachedGeneration(ctx context.Context, remoteFor func(string) (st if err != nil { return 0, err } - head, err := remote.GetHead(ctx) + head, err := storage.ReadDetachedChunkHead(ctx, remote, id.Epoch, holder) if err != nil { return 0, err } - proof := head.DetachedBy - if head.Gen == 0 || head.Epoch != id.Epoch || head.Holder != holder || head.State != storage.ChunkHeadDetached || proof == nil || proof.Gen != head.Gen || proof.Epoch != head.Epoch || proof.Holder != head.Holder { - return 0, fmt.Errorf("workspace shutdown has no matching stored detached HEAD") - } return head.Gen, nil } diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 9a07e8cd70..c92859ef2e 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -711,7 +711,7 @@ Notes: | `INV-WS-HEAD-KEY-PROVENANCE-001` | Every key a HEAD names is named by its predecessor HEAD or was uploaded by this owner under an intent that rooted it until the CAS settled; a key that left every root is never named again. | M5 Manifest → CAS | `core/storage/chunk_layer.go` `captureLocked`; `core/frontend/chunkstore/manifest.go` `PrepareManifest` | — | — | STUB | | `INV-WS-REOPEN-FENCE-001` | Before I/O, an active reopened holder replaces the observed HEAD generation, including the same epoch/holder and an empty HEAD. A previous incarnation's delayed CAS cannot publish afterward. Local acknowledged WAL is retained. | M4 Claiming -> Holder | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestClaimChunkHeadSameOwnerReopenRejectsKilledProcessCAS`, `TestHeadBeltSameOwnerReopenPreservesAcknowledgedWrites` (`core/storage/chunk_reopen_belt_test.go`); `TestLocalReopenClaimsBeforeServing` (`core/frontend/durable/provider_reopen_belt_test.go`) | `HeadReopenBelt` `OldCASCannotLandAfterReopen` | ACTIVE | | `INV-WS-SEALED-REOPEN-001` | A same-epoch/holder reopen cannot reactivate a detached HEAD. It refuses before preparation, CAS or serving, retaining the exact generation, owner, frontier, image and detachedBy proof for the planned new holder. | M4 Claiming -> Detached | `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestClaimChunkHeadSameOwnerReopenPreservesSeal` (`core/storage/chunk_reopen_belt_test.go`); `TestRestoreEqualOwnerDetachedHEADStaysSealed` (`core/frontend/durable/provider_seed_order_test.go`) | `SealedReopen` `SealedReopenPreservesProof` | ACTIVE | -| `INV-WS-SEAL-REPLAY-001` | A repeated plain seal, also after restart, succeeds only from a fresh filer HEAD with exact owner/epoch and detachedBy proof. It returns that original HEAD/frontier without a CAS or new generation. An unreadable or mismatched proof cannot be answered from process memory. | M5 PlainStop -> RemoteProof -> SealedReply | `core/frontend/durable/provider_seal_replay.go` `replayPlainSeal`; `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead` | `TestPlainSealLostAnswerRestartReplaysFilerProof`, `TestPlainSealReplayNeverUsesProcessMemory`, `TestPlainSealReplayDuringDeferredAuthorityStartup` (`core/frontend/durable/provider_plain_seal_replay_test.go`) | `PlainSealReplay` `SuccessNeedsFreshExactProof`, `ValidProofDoesNotNeedProcessMemory` | ACTIVE | +| `INV-WS-SEAL-REPLAY-001` | A repeated plain seal, also after restart, succeeds only from a fresh filer HEAD with exact owner/epoch and detachedBy proof. It returns that original HEAD/frontier without a CAS or new generation. An unreadable or mismatched proof cannot be answered from process memory. | M5 PlainStop -> RemoteProof -> SealedReply | `core/frontend/durable/provider_seal_replay.go` `replayPlainSeal`; `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`; `cmd/blockvolume/workspace_lease.go` `workspaceDetachedGeneration` | `TestWorkspaceRevocationUsesExactStoredSeal` (`cmd/blockvolume/workspace_proof_test.go`); `TestPlainSealLostAnswerRestartReplaysFilerProof`, `TestPlainSealReplayNeverUsesProcessMemory`, `TestPlainSealReplayDuringDeferredAuthorityStartup` (`core/frontend/durable/provider_plain_seal_replay_test.go`) | `PlainSealReplay` `SuccessNeedsFreshExactProof`, `ValidProofDoesNotNeedProcessMemory` | ACTIVE | | `INV-WS-CAS-UNKNOWN-001` | An unknown HEAD CAS outcome is settled by re-reading HEAD, never by a blind retry; until it is settled the proposal stays pending and its intents stay. | M5 CAS → Pending | `core/storage/chunk_layer.go` `captureLocked`, `resolvePending`; `core/storage/chunk_restore.go` `ClaimChunkHead` | `TestChunkRemote_UncertainCASIsNotPrecondition` (`core/frontend/chunkstore/chunk_remote_test.go`); `TestChunkLayer_C6_UnknownNotAppliedNeverClaimsSuccess` (`core/storage/chunk_layer_contract_test.go`); `TestClaimChunkHeadSettlesUnknownWithoutReplay` (`core/storage/chunk_restore_test.go`); `TestChunkIntent_UncertainCASKeepsIntentUntilSettled` (`core/storage/chunk_layer_intent_test.go`) | — | ACTIVE | | `INV-WS-CLAIM-BEFORE-SERVE-001` | A new holder claims HEAD at its master-issued epoch before I/O opens; a HEAD with a higher epoch, or another holder at the same epoch, fences the claim. | M4 Claiming → Holder \| Fenced | `core/storage/chunk_restore.go` `ClaimChunkHead`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestClaimChunkHeadRefusesStaleAuthorityAndAdmissionDrift` (`core/storage/chunk_restore_test.go`); `TestRestoreSeedPrecedesTakeoverCAS` (`core/frontend/durable/provider_seed_order_test.go`); `TestWorkspaceMoveRestoresLazilyAndFencesOldHost` (`core/host/master/workspace_restore_test.go`) | `WorkspaceTakeover` `SeedMatchesTakeover` | ACTIVE | | `INV-WS-STALE-LOCAL-ROOT-001` | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn` (a rolled-back copy), is not served or cut; the attach fails closed with `ErrChunkStaleLocalRoot`. | M4 Claiming → Refused | `core/frontend/durable/provider_chunk.go` `newChunkLayer` | `TestWALStoreChunk_MoveBackOntoAnOldRootIsRefused`, `TestWALStoreChunk_MoveBackRefusedOnDeferredAttach` (`core/frontend/durable/provider_chunk_moveback_test.go`); `TestLocalReopenRejectsForeignClaimImage` (`core/frontend/durable/provider_reopen_belt_test.go`); `TestRolledBackCopyBelowHeadLSNIsRefused` (`core/frontend/durable/rolled_back_copy_test.go`); `TestCutPublishesOnlyLocallyDurableLSN` (`core/frontend/durable/cut_durable_before_cas_test.go`) | — | ACTIVE | @@ -1070,7 +1070,7 @@ A row that names a function existing only on an open pull request says so ("on # | `TERM-STOP-LEASE-FENCED-001` Lease fenced / revoked | The lease guard has latched: its deadline passed, a reply was invalid or late, the lease is revoking, or the process is stopping. A fenced guard never reopens. The host drains, and only when the lease was revoked does it acknowledge with the HEAD generation. | `WorkspaceLeaseGuard` `fenced`, `cause`, `revoked` (`core/host/volume/workspace_lease.go`) | Volume: `core/host/volume/workspace_lease.go` `WorkspaceLeaseGuard.fenceLocked`, the one writer of `fenced`; it is read through `permits`. | `Host.FenceWorkspaceLease` and `runWorkspaceLease` (`core/host/volume/workspace_runtime.go`) set `fenced` directly, with no cause, and keep a second latch, `Host.workspaceLeaseFenced`: open. On `main` a guard fence ends the process with status 0: #409 makes it exit 75. | volume host | | `TERM-STOP-HEAD-FENCED-001` HEAD fenced | HEAD shows a higher epoch, or another holder at this epoch. The chunk layer latches fenced and publishes nothing more, and the backend refuses I/O as stale. | HEAD `Epoch`, `Holder`, `Gen`; `chunkLayerImpl` `fenced` (`core/storage`) | Volume: `core/storage/chunk_layer.go` `chunkLayerImpl.supersededBy`. | `ClaimChunkHead` (`core/storage/chunk_restore.go`) repeats the comparison inline: open. Four cut and detach paths in `chunk_layer.go` set `fenced` directly, next to the setter `fencePublication`: open (one setter). A HEAD fence after startup ends the process with 78 (`head_fenced`): on #410. A refused startup claim exits with 78: on #409. | chunk layer | | `TERM-STOP-STALE-ROOT-001` Stale local root | An existing local root whose HEAD another holder has published, or whose local durable LSN is below HEAD's `remote_lsn`, is refused before the claim and never served. A rolled-back copy exits 78; a foreign holder below the assignment's epoch stays up without serving. | HEAD `Holder`, `RemoteLSN`; `ProviderConfig.ChunkHolder`; the store's durable LSN (`WALStore.Boundaries`) | Volume: the `PrepareRestore` check inside `DurableProvider.newChunkLayer` (`core/frontend/durable/provider_chunk.go`). It is not a named function: open. | A copy of the root taken after its last cut has HEAD's LSN and passes: no local check sees it (never restore a root from a copy). | volume host | -| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`) reimplements the proof check for the revocation ACK: open. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | +| `TERM-STOP-SEALED-001` Sealed | HEAD is detached by this holder at this epoch with a matching `DetachedBy` proof (generation, epoch, holder). The sealing process never reopens it, and only that proof licenses a clean move. | HEAD `State`, `DetachedBy` `Gen`, `Epoch`, `Holder` | Volume: `core/storage/chunk_seal_replay.go` `ReadDetachedChunkHead`. Master: `core/host/master/workspace_head.go` `NewWorkspaceHEADReader`, whose reader checks the proof before `workspaceHeadAdmits` sees the HEAD. | Revocation ACK also delegates to `ReadDetachedChunkHead` through `workspaceDetachedGeneration` (`cmd/blockvolume/workspace_lease.go`); `TestWorkspaceRevocationUsesExactStoredSeal` (`cmd/blockvolume/workspace_proof_test.go`) checks assigned epoch/holder, fresh proof and read errors without a write. The sealed-reopen test in `ClaimChunkHead` checks state, epoch and holder without the proof: open. | chunk layer (volume side); authority (master side) | | `TERM-STOP-EXIT-001` Exit class of a stopped workspace primary | A workspace primary that stops ends its process with one latched class. 75 means retry (start-time wait exhausted, lease fence, unconfirmed ACK). 78 means superseded (the line names another holder). 0 is used only after an ACKed revocation or a signal. | `workspaceExit` `code`, `reason`; the `processExit` decision (`cmd/blockvolume/process_exit.go`, on #409) | Volume: `cmd/blockvolume/process_exit.go` `workspaceRetryOutcome`, on #409. `processExit.choose` latches the first outcome. | `chooseChunkStartupExit` (on #409) turns 75 into 78 on a refused HEAD claim (`DurableProvider.ChunkStartupSuperseded`), outside `workspaceRetryOutcome`: open. On #409 alone, "superseded" means another replica; the same replica on another server counts only with #411's `IsSuperseded`: open until both merge. | volume host | | `TERM-ONE-PROCESS-001` One live process per volume per host | At most one blockvolume process serves a volume on one host: each holds `/run/sw-block/locks/.lock` from before its store opens, whatever its `--durable-root`. Across hosts the assignment and the workspace lease keep holders apart. | The host lock file (`durable.HostVolumeLockDir`, `deploy/systemd/sw-block.tmpfiles.conf`); the store file `<--durable-root>/.bin` (`cmd/blockvolume/main.go` `durableCreateGeometry`); their exclusive OS file locks; the HEAD `Holder` | Volume: `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` (on #439; `ProviderConfig.HostVolumeLock`, set by blockvolume; a missing directory refuses the provider), taken in `ensureHandle` before the store opens and released after it closes. `core/storage/volume_lock.go` `LockWALStoreFile`: an exclusive, non-blocking `flock` in `volume_lock_unix.go` and an exclusive, fail-immediately `LockFileEx` in `volume_lock_windows.go`. It is taken by v3 create and open and by the read-only open. | Not a second derivation but the locks' limit: they cover one host. A second process is not refused when it runs on another host with the same server id, in a container without the host's `/run/sw-block/locks` (the Kubernetes renderer does not mount it: open), or on a copied root on another host. Two such processes with one holder string both pass `ClaimChunkHead` and both renew. A failed CAS against the other process's same-epoch, same-holder HEAD is treated as a conflict, not a fence (`publicationOwnerChanged`): open. #416 refuses a server id that heartbeats from another host's address (`refuseServerIDFromOtherHost`), which covers part of this. The master's grants carry no per-process identity: open. | storage engine | From 62b71734c1f55a6c6fbdbcdd49ab9355c79f2797 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 13:26:06 -0800 Subject: [PATCH 203/204] docs: lifecycle, the returning old host after a forced move as the procedure test shows it Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/volume-lifecycle.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index c6be7a1d72..bd44bc91f5 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -153,8 +153,9 @@ These are rules for the operator. The product does not detect every breach. detected: it attaches and loses the writes acknowledged after the copy was taken. To go back, start from the remote image with a fresh root. - **After a forced move, stop and disable the old host's unit.** Until you do, it - restarts about every 35 seconds, logs that it waits for an assignment, and cannot - serve. + starts, refuses, exits 75 and is started again, and cannot serve. The shipped unit + gives up after 10 starts in 10 minutes (`StartLimitBurst=10`, + `StartLimitIntervalSec=600`) and then stays failed until you reset it. - **Before moving a volume back to a host that held it earlier, move that host's old root aside** (after the check above). The old root is stale; the new holder must start on a fresh one. @@ -180,7 +181,7 @@ Each procedure below runs as written on this page, with the real binaries, two | Same host: restart inside the lease | `TestProcedureSameHostRestartInsideTheLease` | runs | | After a crash: return after a lapsed lease (started 65 s after the stop) | `TestProcedureReturnAfterALapsedLease` | runs | | Revoke without the ACK, then forced move to another node | `TestProcedureRevokeWithoutACKThenForcedMove` | runs | -| Forced move, then the old host returns | `TestProcedureForcedMoveWithTheOldHostReturning` | **fails in this release**: the returning old host takes the new host's assignment and reports itself ready, although it refuses I/O. Keep the old host down (see "The holder never comes back") | +| Forced move, then the old host returns | `TestProcedureForcedMoveWithTheOldHostReturning` | runs: the returning old host does not take the new host's assignment, does not report ready and does not listen for I/O; it logs the refusal and exits 75, on its old local root and on a fresh one, each time the unit starts it; the new host keeps serving | | A start inside the window before the re-grant barrier ("started too early") | none | not run | | Hand-over between two machines | none | not run (the tests use one machine's loopback) | From ca6ea25f660ee02bde93e07adbfabf538eebd1db Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sun, 22 Nov 2026 13:26:59 -0800 Subject: [PATCH 204/204] docs: lifecycle, after a crash the process exits 75 and the unit restarts it; run table from the procedure tests Co-Authored-By: Claude Fable 5.2 --- seaweed-block/docs/volume-lifecycle.md | 46 +++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index bd44bc91f5..478947e1d5 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -182,7 +182,9 @@ Each procedure below runs as written on this page, with the real binaries, two | After a crash: return after a lapsed lease (started 65 s after the stop) | `TestProcedureReturnAfterALapsedLease` | runs | | Revoke without the ACK, then forced move to another node | `TestProcedureRevokeWithoutACKThenForcedMove` | runs | | Forced move, then the old host returns | `TestProcedureForcedMoveWithTheOldHostReturning` | runs: the returning old host does not take the new host's assignment, does not report ready and does not listen for I/O; it logs the refusal and exits 75, on its old local root and on a fresh one, each time the unit starts it; the new host keeps serving | -| A start inside the window before the re-grant barrier ("started too early") | none | not run | +| Same host: restart after a crash inside the lease | `TestProcedureSameHostCrashRestartInsideTheLease` | runs | +| After a crash: started 40 s after the stop, the barrier passes inside the start wait | `TestProcedureStartInsideTheBarrierWaitIsReGranted` | runs: does not serve while renewals are refused, serves once re-granted | +| After a crash: started too early (the start wait ends before the barrier) | `TestProcedureStartTooEarlyExitsAndARestartServes` | runs: exits 75 with `reason=assignment_timeout`; a later start serves | | Hand-over between two machines | none | not run (the tests use one machine's loopback) | ## Planned hand-over @@ -297,24 +299,30 @@ without the move does not serve: a sealed HEAD stays sealed for its own epoch. unit restarts a crashed one after `RestartSec=5s`) renews at once and serves from its local WAL. -**The lease lapsed, and the holder is still the recorded holder.** A lapsed -holder fences itself, drains and exits with status 0, logging -`workspace lease: fenced volume=v1 replica=r1 epoch=E: lease expired at ...`. -Start it again yourself. blockmaster grants it again only after a barrier: the -stored lease horizon (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`. After the grant it reclaims -HEAD and serves its local WAL: nothing acknowledged is lost. +**The lease lapsed, and the holder is still the recorded holder.** A holder whose +lease lapses fences itself, drains and exits with status 75, logging +`workspace lease: fenced volume=v1 replica=r1 epoch=E: lease expired at ...` and +`blockvolume: exiting status=75 reason=lease_expired`. The example unit starts it +again (`Restart=on-failure`, `RestartSec=5s`); so does any supervisor that restarts on +a non-zero status. You do not need to time the restart. -**Start it no earlier than 65 seconds after it stopped.** blockvolume waits for -its lease only 30 seconds after start (fixed, no flag). Started too early, it logs -`durable: chunk authority wait for volume=v1 ended after ...: assignment -unavailable, not serving (...)`, keeps running and does not serve. Restart it -once more: its lease is then valid and it serves at once. +blockmaster grants the lease again only after a barrier: the stored lease horizon +(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. + +**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 +`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. No re-grant happens after a revoke, a recorded ACK or a move of the volume. @@ -358,7 +366,7 @@ serving when its lease ends. Make sure it stays down. | 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 | Restart it once more after the barrier | +| `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 | | `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 `/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