fix: latch exhausted workspace startup and bound process retry exit

This commit is contained in:
pingqiu committed 2026-11-21 23:52:54 -08:00
1 parent 42e8491478
commit 5d730c1ecc
14 files changed
+343 -38

No files matched your search

+9 -23
View File
@@ -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()
@@ -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
}
}
@@ -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)
}
}
+14 -10
View File
@@ -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)
@@ -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):
@@ -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:
}
}
@@ -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")
}
}
@@ -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 {
@@ -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
}
+4 -3
View File
@@ -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=
@@ -69,6 +69,7 @@ ExecStart=/usr/local/bin/blockvolume \
KillSignal=SIGTERM
TimeoutStopSec=30s
Restart=on-failure
RestartPreventExitStatus=78
RestartSec=5s
NoNewPrivileges=true
@@ -68,6 +68,7 @@ ExecStart=/usr/local/bin/blockvolume \
KillSignal=SIGTERM
TimeoutStopSec=30s
Restart=on-failure
RestartPreventExitStatus=78
RestartSec=5s
NoNewPrivileges=true
@@ -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.
+5 -1
View File
@@ -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 <volume>@<expected epoch>`; `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. |