Files
seaweedfs/seaweed-block/docs/releases/one-process-per-volume.md
T
pingqiuandClaude Opus 5.5 4c36f1f861 durable: lay out a created lock directory as tmpfiles.d does
A missing /run/sw-block is created 0755 and the locks directory 0700, with
the modes set explicitly (the umask cannot narrow them); existing
directories are left alone. The cure line also names the parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:10:34 -08:00

3.8 KiB

One live process per volume per host

A blockvolume with a durable root takes an exclusive, non-blocking lock on /run/sw-block/locks/<volume id>.lock before it opens the volume's store, and holds it until the volume closes. A second blockvolume for the same volume on the same host is refused before it opens anything, whatever its --durable-root. The lock is released when the process exits, including on a crash or kill.

blockvolume creates the directory when it is missing and it may, laid out as the tmpfiles.d entry does (/run/sw-block 0755, /run/sw-block/locks 0700), and refuses to start when it cannot create or open the directory or a volume's lock file. The shipped units cannot create it (ProtectSystem=strict), so install the tmpfiles.d entry shipped in deploy/systemd/sw-block.tmpfiles.conf:

sudo install -m 0644 deploy/systemd/sw-block.tmpfiles.conf /etc/tmpfiles.d/sw-block.conf
sudo systemd-tmpfiles --create /etc/tmpfiles.d/sw-block.conf

It creates /run/sw-block/locks as 0700, owned by sw-block, at every boot. Both shipped units allow writes to it (ReadWritePaths=-/run/sw-block/locks). Without it, or when it is not usable, blockvolume exits at start with host volume lock directory unavailable ... install the tmpfiles.d entry (deploy/systemd/sw-block.tmpfiles.conf), or make its parent directory traversable (0755) and chown the directory and its lock files to this process's user. A directory created by a root process (the root ublk unit, or blockvolume run by hand as root) is root-owned, and an unprivileged unit on that host then cannot use it: install the tmpfiles.d entry, or chown the locks directory to the unit's user and make sure /run/sw-block is 0755. Lock files are opened read-only, so a lock file another user created stays lockable.

A rolled-back copy of a root is refused

An existing local root attaches only if its local durable LSN reaches the remote_lsn of the HEAD it attaches under. A copy of a root taken before a later cut (a backup, a snapshot of the disk, an older replica of the directory) is below that HEAD: it is refused with ErrChunkStaleLocalRoot, never serves, and its process exits 78 (no automatic restart) with the root kept; its last line is exiting status=78 reason=superseded cure="remove or quarantine the local root to attach fresh from HEAD".

A power loss does not trigger this refusal on a correct root: a cut makes its LSN durable on the local root (the barrier sync, an fsync or fdatasync of the WAL) before the HEAD update that publishes it as remote_lsn, so the root is never below the HEAD it published.

Do not

  • Do not start a second blockvolume for a volume on any host while one runs. The lock covers one host only. Two hosts are kept apart by the master's assignment and the workspace lease, not by this lock.
  • Do not restore a local root from a copy. A copy taken after the root's last cut has the same LSN as HEAD, attaches, and loses the writes the original acknowledged after the copy was taken (in its local WAL, not yet cut). No local check can see that. Restore from the remote image (the sealed or latest HEAD).
  • Do not copy or move a local root to another host or another --durable-root and start it there while the original may still run.
  • Do not delete /run/sw-block/locks or its lock files while blockvolume runs: a new process would then get a different lock file and not see the running one.
  • Do not run blockvolume in containers or mount namespaces that do not share the host's /run/sw-block/locks. /run is per mount namespace: the lock is per host only if that directory is the host's (a hostPath mount). The Kubernetes renderer (core/launcher/k8s_renderer.go) and deploy/k8s manifests do not mount it yet: there, the lock is per pod.