Files
seaweedfs/seaweed-block/docs/chunk-manifests.md
T
pingqiuandClaude Opus 5.5 c42dbc95a3 layout: a HEAD of a newer version is malformed to every caller, named as newer
ErrHeadNewerVersion now wraps ErrMalformed: every caller that refuses a
malformed HEAD for good refuses a newer one the same way (Start stays a
final refusal, never a retry loop), and its text says to use a newer
binary. The Start classification table pins it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 00:24:53 -08:00

4.9 KiB

Chunk upload and manifest format

blockvolume --durable-impl=walstore-chunk uploads dirty chunks in parallel. --chunk-upload-concurrency defaults to 8 and accepts 1 through 64; 1 selects serial upload. The setting applies to both capture and pre-copy. Segment size is a format constant: each segment covers one logical GiB.

HEAD format 1 remains readable. A volume's next cut upgrades it to format 2 in one ordinary fenced root CAS (including an otherwise no-op cut); generation advances once, with the ordinary epoch/holder/LSN checks. Old binaries cannot read format 2: deploy format-aware readers and GC before publishing new cuts. Downgrading a volume after its first format-2 cut is unsupported.

A format-2 HEAD contains lineage, chunk geometry/count, and immutable segment references, instead of a flat chunk map. Each segment contains a sparse map of chunk indices and SHA-256 references; missing indices mean ZERO. Unchanged ranges retain their exact segment keys. Data and segment keys are protected by cut intents before upload. A root is published only after its objects exist; an unknown root CAS retains the intents until reconciliation.

Segment keys are owner-qualified (@<volume>/seg/<nonce>); a segment's chunk references retain their source namespace. Snapshot/fork copies only the root. The fork's root alone keeps inherited segments/data live after deleting its parent snapshot. There is no separate segment claim or segment publication tombstone. Snapshot attempt tombstones and never-reused volume ids are unchanged. Reclaimed immutable key bindings keep the existing GC marker that prevents rebinding an old key.

GC traces HEADs, snapshot attempts and copy intents through their verified segments to data. It also marks segment objects themselves. A published segment that cannot be read or verified refuses the entire mark, in dry-run and apply; no chunks are deleted after an incomplete mark. Capture intents protect prospective keys directly, including not-yet-uploaded segments. The existing higher-epoch plus TTL rule, copy-target tombstone settlement, two marks separated by grace, upload age floor and unbound-needle retention remain. A collector adapter without blob reads can collect flat roots but refuses a segmented root rather than omitting its children.

Locks and cancellation

The existing cut/publication serialization is unchanged. Capture buffers and staged versions are selected as before; upload workers acquire no WAL, publication, shard or capture-state lock. Only the caller updates maps and counters after joining workers. The worker queue mutex guards admission and first error only, with no I/O under it. Failure cancels new admission and joins all owned calls before clean-abort intent cleanup. A remote ignoring cancellation can delay that join; it is never reported settled early.

HEAD record version and ext

The HEAD record's own version field is separate from the manifest format above. Absent (version 0) is the v1.0 record, decoded strictly as before. Version 1 (v1.1) adds current_bytes (the size of the current manifest: its root and every segment it names) and manifest_bytes per snapshot (written once, by the commit that names it). An absent size is unknown, never 0. A commit by change keeps current_bytes without lookups: it subtracts the base root and the segments it replaces and adds the new ones; an unknown size stays unknown. Snapshot listings report manifestBytes, null when unknown.

A binary refuses a HEAD with a version newer than it reads with "HEAD written by a newer version: use a newer binary". That refusal is a kind of malformed HEAD, so every final refusal of a malformed HEAD (a holder's Start among them) stays final for it, with no retry loop. Known top-level fields stay strict; a v1.0 record carrying a v1.1 field is malformed.

Upgrade order: every build from this version on reads a version-1 HEAD, but only a data plane on the draft v1.1 store format writes one; release builds keep writing version 0. A v1.0.x binary decodes HEAD strictly and refuses a version-1 record as malformed (it fails closed, it never rewrites it), so every reader of a volume, the control plane included, must run a version-aware build before any v1.1 writer touches that volume.

The ext contract: a v1.1 HEAD may carry one ext object, in its canonical bytes (compact JSON, as HEAD is encoded), which every writer keeps and re-emits byte for byte while it changes the known fields. An ext that is not an object, or not canonical, makes the record malformed. Ext holds only additive facts that such a writer cannot make wrong. A fact an older writer could invalidate by changing a known field without updating it bumps the version instead. Ext counts toward the 64 KiB inline limit, which Encode enforces. With the holder, claim, session and volume names at 64 bytes, the fullest v1.1 HEAD the other bounds allow is about 28 KiB; those names have no HEAD bound of their own, so this is a sizing check, not a proof.