Commit Graph
1012 Commits
Author SHA1 Message Date
Ping Qiu 6daca22e2f Merge pull request #123 from seaweedfs/feat/chunk-gc-copy-sweep
storage: settle copy intents through permanent publication claims
2026-11-15 10:33:48 -08:00
Ping Qiu c5283a6855 Merge pull request #112 from seaweedfs/feat/workspace-move-master
feat: guard RF1 workspace moves with durable journals and leases
2026-11-15 10:33:39 -08:00
Ping Qiu 81d338f7fe Merge pull request #120 from seaweedfs/blockc/repro-ship-lsn-seed
replication, durable: rebase the ship order after a restored host's frontier seed
2026-11-15 10:33:25 -08:00
Ping Qiu 257263e357 Merge pull request #107 from seaweedfs/feat/workspace-restore-head
durable: claim HEAD before empty-host restore and fence stale serving
2026-11-15 10:33:11 -08:00
Ping Qiu 49b726d6dd durable: remove successful write logging without weakening I/O drain (#105) 2026-11-15 10:18:02 -08:00
Ping QiuandClaude Opus 5.5 e048246c0a storage: capture-path intents (write before upload, settle after the CAS) (#122)
* storage: capture-path intent schedules (RED)

A cut that uploads writes an intent naming exactly its keys before the
first upload and deletes its own intent after the confirmed CAS; no
upload, no intent; a failed intent write uploads nothing; a failed
upload or a refused CAS deletes the intent; an unknown CAS outcome keeps
it until the next cut settles the proposal; a lost CAS response
confirmed by re-read deletes it; a failed delete is retried at the next
cut; other intents are untouched. The fake remote gains intent failure
hooks and records written intents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* storage: the capture path writes an intent before uploading and settles it

A cut that uploads chunks now writes one intent naming exactly the keys
it will upload, at the cut's base HEAD generation with the layer's epoch
and holder. The intent is durable before the first upload; if it cannot
be written, nothing is uploaded. A cut that only drops chunks writes
none.

The cut deletes only its own intent, once its outcome is settled:
- after the HEAD CAS succeeds, or a HEAD re-read confirms its proposal;
- on a clean abort: a failed upload, a refused admission, a fence, or a
  HEAD that moved past the CAS's base.

An unknown CAS outcome keeps the intent with the pending proposal. The
next cut deletes it once that proposal is settled, whether it landed or
can never land. A failed delete never fails a settled cut; the next cut
retries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:17:53 -08:00
Ping Qiu 18746f0e12 Merge pull request #119 from seaweedfs/w2/chunk-contract
storage, blockvolume, volume, sw-block: chunk control contract fixes (remote_lsn order, holder, codes, CLI errors, show)
2026-11-15 10:17:44 -08:00
Ping Qiu 55d45ef0bd Merge pull request #116 from seaweedfs/w2/chunk-cli
sw-block: ops chunk cut|snapshot|detach|snapshots|snapshot-delete|fork
2026-11-15 10:17:30 -08:00
pingqiuandClaude Opus 5.5 0fd9b1c3a8 durable: the ship-order rebase runs inside PrepareRestore, before the takeover CAS
A fresh host restoring an epoch-1 HEAD with an LSN-ordering observer
installed: at the takeover CAS the observer must already be rebased to the
seeded next LSN, and a refused post-seed rebase must fail the restore with
HEAD still owned by its previous holder and I/O refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:15:04 -08:00
pingqiuandClaude Opus 5.5 273ca809d8 durable: a refused observer rebase never leaves I/O open; seed and install serialized
SetWriteObserver published the observer first and only logged a refused
ship-LSN rebase, so the volume kept serving writes its observer would
mis-order.

Now:
- SetWriteObserver rebases an LSN-ordering observer to the store's next
  LSN before installing it. If the rebase is refused, the observer is
  not installed and the error is returned. The backend also records the
  fault and refuses every I/O until an install succeeds, so a later
  attach that marks the volume operational cannot reopen it. blockvolume
  reports the error.
- The frontier seed and its observer rebase run in one critical section
  with observer installs (observerMu). Whichever runs second sees the
  other's result; a seed landing between an install's rebase and its
  publication can no longer leave the observer on the old LSN. A refused
  rebase after the seed records the same fault.
- RebaseShipLSN documents that it moves only the ordering cursor:
  entries already dispatched to peer queues carry lower LSNs and are
  untouched.

The composition test checks the install error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:15:04 -08:00
pingqiuandClaude Opus 5.5 ea4f986b67 durable: a refused observer ship-LSN rebase keeps I/O closed (RED)
An observer whose RebaseShipLSN is refused at install must not be
published with I/O left open: the next write must be refused. A later
install whose rebase succeeds reopens I/O.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:14:54 -08:00
pingqiuandClaude Opus 5.5 d7d1718358 replication, durable: rebase the ship order after a restored host's frontier seed
A ReplicationVolume orders writes from the store's next LSN, captured
when it is built. On a restored walstore-chunk host the frontier seed
moves that LSN to HEAD.remote_lsn+1 later, during the deferred attach.
The resequencer then waited forever for the LSNs below it, and writes
and flushes hung.

Whoever moves the next LSN now tells every component that cached it:
- ReplicationVolume.RebaseShipLSN(lsn) moves the ship order forward. It
  is refused while any write is pending or in flight, never dropping
  one, and never moves backwards; an equal LSN is a no-op.
- The provider calls it through the backend's observer right after
  SeedChunkFrontier, before the layer attaches and the volume serves
  I/O.
- StorageBackend.SetWriteObserver rebases a newly installed observer
  to the store's next LSN, covering a seed that landed before the
  observer was installed (blockvolume installs it after
  SetReplicationVolume, while the attach is still deferred).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:14:54 -08:00
pingqiuandClaude Opus 5.5 53e76f75c0 volume: restored-host write after the frontier seed (RED)
A fresh walstore-chunk host restoring from a remote HEAD, in the
production order of cmd/blockvolume, with the real RF=1
ReplicationVolume as the backend's write observer:
1. Recovery runs before the master's assignment is visible, so the
   chunk layer attach is deferred.
2. blockvolume builds the ReplicationVolume, which captures the store's
   next LSN.
3. The replayed assignment lets the deferred attach claim HEAD and seed
   the frontier to HEAD.remote_lsn.
4. A frontend write and flush then wait forever for LSNs below the
   seeded frontier to be shipped.

The control differs only in having no remote HEAD, so nothing is
seeded; it writes and flushes fine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 10:14:36 -08:00
pingqiu 8fa8cd5243 fix(gc): accept final W2 aborted tombstones without published-attempt metadata 2026-11-15 10:12:53 -08:00
pingqiu 82a73daff1 docs(gc): document permanent copy claims and W2 capture integration 2026-11-15 10:11:40 -08:00
pingqiu 4e54d2cfe8 test(gc): bind fencing controls to the initialized W2 HEAD version 2026-11-15 10:11:40 -08:00
pingqiu 03e8253885 test(gc): cover fork claims, unnamed snapshot grace and unknown settlement 2026-11-15 10:11:40 -08:00
pingqiu 0aa9344cfe feat(gc): settle dead copy intents through permanent final-target claims 2026-11-15 10:11:40 -08:00
pingqiu 68f98a0ff5 test(gc): require permanent snapshot claim before releasing dead copy intent 2026-11-15 10:11:40 -08:00
pingqiu b26dcade9a docs(gc): record lock order, conservative retention and first-slice evidence limits 2026-11-15 10:11:40 -08:00
pingqiu 5198672a08 fix(gc): retain epochless catalog copy intents and validate blob deletion responses 2026-11-15 10:11:40 -08:00
pingqiu 9206e11319 test(gc): correct directory fixture create result 2026-11-15 10:11:40 -08:00
pingqiu 4ff1211d6d test(gc): cover fencing, snapshot roots, failed marks and restart safety 2026-11-15 10:11:40 -08:00
pingqiu 68e211a5d9 fix(gc): root live upload intents and require authoritative epoch fencing for expiry 2026-11-15 10:11:40 -08:00
pingqiu d3de789471 test(gc): expose missing in-flight intent protection in initial collector candidate 2026-11-15 10:11:40 -08:00
pingqiu 7408341630 merge accepted W2 contract 0826d84 with capture intents 15e98ba 2026-11-15 10:11:40 -08:00
pingqiu 6f7ab89ac3 feat: bind guarded workspace moves to qualified HEAD holders 2026-11-15 10:05:23 -08:00
pingqiu a9e515798f fix: restore seeded frontier and reactivate detached HEAD before serving 2026-11-15 10:05:23 -08:00
pingqiuandClaude Opus 5.5 0826d846db chunkstore: decide from one read of the entry acted on
Review of the attempt-scoped layout (one rule for both P1s: the decision
comes from ONE read of the entry acted on, and success from re-reading the
entry the operation tried to create):
- EnsureVolume decides a fork's attach from one HEAD read: absent and
  aborted both refuse (fork_incomplete), so a sweep between two reads can
  no longer pass an aborted HEAD.
- Fork decides from the HEAD it re-reads after its create: a real HEAD
  completes the fork; an aborted tombstone means the fork lost to a sweep
  (target_exists, its intent dropped, the tombstone is permanent); an
  unreadable HEAD after a refusal is retryable, never a replay.
- A snapshot completes from its own attempt entry, never by resolving the
  reusable name again; a snapshot tombstone carries no attempt stamp, so it
  is never taken for this attempt's create.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:55:30 -08:00
pingqiuandClaude Opus 5.5 9f597b111a chunkstore: attempt-scoped snapshot publication; fork HEAD tombstones
W5 ruling (2026-11-15 17:30Z), W2 part: a GC sweep settles a dead copy
attempt by claiming the operation's final publishing entry with an aborted
tombstone, and every attempt publishes to a target that is never freed.

- Snapshot: the name is taken by an exclusive name record
  snapnames/<name> {request, attempt}; the intent names the attempt
  (holder "snapshot:<vol>/<name>/<attempt>"); the snapshot is published by
  an exclusive create at snaps/<name>/<attempt>. A retry of the same
  request publishes to the same attempt path. List and Fork resolve names
  through the record and skip aborted or unpublished attempts.
  DeleteSnapshot marks the attempt deleting (or claims an unpublished
  attempt's path with a tombstone) and removes the name record, freeing
  the name; attempt paths are never removed, so a late insert always
  fails. Catalog.AbortSnapshot(vol, name, attempt) is the sweep's claim.
- Fork: the publishing entry is the target's HEAD. Catalog.AbortFork
  claims it with an aborted HEAD tombstone (state "aborted", gen 1, no
  chunks); a fork whose HEAD is a tombstone never attaches
  (fork_incomplete) and its replay is target_exists.
- The copy-intent deadline stays as metadata only.

A deleted snapshot no longer holds its name: it is no longer listed (even
with includeDeleting) and a fork of its name is snapshot_not_found; its
attempt entry stays for GC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:43:37 -08:00
pingqiuandClaude Opus 5.5 15e98ba7ee storage: the capture path writes an intent before uploading and settles it
A cut that uploads chunks now writes one intent naming exactly the keys
it will upload, at the cut's base HEAD generation with the layer's epoch
and holder. The intent is durable before the first upload; if it cannot
be written, nothing is uploaded. A cut that only drops chunks writes
none.

The cut deletes only its own intent, once its outcome is settled:
- after the HEAD CAS succeeds, or a HEAD re-read confirms its proposal;
- on a clean abort: a failed upload, a refused admission, a fence, or a
  HEAD that moved past the CAS's base.

An unknown CAS outcome keeps the intent with the pending proposal. The
next cut deletes it once that proposal is settled, whether it landed or
can never land. A failed delete never fails a settled cut; the next cut
retries it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:19:07 -08:00
pingqiuandClaude Opus 5.5 22b53ce945 storage: capture-path intent schedules (RED)
A cut that uploads writes an intent naming exactly its keys before the
first upload and deletes its own intent after the confirmed CAS; no
upload, no intent; a failed intent write uploads nothing; a failed
upload or a refused CAS deletes the intent; an unknown CAS outcome keeps
it until the next cut settles the proposal; a lost CAS response
confirmed by re-read deletes it; a failed delete is retried at the next
cut; other intents are untouched. The fake remote gains intent failure
hooks and records written intents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:18:33 -08:00
Ping Qiu 5389a441ff perf(storage): reuse already durable WAL sync generations (#106)
* test(storage): count physical WAL syncs for paired TCP Flush commands

* perf(storage): deduplicate already durable WAL generations

* test(storage): gate concurrent sync cut and conservative bypass controls

* test(nvme): verify Flush ACK survives process crash and retain barrier gates

* test(storage): join crash helper diagnostics before reading

* test(storage): reproduce recovered partial batch reusing stale sync coverage

* fix(storage): invalidate sync coverage after partial append and recovery

* docs(storage): distinguish recovery invalidation from direct-path bypass
2026-11-15 09:10:34 -08:00
Ping Qiu 87098238c5 Merge pull request #115 from seaweedfs/w2/chunk-http
volume, durable, blockvolume: /chunk/* control routes and the VOLUME attach check
2026-11-15 09:10:24 -08:00
Ping Qiu b15faeea96 Merge pull request #111 from seaweedfs/w2/catalog-fork-detach
chunkstore, storage: snapshot catalog, fork, detached HEAD and Detach
2026-11-15 09:10:11 -08:00
Ping Qiu 2c535811e4 Merge pull request #110 from seaweedfs/w2/chunkstore-list-delete-qualified
chunkstore: filer list and conditional delete, owner-qualified keys, intents seam
2026-11-15 09:09:57 -08:00
Ping Qiu 1c0892981d Merge pull request #108 from seaweedfs/w2/chunk-cut-result
storage: chunk Cut returns the installed HEAD; typed capture refusals
2026-11-15 09:09:41 -08:00
pingqiuandClaude Opus 5.5 e1da68753b chunkstore: copy intents record their deadline; the publish is bounded by it
W5 ruling (2026-11-15 17:06Z), W2 part: a snapshot or fork copy intent
records its absolute publication deadline (DeadlineNs: the read time plus
OpDeadline); the deadline is re-checked immediately before the publishing
exclusive create, and that create runs under a context bounded by the same
deadline, so it never publishes after it. GC may then expire a copy intent
by its recorded deadline (plus RPC timeout and grace) instead of by epoch.
The re-read that settles an ambiguous create keeps the caller's context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 09:09:36 -08:00
Ping Qiu c29f7706a9 Merge pull request #114 from seaweedfs/blockc/chunk-provider-swfs-r6
durable: walstore-chunk provider with a SeaweedFS chunk remote
2026-11-15 09:09:27 -08:00
pingqiuandClaude Opus 5.5 122321b9e0 durable: a layer fenced at attach fails recovery and never serves
Integration ruling F2: when the chunk layer attaches fenced (HEAD belongs
to a newer epoch or another holder, e.g. another server serving the same
replica), RecoverVolume fails with ErrChunkLayerFenced and the volume stays
non-operational, before anything can serve; the deferred authority attach
does not enable I/O either. HEAD is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 07:44:09 -08:00
pingqiuandClaude Opus 5.5 fb939771f6 storage, chunkstore: a fresh volume starts with an initial HEAD and an empty bitmap
Integration ruling F1(a):
- Catalog.EnsureVolume (the attach check) gives a created volume its
  initial HEAD with the VOLUME entry: gen 1, epoch 0, no holder,
  remote_lsn 0, no chunks (all zero), by exclusive create. An existing HEAD
  is kept (a volume published before VOLUME entries), and a missing one is
  created on the next attach.
- A fresh local volume (FreshFromHead) without a saved bitmap starts with
  an empty bitmap bound to HEAD instead of hash mode: it took no write
  before its first attach, so its image is HEAD's. Its first cut uploads
  only the chunks written. Hash mode stays for an existing volume whose
  bitmap is lost (F1(b)'s background reconciliation is separate work).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 07:44:09 -08:00
pingqiuandClaude Opus 5.5 4c25191694 sw-block: ops chunk show
Prints one volume's VOLUME entry and HEAD from the filer (B9 W2 §0.1 and
appendix 2026-11-15 14:30Z): {volumeID, volume, head}, each null when it
does not exist; a HEAD without a state shows as active. Catalog.ReadHead
reads the HEAD; the show body lives with the other shared API bodies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:17:18 -08:00
pingqiuandClaude Opus 5.5 341c80b2fb sw-block, volume: errors are the JSON error body on stdout
ops chunk failures print {code,message,retryable} on stdout, the same body
the routes answer (relayed as-is for an HTTP error), with a log line on
stderr and a non-zero exit (2 for usage errors) (B9 W2 appendix,
2026-11-15 14:30Z). CLI-side failures use the routes' codes: bad_request
for usage, remote_unavailable (retryable) when blockvolume or the filer
cannot be reached, internal otherwise; catalog refusals keep their code.

Messages no longer repeat the code: CatalogError.Detail is the message
and cause without it, used by the routes and the CLI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:15:09 -08:00
pingqiuandClaude Opus 5.5 f947bd4063 volume, chunkstore: lsn_behind, closing 409 after detach, invalid_label, no cut stats
Contract revisions from integration (B9 W2 appendix, 2026-11-15 14:30Z, and
the rulings of 14:09Z):
- a cut behind HEAD's remote_lsn answers lsn_behind (409, not retryable);
- a detached layer answers closing with 409 (it stays closed until a new
  attach); a closed layer (process shutdown) stays closing 503;
- an invalid label is invalid_label (400), and SnapshotReplay validates
  labels and consistency with the name and request id, so a bad request is
  refused before any cut;
- the /chunk/cut body omits the cut statistics until W3 fills them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:12:20 -08:00
pingqiuandClaude Opus 5.5 e483d45728 blockvolume: HEAD holder is <server-id>/<replica-id>
The replica id alone made two hosts that both serve replica r1 look like
the same holder returning, so the later one was not fenced (B9 W2
appendix, 2026-11-15 14:30Z). blockvolume now passes
<server-id>/<replica-id> as the provider's ChunkHolder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:11:08 -08:00
pingqiuandClaude Opus 5.5 b06bf7dc45 storage: HEAD's remote_lsn never decreases
A cut whose LSN is below the base HEAD's remote_lsn is refused before any
upload (ErrChunkCaptureRefused with ErrChunkLSNBehind; the expected gen
pins that base HEAD), unless that HEAD belongs to a newer holder, which
fences as before. MemChunkRemote refuses a lowering CAS too (B9 W2
appendix, 2026-11-15 14:30Z).

Until LSN continuity across hosts exists, a fresh, migrated or forked
volume cannot cut or detach; the carry-forward must merge before or with
this check. Tests that model a host continuing from a seeded HEAD now
advance the local log to that HEAD's remote_lsn first, as the
carry-forward will.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:11:08 -08:00
pingqiuandClaude Opus 5.5 95b6b7d62e sw-block: ops chunk never exits 0 with its result lost
An HTTP response over the 64 MiB limit is refused (read limit+1) instead of
being relayed truncated, and every result write checks for a failed or
short write, for the route commands and the filer commands alike. There is
no retry of the operation: the error says the result was not relayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:51:12 -08:00
pingqiuandClaude Opus 5.5 399d3a8ead sw-block: ops chunk cut|snapshot|detach|snapshots|snapshot-delete|fork
The walstore-chunk control plane on the command line (B9 W2 §0.1, §3):
- cut, snapshot and detach call a blockvolume's /chunk/* routes
  (--status-addr, with --chunk-control-endpoint); the request carries
  timeoutMs and the client waits a little longer;
- snapshots, snapshot-delete and fork read and write the filer directly
  (--chunk-filer, --chunk-path), so they work while the volume is offline;
- snapshot and fork generate a request id when none is given and print it
  on stderr for a retry; --label k=v repeats;
- stdout carries the operation's JSON body (the route's, or the shared
  list/delete bodies, or the fork result with remoteLSN); a failure prints
  "<code>: <message> (retryable=...)" and exits 1; usage errors exit 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:35:16 -08:00
pingqiuandClaude Opus 5.5 0c5ea94830 chunkstore: the snapshot list and delete bodies as shared API types
SnapshotListItem / SnapshotListBody (exactly B9 §3.3's fields) and
SnapshotDeleteBody move from the volume routes to chunkstore, so the
sw-block CLI, which reads the filer directly, emits the same bodies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:35:16 -08:00
pingqiuandClaude Opus 5.5 f94b20724b durable, volume: one owned drain, one handle lookup, one JSON object per request
- StopIO keeps one pending drain per backend; every StopIO waits on it,
  so timed-out detach retries behind a held I/O no longer each leave a
  goroutine waiting for the admission lock.
- CutVolume resolves the volume's handle and layer in one critical section
  (chunkHandle) and keeps that handle: a Close that empties the volume map
  mid-call no longer leaves the minLSN check reading a missing handle.
- A /chunk/* request body must be exactly one JSON object: trailing data
  is bad_request before any operation runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 05:34:42 -08:00