Files
seaweedfs/seaweed-block
cccad8d5ce seaweed-block: a stale metadata change cannot land on a re-created intent page (filer chunk condition, page re-read as fallback) (#13457)
* seaweed-block: red: a snapshot delete is published over a page whose data was freed

Two overlapping runs of one snapshot delete write their intent pages under
the same tag. If the first run's stalled page update lands between the
second run's read of a page and its adoption (after a cleaning pass
deleted and the second run re-staged the page), the second run adopts and
publishes an intent whose page data was freed: later snapshot deletes on
the volume are refused and its cleaning stops.

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

* seaweed-block: a snapshot delete re-reads each intent page after adopting it

Publication reads every intent page, adopts it under this run's tag, then
publishes. A stalled update from another run of the same delete can land
between that read and the adoption and put a deleted page's data reference
on the entry. Reading the page again after the adoption, before the
transition publishes, refuses that case: once this run's tag is on the
entry, no such update passes. No persisted change; a run that hits it
stays refused, and a new request id writes new pages.

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

* seaweed-block: ledger row for the intent page re-read

INV-SNAPSHOT-DELETE-ADOPT-002 names the re-read after adoption, its test
and the model row it projects (PublishedReadable; the refused run is the
residue a new request id clears).

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

* seaweed-block: the intent page re-read: typed refusal, twins and a store witness

Review: the re-read test now separates the guard from weaker ones. A page
that reads but holds other bytes, and a change to only the later of two
pages, are refused as well as a freed page; the refusal is a precondition
that writes nothing to HEAD, keeps the snapshot, and comes after the
adoption; the same schedule with intact bytes publishes. The test is a
consequence-level projection; a store-level witness shows the tag-only
metadata update writing a deleted object's chunk over a re-created one,
which the re-read does not depend on refusing. The ledger row names the
witness and marks the model as checked outside the repository.

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

* seaweed-block: the intent page re-read keeps its error's cause

The refusal wrapped the re-read's error with %v, so a caller deadline
that ended the re-read reached the CLI as a precondition ("page changed
during adoption", no_progress) instead of deadline_exceeded, unlike the
same deadline on the chain's first read. Wrap both errors.

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

* seaweed-block: the intent page re-read sees only data the filer already freed

The filer frees a deleted entry's chunks, and the chunks an update drops,
from its deletion queue: polled every 1.123 s, and retried after 5 min
when a volume server does not answer. A stale update that puts such a
reference on an adopted page therefore reads back intact while the
deletion is still queued, and the intent publishes over data that is
freed moments later. The intact-bytes twin publishes for that reason.
State that bound in INV-SNAPSHOT-DELETE-ADOPT-002 and at the guard
instead of "changed or vanished ... refuses the publication".

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

* seaweed-block: the delete intent publication row and diagram carry the re-read

Part C rule 2 moves a changed guard's Part A row and diagram with it.
The publication row now names the re-read after adoption and
INV-SNAPSHOT-DELETE-ADOPT-002, and the M9 diagram gains the transition's
idle and snap self-loops, which it lacked.

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

* seaweed-block: red: a stale adoption or mark lands on a re-created object

A metadata change writes the looked-up entry back, chunks included,
conditional only on its tags: paused between its lookup and its update, it
lands on an object deleted and created again with the same tags in between,
puts the deleted object's chunk on it, and a cleaner's stale mark then
deletes it. The filer's IF_CHUNKS_EQUAL condition refuses such a write.

This commit adds the plumbing and the tests, not the guard itself:
- the filer protocol subset gains WriteCondition (IF_CHUNKS_EQUAL) on
  UpdateEntryRequest; SWFS sends it through UpdateEntryIfChunks, and the
  fakes evaluate it (or drop it, as an older filer does);
- a startup probe sends a mismatched conditional update to the disposable
  probe HEAD; only a definite refusal turns the guard on for the stores the
  catalog opens. The startup log and /status/chunk (metadata_guard) name it.
The two guard tests fail here: changeMeta does not send the condition yet.

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

* seaweed-block: metadata changes send the filer's chunk condition

With the guard on (the startup probe saw the filer enforce it), an
adoption or mark sends IF_CHUNKS_EQUAL with the looked-up entry's chunk
fids. A re-created object always has a new chunk, so a stale whole-entry
write is refused instead of putting a deleted object's chunk on it; a
cleaner's delete expects its own mark and so follows. Without the guard
the write is unchanged and the intent page re-read stays the check.

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

* seaweed-block: ledger rows for the chunk condition and its probe

INV-LAYOUT-META-CHUNKS-001 (adoption and mark under IF_CHUNKS_EQUAL) and
INV-WS-CHUNK-CONDITION-PROBE-001 (the startup probe decides it, the log
and /status/chunk name it); ADOPT-002 names the renamed store test.

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

* seaweed-block: the chunk probe without a definite refusal leaves the guard off; fallback wording

Review: the existing failure cases stop at the HEAD gate. New cases pass
the gate and then fail only the chunk condition probe (unavailable, lost,
deadline, filer error, vanished entry, failed HEAD read): the catalog, its
stores, the startup log and the usage all stay on page_reread_only.
page_reread_only now reads as enforcement not established, not as a filer
without the condition; INV-SNAPSHOT-DELETE-ADOPT-002 cites MetaABA r2's
delayed-free counterexample, r1 kept as historical scope.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-12-05 11:29:24 -08:00
..
2026-04-11 14:21:09 -07:00

Seaweed Block

tag CI Go License

Local-first block storage for AI agents.

Run locally. Persist incrementally. Resume anywhere.

Seaweed Block gives each agent sandbox or microVM its own block disk on the host's local storage, and checkpoints the changed data to your own SeaweedFS. Writes and fsync complete locally; checkpoints, named snapshots and restores carry the workspace's state beyond that host. High density per host is a design goal; see Vision.

Quick start · How it works · Project status · Documentation

The Seaweed Block lifecycle. Run locally: agent VMs on host A write to the host's local disk, where writes and fsync complete with no network round trip. Persist incrementally: checkpoints send only the changed 4 MiB chunks to your SeaweedFS in the background, and named snapshots share those chunks. Resume anywhere: host B restores a snapshot into a new volume, or takes a volume over in a planned move; it serves at once and fetches chunks on first read. Normal I/O to locally available data stays on the host.

Why not just use...

Local disk Conventional network block storage Seaweed Block
Where writes and fsync complete On the host Typically on a remote storage service On the host
Network in the I/O path No Typically, for every read and write No, for data on the host; a restored or moved volume fetches chunks on first read
If the host is lost The state is lost with it The volume typically survives The state survives up to its last confirmed checkpoint
Resume on another host Copy the data yourself Typically, detach the volume and attach it there Move the volume there, or restore a snapshot into a new volume there (placed by the cluster spec)
What persistence sends Nothing Typically every write, as it happens Only the whole 4 MiB chunks that changed, at each checkpoint

Three ways to give an agent VM a disk. Local disk: all I/O stays on the host, fast, but the state is tied to that host. Network block storage: I/O typically crosses the network to a remote volume, so the state outlives the host, but the network is in the I/O path. Seaweed Block: normal I/O to locally available data stays on the host's local disk, and changed chunks go to your SeaweedFS in the background, so it runs at near-local speed and the state outlives the host up to its last checkpoint.

Run, checkpoint, snapshot, restore

  1. Run. Start a volume on the host where the agent runs. The guest attaches it over NVMe/TCP or iSCSI, formats it with its own file system, and works at near-local speed.
  2. Checkpoint. The changed chunks go to your SeaweedFS: on demand (sw-block ops chunk cut), periodically (the holder's --chunk-capture-interval, 5 minutes or more), with the default daily snapshot, and when you stop the volume (sw-block volume stop).
  3. Snapshot. sw-block volume backup <volume> --name <name> (or sw-block ops chunk snapshot) names a point in time. Snapshots share chunks with each other.
  4. Restore. A restore makes a new volume from a snapshot, on the host that its placement in the cluster spec names. It serves at once and fetches chunks on first read.

The commands and what each needs: snapshots, restore and verification.

Features

  • Near-local speed for agent workloads. Writes and fsync complete on the host's disk, with no network round trip, and every guest fsync reaches it.
  • Any file system, unchanged tools. The guest sees a plain block device, so git, npm and builds run as on a local disk.
  • Incremental checkpoints. Only the changed 4 MiB chunks upload: on demand, periodically, or with the daily snapshot.
  • Snapshots and instant restore. Named snapshots share chunks, and a restored volume serves before its data arrives.
  • Safe moves between hosts. Epochs and leases fence the old host, so a stale host cannot publish over the workspace's state.
  • Self-hosted and open source. Your data stays in your SeaweedFS. Apache-2.0, written in Go.

Use cases

  • AI coding agents whose repositories, dependencies and build caches must outlive the sandbox.
  • Agent sandboxes and microVM platforms that give each sandbox its own disk.
  • Long-running agents that stop, resume and move between hosts.
  • Also: Kubernetes block volumes through the CSI driver (alpha), and replicated volumes for workloads that need synchronous copies (sync-quorum, sync-all; preview).

One engine, two durability profiles

Agent workspaces are the focus. The same block engine (write-ahead log and extent, NVMe/TCP and iSCSI frontends, blockmaster's epochs) also runs replicated volumes, for workloads that need copies on other hosts before fsync completes (sync-quorum, sync-all).

Checkpointed volume Replicated volume (preview)
Built for Agent workspaces: many independent, portable disks Workloads that need online copies on other hosts
When fsync completes Once the data is on the host's local disk With sync-quorum or sync-all, once a quorum or every replica has it (the default best-effort waits for none)
After a host is lost An operator's forced move continues from the last checkpoint in SeaweedFS With --cluster-spec and the lifecycle loop enabled (--lifecycle-product-loop-interval, off by default), blockmaster fails a sync-quorum or sync-all volume over to a replica when its fencing round decides; the operator then starts the guest on the new primary's host (no path failover in the guest). best-effort is not failed over automatically; the operator's forced failover may lose the last acknowledged writes
Snapshots, restore, moves Yes Not yet: the two profiles cannot be combined in v1.1.x
Status in v1.1.x Supported Preview, with known limits

The two biggest limits of the preview: a replica that falls behind the retained log needs a manual re-add, and a primary cut off from blockmaster is not stopped by a lease, so it may serve stale reads and, under best-effort, accept writes that are later lost. Do not use replicated volumes for data you cannot lose.

A workload chooses the durability it needs: a checkpointed workspace does not pay for synchronous replicas, and a replicated volume does not wait for checkpoints.

Performance

Time on Seaweed Block relative to a local disk, over NVMe/TCP loopback: npm ci 1.00, git clone 1.02, untar 100,000 files 1.04, cold find and stat 0.97, 2,000 create plus write plus fsync 1.52, guest fsync median 1.31.

Metadata-heavy agent work runs at local-disk speed, timing the operation itself (with the guest's final syncfs, 11-23% slower); fsync latency and fsync-bound work are 1.3 to 1.5 times local. These are lab runs of pre-release builds (the first four rows on the walstore engine, the last two on walstore-chunk) on Firecracker microVMs over NVMe/TCP loopback, median of 3: measurements, not SLOs. Every number and how it was measured, with the build where it was recorded: workspace measurements.

Quick start

A trial on a disposable Linux host, not for data you keep. You need nvme-cli, sudo, and SeaweedFS's weed binary, tested with SeaweedFS 4.53 (from its release page, asset linux_amd64.tar.gz, which holds the one weed binary).

TAG=v1.1.1
curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/sw-block-$TAG-linux-amd64.tar.gz
curl -fsSLO https://github.com/seaweedfs/seaweed-block/releases/download/$TAG/SHA256SUMS
sha256sum -c --ignore-missing SHA256SUMS && tar -xzf sw-block-$TAG-linux-amd64.tar.gz
export PATH="$PWD:$PATH"     # so the sw-block commands that mini prints run as shown
./blockvolume --version      # must print the tag's commit
# blockvolume keeps one lock per volume here, so only one live process serves a volume on a host:
sudo install -d -m 0755 -o root -g root /run/sw-block
sudo install -d -m 0755 -o "$USER" -g "$(id -gn)" /run/sw-block/locks
./sw-block mini --dir ./swb-mini --weed /path/to/weed

A failed start leaves --dir behind: start again with a new --dir, or on the same one with --reuse.

What it shows today:

  • mini starts weed mini, blockmaster and one blockvolume: volume v1, 256 MiB, on loopback.
  • It never runs sudo itself. It prints the nvme connect command that attaches v1, and the status, check and snapshot commands. After the connect, sudo nvme list shows the disk's device (for example /dev/nvme0n1).
  • Snapshots of v1 work at once, through the sw-block ops chunk snapshot command it prints. A scheduled sched-<time> snapshot also appears soon after the start. A restore into a new volume does not run inside mini yet; use the standalone setup for it.
  • To stop: unmount v1, run the sudo nvme disconnect that mini printed, then press Ctrl-C.

Next:

How it works

  • Local execution. blockvolume serves the guest's block device over NVMe/TCP or iSCSI on the same host. A write lands in a local write-ahead log, and fsync completes once the data is on the host's disk. The log then drains into a local extent.
  • Incremental persistence. A checkpoint (a cut in the CLI and the manuals) uploads the volume's changed 4 MiB chunks to SeaweedFS. It then advances the volume's HEAD root with a conditional update on its generation and epoch. A snapshot names a root and shares chunks with the others, with no backing chain.
  • Recovery and mobility.
    • A restore makes a new volume that serves at once and fetches each chunk from the snapshot on first read.
    • One blockmaster issues epochs and leases, and the holder of a checkpointed (single-replica) volume serves only under its current lease.
    • A planned move first seals the volume with a final checkpoint, then revokes the old holder, waits for its recorded release, and grants the next epoch on the new host, which loads chunks on first read.
    • The store refuses a HEAD update from a stale holder, even before that holder notices it was replaced.

Write path: a microVM writes over NVMe/TCP or iSCSI to blockvolume, which completes write and fsync on its local WAL. Background path: a checkpoint uploads changed 4 MiB chunks to SeaweedFS and updates HEAD on generation and epoch; blockmaster issues epochs and leases; a stale holder's update is refused.

More: agent workspace design, volume lifecycle, and the TLA+ specifications of the protocols where a bug would lose data.

Durability model

Level Reached when Where the data is What it protects against
Local synced the guest's fsync returns the holder host's disk a crash or restart of the processes on that host
Remotely checkpointed a checkpoint is confirmed (after its commit in SeaweedFS) SeaweedFS the loss of the host: a forced move continues from the last confirmed checkpoint
Named snapshot a snapshot command answers ok SeaweedFS, kept by name a restore into a new volume at that point (in v1.1.x, not for a snapshot of a restored volume)
  • Writes since the last confirmed checkpoint are lost if the host is lost.
  • The default schedule is one snapshot a day. It is attempted, not guaranteed, and it is not a recovery-point objective. Periodic checkpoints (--chunk-capture-interval, 5 minutes or more) shorten the window. A persistent agent should checkpoint at its task boundaries.
  • sw-block volume stop takes a checkpoint by default (--no-cut skips it). A holder stopped any other way (systemctl stop, a kill, or the loss of its host) takes none.
  • No production SLO, RPO or RTO is claimed. Details: operator guide.

Project status

Capability v1.1.x
Local single-replica volumes (walstore-chunk) Supported
NVMe/TCP and iSCSI Supported; in a standalone setup the guest runs on the holder's host
Incremental checkpoints Supported
Named snapshots and lazy restore into a new volume Supported
Planned moves between hosts (operator-run, fenced) Supported
Volumes up to 1 TiB Supported; above 256 GiB only at format level 1 (new clusters start at it; upgraded clusters run sw-block cluster finalize-format) and only after every host runs v1.1
Replicated volumes (replication_factor above 1) Preview: no snapshots, restore or moves; a replica that falls behind the retained log needs a manual re-add (limits)
Kubernetes CSI Alpha; in v1.1.x deleting a PVC may leave its volume behind, and that volume cannot be removed until v1.2
Remote guests in a standalone setup, authenticated remote NVMe/TCP Not in v1.1.x
Templates, instant fork Not in v1.1.x

Use tagged releases only: main is unreleased work. Each release's conditions are in the capabilities table and the release notes.

Vision

Directions, not commitments; no dates.

  • Lightweight execution: more volumes per host and less overhead per volume.
  • Instant workspaces: shared templates, fast creation, branching.
  • Continuous persistence: efficient rolling checkpoints.
  • Portable state: recovery, migration and resume across hosts with less operator work.
  • Storage efficiency: remote space that is reclaimed and reused, and rolling persistence with low write amplification.
  • Flexible durability: replicated volumes out of preview, and replicas combined with checkpoints and snapshots in SeaweedFS.

Documentation

To Read
Try it, run the services, restore a snapshot Standalone deployment
Install, upgrade, finalize, monitor, read typed errors Operations manual
Size a host, choose a recovery point, handle host loss Operator guide
Move, revoke, delete Volume lifecycle
Run on Kubernetes (alpha) Kubernetes quick start, Kubernetes status
See what each release supports Capabilities, release notes
Check the numbers Workspace measurements
Read the architecture and formal specifications Agent workspace design, core design, TLA+ specifications

Community and license

Questions and bug reports: GitHub Issues. To build and test: go build ./... && go vet ./... && go test -short ./... (the unit checks; CI also runs the process-level suite). Seaweed Block builds on SeaweedFS. License: Apache-2.0.