Commit Graph
1551 Commits
Author SHA1 Message Date
Ping Qiu 22fe6eae01 Merge pull request #207 from seaweedfs/fix/workspace-lease-trigger
volume: name the cause when the workspace lease guard fences (#205)
2026-11-18 07:42:09 -08:00
Ping Qiu ce589edaa7 Merge pull request #203 from seaweedfs/docs/cow-cut-design
docs: propose copy-before-write for the cut window, with its TLA+ model
2026-11-18 07:42:02 -08:00
pingqiu 80ba50dfd2 test(replication): pin WAL across both two-replica catch-up sessions 2026-11-18 07:22:56 -08:00
pingqiuandClaude Opus 5.5 6f5710a11b spec(workspace): record the WorkspaceTakeover rerun for the durable horizon (#205)
All 27 W4_*/RED_* configurations re-run against the model at 7dd83eb6
(TLC 2.19, BFS): existing passes still pass, the new horizon
configurations pass with failing extension writes and a restart,
RED_hz_noclamp violates HostWithinHorizon as expected, the existing REDs
and witnesses keep their verdicts, the two large and the two "both"
configurations reached their time limits with no violation, and the two
open findings (W4_drift, W4_forced_exact) are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 07:12:54 -08:00
pingqiu d4ebc48ef7 test(durable): handle caller expiry before recovery reaches the remote 2026-11-18 06:15:52 -08:00
pingqiuandClaude Opus 5.5 7dd83eb6c0 spec(workspace): model the durable lease horizon in WorkspaceTakeover (#205)
lease.exp is now the published horizon, dhz the horizon on disk and
deadline the latest grant. A renewal of a live lease writes nothing:
grant = min(now + TTL, horizon), refused while uncertain or without
validity, and it may trigger an extension. The extension (MasterExtend)
is an ordinary serialized writer that raises the horizon to
trigger + TTL + HSlack; with ExtFail its write may fail without landing or
after landing, and either way latches uncertain. Revocation, ACK and move
writes are refused while uncertain; a restart reloads the disk horizon and
clears uncertainty. The revoking drain reply is clamped to
min(horizon, deadline). Nondecreasing time is stated as a model assumption.

New invariants HostWithinHorizon and DiskCoversMemory; witnesses
W_NoExtension, W_NoExtLanded, W_NoUncertain. New cfgs W4_hz_* (failing
extensions, clean/forced/both, one restart) and RED_hz_noclamp (no clamp:
EXPECTED to violate HostWithinHorizon) with the control
RED_hz_noclamp_safety (no clamp, split-brain invariants: expected to pass,
the restart rule covers grants). Existing cfgs gain Clamp = TRUE and
ExtFail = FALSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:28:45 -08:00
pingqiuandClaude Opus 5.5 42e828a14c test(workspace): strengthen the concurrency control, bound held-write cleanup (#205)
Review folds, tests and docs only:
- The combined concurrency control now requires its schedule: a bounded
  handshake holds the first horizon-extension write inside the store
  while renewals keep succeeding and the writers and Close are in flight
  behind it, then releases it. It counts successful grants per eligible
  volume and extension writes classified by content (a raised horizon at
  the same epoch, not an ordinary writer's record) and requires both.
- It adds the forced-move arm next to the clean move: the forced volume
  is granted at an earlier injected time, so its horizon + skew barrier
  has passed when the writers run; the clock only moves forward.
- Held-write controls install their release cleanup before the hold is
  triggered, bound every admission and completion wait, and on any
  failure release, settle workers with bounded joins and only then close
  fixtures.
- Docs: an uncertain volume refuses renewals that would issue a new or
  extended grant; a Revoking lease still gets its bounded drain reply,
  min(horizon, deadline), never extended, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:22:00 -08:00
pingqiuandClaude Opus 5.5 c74f8d1afb fix(workspace): no mutual recursion between renewal and first grant (#205)
If another writer created the lease after the renewal read the view, the
first-grant path now returns a retryable error instead of re-entering the
memory path. The host has no deadline before its first grant, so a failed
first renewal does not fence it; its retry takes the memory path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:07:26 -08:00
pingqiuandClaude Opus 5.5 dfd65907d4 test(workspace): log unrounded renewal timings in r1-r5 (#205)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:01:45 -08:00
pingqiuandClaude Opus 5.5 521e1e8cb2 docs(workspace): invariants and lease docs for the durable horizon (#205)
- invariants.md: M2 lease rows (first grant writes the horizon, renewal
  from memory under a clamp, revoking reply carries the grant, expiry
  and forced barrier on the persisted horizon); new rows
  INV-LEASE-VIEW-001, INV-WS-LEASE-HORIZON-001,
  INV-WS-RENEW-NONBLOCKING-001 and INV-LIFECYCLE-SNAPSHOT-001;
  INV-WS-FORCED-MOVE-001 now names the horizon and the reply clamp.
- INV-AUTH-UNCERTAIN-001 moves from STUB to ACTIVE: its renewal reader is
  documented, and the ambiguous-extension control now also asserts that
  a revocation and an endpoint change of the uncertain volume are
  refused.
- Proof-text folds: the forced-barrier argument assumes nondecreasing
  master time, an assumption of the current WorkspaceTakeover model,
  not a consequence of time.Now's monotonic reading; the horizon
  invariant treats an ambiguously persisted issued successor (lease
  cleared) as the ordered clean-handoff or forced-barrier case.
- agent-workspace-design.md section 7 and workspace-lease.md: the
  master side of a renewal, the extension, the capacity bound, the logs.

The WorkspaceTakeover specification is not changed here; its update and
recorded configuration results are a later acceptance step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 05:00:43 -08:00
pingqiuandClaude Opus 5.5 31b911dac7 test(workspace): safety controls for the lease horizon (#205)
GREEN-gating controls for the memory-only renewal:
- grants clamp to the durable horizon under a permanently stalled
  store, renewals without host validity or at the horizon are refused,
  and a real guard fences by horizon - skew/2;
- a restart honours the persisted horizon in the forced barrier;
- an extension whose rename landed but whose directory sync failed
  latches uncertainty, refuses the next renewal, and reloads with the
  landed horizon barring a forced move until horizon + skew;
- an extender held inside its write orders a same-volume revocation or
  forced move after it;
- same-volume renewals during held revocation and forced-move writes;
- the lease view equals derive(published) after every writer kind;
- N volumes renew concurrently with apply, revocation, ACK, a clean
  move, extenders and Close (run with -race);
- Close joins a held extender, and an extender admitted before closing
  writes nothing;
- lifecycle snapshots follow every records change, stay immutable, are
  read without the store mutex, and keep a protective unknown outcome;
- through the services layer, query and revoke replies report the
  grant, and a renewal during a held same-volume reservation returns
  the revoking lease.

The r1-r3 slow-store wrappers count the delayed writes and require at
least one, so a green cannot bypass the injected stall. Tests that own
a Publisher directly join its extenders before their store closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:58:54 -08:00
pingqiuandClaude Opus 5.5 a4fd1303ef fix(workspace): answer lease renewals from memory under a durable horizon (#205)
A renewal of a live workspace lease persisted the new expiry with a
temp-file fsync under the publisher's global lock, and the renewal RPC
also read two lifecycle stores whose mutexes writers hold across file
I/O. A slow or busy master disk therefore made the host's 2 s renewal
RPC time out, the guard fence and the volume shut down.

Renewal now takes only a small leaf lock (leaseMu) over a per-volume
lease view and does no I/O:
- grant = min(now+TTL, durable horizon), where the horizon is the
  published Lease.ExpiresAtNS; the deadline is raised to the grant.
- It refuses stale, pending-move, expired, uncertain or storeless
  state as before (never bypasses INV-AUTH-UNCERTAIN-001), and refuses
  with an error when the grant would leave no positive host validity.
- The first grant of a lease still writes synchronously under p.mu and
  persists horizon = now + 1.5*TTL.
- A per-volume single-flight extender is an ordinary p.mu writer: it
  writes horizon = trigger + 1.5*TTL through persistWorkspaceLocked, so
  its write and publication are one p.mu section; any write error
  latches uncertainty as before.

Writers keep persist-before-publish and refresh the view (p.mu ->
leaseMu, the only new lock edge) at every derive-input change.
Revocation and query replies report the granted expiry, never the
horizon. Host.Close joins extenders before the store closes.

The renewal RPC reads lock-free immutable snapshots of the Volumes and
deletion-reservation stores, republished at every records change
(including load, delete and the protective unknown outcome).

Behaviour change: a forced move now waits for the durable horizon plus
skew, at most TTL/2 later than before. Existing tests that read the
persisted lease as the grant, or waited only grant + skew, are updated
with that reason. The store-write boundary guard now skips _test.go
files: a test double that delays and delegates Put is not a production
write caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:58:54 -08:00
pingqiuandClaude Opus 5.5 1193cb751b test(workspace): reservation persist hook and RED for renewal behind a held lifecycle write (#205)
Add DeletionReservationStore.SetPersistHookForTest, an instance-local
test seam that installs the existing write-fault hook under the store
mutex (nil by default).

r5: while the deletion-reservation write of an unrelated volume is held
in that hook, a renewal through the services layer must return within
2 s. On main it waits on the reservation store's mutex.

r4 and r5 now release held writes first and settle every worker with
bounded waits before clearing hooks or closing fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:42:15 -08:00
pingqiuandClaude Opus 5.5 c5192fc4c1 test(workspace): RED for renewal blocked by an unrelated held write (#205)
r4: while the revocation write of volume a is held inside the
authority store, a renewal of volume b must return within 2 s.
On main the renewal waits on the publisher's global lock until a's
write is released.

Tests only; no fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:23:12 -08:00
pingqiu 731b1118eb test(replication): retain WAL for both RF2 catch-up sessions across checkpoint 2026-11-18 04:23:00 -08:00
pingqiu fbd33f9712 test: restore native typed cut controls and close activation isolation coverage 2026-11-18 04:16:20 -08:00
pingqiuandClaude Opus 5.5 c902547a44 volume: name which limit a late renewal reply missed
Review fold for #207: a valid reply that lands after the renewal call's
context ended, while the old lease and the new grant are still valid, was
recorded as "arrived after the lease deadline". The refusal is unchanged;
the cause now says which limit the reply missed: the lease deadline, its
own grant, or the call's context (with the lease's remaining validity).
Adds a bounded regression where the reply lands just after the 2s call
timeout with a 20s lease.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:12:40 -08:00
pingqiuandClaude Opus 5.5 75490ef76c test(workspace): RED for lease renewal waiting on a slow authority store (#205)
A renewal of a live workspace lease persists the new expiry with a
temp-file fsync under the publisher's global lock. When the master's
disk is slow, the host's 2 s renewal RPC times out, the guard fences
and the volume shuts down.

- r1: one renewal behind a 2.5 s store write must return within 2 s.
- r2: six concurrent renewals behind 0.5 s writes must not serialize.
- r3: a real WorkspaceLeaseGuard must not fence while the store takes
  2.5 s per write (TTL 6 s).

Tests only; no fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:03:52 -08:00
pingqiuandClaude Opus 5.5 aa6b0cecc8 volume: say which limit a failed renewal reached; keep the cause on a failed stop
Review fold for #207:
- A failed renewal now logs whether the call reached the lease deadline,
  the 2s per-call timeout, or neither, so a slow master is told apart from
  a lease that ran out.
- A stop that fails after a fence returns an error that names the fence
  cause and wraps the stop error; after a renewal expiry or an invalid
  reply both the renewal error and the stop error are kept (errors.Is).
- Tests assert the first cause wins, the fence is logged once, the cause
  carries the exact deadline, and a late revoking reply keeps the
  late-reply cause.
- The #205 test comment states the renewal-failure trigger as a hypothesis
  that matches the code path, not a diagnosis the logs proved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 04:02:23 -08:00
pingqiuandClaude Opus 5.5 6896463a44 volume: name the cause when the workspace lease guard fences
The guard fenced silently: when renewals kept failing until the lease
expired, it drained the volume through blockvolume's lease-stop path, which
logged nothing, and returned the raw RPC error (issue #205).

- Every fence records its first cause: lease expired without a successful
  renewal, expired after a failed renewal (with the renewal's latency and
  error), an invalid reply, a reply that arrived after the deadline,
  revocation by the master, or shutdown. The guard logs it once as
  "workspace lease: fenced ...", FenceCause() returns it, and the non-ACK
  drain error carries it.
- Every failed renewal is logged with its latency and the lease deadline,
  also when the lease is still valid: a run of them is the warning before
  an expiry fence.
- An expiry after a failed renewal returns "workspace lease expired:
  renewal failed after <d>: <err>", wrapping the RPC error.
- blockvolume logs when it stops because the guard requested the drain.

The fence behaviour itself is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:50:08 -08:00
pingqiu a81bca4926 feat(storage): activate mapped v3 through the production storage callers 2026-11-18 03:49:47 -08:00
pingqiuandClaude Opus 5.5 dc877aa4b5 volume: RED: a workspace lease fence must name its cause
Issue #205: under sustained write load a volume fenced because its lease
renewals kept failing until the lease expired, and nothing said so. The
shutdown path logged nothing; the only trace was the raw RPC error printed
at closeout. The fence itself is correct.

Two tests fail on main:
- a renewal that times out past the lease deadline fences (as today), but
  the returned error must say the lease expired and keep the RPC error,
  and the fence and its cause must be logged;
- a renewal that fails while the lease is still valid must be logged with
  its latency (it does not fence).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 03:48:38 -08:00
pingqiu 8bdaf88f66 fix(storage): serialize WAL reuse with dirty retirement and revalidate catch-up reclamation 2026-11-18 03:38:12 -08:00
pingqiu f578d109b5 fix(sparrow): bound repeat cleanup to the actual map file format 2026-11-18 02:37:27 -08:00
pingqiu aa5ab59457 fix(storage): retain only post-HEAD WAL dirt in v3 capture candidates 2026-11-18 02:26:41 -08:00
pingqiu eb14704197 fix(sparrow): clean the owned persist demo map on repeat runs 2026-11-18 02:25:34 -08:00
pingqiu 79c6b0014c fix(storage): expose actual v3 flusher record stage accounting 2026-11-18 02:14:25 -08:00
pingqiu 833a97925f fix(storage): hold the creator lock through descriptor publication and ownership transfer 2026-11-18 02:04:10 -08:00
pingqiu 169923df83 fix(storage): reclaim covered v3 WAL prefixes through both slots 2026-11-18 01:40:01 -08:00
pingqiu 0fe8b00efc fix(storage): exclude offline migration from v3 open owners 2026-11-18 01:00:15 -08:00
pingqiu 5d3a11f910 fix(storage): close v3 catch-up BASE source lifetime gaps 2026-11-18 00:43:07 -08:00
pingqiuandClaude Opus 5.5 883b455134 docs: COW design, review fold 2: owner references through all I/O
Step 6 counted only saved-chunk readers. A saving writer and a copier
reading the live chunk also do I/O outside the per-chunk mutex, so an abort
or Close could see zero references and delete the side store while they
were still in I/O. Now every saving or copying owner holds a window
reference from its state claim until its I/O ends, readers hold one too,
abort does not wait for its caller's own reference (a self-aborting owner
releases first), Recover/reset/Close join every owner and reader before
their destructive transition, and the side store is deleted exactly once
at a terminal state with no reference outstanding. The test list names the
held saving owner and held live-copy owner cases. Text only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 22:18:56 -08:00
pingqiuandClaude Opus 5.5 451fa936a7 docs: COW design, review fold: pre-publication save, owners, abort protocol
Design review of the copy-before-write proposal, folded in one revision:
- the COW step runs before publication and outside store.mu (right after
  captureMu shared, before lifecycleMu/mu, the WAL append and the dirty-map
  insert), because the save uses the ordinary read path; a post-publication
  hook cannot do this; lock order stated;
- one owner per chunk (copier: pending -> copying -> done; writer:
  pending -> saving -> saved), a per-chunk mutex never held across I/O,
  waiters on a per-chunk condition;
- batches visit chunks in ascending index and finish each before the next,
  so they cannot deadlock with each other or the copier;
- terminal states closed or aborted; abort on save error, cancel, fence,
  and before Recover/reset/Close in the same open, taken before the
  mutation proceeds; waiters woken; the cut fails retryable and keeps its
  dirty set; a guest write is never refused for a cut problem;
- the side store is deleted only after close/abort with its refcount at
  zero; upload, manifest and CAS work from the buffers, so an unknown CAS
  keeps today's semantics;
- BASE: capMu stays held for the whole cut and already excludes
  Begin/EndBaseInstall (the earlier open point is removed);
- reads bind to the format-v3 read path, no flusher hook;
- the Model paragraph states what the model does not cover (owner races,
  batch order, abort), and the test list grows to match.

Text only; the TLA+ model is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 22:13:36 -08:00
pingqiuandClaude Opus 5.5 4408dd8ee1 docs: propose copy-before-write for the cut window, with its TLA+ model
The cut copies every candidate chunk under the capture barrier, so writes
stall for the whole copy (1.50 s at 3 GiB dirty in a lab measurement).
agent-workspace-design.md section 5 now has a proposed (not implemented)
copy-before-write design: the barrier only fixes H and the candidate set;
the first write to an uncopied candidate saves its at-H content to a local
side store; a write to a chunk being copied waits; the copier reads the side
store or the live chunk; the side store is dropped at the CAS and on crash,
and recovery never reads it. Alternatives, the open BASE-install point, and
the tests to write with the code are listed. Section 14's cut-cost gap
points at it.

docs/spec/CutCOW.tla (S4c) models today's barrier cut and the design, with a
two-step chunk copy and one crash. Both pass exhaustively at MaxLSN 6 with 2
cuts (COW 34,342,214 states, barrier 5,070,320). Each of the six design rules
is necessary: dropping any one violates BufFrozen. 11 configs, run.sh and
the spec README updated; all 13 specs pass SANY with tla2tools 1.7.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 22:02:53 -08:00
pingqiuandClaude Opus 5.5 3ecde2ccc9 fix(storage): v3 ScanLBAs is all or nothing (review P1s)
ScanLBAs on v3 now returns entries only when the trusted chain covers the
whole captured range [fromLSN, head): a chain that stops short is a WAL
integrity failure carrying the scanner's stop cause (CRC, binding,
truncation), a chain that starts after fromLSN is WALRecycled, and a
missing LSN mid-range is an integrity failure. Nothing is emitted before
the check.

An installing source is refused with ErrBaseInstalling before emitting.
The capture (recover generation, descriptor, head) is taken under s.mu
and revalidated after the scan, with no lock held across the callbacks;
a transition during the scan retries from a fresh capture, and a source
that began installing meanwhile is refused.

Controls: corrupt middle and first records (store), an installing
source, an install begun during a held scan, a Recover during a held
scan (retry), and a corrupt middle record through the actual catch-up
sender (the session does not close successfully).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 21:58:51 -08:00
pingqiuandClaude Opus 5.5 88d52b76c1 feat(storage): v3 ScanLBAs, the primary's catch-up source
The 12b census found WALStore.ScanLBAs walking only the v2 WAL writer, so
a v3 primary served no catch-up: every catch-up shipped nothing and the
replica then refused the next live LSN as an unanchored gap. On v3 it now
scans the trusted v3 chain from the selected descriptor's scan start
(after the unchanged retention gate): a write record is one entry, a
batch record one entry per block with consecutive LSNs, every LSN in
[fromLSN, head), in LSN order. If the WAL no longer holds fromLSN it
refuses with the typed WALRecycled failure (the caller rebuilds) rather
than skip a range; today no v3 tail release exists, so that guard is
defensive until one lands.

Controls: the store scan (singles and a batch, from the start and from
mid-batch, the retention refusal) and the actual catch-up sender from a
v3 primary to an empty v3 replica (byte-identical). Mutants: the v2 scan
on v3, a batch emitting only its first block. The missing-fromLSN guard
has no discriminating control until a v3 tail release exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 21:44:06 -08:00
pingqiuandClaude Opus 5.5 af0e3d7210 feat(storage): v3 ordinary replicated ApplyEntry (codex03 12a inventory)
Ordinary replicated ApplyEntry was still refused (errV3NotYet) on dark
v3, while its real callers are the replica's MsgShipEntry handler
(replica.go) and the ReplicaApplyGate's recovery and live lanes. It now
shares one body with the install-lane apply (applyEntryV3, DESIGN 8.1,
6.7, r16.1): through the v3 writer in LSN order; an LSN at or below the
highest appended is a superseded no-op when the LBA holds a higher LSN
and ErrWALLSNOrder otherwise; an unanchored gap is refused (recovery
needs a contiguous prefix); and an ordinary apply while installing is
refused with ErrBaseInstalling (the install lane is the handle's).

Controls: the store rules and a crash; the real ship handler on a v3
replica (apply, barrier ack, crash and reopen; an out-of-order entry
ends the connection); the real apply gate (recovery lane with its
stale-skip, live lane). Mutants: ApplyEntry refused on v3, no gap check,
no installing refusal. The store's order check alone is equivalent: the
v3 writer refuses the same LSN with ErrWALLSNOrder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 21:24:48 -08:00
Ping Qiu b33a0d67f6 Merge pull request #202 from seaweedfs/docs/snapshot-sharing-and-freeing
docs(design): how versions share chunks and how an old snapshot's data is freed
2026-11-17 21:18:29 -08:00
pingqiu 238aa54b02 fix(durable): withhold chunk publication until owner attachment commits 2026-11-17 21:06:20 -08:00
pingqiu 16c913e32b fix(durable): retain BASE until provider attachment is durably committed 2026-11-17 20:53:02 -08:00
pingqiuandClaude Opus 5.5 e69c54de17 feat(storage): the provider's durable chunk-attach commit lifts the BASE deferral (row 12a)
codex03's row 12a retirement-timing seam, store half: a completed BASE
must not retire while the provider's fresh-from-HEAD marker could still
make a reopen seed from HEAD over the completed local bytes.

- CommitChunkAttachV3(commit) runs the provider's commit (the marker
  removal and directory fsync; no store re-entry) under installMu
  exclusive, and only when it succeeds records this open's durable
  attach and lifts the retirement deferral of an installed volume. A
  failed commit changes nothing.
- OwnerChunkAttachDurableV3 reports that flag (atomic); Defer resets it at
  every managed open; a begin re-arms the gate but keeps the flag.

New edge: the provider's attachMu -> installMu; the store takes no
provider lock. Not a v3 store: commit only.

Control: the commit runs under installMu exclusive; a failed commit sets
no flag and the volume stays installed; a successful one retires it on
the next publication; Defer resets the flag. Mutants: lifting on a
failed commit, not recording the flag, committing outside installMu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:46:27 -08:00
pingqiu fd2ea05307 fix(durable): defer BASE retirement until local presence is durable 2026-11-17 20:35:12 -08:00
pingqiuandClaude Opus 5.5 7b47dd72ff feat(storage): an opt-in gate that defers BASE retirement (row 12a retired-BASE)
Descriptor-owner ruling on codex03's row 12a retired-BASE RED (6f545aad):
once a completed BASE retires to none, nothing durable tells the provider
that the local image is complete rather than a lazy seed. Retirement may
now be deferred, opt-in per store, so the installed descriptor stays that
evidence until the chunk layer has durably recorded local presence:

- DeferBaseRetirementV3 (the provider, at open, before Recover and any
  publication) and AllowBaseRetirementV3 (the chunk layer, after durable
  local presence) set an atomic gate on the publisher;
- retireBaseV3 is skipped while the gate is deferred; once allowed,
  retirement happens on the next ordinary publication;
- every successful begin re-arms a lifted deferral, so a later install in
  the same open needs its own durable presence before it may retire.

The publisher only reads the atomic under descMu: no new lock edge, no
format or durable field. Stores that never set the gate retire as
before, so a volume without a chunk layer cannot be stuck installed.

Control: a deferred store stays installed through publications whose
8.4 conditions hold, retires on the first one after Allow, and a second
install in the same open is deferred again. Mutants: a publisher that
ignores the gate; a begin that does not re-arm it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:26:34 -08:00
Ping Qiu c9c0e1fdbc Merge pull request #201 from seaweedfs/feat/chunk-cut-stats-body
volume: return the cut's statistics in POST /chunk/cut
2026-11-17 20:21:02 -08:00
pingqiuandClaude Opus 5.5 173df33abd docs(design): how versions share chunks and how an old snapshot's data is freed
agent-workspace-design.md:
- section 3: a HEAD, a snapshot and a fork root are each a complete map
  (no backing chain, no per-layer bitmap); a cut uploads only changed
  chunks and rewrites only their segments; the dirty bitmap is local
  holder state, not part of a snapshot; a worked example (100 chunks,
  init, 20 rewritten, snap1: 120 objects, deleting init frees 20).
- section 6: the GC roots line now says what the code does: a deleted
  snapshot's attempt stays a root for one grace period after its delete
  time (Collector.snapshotAttemptHeads), then stops counting.
- section 6: freeing an old snapshot's data in three steps (delete the
  name, GC --apply with two marks a grace apart, SeaweedFS volume vacuum)
  with the timing at the default grace, and why GC uses a reachability
  mark rather than reference counts.

No invariant row changes (INV-GC-REACHABLE-001 already covers attempts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 20:04:50 -08:00
pingqiuandClaude Opus 5.5 e4135b9668 fix(sw-block): refuse bad migration geometry before any write (row 13b P1, P2s)
codex01 review of 7c6a29d8:

- P1: ValidateMigrationV3 lacked the checked extent end, so an aligned
  geometry whose extent end overflows passed, the backup and the map were
  written, and only the slot validation refused. The geometry check now
  applies the same bounds (volume, extent, block, the checked WAL and
  extent ends, the file end within MaxInt64), and the tool runs it, and a
  file-size bound on the v2 WAL, before the WAL is read or anything is
  written.
- P2: the scan allocated the v2 WAL size from the superblock before any
  bound; it is now bounded by the file size first, with no wrapping sum.
- P2: a rerun that found the v2 chunk bitmap already renamed skipped the
  directory fsync an earlier run may have failed; it now fsyncs it.

Controls: an overflowing extent end, a WAL past the file end and a WAL
size whose sums wrap are each refused with no byte written; a retirement
whose directory fsync failed is made durable by the rerun. Mutants: no
checked file end, no file-size bound, the rerun skipping the fsync. The
WAL-region overflow check alone is equivalent: the file-size bound also
refuses that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:22:05 -08:00
pingqiu 12e9536674 test(durable): retain real batch caller and reopen completed local BASE 2026-11-17 18:06:42 -08:00
pingqiu 4a9d33f6f1 docs(storage): record dark chunk BASE transition guards and lock graph 2026-11-17 18:02:51 -08:00
pingqiu f732290a2d Merge offline migration row13b into chunk BASE adaptation 2026-11-17 18:02:51 -08:00
pingqiu 8ab2266cb7 test(storage): keep BASE incomplete on presence failure and join close 2026-11-17 17:59:44 -08:00