From d75c61cff58e35d08531a07a9e282d8ed567de8b Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 08:14:16 -0800 Subject: [PATCH] feat: seal idle volumes under the caller deadline --- .../core/frontend/durable/provider_chunk.go | 21 +++++++-- .../durable/provider_offline_seal_test.go | 47 +++++++++++++++++++ .../core/frontend/durable/storage_adapter.go | 3 -- .../core/host/volume/chunk_control.go | 9 ++++ seaweed-block/docs/design/invariants.md | 7 +-- seaweed-block/docs/spec/PlainDetach.tla | 21 +++++---- seaweed-block/docs/spec/README.md | 11 +++++ 7 files changed, 99 insertions(+), 20 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index 2c194a39e8..5acf59d19d 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -1049,7 +1049,8 @@ func (p *DurableProvider) DetachVolumeFrozen(ctx context.Context, volumeID strin var ErrPlainDetachBusy = errors.New("durable: plain detach requires idle frontend I/O") // DetachVolumePlain bypasses pre-copy cost admission only after atomically -// closing an idle frontend. Publication and failure settlement are unchanged. +// closing an idle frontend (including a closed handle). G.GONE.SEALED uses +// only the caller context, not the live-serving freeze timer. func (p *DurableProvider) DetachVolumePlain(ctx context.Context, volumeID string) (storage.ChunkCutResult, uint64, error) { return p.detachVolume(ctx, volumeID, true) } @@ -1107,6 +1108,10 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla start = guestFreeze.StartedAt } casAtFreeze = countCAS() + if plain { // G.GONE.SEALED: no live frontend, caller owns the bound. + settleDeadline, _ = ctx.Deadline() + return + } operationStart := start if guestFrozen && guestFreeze.AllowOverBudget { operationStart = time.Now() @@ -1123,7 +1128,7 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla if timer != nil { timer.Stop() } - if !start.IsZero() { + if !plain && !start.IsZero() { if d := time.Since(start); d > detachFreezeTarget { log.Printf("durable: ALARM detach of volume=%s held guest I/O for %s (target %s, bound %s)", volumeID, d.Round(time.Millisecond), detachFreezeTarget, freeze) } @@ -1204,7 +1209,11 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla } } if trace := p.testDetachTrace; trace != nil { - trace("cut", start.Add(freeze*3/4)) + deadline := start.Add(freeze * 3 / 4) + if plain { + deadline, _ = cutCtx.Deadline() + } + trace("cut", deadline) } h.chunkDetach = true notifyDetach() @@ -1228,7 +1237,11 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla // resumes: an earlier detach that applied, an unresolved detach CAS or a // fenced layer must never resume serving. The settlement keeps the rest // of the freeze budget even when the caller's context is gone. - sctx, scancel := context.WithDeadline(context.WithoutCancel(cutCtx), settleDeadline) + sctx, scancel := context.WithCancel(cutCtx) + if !plain { // Live detach retains its reserved settlement budget. + scancel() + sctx, scancel = context.WithDeadline(context.WithoutCancel(cutCtx), settleDeadline) + } defer scancel() if trace := p.testDetachTrace; trace != nil { dl, _ := sctx.Deadline() diff --git a/seaweed-block/core/frontend/durable/provider_offline_seal_test.go b/seaweed-block/core/frontend/durable/provider_offline_seal_test.go index b16f55a5eb..4f149ef382 100644 --- a/seaweed-block/core/frontend/durable/provider_offline_seal_test.go +++ b/seaweed-block/core/frontend/durable/provider_offline_seal_test.go @@ -3,6 +3,8 @@ package durable_test import ( "bytes" "context" + "errors" + "sync" "testing" "time" @@ -68,3 +70,48 @@ func TestOfflineSealUsesCallerDeadline(t *testing.T) { }) } } + +// Caller cancellation ends an offline upload; the closed backend stays closed, +// and a new caller can retry the seal without losing acknowledged bytes. +type cancelSealRemote struct { + *storage.MemChunkRemote + once sync.Once + cancel context.CancelFunc +} + +func (r *cancelSealRemote) Put(ctx context.Context, key string, b []byte) error { + r.once.Do(r.cancel) + if err := ctx.Err(); err != nil { + return err + } + return r.MemChunkRemote.Put(ctx, key, b) +} +func TestOfflineSealCallerCancelCanRetry(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + remote := &cancelSealRemote{MemChunkRemote: storage.NewMemChunkRemote(), cancel: cancel} + p := chunkProvider(t, t.TempDir(), remote, v1View(), 0) + openRecovered(t, p) + b, err := p.Open(context.Background(), "v1") + if err != nil { + t.Fatal(err) + } + if _, err = b.Write(context.Background(), 4096, block(0x72)); err != nil { + t.Fatal(err) + } + if err = b.Close(); err != nil { + t.Fatal(err) + } + if _, _, err = p.DetachVolumePlain(ctx, "v1"); !errors.Is(err, context.Canceled) { + t.Fatalf("offline caller cancellation lost: %v", err) + } + if _, err = b.Write(context.Background(), 8192, block(0x73)); err == nil { + t.Fatal("failed offline seal reopened closed frontend") + } + retry, end := context.WithTimeout(context.Background(), time.Minute) + defer end() + r, _, err := p.DetachVolumePlain(retry, "v1") + if err != nil || r.Head.State != storage.ChunkHeadDetached || !bytes.Equal(headBlock(t, remote.MemChunkRemote, 1), block(0x72)) { + t.Fatalf("offline retry failed: %+v %v", r, err) + } +} diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 9ac6db58e4..a7641ecd08 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -554,9 +554,6 @@ func (b *StorageBackend) stopPlainDetachIfIdle() error { defer b.ioMu.Unlock() b.mu.Lock() defer b.mu.Unlock() - if b.closed { - return frontend.ErrBackendClosed - } if b.admittedIO != 0 { return ErrPlainDetachBusy } diff --git a/seaweed-block/core/host/volume/chunk_control.go b/seaweed-block/core/host/volume/chunk_control.go index c6cd4f7525..b66bc2c910 100644 --- a/seaweed-block/core/host/volume/chunk_control.go +++ b/seaweed-block/core/host/volume/chunk_control.go @@ -556,6 +556,15 @@ func (s *StatusServer) handleChunkDetach(w http.ResponseWriter, r *http.Request) return } ctx, cancel := chunkContext(r, req.TimeoutMs) + if req.Plain { // G.GONE.SEALED: offline work is bounded by its caller. + cancel() + ctx, cancel = context.WithCancel(r.Context()) + if req.TimeoutMs > 0 { + const maxTimeoutMs = int64((1<<63 - 1) / time.Millisecond) + cancel() + ctx, cancel = context.WithTimeout(r.Context(), time.Duration(min(req.TimeoutMs, maxTimeoutMs))*time.Millisecond) + } + } defer cancel() var res ChunkDetachResponse var err error diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 0c69765881..618daa6d22 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -209,7 +209,7 @@ stateDiagram-v2 [*] --> Refused: invalid frozen request; invalid_freeze_budget; no provider mutation Admit --> Refused: budget refused, closed, fenced, detached, base install, or lineage or lease invalid Admit --> PlainStop: plain detach and idle frontend lock acquired - PlainStop --> Quiesce: frontend stopped; ordinary detached cut + PlainStop --> Quiesce: idle frontend closed; caller-bounded offline seal Admit --> FrozenForecast: guest already frozen with an explicit origin FrozenForecast --> Refused: unknown or non-fitting remaining budget FrozenForecast --> Quiesce: plausible estimate or explicit final override; skip staging @@ -243,7 +243,7 @@ stateDiagram-v2 | Admit | optional Budget admitted before staging/barrier; not closed, fenced, detached or installing a base; `CaptureAllowed` (healthy primary, unchanged lineage, valid lease) | `core/storage/chunk_layer.go` `admit`, `captureLocked`; `core/frontend/durable/provider_chunk.go` `newChunkLayer` (`CaptureAllowed`) | `INV-WS-LEASE-001` | | Settle pending | an earlier unknown CAS is resolved by re-reading HEAD before any new proposal | `core/storage/chunk_layer.go` `resolvePending` | `INV-WS-CAS-UNKNOWN-001` | | Stage | native remaining bytes above half the COW side cap trigger logical-read pre-copy straight to remote; repeat only while the remainder shrinks; legacy fixtures retain the chunk-count bound; each new key is intent-rooted first | `core/storage/chunk_layer.go` `stage` | `INV-CUT-INTENT-FIRST-001`, `INV-CUT-STAGED-REUSE-001`, `INV-CUT-PAYLOAD-BOUNDED-001` | -| Plain detach | explicit `plain=true` bypasses pre-copy cost admission only after exclusive frontend I/O admission succeeds immediately; busy requests change no frontend/pause/HEAD state. It then uses the ordinary StopIO, final cut and outcome settlement. | `provider_chunk.go` `DetachVolumePlain`; `storage_adapter.go` `stopPlainDetachIfIdle`; `chunk_control.go` `handleChunkDetach` | `INV-CUT-PLAIN-DETACH-001`, `INV-WS-HEAD-BELT-001` | +| Plain detach | explicit `plain=true` bypasses pre-copy cost admission only after exclusive frontend I/O admission succeeds immediately; busy requests change no frontend/pause/HEAD state. It then uses StopIO and a final detached cut under the caller context, including a closed idle frontend (G.GONE.SEALED). | `provider_chunk.go` `DetachVolumePlain`; `storage_adapter.go` `stopPlainDetachIfIdle`; `chunk_control.go` `handleChunkDetach` | `INV-CUT-PLAIN-DETACH-001`, `INV-WS-HEAD-BELT-001` | | Pre-copy admission | opt-in: close frontend admission and drain registered operations for at most 100 ms before taking the store barrier; rejected attempts clear the pause and grant every waiter FIFO admission under one lock hold before ordinary uploads; each waiter rechecks the ordinary gate without waiting for another I/O to finish | `precopy_admission.go` `BeginPrecopyPause`; `chunk_precopy.go` `PrecopyDetachWithAdmission` | `INV-CUT-PRECOPY-001` | | Quiesce | the capture barrier (`captureMu`) is held exclusively, then `Sync` fixes H; `Recover` and writes hold the barrier shared | `core/storage/chunk_layer.go` `captureLocked`; `core/storage/walstore.go` `WALStore.Recover`, `WALStore.Write` | `INV-CUT-QUIESCED-001`, `INV-CUT-RECOVER-BARRIER-001` | | Pre-copy detach | at most five rolling attempts within a cooperative 60 s context; authoritative candidates and measured costs admit the final cut after the bounded drain; a known estimate may use the declared five-second freeze ceiling when it is at least 90% of the previous comparable known estimate or on the final physical round; frozen commands wait up to the five-second cutover budget and receive FIFO admission grants together after a safe abort, without serializing on I/O completion; each queue bound starts at the command arrival | `chunk_precopy.go`; `precopy_admission.go`; `DurableProvider.DetachVolume` | `INV-CUT-PRECOPY-001` | @@ -526,7 +526,7 @@ Notes: |---|---|---|---|---|---|---| | `INV-CUT-COW-OWNER-001` | Before any read-visible native mutation, a pending candidate has one saving owner; copying/saving collisions wait. The immutable cut buffer is exactly the image at H. | M5 OpenWindow → Copy | `chunk_cut_cow.go` `claim`, `beforeCOWMutation`; Write/WriteBatch/applyEntryV3 pre-publication hooks | `TestCutCOWV3_MutationCompletesWhileEarlierChunkCopyIsHeld`, `TestCutCOWV3_CopyingChunkWaitsButPendingChunkSaves`, `TestCutCOWV3_TwoWritersOneSaveAndCloseJoinsSavedReader`, `TestCutCOWV3_OverlappingRealBatchesPreserveCut` | CutCOW2 BufFrozen/HeadImage; writer/batch multiplicity tested, not modelled | ACTIVE | | `INV-CUT-COW-DRAIN-001` | Terminal invalidation forbids new references; aborting owners release themselves before join. Side cleanup and destructive transitions wait for actual I/O references. Store Close cannot miss first attachment; every Close waits for full shutdown. | M5 Closed/Aborted → Drain; M1 Close/Recover | `chunk_cut_cow.go` `abort`, `join`, `holdChunkDestructive`; `WALStore.Close`; attach capture admission | `TestCutCOWV3_RecoveryAndCloseDrainSavingOwner`, `TestCutCOWV3_CloseJoinsHeldLiveCopy`, `TestCutCOWV3_CloseSnapshotRejectsFirstAttachAndSharesCompletion`, `TestCutCOWV3_DestructiveSnapshotRetriesFirstAttachment`, `TestCutCOWV3_SpillIsEphemeralAndCleanupIsPrefixScoped`, `TestCutCOWV3_ProcessCrashDropsSideAndRestoresSyncedImage` | CutCOW2 SideOnlyInCut, abortNoJoin RED; real lifecycle races tested separately | ACTIVE | -| `INV-CUT-PLAIN-DETACH-001` | A plain detach closes the frontend only when no I/O holds its admission lock; no store or remote call occurs while this lock is held. An admitted or entering operation makes the request refuse unchanged. Cost admission alone is bypassed; ordinary detached publication and unknown/fenced/aborted settlement stay enforced. An absent or false field preserves pre-copy policy. | M5 Admit -> PlainStop -> Quiesce | `core/frontend/durable/provider_chunk.go` `detachVolume`; `storage_adapter.go` `stopPlainDetachIfIdle`; `core/host/volume/chunk_control.go` | `TestPlainDetachAfterPrecopyRefusalRequiresIdleFrontend`, `TestPlainDetachSkipsPrecopyCostAdmission`, `TestChunkDetachPlainFieldDispatch`, `TestChunkDetachPlainAdapterAndBusyResponse` | `PlainDetach` `IdleAtStop`; physical byte and HEAD controls remain native | ACTIVE | +| `INV-CUT-PLAIN-DETACH-001` | Plain detach excludes entering/admitted I/O, then seals under the caller context, including a closed idle frontend. Publication and unknown/fenced settlement remain enforced. Closed frontend handles never reopen; absent/false preserves live policy. | M5 Admit -> PlainStop -> Quiesce | `core/frontend/durable/provider_chunk.go` `detachVolume`; `storage_adapter.go` `stopPlainDetachIfIdle`; `core/host/volume/chunk_control.go` | `TestPlainDetachAfterPrecopyRefusalRequiresIdleFrontend`, `TestPlainDetachSkipsPrecopyCostAdmission`, `TestChunkDetachPlainFieldDispatch`, `TestChunkDetachPlainAdapterAndBusyResponse` ; `TestOfflineSealUsesCallerDeadline`, `TestOfflineSealCallerCancelCanRetry` (`core/frontend/durable/provider_offline_seal_test.go`); `TestChunkPlainDetachUsesCallerDeadline` (`core/host/volume/chunk_offline_seal_test.go`) | `PlainDetach` `IdleAtStop`; physical byte and HEAD controls remain native | ACTIVE | | `INV-WS-FREEZE-ACCOUNTING-001` | Frozen detach validates its origin and rechecks elapsed + known estimate against 5 s; override is explicit. Storage reports its admission estimate and quiesce slack using same-host monotonic durations. Stale advice is rechecked before upload; override and actual elapsed remain visible. | G frozen detach (M5) | `core/storage/chunk_frozen_budget.go` `WithFrozenDetach`, `admitFrozenAt`; `core/frontend/durable/provider_chunk.go` `DetachVolumeFrozen` | `TestFrozenBudgetInputValidation`, `TestFrozenBarrierConsumesElapsedWithoutNewAllowance`, `TestFrozenFinalOverrideIsVisibleEvenWhenEstimateFits`, `TestFrozenValidationPrecedesAnyProviderAccess`; `TestCandidateTailReportsCompleteFrozenBudget`, `TestFrozenRefusalRetainsUnknownCompleteEstimate`, `TestChunkFrozenRefusalCarriesServerBudget`, `TestChunkFrozenDrainRefusalCarriesObservedBudget`, `TestFrozenDrainObservationPreservesKnownBeforeReasonMutation`, `TestFrozenSaturatedTailRemainsKnownButNonActionable` | `FrozenDetachBudget` `BudgetAtAdmission`, `OverrideVisible`, `ReportSlackSound` | ACTIVE | | `INV-WS-FREEZE-REFUSAL-001` | HTTP400 `invalid_freeze_budget`, retryable=false, is emitted only for frozen-request validation before any provider admission or mutation. Missing/zero/future origin, override without frozen, and frozen+plain preserve that boundary. Generic `bad_request` is not a clean-refusal proof. Terminal and unknown-publication causes retain precedence; no production path emits this typed code after mutation. | G frozen detach: request → refused before admission (M5) | `core/host/volume/chunk_control.go` `handleChunkDetach`, `chunkErrorCode`; `core/storage/chunk_frozen_budget.go` `WithFrozenDetach`; `core/frontend/durable/provider_chunk.go` `DetachVolumeFrozen` | `TestChunkFrozenValidationHasDistinctPreMutationCode`, `TestFrozenValidationPrecedesAnyProviderAccess` | — (wire classification; validation/admission guards unchanged) | ACTIVE | | `INV-CUT-PRECOPY-001` | Resume grants waiters FIFO under one lock; gates and completion are independent. Each command keeps its arrival/caller bound. Only pause refusals requeue; stale and terminal errors survive. Detached handoff requires settled publication. See Notes for admission and freeze guards. | M5 tentative admission -> ordinary COW or FinalFreeze | `chunk_precopy.go`; `chunk_frozen_budget.go`; `precopy_admission.go`; `storage_adapter.go`; `provider_chunk.go` | `TestFrozenDetachRejectsBeforeStagingOrUpload`, `TestFrozenDetachRechecksBudgetAtBarrierWithoutUpload`, `TestFrozenBarrierConsumesElapsedWithoutNewAllowance`, `TestCheckpointTailScanIncludedInTotalAndFixedCosts`, `TestCheckpointTailUsesLiteralLatestThreeConservativeRate`, `TestFrozenDetachForcedFinalCommitsSamePoint`, `TestFrozenFinalOverrideKeepsAuthorityAndCloseGuards`, `TestFrozenRetryDoesNotHideUnknownPublication`, `TestFrozenProviderFlagOffRefusesWithoutUploadThenFinalCommits`, `TestChunkFrozenDetachWireContractAndPrecedence`, `TestCheckpointTailMeasuresWritesAfterItsCut`, `TestChunkCutFixedSpansAttributeManifestAndCleanup`, `TestPrecopyLiveBarrierSpansExplainOverage`, `TestPrecopyFixedPartsDoNotDoubleCountSyncPhases`, `TestPrecopyProviderBusyOwnerKeepsServing`, `TestPrecopyProviderBusyOwnerRetryRetainsSlowFixedSample`, `TestPrecopyDetachBusyOwnerExhaustsWithoutStopping`, `TestPrecopyDetachBusyOwnerRetainsSlowFixedCost`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachRefusedFinalCutRetainsSlowFixedCost`, `TestPrecopyDetachRetryResolvesPreviouslyAppliedDetachedCut`, `TestPrecopyDetachAppliedRetryRetainsSlowFixedCost`, `TestPrecopyAttemptDiagnosticsSeparateTimeoutFromFit`, `TestPrecopyAttemptDiagnosticsRetainSlowFixedCost`, `TestPrecopyStopIOReturnTimestampPrecedesFinalPublication`, `TestPrecopyCountsWarmAttemptsSeparatelyFromMeasurementRounds`, `TestPrecopyUnknownPreviousCannotClaimProgress`, `TestPrecopyCallerExpiryVersusClose`, `TestPrecopySmokeTraceAmendment4`, `TestPrecopyFixedWindowDecays`, `TestPrecopyFinalAttemptFreezeCeiling`, `TestPrecopyFixedCostSmallTailCommitsBySecondAttempt`, `TestPrecopyLargeTailStillRefusesFixedCostException`, `TestPrecopyFixedCommitRuleKeepsProgressAndFreezeBounds`, `TestPrecopyFixedPartsStayWithLargestObservation`, `TestPrecopyFixedPartsMeasureCASAndReadbackSeparately`, `TestPrecopyFixedExceptionFinishUsesDeclaredFreeze` (`core/storage/chunk_precopy_fixed_commit_test.go`), `TestPrecopyFiftyIOPSSyncConvergesFirstAttempt` (first eligible allowance or plateau attempt), `TestPrecopyFiftyIOPSSlowMeasuredCostsKeepServing` (retained slow cost, declared admission or refusal, active owner and exact local bytes), `TestPrecopyFiftyIOPSColdCostsKeepAdmissionHonest`, `TestPrecopyFiftyIOPSRoundAccounting` (five total physical rounds, including success and measurement rounds), `TestPrecopyHostDrainDoesNotCompleteHeldGuestIO`, `TestPrecopyTargetCloseDropsHeldCommandWithoutCompletion`, `TestPrecopyDrainLetsAnAdmittedWriterReachTheBarrier`, `TestPrecopyDrainReceives100MillisecondBound`, `TestPrecopyDrainTimeoutReopensWithoutWaitingUnderCapture`, `TestPrecopyLateGateCallerCannotCrossFreeze`, `TestPrecopyResumeReleasesAllWaiters` (FIFO grants under one lock, concurrent outstanding I/O), `TestPrecopyResumedArrivalDoesNotInheritExpiredPause`, `TestPrecopyQueueBoundStartsAtCommandArrival`, `TestPrecopyResumeGrantVersusExpiry`, `TestPrecopyGrantedWaiterFollowsReplacementPause`, `TestPrecopyNewPauseCannotEraseObservedStalePrimary`, `TestPrecopyStopFallbackPreservesQueuedPause`, `TestPrecopyQueueUsesFiveSecondCutoverBudget`, `TestPrecopyRollingUploadReopensTentativeAdmission`, `TestPrecopyDetachRefusedFinalCutKeepsChangedBytes`, `TestPrecopyDetachSustainedWrapFlushAndFreshRestore` | `PrecopyFixedAdmission.tla` (ordinary admission), `FrozenDetachBudget.tla` (forecast/barrier budget, upload guard, explicit override and stable-authority publication); controlled callers and measured latency are not a model proof | ACTIVE | @@ -668,6 +668,7 @@ Format v3 row 4 remains dark. Its typed scan result preserves trusted records, a | Wait | Machine / invariant | Bound | Release and cancellation | Locks / remote work | |---|---|---|---|---| +| Offline seal | G.GONE.SEALED; `INV-CUT-PLAIN-DETACH-001` | Caller context, including its optional explicit HTTP timeout; no live-serving timer | 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. | | Frontend pre-copy admission | M5 tentative admission -> resume; `INV-CUT-PRECOPY-001` | 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. | Frozen estimate reporting: a tail above the existing 60 s estimator ceiling reports the same 60 s rejection sentinel used by admission. It is known but saturated, not a complete fixed-plus-tail duration; quiesce slack is zero. Consumers must not use it as a completion forecast. Drain refusals retain the observation before their reason changes; this reporting does not reclassify refusal causes. diff --git a/seaweed-block/docs/spec/PlainDetach.tla b/seaweed-block/docs/spec/PlainDetach.tla index 0bd3733bb2..3ec5322b96 100644 --- a/seaweed-block/docs/spec/PlainDetach.tla +++ b/seaweed-block/docs/spec/PlainDetach.tla @@ -3,17 +3,18 @@ \* remain the existing detach/cut obligations, outside this abstraction. EXTENDS Naturals, TLC CONSTANT IdleGuard -VARIABLES phase, readers -vars == <> -Init == /\ phase = "serving" /\ readers = 0 -BeginIO == /\ phase = "serving" /\ readers < 2 - /\ readers' = readers + 1 /\ UNCHANGED phase -EndIO == /\ readers > 0 /\ readers' = readers - 1 /\ UNCHANGED phase +VARIABLES phase, readers, closed +vars == <> +Init == /\ phase = "serving" /\ readers = 0 /\ closed = FALSE +BeginIO == /\ phase = "serving" /\ ~closed /\ readers < 2 + /\ readers' = readers + 1 /\ UNCHANGED <> +EndIO == /\ readers > 0 /\ readers' = readers - 1 /\ UNCHANGED <> Plain == /\ phase = "serving" /\ (~IdleGuard \/ readers = 0) - /\ phase' = "stopped" /\ UNCHANGED readers -Publish == /\ phase = "stopped" /\ phase' = "detached" /\ UNCHANGED readers -Abort == /\ phase = "stopped" /\ phase' = "serving" /\ UNCHANGED readers -Next == BeginIO \/ EndIO \/ Plain \/ Publish \/ Abort + /\ phase' = "stopped" /\ UNCHANGED <> +Publish == /\ phase = "stopped" /\ phase' = "detached" /\ UNCHANGED <> +Abort == /\ phase = "stopped" /\ phase' = "serving" /\ UNCHANGED <> +Close == /\ ~closed /\ closed' = TRUE /\ UNCHANGED <> +Next == Close \/ BeginIO \/ EndIO \/ Plain \/ Publish \/ Abort Spec == Init /\ [][Next]_vars IdleAtStop == phase \in {"stopped", "detached"} => readers = 0 ============================================================================= diff --git a/seaweed-block/docs/spec/README.md b/seaweed-block/docs/spec/README.md index 5dc3e958cf..87fad51d5c 100644 --- a/seaweed-block/docs/spec/README.md +++ b/seaweed-block/docs/spec/README.md @@ -517,3 +517,14 @@ checked by native Go tests; this derived arithmetic model does not model the HTT encoder, sampler atomicity, orchestrator timing or an unbounded estimator overrun. #344 review qualification: `TestChunkFrozenDrainRefusalCarriesObservedBudget` drives a real admitted Sync through frontend drain expiry, durable provider and HTTP, with no report injection; `TestFrozenDrainObservationPreservesKnownBeforeReasonMutation` covers the known observation. `TestFrozenSaturatedTailRemainsKnownButNonActionable` and the literal 60 s/61 s candidate cases preserve the existing saturation sentinel (zero slack, not a complete duration). These native controls add no model claim or admission guard. + + +2026-11-21 offline-seal extension: `PlainDetach` now includes frontend Close, +which disables new readers without discarding readers already admitted. An idle +closed frontend may enter PlainStop; abort does not clear its closed bit. +`cfg/PlainDetach.cfg` exhausts 18 generated / 10 distinct states, depth 4, queue +empty (TLC 2.19 with the tools hash above). `PlainDetach_no_idle.cfg` violates +`IdleAtStop` in 8 distinct states. This remains an admission model, not a timing +model. Caller deadline and cancellation are witnessed natively by +`TestOfflineSealUsesCallerDeadline`, `TestOfflineSealCallerCancelCanRetry` and +`TestChunkPlainDetachUsesCallerDeadline`; live-detach bounds retain their tests.