diff --git a/seaweed-block/cmd/sw-block/volume_backup.go b/seaweed-block/cmd/sw-block/volume_backup.go index b0e813308a..f7e1066841 100644 --- a/seaweed-block/cmd/sw-block/volume_backup.go +++ b/seaweed-block/cmd/sw-block/volume_backup.go @@ -104,15 +104,15 @@ func volumeBackup(ctx context.Context, env verbEnv, o backupOpts, stdout, stderr again := fmt.Sprintf("sudo sw-block volume backup %s --name %s", o.Volume, shQuote(o.Name)) id := derivedID("backup", o.Volume, o.Name) if err := env.step(stdout, "snapshot", fmt.Sprintf("snapshot %s as %s (request %s)", o.Volume, shQuote(o.Name), id)); err != nil { - fmt.Fprintf(stderr, "sw-block volume backup: snapshot: %v; to finish, run the same command: %s\n", err, again) + fmt.Fprintf(stderr, "sw-block volume backup: snapshot: %v; a cut that timed out keeps what it uploaded; to finish, run the same command (it resumes the same request and reuses completed uploads): %s\n", err, again) return 1 } a, refusal, err := volumeSnapshot(ctx, env, e["SWB_STATUS_ADDR"], o.Volume, o.Name, id, o.Timeout) if refusal != "" { - return refuse("snapshot", refusal) + return refuse("snapshot", fmt.Sprintf("%s; a cut that timed out keeps what it uploaded; after correcting the refusal, run the same command (it resumes the same request and reuses completed uploads): %s", refusal, again)) } if err != nil { - fmt.Fprintf(stderr, "sw-block volume backup: snapshot: %v; to finish, run the same command (it resumes the same request): %s\n", err, again) + fmt.Fprintf(stderr, "sw-block volume backup: snapshot: %v; a cut that timed out keeps what it uploaded; to finish, run the same command (it resumes the same request and reuses completed uploads): %s\n", err, again) return 1 } fmt.Fprintf(stdout, "sw-block volume backup: snapshot %s of %s: head generation %d, cut LSN %d, at %s\n", diff --git a/seaweed-block/core/frontend/durable/provider.go b/seaweed-block/core/frontend/durable/provider.go index 89e4401359..e06cadc956 100644 --- a/seaweed-block/core/frontend/durable/provider.go +++ b/seaweed-block/core/frontend/durable/provider.go @@ -115,8 +115,10 @@ type ProviderConfig struct { OpenTimeout time.Duration // ChunkAssignmentTimeout bounds deferred startup waiting for a healthy, - // nonzero master assignment and attach. Local recovery returns first so - // the host can apply its assignment. Zero defaults to 30s. + // nonzero master assignment. Attach attempts use per-fetch bounds and + // recovery progress, not this total allowance; failed attempts check it + // before retrying. Local recovery returns first so the host can apply + // its assignment. Zero defaults to 30s. ChunkAssignmentTimeout time.Duration // ChunkMasterWait, when set, replaces ChunkAssignmentTimeout's fixed diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index fab1a4a412..c29e913bce 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -188,24 +188,20 @@ func (p *DurableProvider) chunkAuthorityWait(volumeID string, h *volHandle, gen 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 - // expired: the wait gave up (deadline, or a permanent refusal). Without - // ChunkMasterWait the deadline is the fixed limit from now; with it the - // host's bound, which does not run while the master gives no reply. + // expired: the wait gave up (deadline, or a permanent refusal). The + // bound is checked between attempts, never around growing attach work. expired := false - var waitCtx context.Context - var endWait context.CancelFunc - if p.cfg.ChunkMasterWait == nil { - waitCtx, endWait = context.WithTimeout(p.closeCtx, limit) - } else { - waitCtx, endWait = context.WithCancel(p.closeCtx) - } + // The assignment allowance is polled between attempts, just like the + // master's wait. It must not cancel an in-progress manifest read. + waitCtx, endWait := context.WithCancel(p.closeCtx) defer endWait() // gaveUp: a permanent refusal, or the host's one bound for this wait has // passed (the window opens at the first reply after this wait started; - // none while the master gives no reply or refuses the node). + // none while the master gives no reply or refuses the node). Without a + // master wait, use the fixed assignment allowance from this wait's start. gaveUp := func() bool { if p.cfg.ChunkMasterWait == nil { - return false + return !time.Now().Before(start.Add(limit)) } deadline, final := p.cfg.ChunkMasterWait(start) return final || (!deadline.IsZero() && !time.Now().Before(deadline)) @@ -220,8 +216,8 @@ 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)) why := "master wait ended" - if !expired { - why = waitCtx.Err().Error() // the fixed limit: context deadline exceeded + if p.cfg.ChunkMasterWait == nil { + why = context.DeadlineExceeded.Error() } h.backend.SetOperational(false, "chunk assignment unavailable: "+why) p.endChunkStartup(h, gen, nil) diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index 7d21261498..976d382ed6 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -218,7 +218,8 @@ 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 (including the source host; clean proof or forced-move lease barrier still required), 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 (`INV-WS-MASTER-WAIT-001`: 30 s of answered contact past the master's barrier time; no bound while the master gives no reply) or lease fence exits 75 after bounded cleanup; a typed master MOVED or DELETED refusal exits 78 at once (an issued moved source may be refused on subscription before any own assignment); 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` | +| Awaiting assignment / fenced | Process exited | Workspace chunk primary only: exhausted startup wait (`INV-WS-MASTER-WAIT-001`: 30 s of answered contact past the master's barrier time; no bound while the master gives no reply) or lease fence exits 75 after bounded cleanup; a typed master MOVED or DELETED refusal exits 78 at once (an issued moved source may be refused on subscription before any own assignment); 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-ATTACH-ASSIGNMENT-BOUND-001` | Without a master wait, the assignment allowance is checked between attach attempts; it never cancels a granted attempt's manifest read. Per-fetch bounds, recovery progress and provider Close still apply. | M1 Recovering -> Serving (wait scheduling only) | `DurableProvider.chunkAuthorityWait` | `TestDefaultAttachAt262144EntriesOutlivesAssignmentWait`, `TestRestoreDeferredAssignmentWaitEndsOnDeadlineAndClose`, `TestChunkGrantedAttachThatKeepsFailingIsBounded` | — (scheduling; authority guards unchanged) | ACTIVE | +| `INV-WS-STARTUP-RETRY-001` | | Expired | Moved (forced) | target may be the source host; 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-SAME-HOST-CLEAN-MOVE-001`, `INV-WS-FORCED-MOVE-001`, `INV-WS-LEASE-HORIZON-001`, `INV-WS-LOST-RANGE-READOUT-001`, `INV-WS-FORCED-CONFIRM-001` | | none, Granted, Revoking or Expired | Deleting | the chunk volume delete is admitted with `WorkspaceHolderState` = never started or deleting (`TERM-LIVE-HOLDER-001`): HEAD, read by blockmaster before its locks, is below the line's epoch, or already past the fence (deleting, purging, deleted: the rerun of a delete that stopped midway); no move pending. From then on renewals, grants, re-grants, revocations and moves of the volume are refused; the delete's HEAD compare-and-swap to deleting is its linearization point: a claim applied before it makes the delete refuse `volume_in_use` and give the reservation back, a claim after it fails. The lifecycle `DeleteVolume` reads no HEAD and keeps the ACK rule | `core/authority/workspace_holder_state.go` `WorkspaceHolderState`; `core/authority/workspace.go` `RecordWorkspaceDeletion`; `core/host/master/services.go` `MarkVolumeDeleting`, `deleteHolderEvidence`; `core/frontend/chunkstore/volume_delete.go` (HEAD to deleting) | `INV-WS-DELETE-NO-LIVE-HOLDER-001`, `INV-WS-CLAIM-BEFORE-SERVE-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` | @@ -1190,7 +1191,7 @@ One row per wait in the data and control paths. Guest-visible rows on one path m | `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 (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 | -| `core/frontend/durable/provider_chunk.go` `chunkAuthorityWait` (one goroutine per recovery of a workspace chunk primary awaiting authority) | a healthy projection (own assignment and a lease grant), then the HEAD claim | none while blockmaster gives no reply or refuses the node's credentials or identity (it serves nothing and holds no lease); otherwise max(the first reply after the local open and recovery, the master's barrier time) + 30 s; each attach attempt 30 s | the host's contact observations (`core/host/volume/master_wait.go`), provider Close, a later recovery | exit 75 `assignment_timeout`; 78 `moved` or `deleted` at once on a typed refusal | none: the bound is read on the 20 ms poll without `p.mu` or `h.attachMu` | no (no target listens) | +| `core/frontend/durable/provider_chunk.go` `chunkAuthorityWait` (one goroutine per recovery of a workspace chunk primary awaiting authority) | a healthy projection (own assignment and a lease grant), then the HEAD claim | none while blockmaster gives no reply or refuses the node's credentials or identity (it serves nothing and holds no lease); otherwise max(the first reply after the local open and recovery, the master's barrier time) + 30 s; without a master wait, 30 s for assignment; attach attempts have per-fetch bounds and progress, never a total deadline | the host's contact observations (`core/host/volume/master_wait.go`), provider Close, a later recovery | exit 75 `assignment_timeout`; 78 `moved` or `deleted` at once on a typed refusal | none: the bound is read on the 20 ms poll without `p.mu` or `h.attachMu` | no (no target listens) | | `core/frontend/chunkstore/layout/commit.go` `allOwnedBySession`, admission (`sem <-`, on the commit caller's goroutine) | a free slot among `commitVerifyParallel` (32) object lookups in flight | one lookup's duration: each admitted lookup honours the commit's context (`ObjectStore.Stat` returns on cancellation) and frees its slot when it returns | the admitted lookup's goroutine (`<-sem` on return) | none of its own: the caller's context ends the lookups; once any lookup fails, no further one is admitted | the caller's `LayoutRemote.mu` (`core/frontend/chunkstore/layout_remote.go` `CASHead`, `CommitPendingSnapshot` hold it across `RunCommit`); no HEAD-store lock | indirect: within the cut or snapshot deadline (5 min) | | `core/frontend/chunkstore/layout/commit.go` `allOwnedBySession`, join (`wg.Wait`) | every admitted lookup to return | the slowest admitted lookup, bounded by the commit's context | `allOwnedBySession` (it admitted them; it returns only after the join, so none outlives the call) | none of its own, as the admission row | the caller's `LayoutRemote.mu`, as the admission row | indirect: within the cut or snapshot deadline (5 min) | @@ -1208,6 +1209,7 @@ One row per fixed time limit on a volume's path that surrounds, or once surround | the cleaning pass (`boundedPass`) | the configured pass limit | listing and removing by page | yes | the pass resumes at its cursor; a session after a restart starts at the root page | the cleaning cursor's tests | | `core/host/volume/chunk_control.go` `chunkContext` (a chunk control operation: a cut, a snapshot or a detach, each of which takes a cut; the chunk status read also runs under it and reads one HEAD) | 5 min, or the request's shorter limit | the operation, including the cut it takes | yes | the cut's uploads, as the cut's row: an attempt that runs out of time keeps what it uploaded | STUB: no test at the control operation's level yet | | `core/host/volume/recovery_watchdog.go` (`--recover-timeout`), over `cmd/blockvolume/durable_startup.go` `openAndRecoverDurable` and the chunk layer's attach | 30 s without a new completed-work frontier, shared by recovery and attach | bounded local reads and final fence/publication; no total context around the per-entry recovery | the WAL scan, map copy and retained replay grow | a cumulative fixed-order phase/count high-water mark; repeated preparation cannot renew the clock; attach retries retain completed local recovery | `TestDurableStartup_LocalRecoveryWorkIsOutsideFixedDeadline`, `TestRecoveryMapCountsOneTiBEntriesWithoutATotalDeadline`, `TestRecoveryProgress_CountingEntriesOutliveTheTotalWindow`, `TestRecoveryReporterSlowReplayReportsBeforeTheEntryBatch`, `TestRecoveryProgress_RepeatedAttachPreparationDoesNotRenew`, `TestAttachProgressCountsEachAttemptFromZero` (attach integration); joint recovery+attach Linux qualification passed; ACTIVE (landed together); no 1 TiB time claim | +| `DurableProvider.chunkAuthorityWait`, without a master wait | 30 s by default, checked between attempts | waiting for assignment; failed attempts check the same allowance before retrying | no | an admitted attach uses the same per-fetch bounds and recovery progress as lease mode | `TestDefaultAttachAt262144EntriesOutlivesAssignmentWait` (262144 real manifest entries, 27 segments; full run exceeds the shipped 30 s) | | `core/frontend/durable/provider_chunk.go` `chunkAttachTimeout` | 30 s around each remote call of an attach (the attach check, the layout Start, the root fetch and each segment fetch of the manifest read), never around the attempt | each object fetch bounded; the fetch count grows (27 segments at 1 TiB); judged by the window | **yes** (the fetch count) | each completed segment and the attach's local entries report RecoveryAttach, per attempt from zero, under the shared window above | `TestAttachReportsItsVolumeSizedLocalWork` (the counting test, 262144 entries), `TestAttachManifestReadBoundsEachFetch`, `TestAttachGetHeadBoundsTheHeadRead`, `TestAttachRemoteCallsCarryTheirOwnBound`, `TestAttachManifestReadCarriesThePerFetchRule`, `TestAttachProgressCountsEachAttemptFromZero`; joint recovery+attach Linux qualification passed; ACTIVE (landed together) | Known limits of this table: what an attempt keeps is kept in the memory of one process. After a restart the cut uploads again what it cannot prove was uploaded; names are by content, so this costs time and no correctness. diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index aa0c679f6e..73911ca368 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -705,7 +705,10 @@ Perform a clean hand-over in this order: what happened, so a seal that runs out still answers within the timeout, aborted (nothing published, the volume serves again) or unknown. Busy admission refuses the operation. Do not proceed on any failure or - unknown outcome. JSON remains on stdout; a successful command also prints + unknown outcome. Rerunning the same seal keeps completed uploads and + advances the cut in the same holder process; for a large volume, rerun + the seal until it succeeds. Never bypass it with a revoke `--without-seal`. + JSON remains on stdout; a successful command also prints `sealed HEAD generation: G` on its own stderr line, taken from the same JSON `headGen` field on stdout. Copy the positive `G`. 3. Request revocation using that seal and the identity from `show`: