Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f948410e11 | ||
|
|
6179c6a03b | ||
|
|
615163658f | ||
|
|
c1c7679a29 | ||
|
|
b063945815 | ||
|
|
1041f38efe | ||
|
|
e987ffb8f3 | ||
|
|
31867a5b0a | ||
|
|
cb46aee067 | ||
|
|
32d1b6eaf7 | ||
|
|
5577472124 | ||
|
|
489862a4fe | ||
|
|
b0053091fd | ||
|
|
aa12233a31 | ||
|
|
d8b8ddf7db | ||
|
|
083458fef7 |
No files matched your search
@@ -1,4 +1,6 @@
|
||||
# Exact repository-relative path<TAB>Module.Action; repeat a path for alternatives.
|
||||
# FormatGate.Finalize: BeginFormatFinalize checks and sets its memory-only intent atomically under Publisher mu + leaseMu; the durable raise holds neither lock.
|
||||
# FormatGate.Grant: grants/regrants and deadline-extending renewals require GrantReport (a current process report) during intent and at level 1.
|
||||
cmd/blockvolume/snapshot_operation_shutdown.go SnapOps.Stall
|
||||
cmd/sw-block/chunk.go CutTime.Poll
|
||||
cmd/sw-block/cut_progress_poll.go CutTime.CliGiveUp
|
||||
@@ -18,7 +20,11 @@ cmd/sw-block/volume_verbs.go CutTime.CliGiveUp
|
||||
cmd/sw-block/volume_verbs.go CutTime.Poll
|
||||
cmd/sw-block/workspace_show.go MoveAdmission.ReadForMove
|
||||
core/authority/authority.go DeleteRetire.RetireLine
|
||||
core/authority/authority.go FormatGate.Finalize
|
||||
core/authority/authority.go FormatGate.Place
|
||||
core/authority/authority_store_file.go DeleteRetire.RetireLine
|
||||
core/authority/format_finalize.go FormatGate.Finalize
|
||||
core/authority/format_finalize.go FormatGate.Grant
|
||||
core/authority/workspace.go HolderInterface.ForcedMove
|
||||
core/authority/workspace.go HolderInterface.PlannedMove
|
||||
core/authority/workspace.go MoveAdmission.Ack
|
||||
@@ -34,6 +40,9 @@ core/authority/workspace.go StopAndRestart.LeaseEnds
|
||||
core/authority/workspace.go StopAndRestart.ReadForced
|
||||
core/authority/workspace_delete_reservation.go MoveAdmission.DelCheck
|
||||
core/authority/workspace_delete_reservation.go MoveAdmission.Reserve
|
||||
core/authority/workspace_lease_v100.go FormatGate.Finalize
|
||||
core/authority/workspace_lease_view.go FormatGate.Grant
|
||||
core/authority/workspace_lease_view.go FormatGate.Renew
|
||||
core/authority/workspace_lease_view.go HolderInterface.Grant
|
||||
core/authority/workspace_lease_view.go HolderInterface.Regrant
|
||||
core/authority/workspace_retirement.go DeleteRetire.RetireLine
|
||||
@@ -208,9 +217,11 @@ core/host/master/product_loop.go Promotion.Decide
|
||||
core/host/master/services.go FormatGate.Report
|
||||
core/host/master/spec_retirement.go DeleteRetire.ReadOK
|
||||
core/host/master/spec_retirement.go DeleteRetire.RetirePlace
|
||||
core/host/master/store_attestation.go FormatGate.Finalize
|
||||
core/host/master/store_attestation.go ReplicationPeer.Attest
|
||||
core/host/master/workspace_binding.go FormatGate.Grant
|
||||
core/host/master/workspace_binding.go FormatGate.Place
|
||||
core/host/master/workspace_binding.go MoveAdmission.Ack
|
||||
core/host/master/workspace_service.go FormatGate.Grant
|
||||
core/host/master/workspace_service.go FormatGate.Place
|
||||
core/host/master/workspace_service.go FormatGate.Renew
|
||||
core/host/master/workspace_service.go MoveAdmission.ReadForMove
|
||||
|
||||
|
@@ -4,26 +4,56 @@
|
||||
[](https://github.com/seaweedfs/seaweed-block/actions/workflows/test.yml)
|
||||
[](go.mod)
|
||||
[](LICENSE)
|
||||
[](#project-status)
|
||||
|
||||
**Local-first block storage for AI agents.**
|
||||
**Block storage for [SeaweedFS](https://github.com/seaweedfs/seaweedfs), in two modes.** **Beta:** v1.1.x is a
|
||||
test release.
|
||||
|
||||
*Run locally. Persist incrementally. Resume anywhere.*
|
||||
Seaweed Block gives a VM, sandbox or container a plain block device over NVMe/TCP or iSCSI. Either the disk lives on
|
||||
the host and its changed data is checkpointed to your SeaweedFS, or every write is copied to replicas on other hosts.
|
||||
Its first use case is agent workspaces: disks that must outlive the sandbox that uses them.
|
||||
|
||||
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](https://github.com/seaweedfs/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](#vision).
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/seaweed-block-mode-overview-dark.svg">
|
||||
<img src="docs/assets/seaweed-block-mode-overview-light.svg" alt="Seaweed Block in two modes. One blockmaster per cluster issues epochs and leases and decides failover; the sw-block CLI talks to it. Left, checkpointed local block (supported): on a host, the guest writes over NVMe/TCP or iSCSI to blockvolume, which completes write and fsync on its local write-ahead log and extent and checkpoints the changed 4 MiB chunks to SeaweedFS (master, volume servers and filer) in the background; blockmaster reads the HEAD records from the filer. Right, replicated network block (preview): the guest writes to the primary blockvolume, which sends every write to replica blockvolumes on other hosts; SeaweedFS is not used." width="100%">
|
||||
</picture>
|
||||
|
||||
**[Quick start](#quick-start)** · [How it works](#how-it-works) · [Project status](#project-status) ·
|
||||
[Documentation](#documentation)
|
||||
**[Quick start](#quick-start-explained)** · [Two modes](#two-modes) · [Architecture](#architecture) ·
|
||||
[Project status](#project-status) · [Documentation](#documentation)
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/seaweed-block-lifecycle.svg" alt="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." width="100%">
|
||||
</p>
|
||||
## Two modes
|
||||
|
||||
## Why not just use...
|
||||
| | Checkpointed local block | Replicated network block |
|
||||
|---|---|---|
|
||||
| Status in v1.1.x (Beta) | **Supported** within the Beta | **Preview** inside the Beta, with [known limits](docs/releases/replicated-volumes-preview.md) |
|
||||
| Where the guest's disk is | A local write-ahead log and extent on the host | A primary on the guest's host, with replicas 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 each replica's answer but completes even if every replica fails) |
|
||||
| What leaves the host | The changed 4 MiB chunks, checkpointed to SeaweedFS in the background | Every write, to the replicas |
|
||||
| Snapshots, restore, planned moves | Yes | Not yet: the two modes cannot be combined in v1.1.x |
|
||||
| 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. `best-effort` is not failed over automatically |
|
||||
| Use it for | Agent workspaces, sandboxes and VMs that need portable state | Workloads that need online copies on other hosts |
|
||||
|
||||
| | Local disk | Conventional network block storage | Seaweed Block |
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/seaweed-block-mode-checkpointed-dark.svg">
|
||||
<img src="docs/assets/seaweed-block-mode-checkpointed-light.svg" alt="Checkpointed local block (supported). The guest writes over NVMe/TCP or iSCSI to blockvolume on the same host, which completes write and fsync on its local write-ahead log and extent. In the background, checkpoints send the changed 4 MiB chunks to SeaweedFS (master, filer and volume servers), which also holds the HEAD records. blockmaster issues epochs and leases to blockvolume. Snapshots, restore and planned moves use the chunks in SeaweedFS." width="100%">
|
||||
</picture>
|
||||
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/seaweed-block-mode-replicated-dark.svg">
|
||||
<img src="docs/assets/seaweed-block-mode-replicated-light.svg" alt="Replicated network block (preview). The guest writes over NVMe/TCP or iSCSI to the primary blockvolume on its host. The primary sends every write to replica blockvolumes on other hosts; with sync-quorum or sync-all, fsync completes once a quorum or every replica has it. Each replica keeps a local store. blockmaster issues epochs, decides failover and names the new primary. No SeaweedFS is involved and there are no snapshots, restore or moves in this mode yet." width="100%">
|
||||
</picture>
|
||||
|
||||
The two biggest limits of the replicated 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.
|
||||
|
||||
## Agent workspaces
|
||||
|
||||
The first use case is the checkpointed mode: each agent sandbox or microVM gets its own disk on the host's local
|
||||
storage. Writes and `fsync` complete locally, and checkpoints, named snapshots and restores carry the workspace's
|
||||
state beyond that host.
|
||||
|
||||
| | Local disk | Conventional network block storage | Checkpointed local 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 |
|
||||
@@ -31,12 +61,6 @@ design goal; see [Vision](#vision).
|
||||
| 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 |
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/seaweed-block-storage-models.svg" alt="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." width="100%">
|
||||
</p>
|
||||
|
||||
## 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
|
||||
@@ -49,48 +73,33 @@ design goal; see [Vision](#vision).
|
||||
|
||||
The commands and what each needs: [snapshots, restore and verification](docs/operations-manual.md#5-snapshots-restore-and-verification).
|
||||
|
||||
## Features
|
||||
Also: AI coding agents whose repositories, dependencies and build caches must outlive the sandbox; long-running
|
||||
agents that stop, resume and move between hosts; and Kubernetes block volumes through the CSI driver (alpha).
|
||||
|
||||
- **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.
|
||||
## Architecture
|
||||
|
||||
## Use cases
|
||||
| Process | What it does | Where it runs | Talks to |
|
||||
|---|---|---|---|
|
||||
| `blockmaster` | The control plane: epochs, leases, placement and failover. A single instance per cluster in v1.1.x, with no high availability; its authority and lifecycle records are local files. | One host. Put its state directory on its own filesystem. | `blockvolume` (heartbeats, leases, assignments), `sw-block` (control API), and in the checkpointed mode the SeaweedFS filer (HEAD records). There it needs a reachable filer to start. |
|
||||
| `blockvolume` (the holder) | Serves one volume to its guest over NVMe/TCP or iSCSI, from a write-ahead log and extent. In the checkpointed mode it checkpoints to SeaweedFS; in the replicated mode it sends writes to, or receives them from, the other replicas. | On the host where the guest runs: one process per volume (and per replica). | Its guest, `blockmaster`, SeaweedFS (checkpointed mode), the other replicas (replicated mode) |
|
||||
| SeaweedFS: `weed master`, `weed volume`, `weed filer` | Holds the checkpointed chunks and the HEAD records. | Your SeaweedFS cluster. | `blockvolume`, `blockmaster` and `sw-block` reach it over the network |
|
||||
| `sw-block` | The operator CLI: start and stop volumes, checkpoints, snapshots, restore, moves, checks. | Wherever the operator works. | `blockmaster`, each holder's status endpoint, the SeaweedFS filer |
|
||||
|
||||
- **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).
|
||||
What each mode needs:
|
||||
- **Checkpointed:** `blockmaster` (with `--workspace-rpc`), one `blockvolume` per volume, and SeaweedFS.
|
||||
`blockmaster` contacts the filer only in this mode: at start it waits about 60 s for the filer to answer, then exits
|
||||
with an error.
|
||||
- **Replicated:** `blockmaster` and one `blockvolume` per replica, each on its own host. These volumes do not use
|
||||
SeaweedFS: in a cluster of replicated volumes only, `blockmaster` runs without `--workspace-rpc` and opens no filer
|
||||
connection.
|
||||
|
||||
## One engine, two durability profiles
|
||||
In a standalone setup the guest runs on the holder's host: remote guests are not supported in v1.1.x. The Kubernetes
|
||||
CSI driver (alpha) can attach a volume to a pod on another node when the chart enables an external target
|
||||
(`network.externalISCSI`, with CHAP, or `network.externalNVMe`).
|
||||
|
||||
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](docs/releases/replicated-volumes-preview.md) |
|
||||
|
||||
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.
|
||||
More: [agent workspace design](docs/design/agent-workspace-design.md), [volume lifecycle](docs/volume-lifecycle.md),
|
||||
the [core design](docs/design/block-design.md), and the [TLA+ specifications](docs/spec/README.md) of the
|
||||
protocols where a bug would lose data.
|
||||
|
||||
## Performance
|
||||
|
||||
@@ -99,76 +108,67 @@ replicated volume does not wait for checkpoints.
|
||||
<img src="docs/assets/measured-results-light.svg" alt="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." width="100%">
|
||||
</picture>
|
||||
|
||||
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](docs/workspace-measurements.md).
|
||||
Metadata-heavy agent work runs at local-disk speed, timing the operation itself (with the guest's final `syncfs`, the
|
||||
first three rows are 11-23% slower, and untar of 5,000 small files takes about 2.2 times as long); `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](docs/workspace-measurements.md).
|
||||
|
||||
## Quick start
|
||||
## Quick start, explained
|
||||
|
||||
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](https://github.com/seaweedfs/seaweedfs/releases/tag/4.53),
|
||||
asset `linux_amd64.tar.gz`, which holds the one `weed` binary).
|
||||
A trial of the checkpointed mode on a disposable Linux host, not for data you keep. You need `nvme-cli`, `sudo` for
|
||||
the connect step, and SeaweedFS's `weed` binary, tested with SeaweedFS 4.53 (from its
|
||||
[release page](https://github.com/seaweedfs/seaweedfs/releases/tag/4.53), asset `linux_amd64.tar.gz`, which holds the
|
||||
one `weed` binary).
|
||||
|
||||
```bash
|
||||
TAG=v1.1.1
|
||||
TAG=v1.1.2
|
||||
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
|
||||
# v1.1.1 prerequisite: its child lookup uses PATH and its lock is host-wide.
|
||||
export PATH="$PWD:$PATH"
|
||||
sudo install -d -m 0755 /run/sw-block
|
||||
sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" /run/sw-block/locks
|
||||
./blockvolume --version # must print the tag's commit
|
||||
./sw-block mini --dir ./swb-mini --weed /path/to/weed
|
||||
```
|
||||
|
||||
**What `mini` starts**, as the [standalone deployment](docs/standalone-deployment.md) describes:
|
||||
- `weed mini`: a one-process SeaweedFS (master, volume server and filer) that holds the checkpointed chunks.
|
||||
- `blockmaster`: the control plane.
|
||||
- One `blockvolume`: volume `v1`, 256 MiB, as `walstore-chunk`, on loopback.
|
||||
|
||||
It prints every command before it runs it, and each process logs to `<dir>/<name>.log`. It never runs `sudo`
|
||||
itself.
|
||||
|
||||
From v1.1.2 `mini` needs no `sudo` to start: it keeps the volume lock under `--dir`, prints every command with the
|
||||
absolute paths of `sw-block` and `weed`, and on a failed start prints the `--reuse` command that starts again on the
|
||||
same `--dir`. With v1.1.1, see its [known issue](docs/releases/v1.1.1.md#known-issue-sw-block-mini-as-a-non-root-user-fixed-in-v112).
|
||||
|
||||
**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. From v1.1.2 `mini`
|
||||
takes no scheduled snapshot (with v1.1.1 a scheduled `sched-<time>` snapshot 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.
|
||||
**What it prints for you:** the `nvme connect` command that attaches `v1`, its status URL, and the next commands
|
||||
(snapshot, checks). 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. From v1.1.2 `mini` takes
|
||||
no scheduled snapshot (with v1.1.1 a scheduled `sched-<time>` snapshot 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:**
|
||||
- Other ways to install (the release image, a build from the tag): [operations manual](docs/operations-manual.md#1-install-the-binaries-and-units).
|
||||
**From `mini` to a real deployment:**
|
||||
|
||||
| In `mini` | In a deployment |
|
||||
|---|---|
|
||||
| `weed mini` | Your SeaweedFS cluster: `weed master`, `weed volume` and `weed filer` |
|
||||
| `blockmaster` | The `sw-blockmaster` systemd unit, its state in `/var/lib/sw-block-master` on its own filesystem ([why](docs/releases/v1.1.2.md#known-issue-blockmaster-restart-can-stall-on-a-busy-filesystem)) |
|
||||
| `blockvolume` for `v1` | One `sw-blockvolume@<volume>` unit per volume, started with `sudo sw-block volume start` |
|
||||
| The loopback trial | A cluster spec that names the hosts and the volumes' placements |
|
||||
|
||||
Next:
|
||||
- Install, upgrade and run the services: [operations manual](docs/operations-manual.md#1-install-the-binaries-and-units).
|
||||
- Services, restore and a second host: [standalone deployment](docs/standalone-deployment.md) and
|
||||
[two hosts and a planned move](docs/operations-manual.md#appendix-b-two-hosts-and-a-planned-move).
|
||||
- Kubernetes (alpha): [Kubernetes quick start](docs/quickstart-kubernetes.md), with v1.1.1. v1.1.0's generated pod
|
||||
cannot start.
|
||||
|
||||
## 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.
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/seaweed-block-hero.svg" alt="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." width="100%">
|
||||
</p>
|
||||
|
||||
More: [agent workspace design](docs/design/agent-workspace-design.md), [volume lifecycle](docs/volume-lifecycle.md),
|
||||
and the [TLA+ specifications](docs/spec/README.md) of the protocols where a bug would lose data.
|
||||
- Kubernetes (alpha): [Kubernetes quick start](docs/quickstart-kubernetes.md).
|
||||
|
||||
## Durability model
|
||||
|
||||
For the checkpointed mode:
|
||||
|
||||
| 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 |
|
||||
@@ -185,9 +185,12 @@ and the [TLA+ specifications](docs/spec/README.md) of the protocols where a bug
|
||||
|
||||
## Project status
|
||||
|
||||
| Capability | v1.1.x |
|
||||
Seaweed Block v1.1.x is a **Beta**: a test release. "Supported" below means the configuration this Beta is built
|
||||
and tested for; "Preview" has the stated limits. No production SLO is claimed.
|
||||
|
||||
| Capability | v1.1.x (Beta) |
|
||||
|---|---|
|
||||
| Local single-replica volumes (`walstore-chunk`) | Supported |
|
||||
| Checkpointed local 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 |
|
||||
|
||||
@@ -193,7 +193,16 @@ func chunkPostUntil(name, statusAddr, route string, timeout time.Duration, waitU
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
responseFailure := func(cause error) int {
|
||||
if resp.StatusCode >= http.StatusBadRequest {
|
||||
// A 409 body can describe work after admission; status alone cannot
|
||||
// settle the original operation or authorize a new request identity.
|
||||
if resp.StatusCode == http.StatusConflict {
|
||||
if id, ok := body["requestID"].(string); ok && id != "" {
|
||||
cause = fmt.Errorf("HTTP 409 body is unusable; recover original request %s: %w", id, cause)
|
||||
} else {
|
||||
cause = fmt.Errorf("HTTP 409 body is unusable: %w", cause)
|
||||
}
|
||||
}
|
||||
if resp.StatusCode >= http.StatusBadRequest && resp.StatusCode != http.StatusConflict {
|
||||
cause = answer.HTTPStatusFailure(resp.StatusCode, cause)
|
||||
} else {
|
||||
cause = answer.Rekind(answer.Record(answer.PossiblyAdmitted, cause), answer.Connection)
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A 409 can follow admission. Without its typed body, keep the original
|
||||
// operation unknown and preserve its request identity for recovery.
|
||||
func TestChunkUnusableConflictAnswerIsUnknown(t *testing.T) {
|
||||
for _, mode := range []string{"truncated", "malformed"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
receivedIDs := make(chan string, 1)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var request struct {
|
||||
ID string `json:"requestID"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&request); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
receivedIDs <- request.ID
|
||||
if mode == "truncated" {
|
||||
w.Header().Set("Content-Length", "1000")
|
||||
}
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
fmt.Fprint(w, `{`)
|
||||
}))
|
||||
defer srv.Close()
|
||||
var out, diag bytes.Buffer
|
||||
var admission snapshotCLIAdmission
|
||||
exit := chunkPost("snapshot", srv.URL, "/chunk/snapshot", time.Second, map[string]any{"volumeID": "v1", "name": "s1", "requestID": "original"}, &out, &diag, &admission)
|
||||
got := chunkErrorOut(t, out.String())
|
||||
var receivedID string
|
||||
select {
|
||||
case receivedID = <-receivedIDs:
|
||||
default:
|
||||
t.Fatal("server did not receive the request")
|
||||
}
|
||||
if exit != 3 || got.Code != "outcome_unknown" || !got.Retryable || admission.Accepted || receivedID != "original" || !strings.Contains(got.Message, "original") || !strings.Contains(got.Message, "recover") || strings.Contains(got.Message, "nothing applied") {
|
||||
t.Fatalf("exit=%d answer=%+v accepted=%v stderr=%s", exit, got, admission.Accepted, &diag)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkConflictLoopKeepsOriginalRequest(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
name, body string
|
||||
truncated bool
|
||||
posts, exit int
|
||||
}{
|
||||
{"unreadable", `{`, true, 2, 0},
|
||||
{"malformed", `{`, false, 2, 0},
|
||||
{"typed-retryable", `{"code":"head_conflict","retryable":true,"message":"HEAD changed"}`, false, 2, 0},
|
||||
{"typed-terminal", `{"code":"snapshot_limit","retryable":false,"message":"limit reached"}`, false, 1, 1},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
shortLoop(t, 200*time.Millisecond, time.Millisecond, 2*time.Millisecond)
|
||||
var mu sync.Mutex
|
||||
var received []map[string]any
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
fmt.Fprint(w, `{}`)
|
||||
return
|
||||
}
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
mu.Lock()
|
||||
received = append(received, body)
|
||||
n := len(received)
|
||||
mu.Unlock()
|
||||
if n == 1 {
|
||||
if row.truncated {
|
||||
w.Header().Set("Content-Length", "1000")
|
||||
}
|
||||
w.WriteHeader(http.StatusConflict)
|
||||
fmt.Fprint(w, row.body)
|
||||
return
|
||||
}
|
||||
fmt.Fprint(w, `{"volumeID":"v1","name":"s1","headGen":7}`)
|
||||
}))
|
||||
defer srv.Close()
|
||||
var out, diag bytes.Buffer
|
||||
exit := chunkPostLoop("snapshot", srv.URL, "/chunk/snapshot", time.Second, map[string]any{"volumeID": "v1", "name": "s1", "requestID": "original"}, &out, &diag)
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if exit != row.exit || len(received) != row.posts {
|
||||
t.Fatalf("exit=%d posts=%d wantExit=%d wantPosts=%d out=%s stderr=%s", exit, len(received), row.exit, row.posts, &out, &diag)
|
||||
}
|
||||
for _, q := range received {
|
||||
if q["volumeID"] != "v1" || q["name"] != "s1" || q["requestID"] != "original" {
|
||||
t.Fatalf("recovery changed request: %+v", q)
|
||||
}
|
||||
}
|
||||
if row.name == "typed-terminal" {
|
||||
got := chunkErrorOut(t, out.String())
|
||||
if got.Code != "snapshot_limit" || got.Retryable {
|
||||
t.Fatalf("terminal answer changed: %+v", got)
|
||||
}
|
||||
} else if row.name != "typed-retryable" && !strings.Contains(diag.String(), "request 1 ended: outcome_unknown") {
|
||||
t.Fatalf("lost conflict must remain unknown: %s", &diag)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/answer"
|
||||
)
|
||||
|
||||
func TestSnapshotProxyUnlistedHTTPStatusIsUnknown(t *testing.T) {
|
||||
for _, code := range []int{408, 421, 423, 431, 499, 505, 520, 524} {
|
||||
t.Run(fmt.Sprint(code), func(t *testing.T) {
|
||||
received := make(chan string, 1)
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var body struct {
|
||||
RequestID string `json:"requestID"`
|
||||
}
|
||||
if r.Method != http.MethodPost || r.URL.Path != "/chunk/snapshot" {
|
||||
t.Errorf("unexpected request %s %s", r.Method, r.URL.Path)
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
received <- body.RequestID
|
||||
w.WriteHeader(code)
|
||||
fmt.Fprint(w, "<html>proxy could not observe the origin outcome</html>")
|
||||
}))
|
||||
defer srv.Close()
|
||||
var out, diag bytes.Buffer
|
||||
var admission snapshotCLIAdmission
|
||||
exit := chunkPost("snapshot", srv.URL, "/chunk/snapshot", 3*time.Second, map[string]any{"requestID": "same-original-snapshot"}, &out, &diag, &admission)
|
||||
got := chunkErrorOut(t, out.String())
|
||||
if exit != 3 || got.Code != "outcome_unknown" || !got.Retryable || admission.Accepted || !strings.Contains(got.Message, "replay key") {
|
||||
t.Fatalf("exit=%d answer=%+v accepted=%v stderr=%s", exit, got, admission.Accepted, &diag)
|
||||
}
|
||||
select {
|
||||
case id := <-received:
|
||||
if id != "same-original-snapshot" {
|
||||
t.Fatalf("wire ID=%q", id)
|
||||
}
|
||||
default:
|
||||
t.Fatal("POST never reached proxy")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorUnlistedHTTPStatusIsUnknown(t *testing.T) {
|
||||
p, err := operatorAnswer(answer.HTTPStatusFailure(418, fmt.Errorf("proxy lost origin answer")), answer.Failover)
|
||||
if p.Code != "outcome_unknown" || !p.Retryable || p.Retry != answer.Recover || p.Exit != 3 || !strings.Contains(err.Error(), "current authority line") {
|
||||
t.Fatalf("policy=%+v err=%v", p, err)
|
||||
}
|
||||
}
|
||||
@@ -592,7 +592,7 @@ func mini(ctx context.Context, cfg miniConfig, stdout, stderr io.Writer) (int, e
|
||||
fail := func(err error) (int, error) {
|
||||
r.tail(20)
|
||||
r.stop()
|
||||
fmt.Fprintf(stderr, "sw-block mini: not started; logs in %s/*.log. After fixing the cause, start again on it with\n %s\nor remove %s and start fresh.\n", shQuote(cfg.Dir), miniResume(cfg), shQuote(cfg.Dir))
|
||||
fmt.Fprintf(stderr, "sw-block mini: stopped; logs in %s/*.log. After fixing the cause, start again on it with\n %s\nRemoving %s deletes the trial volume's data (and SeaweedFS's); do that only to start over without it.\n", shQuote(cfg.Dir), miniResume(cfg), shQuote(cfg.Dir))
|
||||
return 1, err
|
||||
}
|
||||
if chunk {
|
||||
|
||||
@@ -938,3 +938,27 @@ func TestMiniProductionWeedHintQuotesItsExecutable(t *testing.T) {
|
||||
t.Fatalf("production weed hint lacks %q:\n%s", want, out.String())
|
||||
}
|
||||
}
|
||||
|
||||
// A run that stops on a failure offers the --reuse command for its dir
|
||||
// first; removing the dir is named only with the warning that it deletes
|
||||
// the trial volume's data, never as a plain "start fresh".
|
||||
func TestMiniFailureOffersReuseBeforeRemoval(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("signals and listening children: Linux")
|
||||
}
|
||||
t.Setenv("PATH", t.TempDir())
|
||||
t.Setenv("SWB_MINI_FAKE_CHILD", "die-blockvolume")
|
||||
c := miniConfig{Dir: filepath.Join(t.TempDir(), "run"), Bin: fakeBin(t), NQN: "n", SizeBytes: 1 << 20, Ports: freePorts(t)}
|
||||
errb := &syncBuf{}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||
defer cancel()
|
||||
if code, _ := mini(ctx, c, io.Discard, errb); code == 0 {
|
||||
t.Fatal("a dead blockvolume: exit 0")
|
||||
}
|
||||
text := errb.String()
|
||||
reuse := strings.Index(text, " --reuse")
|
||||
warn := strings.Index(text, "deletes the trial volume's data")
|
||||
if reuse < 0 || warn < 0 || warn < reuse || strings.Contains(text, "start fresh") {
|
||||
t.Fatalf("failure text %q: want the --reuse command first and removal only with the data warning", text)
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func TestReviewCompleteBodyKeepsStatusAndAdmission(t *testing.T) {
|
||||
{"malformed-forbidden", 403, "{", 5, "not_authorized"},
|
||||
{"malformed-arguments", 400, "{", 2, "bad_request"},
|
||||
{"malformed-missing", 404, "{", 1, "not_found"},
|
||||
{"malformed-precondition", 409, "{", 1, "not_admitted"},
|
||||
{"malformed-conflict", 409, "{", 3, "outcome_unknown"},
|
||||
{"malformed-rate-limit", 429, "{", 3, "outcome_unknown"},
|
||||
{"malformed-server", 500, "{", 3, "outcome_unknown"},
|
||||
{"malformed-gateway", 502, "{", 3, "outcome_unknown"},
|
||||
@@ -32,6 +32,7 @@ func TestReviewCompleteBodyKeepsStatusAndAdmission(t *testing.T) {
|
||||
{"empty-success", 204, "", 3, "outcome_unknown"},
|
||||
{"malformed-redirect", 302, "{", 3, "outcome_unknown"},
|
||||
{"oversized-forbidden", 403, "oversized", 5, "not_authorized"},
|
||||
{"oversized-conflict", 409, "oversized", 3, "outcome_unknown"},
|
||||
{"oversized-success", 200, "oversized", 3, "outcome_unknown"},
|
||||
{"oversized-admission", 202, "oversized", 3, "outcome_unknown"},
|
||||
} {
|
||||
|
||||
@@ -485,7 +485,11 @@ func volumeRestore(ctx context.Context, env verbEnv, o restoreOpts, args []strin
|
||||
}
|
||||
}
|
||||
policy, detail := operatorAnswer(err, answer.VolumePlacement)
|
||||
if policy.Retry == answer.Never && !policy.Retryable {
|
||||
// Only blockmaster's own refusal settles that the volume stays
|
||||
// unplaced. An interrupted step (Ctrl-C) or one that failed here
|
||||
// before an answer (a credential or connection error) leaves both
|
||||
// ways open: the same command finishes the restore.
|
||||
if restoreStepAnswered(ctx, err) && policy.Retry == answer.Never && !policy.Retryable {
|
||||
fmt.Fprintf(stderr, "sw-block volume restore: %s: refused: %v; the new volume exists but is not placed; to undo it: %s\n", step, detail, abort)
|
||||
return policy.Exit
|
||||
}
|
||||
@@ -711,3 +715,21 @@ var workspaceBindPlace = func(ctx context.Context, master string, b *control.Wor
|
||||
defer conn.Close()
|
||||
return bindAndPlace(ctx, control.NewWorkspaceServiceClient(conn), b, replica)
|
||||
}
|
||||
|
||||
// restoreStepAnswered says whether err is blockmaster's own answer to a
|
||||
// restore step, not an interruption or a failure on this side before an
|
||||
// answer (cancellation, a deadline, no connection, refused credentials).
|
||||
func restoreStepAnswered(ctx context.Context, err error) bool {
|
||||
if ctx.Err() != nil || errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
|
||||
return false
|
||||
}
|
||||
st, ok := status.FromError(err)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
switch st.Code() {
|
||||
case codes.Canceled, codes.DeadlineExceeded, codes.Unavailable, codes.Unknown, codes.Unauthenticated:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -323,6 +323,11 @@ func (m *restoreMaster) RegisterWorkspaceBinding(_ context.Context, q *control.W
|
||||
m.failNext = ""
|
||||
return nil, status.Error(codes.FailedPrecondition, "server not registered")
|
||||
}
|
||||
if m.failNext == "bind-canceled" || m.failNext == "bind-unauthenticated" {
|
||||
code := map[string]codes.Code{"bind-canceled": codes.Canceled, "bind-unauthenticated": codes.Unauthenticated}[m.failNext]
|
||||
m.failNext = ""
|
||||
return nil, status.Error(code, "the step ended before blockmaster answered")
|
||||
}
|
||||
m.binds++
|
||||
m.bound[q.VolumeId] = q
|
||||
return q, nil
|
||||
@@ -876,6 +881,62 @@ func TestVolumeRestoreRefusedPlacementNamesTheAbort(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A step interrupted (Ctrl-C) or failed here before blockmaster answered
|
||||
// leaves the restore finishable: the failure names both ways, the same
|
||||
// command first and the irreversible abort second, never "refused".
|
||||
func TestVolumeRestoreInterruptedPlacementNamesBothWays(t *testing.T) {
|
||||
for _, fail := range []string{"bind-canceled", "bind-unauthenticated"} {
|
||||
h, env, m, _ := restoreSetup(t)
|
||||
m.failNext = fail
|
||||
code, _, errs := runRestore(env, restoreArgs(h)...)
|
||||
if code == 0 || strings.Contains(errs, "refused") || !strings.Contains(errs, "to finish, run the same command: ") || !strings.Contains(errs, "to undo it: "+abortCmd) {
|
||||
t.Fatalf("%s: %d %s; want both ways and no refusal", fail, code, errs)
|
||||
}
|
||||
if h.called("enable") != 0 {
|
||||
t.Fatalf("%s: started after an interrupted placement", fail)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ctrl-C after the restore-create succeeded but before the binding call goes
|
||||
// out, or a local failure at the connect step (a credential file it cannot
|
||||
// load), leaves the restore finishable: both ways, no refusal.
|
||||
func TestVolumeRestoreCtrlCAtPlacementNamesBothWays(t *testing.T) {
|
||||
orig := workspaceBindPlace
|
||||
t.Cleanup(func() { workspaceBindPlace = orig })
|
||||
for _, c := range []struct {
|
||||
name string
|
||||
hook func(cancel context.CancelFunc) func(context.Context, string, *control.WorkspaceBinding, string) (string, error)
|
||||
}{
|
||||
{"ctrl-c before the binding call", func(cancel context.CancelFunc) func(context.Context, string, *control.WorkspaceBinding, string) (string, error) {
|
||||
return func(ctx context.Context, master string, b *control.WorkspaceBinding, replica string) (string, error) {
|
||||
cancel()
|
||||
return orig(ctx, master, b, replica)
|
||||
}
|
||||
}},
|
||||
{"local connect failure", func(context.CancelFunc) func(context.Context, string, *control.WorkspaceBinding, string) (string, error) {
|
||||
return func(context.Context, string, *control.WorkspaceBinding, string) (string, error) {
|
||||
return "connect", errors.New("load the client certificate: open /etc/sw-block/tls/client.key: no such file or directory")
|
||||
}
|
||||
}},
|
||||
} {
|
||||
h, env, _, _ := restoreSetup(t)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
workspaceBindPlace = c.hook(cancel)
|
||||
var out, errb bytes.Buffer
|
||||
o, err := parseVolumeRestore(restoreArgs(h), &errb)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
code := volumeRestore(ctx, env, o, restoreArgs(h), &out, &errb)
|
||||
cancel()
|
||||
errs := errb.String()
|
||||
if code == 0 || strings.Contains(errs, "refused") || !strings.Contains(errs, "to finish, run the same command: ") || !strings.Contains(errs, "to undo it: "+abortCmd) {
|
||||
t.Fatalf("%s: %d %s; want both ways and no refusal", c.name, code, errs)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --abort acts only on this restore's own target: a volume the master
|
||||
// records for another source, snapshot or request, or a plain volume, is
|
||||
// refused before anything changes (no systemctl, settings kept, no delete
|
||||
|
||||
@@ -71,7 +71,12 @@ func runOpsVolumeCreate(args []string, stdout, stderr io.Writer) int {
|
||||
if policy.Retryable {
|
||||
outcome = "unknown"
|
||||
}
|
||||
fmt.Fprintf(stderr, "sw-block ops volume create: %s %s: %v; %s\n", step, outcome, err, policy.Cure)
|
||||
cure := policy.Cure
|
||||
if step != "create" && step != "create reply" && !policy.Retryable {
|
||||
// CreateVolume already succeeded: the volume record exists.
|
||||
cure += "; earlier steps may remain recorded; retry the identical name, geometry and placement"
|
||||
}
|
||||
fmt.Fprintf(stderr, "sw-block ops volume create: %s %s: %v; %s\n", step, outcome, err, cure)
|
||||
return policy.Exit
|
||||
}
|
||||
q := &control.CreateVolumeRequest{VolumeId: binding.VolumeId, SizeBytes: *size, ReplicationFactor: 1, Protocol: *protocol, FrontendTransport: *transport, BlockSize: geometry.BlockSize, ChunkBytes: geometry.ChunkBytes}
|
||||
|
||||
@@ -209,6 +209,27 @@ func TestOpsVolumeCreateStopsAfterRefusedOrUnknownStep(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A binding or placement refused after CreateVolume succeeded leaves the
|
||||
// created record: the refusal says so and names the identical retry, so an
|
||||
// operator does not move to a new name and orphan it.
|
||||
func TestOpsVolumeCreateRefusalAfterCreateNamesTheIdenticalRetry(t *testing.T) {
|
||||
for _, step := range []string{"bind", "place"} {
|
||||
s := &createAndPlaceReceiver{failStep: step, failErr: status.Error(codes.FailedPrecondition, "injected")}
|
||||
addr := serveCreateAndPlace(t, s)
|
||||
var out, errout bytes.Buffer
|
||||
code := run(createAndPlaceArgs(addr), &out, &errout)
|
||||
if code != 78 || !strings.Contains(errout.String(), "earlier steps may remain recorded; retry the identical name, geometry and placement") {
|
||||
t.Fatalf("%s refused: code=%d err=%q", step, code, &errout)
|
||||
}
|
||||
}
|
||||
s := &createAndPlaceReceiver{failStep: "create", failErr: status.Error(codes.FailedPrecondition, "injected")}
|
||||
addr := serveCreateAndPlace(t, s)
|
||||
var out, errout bytes.Buffer
|
||||
if code := run(createAndPlaceArgs(addr), &out, &errout); code != 78 || strings.Contains(errout.String(), "earlier steps may remain recorded") {
|
||||
t.Fatalf("a refused create claims earlier steps: code=%d err=%q", code, &errout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpsVolumeCreateRefusesUnreadyOrMismatchedAnswers(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
|
||||
@@ -6,6 +6,9 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -18,14 +21,26 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// The real master issues the move and reports the current holder. Only the unit and holder
|
||||
// process are fixtures: enabling the unit renews the real assigned epoch;
|
||||
// the holder's stop ACK goes through the real detached-HEAD check.
|
||||
func TestVolumeStartReleaseAgainstRealMaster(t *testing.T) {
|
||||
for _, loseAnswer := range []bool{false, true} {
|
||||
t.Run(fmt.Sprintf("lost-answer-%v", loseAnswer), func(t *testing.T) {
|
||||
if os.Getenv("VOLUME_START_MASTER_CHILD") != t.Name() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$", "-test.count=1")
|
||||
cmd.Env = append(os.Environ(), "VOLUME_START_MASTER_CHILD="+t.Name())
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("bounded master stop/restart/start child: %v\n%s", err, out)
|
||||
}
|
||||
return
|
||||
}
|
||||
for _, tc := range []struct{ loseAnswer, restartMaster bool }{{false, false}, {true, false}, {false, true}, {true, true}} {
|
||||
loseAnswer := tc.loseAnswer
|
||||
t.Run(fmt.Sprintf("lost-answer-%v/master-restart-%v", loseAnswer, tc.restartMaster), func(t *testing.T) {
|
||||
for _, key := range []string{"SW_BLOCK_TLS_CERT", "SW_BLOCK_TLS_KEY", "SW_BLOCK_TLS_CA"} {
|
||||
t.Setenv(key, "")
|
||||
}
|
||||
@@ -42,6 +57,7 @@ func TestVolumeStartReleaseAgainstRealMaster(t *testing.T) {
|
||||
}
|
||||
defer conn.Close()
|
||||
rpc := control.NewWorkspaceServiceClient(conn)
|
||||
observations := control.NewObservationServiceClient(conn)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
h := newFakeHost(t)
|
||||
@@ -66,6 +82,12 @@ func TestVolumeStartReleaseAgainstRealMaster(t *testing.T) {
|
||||
exited79 := false
|
||||
env.Systemctl = func(ctx context.Context, args ...string) (string, error) {
|
||||
if args[0] == "enable" {
|
||||
// A real newly enabled holder reports before it can receive its
|
||||
// first serving deadline; a move record alone grants no I/O.
|
||||
if _, err := observations.ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-f", ReplicaId: "r1", DataAddr: "127.0.0.1:19200", CtrlAddr: "127.0.0.1:19100"}}}); err != nil {
|
||||
return "report", err
|
||||
}
|
||||
ws, err := rpc.QueryWorkspace(ctx, &control.WorkspaceVolume{VolumeId: "vol-f"})
|
||||
if err != nil {
|
||||
return "query", err
|
||||
@@ -109,6 +131,22 @@ func TestVolumeStartReleaseAgainstRealMaster(t *testing.T) {
|
||||
if code, out, errs := runStop(env, stopOpts{Volume: "vol-f", NoCut: true, Timeout: time.Second}); code != 0 {
|
||||
t.Fatalf("stop=%d %s %s", code, out, errs)
|
||||
}
|
||||
if tc.restartMaster {
|
||||
// Keep the configured endpoint while losing all memory-only reports.
|
||||
cfg.Listen = mh.Addr()
|
||||
stop()
|
||||
_ = conn.Close()
|
||||
restarted, restartStop := startDeleteMaster(t, cfg)
|
||||
defer restartStop()
|
||||
restartedConn, err := grpc.NewClient(restarted.Addr(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer restartedConn.Close()
|
||||
rpc = control.NewWorkspaceServiceClient(restartedConn)
|
||||
observations = control.NewObservationServiceClient(restartedConn)
|
||||
recorder.WorkspaceServiceClient = rpc
|
||||
}
|
||||
code, out, errs := runStart(env, v, startOpts{Wait: time.Second})
|
||||
if loseAnswer {
|
||||
if code != wsExitUnknown || h.called("enable") != 1 {
|
||||
|
||||
@@ -189,7 +189,9 @@ type Publisher struct {
|
||||
// 0 keeps v1.0's master semantics (a current lease horizon, version-1
|
||||
// records), 1 is v1.1's. Written under mu and leaseMu, read under
|
||||
// either.
|
||||
formatLevel uint32
|
||||
formatLevel uint32
|
||||
formatFinalizing bool // guarded by mu and leaseMu; no store I/O while setting it
|
||||
requireFormatReadProofs bool // configured by the master before serving
|
||||
// Level 0's horizon extender (workspace_lease_v100.go).
|
||||
leaseClosing bool // guarded by mu and leaseMu
|
||||
extWG sync.WaitGroup // admitted extenders
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package authority
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
// FormatReadProof is an in-memory report captured before entering grant locks.
|
||||
// Revision changes whenever a reporting process or its read level changes.
|
||||
// Reading it under the grant locks is atomic and never waits on another lock.
|
||||
type FormatReadProof struct {
|
||||
Server, Process, Replica string
|
||||
Epoch uint64
|
||||
Reads uint32
|
||||
Reported bool
|
||||
Revision *atomic.Uint64
|
||||
Version uint64
|
||||
}
|
||||
|
||||
func (r FormatReadProof) current(replica string, epoch uint64, incarnation string) bool {
|
||||
return r.Reported && r.Reads >= 1 && r.Replica == replica && r.Epoch == epoch &&
|
||||
r.Revision != nil && r.Revision.Load() == r.Version &&
|
||||
(incarnation == "" || r.Process == incarnation)
|
||||
}
|
||||
|
||||
// FormatServingBlocker names a possibly-serving process without a proven report.
|
||||
type FormatServingBlocker struct{ Volume, Server, Detail string }
|
||||
|
||||
// RequireFormatReadProofs enables the master's report gate before serving.
|
||||
func (p *Publisher) RequireFormatReadProofs() {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.leaseMu.Lock()
|
||||
defer p.leaseMu.Unlock()
|
||||
p.requireFormatReadProofs = true
|
||||
}
|
||||
|
||||
// BeginFormatFinalize atomically checks possible live leases and closes the
|
||||
// level-0 grant path. No I/O or caller callback runs under these locks.
|
||||
// The caller serializes placement/owner changes with this memory step, then
|
||||
// admits new work at the target level while the durable write runs.
|
||||
func (p *Publisher) BeginFormatFinalize(proofs map[string]FormatReadProof, otherGuardsPassed bool) []FormatServingBlocker {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.leaseMu.Lock()
|
||||
defer p.leaseMu.Unlock()
|
||||
now := p.workspaceNow()
|
||||
var blocked []FormatServingBlocker
|
||||
for volume, lv := range p.leaseViews {
|
||||
if !lv.d.bound || !lv.d.leasePresent || (lv.d.revoking && lv.d.ackRecorded) {
|
||||
continue
|
||||
}
|
||||
skew := time.Duration(lv.d.maxSkewNS)
|
||||
until := lv.deadline.Add(skew)
|
||||
if p.formatLevel == 0 {
|
||||
if horizon := time.Unix(0, lv.d.horizon).Add(skew); horizon.After(until) {
|
||||
until = horizon
|
||||
}
|
||||
}
|
||||
if !lv.d.uncertain && !now.Before(until) {
|
||||
continue
|
||||
}
|
||||
proof := proofs[volume]
|
||||
_, line, ok := p.workspaceLineLocked(volume)
|
||||
if ok && (lv.d.issuedHost == "" || proof.Server == lv.d.issuedHost) && proof.current(lv.d.replica, lv.d.epoch, line.info.Incarnation) {
|
||||
continue
|
||||
}
|
||||
server := proof.Server
|
||||
if lv.d.issuedHost != "" {
|
||||
server = lv.d.issuedHost
|
||||
}
|
||||
if server == "" {
|
||||
server = "unknown"
|
||||
}
|
||||
detail := fmt.Sprintf("volume %s: serving process has not reported reading level 1", volume)
|
||||
if proof.Process != "" {
|
||||
detail += fmt.Sprintf(" (process %s reads level %d)", proof.Process, proof.Reads)
|
||||
}
|
||||
blocked = append(blocked, FormatServingBlocker{volume, server, detail})
|
||||
}
|
||||
sort.Slice(blocked, func(i, j int) bool {
|
||||
if blocked[i].Server == blocked[j].Server {
|
||||
return blocked[i].Volume < blocked[j].Volume
|
||||
}
|
||||
return blocked[i].Server < blocked[j].Server
|
||||
})
|
||||
if len(blocked) == 0 && otherGuardsPassed {
|
||||
p.formatFinalizing = true
|
||||
p.requireFormatReadProofs = true
|
||||
}
|
||||
return blocked
|
||||
}
|
||||
|
||||
// CancelFormatFinalize reopens the level-0 grant path after a failed durable raise.
|
||||
func (p *Publisher) CancelFormatFinalize() {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
p.leaseMu.Lock()
|
||||
defer p.leaseMu.Unlock()
|
||||
p.formatFinalizing = false
|
||||
}
|
||||
|
||||
// Caller holds mu or leaseMu; proof validation reads atomics only.
|
||||
func (p *Publisher) formatReadProofError(proof FormatReadProof, replica string, epoch uint64, incarnation string) error {
|
||||
if !p.requireFormatReadProofs || (p.formatLevel == 0 && !p.formatFinalizing) {
|
||||
return nil
|
||||
}
|
||||
if !proof.current(replica, epoch, incarnation) {
|
||||
return fmt.Errorf("workspace lease: node %q's process must report reading format level 1 before a grant or lease extension (binary_too_old or no current report)", proof.Server)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package authority
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Both the abrupt exit and recovery lifetime are bounded by the parent.
|
||||
func TestFormatFinalizeIntentDoesNotSurviveProcessExit(t *testing.T) {
|
||||
if phase := os.Getenv("FORMAT_INTENT_CRASH_PHASE"); phase != "" {
|
||||
disk, err := NewFileAuthorityStore(os.Getenv("FORMAT_INTENT_CRASH_STORE"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = disk.Close() })
|
||||
clock := newTestClock()
|
||||
p := level0Publisher(t, disk, 30*time.Second, clock)
|
||||
if phase == "crash" {
|
||||
bindAndGrant(t, p, "v", "r")
|
||||
clock.at(120)
|
||||
if blocked := p.BeginFormatFinalize(nil, true); len(blocked) != 0 || !p.formatFinalizing || p.FormatLevel() != 0 {
|
||||
t.Fatalf("before durable raise: intent=%v level=%d blockers=%v", p.formatFinalizing, p.FormatLevel(), blocked)
|
||||
}
|
||||
os.Exit(23) // no Close, no Cancel, no durable raise
|
||||
}
|
||||
p.RequireFormatReadProofs()
|
||||
if p.FormatLevel() != 0 || p.formatFinalizing {
|
||||
t.Fatalf("restart retained intent or raised level: intent=%v level=%d", p.formatFinalizing, p.FormatLevel())
|
||||
}
|
||||
clock.at(360)
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1); err != nil {
|
||||
t.Fatalf("restart changed the level-0 regrant path: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
dir := t.TempDir()
|
||||
for _, phase := range []string{"crash", "recover"} {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$", "-test.count=1")
|
||||
cmd.Env = append(os.Environ(), "FORMAT_INTENT_CRASH_PHASE="+phase, "FORMAT_INTENT_CRASH_STORE="+dir)
|
||||
out, err := cmd.CombinedOutput()
|
||||
cancel()
|
||||
if phase == "crash" {
|
||||
if exit, ok := err.(*exec.ExitError); !ok || exit.ExitCode() != 23 {
|
||||
t.Fatalf("intent child did not reach its own crash boundary: %v\n%s", err, out)
|
||||
}
|
||||
} else if err != nil {
|
||||
t.Fatalf("bounded recovery: %v\n%s", err, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatFinalizeFailedCheckLeavesLevelZeroGrantsOpen(t *testing.T) {
|
||||
for _, otherGuardsPassed := range []bool{false, true} {
|
||||
t.Run(fmt.Sprint(otherGuardsPassed), func(t *testing.T) {
|
||||
disk, _ := newTempStore(t)
|
||||
clock := newTestClock()
|
||||
p := level0Publisher(t, disk, 30*time.Second, clock)
|
||||
p.RequireFormatReadProofs()
|
||||
if otherGuardsPassed {
|
||||
bindAndGrant(t, p, "v", "r") // serving-report check fails
|
||||
}
|
||||
blocked := p.BeginFormatFinalize(nil, otherGuardsPassed)
|
||||
if otherGuardsPassed && len(blocked) == 0 {
|
||||
t.Fatal("unreported serving holder was not refused")
|
||||
}
|
||||
if p.formatFinalizing || p.FormatLevel() != 0 {
|
||||
t.Fatal("failed check left an admission intent or raised the level")
|
||||
}
|
||||
if err := p.apply(AssignmentAsk{VolumeID: "fresh", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind}); err != nil {
|
||||
t.Fatalf("failed finalize changed level-0 publication: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatFinalizeIntentRequiresRegrantReport(t *testing.T) {
|
||||
disk, _ := newTempStore(t)
|
||||
clock := newTestClock()
|
||||
p := level0Publisher(t, disk, 30*time.Second, clock)
|
||||
bindAndGrant(t, p, "v", "r")
|
||||
p.RequireFormatReadProofs()
|
||||
clock.at(120) // both the deadline and level-0 persisted horizon have ended
|
||||
if blocked := p.BeginFormatFinalize(nil, true); len(blocked) != 0 {
|
||||
t.Fatalf("ended lease blocks finalize: %v", blocked)
|
||||
}
|
||||
// The durable envelope has not yet been written: the actual level stays 0.
|
||||
if got := p.FormatLevel(); got != 0 {
|
||||
t.Fatalf("intent prematurely raised level=%d", got)
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1); err == nil || !strings.Contains(err.Error(), "must report") {
|
||||
t.Fatalf("regrant without report during durable raise: %v", err)
|
||||
}
|
||||
revision := &atomic.Uint64{}
|
||||
proof := FormatReadProof{Server: "node", Replica: "r", Epoch: 1, Reported: true, Reads: 1, Revision: revision}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err != nil {
|
||||
t.Fatalf("capable regrant during intent: %v", err)
|
||||
}
|
||||
clock.at(240)
|
||||
revision.Add(1) // report changed after a proof was captured, before re-grant
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err == nil {
|
||||
t.Fatal("stale process proof revived a lease")
|
||||
}
|
||||
proof.Version = revision.Load()
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err != nil {
|
||||
t.Fatalf("fresh proof did not retry: %v", err)
|
||||
}
|
||||
p.CancelFormatFinalize()
|
||||
if p.formatFinalizing {
|
||||
t.Fatal("failed raise kept the intent")
|
||||
}
|
||||
// Clearing a failed raise restores the level-0 path (no report required).
|
||||
clock.at(360)
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1); err != nil {
|
||||
t.Fatalf("level-0 retry after failed finalize: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatFinalizeCountsOnlyPossiblyLiveCurrentLeases(t *testing.T) {
|
||||
for _, state := range []string{"live", "released", "ended", "unserved"} {
|
||||
t.Run(state, func(t *testing.T) {
|
||||
clock := newTestClock()
|
||||
disk, _ := newTempStore(t)
|
||||
p := level0Publisher(t, disk, 30*time.Second, clock)
|
||||
bindAndGrant(t, p, "v", "r")
|
||||
switch state {
|
||||
case "released":
|
||||
ctx := context.Background()
|
||||
if err := p.BeginWorkspaceRevocation(ctx, "v", "r", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.AckWorkspaceRevocation(ctx, "v", WorkspaceRevokeAck{ReplicaID: "r", Epoch: 1, HeadGen: 7, Holder: "host/r", RemoteLSN: 42}, WorkspaceHead{Gen: 7, Detached: true, Epoch: 1, Holder: "host/r", RemoteLSN: 42}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
case "ended":
|
||||
clock.at(120)
|
||||
case "unserved":
|
||||
// An authority line alone is not a grant: reconstruct its no-lease view.
|
||||
p.mu.Lock()
|
||||
p.workspace["v"] = &WorkspaceState{}
|
||||
p.refreshLeaseViewLocked("v")
|
||||
p.mu.Unlock()
|
||||
}
|
||||
blocked := p.BeginFormatFinalize(nil, true)
|
||||
if (len(blocked) > 0) != (state == "live") {
|
||||
t.Fatalf("%s: blockers=%v", state, blocked)
|
||||
}
|
||||
if state == "live" && (blocked[0].Volume != "v" || !strings.Contains(blocked[0].Detail, "serving")) {
|
||||
t.Fatalf("unnamed live holder: %v", blocked)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatFinalizeLiveRenewalChecksCurrentProcess(t *testing.T) {
|
||||
disk, _ := newTempStore(t)
|
||||
p := level0Publisher(t, disk, 30*time.Second, newTestClock())
|
||||
if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Incarnation: "capable", Intent: IntentBind}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
revision := &atomic.Uint64{}
|
||||
proof := FormatReadProof{Server: "node", Process: "capable", Replica: "r", Epoch: 1, Reported: true, Reads: 1, Revision: revision}
|
||||
if blocked := p.BeginFormatFinalize(map[string]FormatReadProof{"v": proof}, true); len(blocked) != 0 {
|
||||
t.Fatal(blocked)
|
||||
}
|
||||
for _, phase := range []string{"intent", "complete"} {
|
||||
if phase == "complete" {
|
||||
p.FinalizeFormatLevel()
|
||||
}
|
||||
for _, invalid := range []string{"missing", "old", "replacement", "stale"} {
|
||||
bad := proof
|
||||
switch invalid {
|
||||
case "missing":
|
||||
bad.Reported = false
|
||||
case "old":
|
||||
bad.Reads = 0
|
||||
case "replacement":
|
||||
bad.Process = "replacement"
|
||||
case "stale":
|
||||
bad.Version++
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, bad); err == nil {
|
||||
t.Fatalf("%s: %s report renewed a live lease", phase, invalid)
|
||||
}
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err != nil {
|
||||
t.Fatalf("%s: current capable process could not renew: %v", phase, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatFinalizeDeadlineProofSurvivesIntentCompletion(t *testing.T) {
|
||||
for _, path := range []string{"first", "live", "regrant"} {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
disk, _ := newTempStore(t)
|
||||
clock := newTestClock()
|
||||
p := level0Publisher(t, disk, 30*time.Second, clock)
|
||||
if err := p.apply(AssignmentAsk{VolumeID: "v", ReplicaID: "r", DataAddr: "d", CtrlAddr: "c", Intent: IntentBind}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if path != "first" {
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if path == "regrant" {
|
||||
clock.at(120)
|
||||
}
|
||||
revision := &atomic.Uint64{}
|
||||
proof := FormatReadProof{Server: "node", Replica: "r", Epoch: 1, Reported: true, Reads: 1, Revision: revision}
|
||||
if blocked := p.BeginFormatFinalize(map[string]FormatReadProof{"v": proof}, true); len(blocked) != 0 {
|
||||
t.Fatal(blocked)
|
||||
}
|
||||
p.testBeforeGrantLock = func(site string) {
|
||||
if site == "renewal" {
|
||||
revision.Add(1) // captured before the process report changed
|
||||
p.FinalizeFormatLevel()
|
||||
}
|
||||
}
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err == nil {
|
||||
t.Fatal("stale proof crossed intent completion into a serving deadline")
|
||||
}
|
||||
p.testBeforeGrantLock = nil
|
||||
proof.Version = revision.Load()
|
||||
if _, err := p.RenewWorkspaceLease(context.Background(), "v", "r", 1, proof); err != nil {
|
||||
t.Fatalf("current capable proof did not retry after completion: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -58,6 +58,7 @@ func (p *Publisher) FinalizeFormatLevel() {
|
||||
p.leaseMu.Lock()
|
||||
defer p.leaseMu.Unlock()
|
||||
p.formatLevel = 1
|
||||
p.formatFinalizing = false
|
||||
}
|
||||
|
||||
// envelopeVersionLocked is the record envelope version the level writes:
|
||||
|
||||
@@ -18,6 +18,7 @@ var ErrWorkspaceRevoked = errors.New("workspace lease: revocation ACK is recorde
|
||||
type leaseDerived struct {
|
||||
bound bool // an authority line exists for the volume
|
||||
replica string
|
||||
incarnation string // current line's process identity; renewal reads only leaseMu
|
||||
epoch uint64
|
||||
ownerFromMove bool
|
||||
issuedHost string // NewHost of the issued move that minted the line; "" if none
|
||||
@@ -48,6 +49,7 @@ func (p *Publisher) deriveLeaseLocked(volume string) leaseDerived {
|
||||
d := leaseDerived{uncertain: p.workspaceUncertain[volume], storeless: p.store == nil, maxSkewNS: int64(p.workspaceSkew(nil))}
|
||||
if _, line, ok := p.workspaceLineLocked(volume); ok {
|
||||
d.bound, d.replica, d.epoch = true, line.info.ReplicaID, line.info.Epoch
|
||||
d.incarnation = line.info.Incarnation
|
||||
d.issuedHost, d.ownerFromMove = line.info.ServerID, line.info.OwnerFromMove
|
||||
}
|
||||
if s := p.workspace[volume]; s != nil {
|
||||
@@ -241,10 +243,14 @@ func (p *Publisher) PublishedAuthorityLines() map[string]PublishedLine {
|
||||
// holder only once its restart floor (deadline restart + TTL, set at load)
|
||||
// plus the skew bound has passed, so no durable horizon is needed. A first grant and an
|
||||
// expired re-grant after the shared move barrier write synchronously.
|
||||
func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder string, epoch uint64) (WorkspaceLease, error) {
|
||||
func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder string, epoch uint64, proofs ...FormatReadProof) (WorkspaceLease, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return WorkspaceLease{}, err
|
||||
}
|
||||
var proof FormatReadProof
|
||||
if len(proofs) > 0 {
|
||||
proof = proofs[0]
|
||||
}
|
||||
p.beforeWorkspaceGrantLock("renewal")
|
||||
p.leaseMu.Lock()
|
||||
now := p.workspaceNow() // read under leaseMu: the forced-barrier argument needs it
|
||||
@@ -268,7 +274,7 @@ func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder stri
|
||||
}
|
||||
if !lv.d.leasePresent {
|
||||
unlock() // never re-enter p.mu while holding the leaf
|
||||
return p.firstWorkspaceGrant(ctx, volume, holder, epoch)
|
||||
return p.firstWorkspaceGrant(ctx, volume, holder, epoch, proof)
|
||||
}
|
||||
if lv.d.revoking { // tell the host to drain; never extend
|
||||
l := lv.d.lease
|
||||
@@ -278,7 +284,7 @@ func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder stri
|
||||
}
|
||||
if !now.Before(lv.deadline) || (p.formatLevel == 0 && now.UnixNano() >= lv.d.horizon) {
|
||||
unlock()
|
||||
return p.regrantWorkspaceLease(ctx, volume, holder, epoch)
|
||||
return p.regrantWorkspaceLease(ctx, volume, holder, epoch, proof)
|
||||
}
|
||||
// Where the synchronous write used to refuse (persistWorkspaceLocked):
|
||||
// a renewal never bypasses uncertainty (INV-AUTH-UNCERTAIN-001).
|
||||
@@ -286,6 +292,13 @@ func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder stri
|
||||
unlock()
|
||||
return WorkspaceLease{}, fmt.Errorf("workspace durable store unavailable or uncertain")
|
||||
}
|
||||
// A live deadline does not prove that the caller is the capable process
|
||||
// checked by finalize: a replacement may already have reported level 0.
|
||||
// Validate its current report under this leaf lock, without I/O or mu.
|
||||
if err := p.formatReadProofError(proof, holder, epoch, lv.d.incarnation); err != nil {
|
||||
unlock()
|
||||
return WorkspaceLease{}, err
|
||||
}
|
||||
if p.formatLevel == 0 {
|
||||
return p.renewV100Locked(volume, holder, epoch, lv, now) // releases leaseMu
|
||||
}
|
||||
@@ -314,7 +327,7 @@ func (p *Publisher) RenewWorkspaceLease(ctx context.Context, volume, holder stri
|
||||
// its holder's lease. A host whose first renewal fails does not fence: it has
|
||||
// no deadline yet and retries. The record's ExpiresAtNS is now+1.5*TTL, the
|
||||
// form v1.0.x reads; this process's deadline is now+TTL.
|
||||
func (p *Publisher) firstWorkspaceGrant(ctx context.Context, volume, holder string, epoch uint64) (WorkspaceLease, error) {
|
||||
func (p *Publisher) firstWorkspaceGrant(ctx context.Context, volume, holder string, epoch uint64, proof FormatReadProof) (WorkspaceLease, error) {
|
||||
p.beforeWorkspaceGrantLock("first grant")
|
||||
p.mu.Lock()
|
||||
if p.deleteReserved[volume] {
|
||||
@@ -326,6 +339,10 @@ func (p *Publisher) firstWorkspaceGrant(ctx context.Context, volume, holder stri
|
||||
p.mu.Unlock()
|
||||
return WorkspaceLease{}, fmt.Errorf("workspace lease: stale authority")
|
||||
}
|
||||
if err := p.formatReadProofError(proof, holder, epoch, line.info.Incarnation); err != nil {
|
||||
p.mu.Unlock()
|
||||
return WorkspaceLease{}, err
|
||||
}
|
||||
s := cloneWorkspace(p.workspace[volume])
|
||||
if s == nil {
|
||||
s = &WorkspaceState{}
|
||||
@@ -356,7 +373,7 @@ func (p *Publisher) firstWorkspaceGrant(ctx context.Context, volume, holder stri
|
||||
// INV-WS-LEASE-REGRANT-001: serialize an expired re-grant with move issue,
|
||||
// reusing the forced-move barrier so the old process's validity is past.
|
||||
// The live renewal path releases leaseMu before entering this writer.
|
||||
func (p *Publisher) regrantWorkspaceLease(ctx context.Context, volume, holder string, epoch uint64) (WorkspaceLease, error) {
|
||||
func (p *Publisher) regrantWorkspaceLease(ctx context.Context, volume, holder string, epoch uint64, proof FormatReadProof) (WorkspaceLease, error) {
|
||||
p.beforeWorkspaceGrantLock("regrant")
|
||||
// INV-WS-RENEW-NONBLOCKING-001: a held writer refuses this attempt;
|
||||
// a returning process can retry after that writer has settled.
|
||||
@@ -376,6 +393,9 @@ func (p *Publisher) regrantWorkspaceLease(ctx context.Context, volume, holder st
|
||||
s.Lease.ReplicaID != holder || s.Lease.Epoch != epoch {
|
||||
return WorkspaceLease{}, fmt.Errorf("workspace lease: stale authority")
|
||||
}
|
||||
if err := p.formatReadProofError(proof, holder, epoch, line.info.Incarnation); err != nil {
|
||||
return WorkspaceLease{}, err
|
||||
}
|
||||
if s.Lease.Revoking || s.Ack != nil || (len(s.Moves) > 0 && !s.Moves[len(s.Moves)-1].Issued) {
|
||||
return WorkspaceLease{}, fmt.Errorf("workspace lease: revocation or move pending")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
)
|
||||
|
||||
const finalizeSetupCheckpoint = "FINALIZE_SETUP_COMPLETE"
|
||||
const finalizeFaultCheckpoint = "FINALIZE_POST_RENAME_FAULT"
|
||||
const finalizeLogCheckpoint = "FINALIZE_LOG_ENTERED"
|
||||
const finalizeWindowCheckpoint = "FINALIZE_INTENT_AND_GRANTS_CHECKED"
|
||||
|
||||
type blockedFinalizeLog struct{ check func() }
|
||||
|
||||
func (w blockedFinalizeLog) Write([]byte) (int, error) {
|
||||
fmt.Fprintln(os.Stderr, finalizeLogCheckpoint)
|
||||
w.check()
|
||||
fmt.Fprintln(os.Stderr, finalizeWindowCheckpoint)
|
||||
select {}
|
||||
}
|
||||
|
||||
func qualifiedFinalizeFailure(out []byte, err, contextErr error, sink string) bool {
|
||||
var exit *exec.ExitError
|
||||
if contextErr != nil || !errors.As(err, &exit) || exit.ExitCode() != authority.ExitDurabilityUnknown {
|
||||
return false
|
||||
}
|
||||
for _, marker := range []string{finalizeSetupCheckpoint, finalizeFaultCheckpoint} {
|
||||
if strings.Count(string(out), marker) != 1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if sink == "blocked" {
|
||||
return strings.Count(string(out), finalizeLogCheckpoint) == 1 && strings.Count(string(out), finalizeWindowCheckpoint) == 1
|
||||
}
|
||||
return strings.Contains(string(out), "ERROR") && strings.Contains(string(out), "supervisor restarts")
|
||||
}
|
||||
|
||||
func TestFormatFinalizeUncertainWriteFailStops(t *testing.T) {
|
||||
for _, sink := range []string{"normal", "blocked", "setup-failure", "setup-durability-failure"} {
|
||||
t.Run(sink, func(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestFormatFinalizeUncertainWriteChild$", "-test.count=1")
|
||||
cmd.Env = append(os.Environ(), "FINALIZE_FAILURE_CHILD="+sink)
|
||||
out, err := cmd.CombinedOutput()
|
||||
qualified := qualifiedFinalizeFailure(out, err, ctx.Err(), sink)
|
||||
if sink == "setup-failure" || sink == "setup-durability-failure" {
|
||||
expected := 1
|
||||
if sink == "setup-durability-failure" {
|
||||
expected = authority.ExitDurabilityUnknown
|
||||
}
|
||||
var exit *exec.ExitError
|
||||
if qualified || ctx.Err() != nil || !errors.As(err, &exit) || exit.ExitCode() != expected || !strings.Contains(string(out), "injected setup") {
|
||||
t.Fatalf("setup failure was not distinguished: %v ctx=%v\n%s", err, ctx.Err(), out)
|
||||
}
|
||||
return
|
||||
}
|
||||
if !qualified {
|
||||
t.Fatalf("fault/checkpoints did not qualify exit %d: %v ctx=%v\n%s", authority.ExitDurabilityUnknown, err, ctx.Err(), out)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func finalizeFailureRig(t *testing.T) *isolationRig {
|
||||
t.Helper()
|
||||
dir := upgradedStoreDir(t)
|
||||
disk, err := authority.NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Put(authority.DurableRecord{VolumeID: "v", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, WriteSeq: 1, DataAddr: hbPorts["node-b"][0], CtrlAddr: hbPorts["node-b"][1]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := newIsolationRig(t, false, dir, t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
r.place(t, "v", "node-b")
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func TestFormatFinalizeUncertainWriteChild(t *testing.T) {
|
||||
sink := os.Getenv("FINALIZE_FAILURE_CHILD")
|
||||
if sink == "" {
|
||||
t.Skip("bounded fault child")
|
||||
}
|
||||
if sink == "setup-durability-failure" {
|
||||
fmt.Fprintln(os.Stderr, "ERROR injected setup durability failure; supervisor restarts")
|
||||
os.Exit(authority.ExitDurabilityUnknown)
|
||||
}
|
||||
if sink == "setup-failure" {
|
||||
t.Fatal("injected setup failure before checkpoints")
|
||||
}
|
||||
r := finalizeFailureRig(t)
|
||||
fmt.Fprintln(os.Stderr, finalizeSetupCheckpoint)
|
||||
r.m.log = log.New(os.Stderr, "", 0)
|
||||
if sink == "blocked" {
|
||||
r.m.log = log.New(blockedFinalizeLog{check: func() {
|
||||
if !r.m.formatFinalizing.Load() || r.m.Publisher().FormatLevel() != 0 {
|
||||
t.Fatal("host intent lost or level raised before recovery")
|
||||
}
|
||||
// At level 0, refusal without a report observes the publisher's intent.
|
||||
if _, err := r.m.Publisher().RenewWorkspaceLease(r.ctx, "v", "r1", 1); err == nil {
|
||||
t.Fatal("publisher intent reopened an unreported serving deadline")
|
||||
}
|
||||
proof := r.m.formatReadProof("v", "r1", "node-b", 1)
|
||||
if _, err := r.m.Publisher().RenewWorkspaceLease(r.ctx, "v", "r1", 1, proof); err != nil {
|
||||
t.Fatalf("capable live renewal blanket-refused while logging blocked: %v", err)
|
||||
}
|
||||
}}, "", 0)
|
||||
}
|
||||
syncAttestationDir = func(string) error {
|
||||
onDisk, err := loadStoreAttestations(r.m.cfg.AuthorityStoreDir)
|
||||
if err != nil || onDisk.level() != 1 {
|
||||
t.Fatalf("fault did not follow the level-1 rename: %v", err)
|
||||
}
|
||||
fmt.Fprintln(os.Stderr, finalizeFaultCheckpoint)
|
||||
return errors.New("injected post-rename directory barrier failure")
|
||||
}
|
||||
_, _, _ = r.m.FinalizeFormat(1)
|
||||
os.Exit(42)
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
||||
)
|
||||
|
||||
func formatReviewLineRig(t *testing.T) *isolationRig {
|
||||
t.Helper()
|
||||
dir := upgradedStoreDir(t)
|
||||
disk, err := authority.NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = disk.Put(authority.DurableRecord{VolumeID: "v", ReplicaID: "r1", Epoch: 1,
|
||||
EndpointVersion: 1, WriteSeq: 1, DataAddr: hbPorts["node-b"][0],
|
||||
CtrlAddr: hbPorts["node-b"][1], Incarnation: "old-v"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := newIsolationRig(t, false, dir, t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
r.place(t, "v", "node-b")
|
||||
r.createVolume(t, "sibling")
|
||||
r.place(t, "sibling", "node-b")
|
||||
r.m.Publisher().FinalizeFormatLevel()
|
||||
r.m.format.v.Store(1)
|
||||
return r
|
||||
}
|
||||
|
||||
func TestFormatRefreshUsesItsOwnReportDespiteAnOldSibling(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
r := formatReviewLineRig(t)
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-sibling", "sibling", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "new-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
line, ok := r.m.Publisher().VolumeAuthorityLine("v")
|
||||
if !ok {
|
||||
t.Fatal("missing existing line")
|
||||
}
|
||||
ask := authority.AssignmentAsk{VolumeID: "v", ReplicaID: line.ReplicaID,
|
||||
DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr, Intent: authority.IntentRefreshEndpoint,
|
||||
Incarnation: "new-v", ExpectCurrent: &authority.ExpectedLine{ReplicaID: line.ReplicaID,
|
||||
Epoch: line.Epoch, DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr}}
|
||||
called := false
|
||||
if err := r.m.admitWorkspacePublicationNow(ask, func() error { called = true; return nil }); err != nil || !called {
|
||||
t.Fatalf("capable existing-holder refresh blocked by sibling: called=%v err=%v", called, err)
|
||||
}
|
||||
// A new placement still faces the server-wide known-old gate.
|
||||
ask.Intent, ask.ExpectCurrent = authority.IntentBind, nil
|
||||
if err := r.m.admitWorkspacePublicationNow(ask, func() error { t.Error("new placement admitted"); return nil }); err == nil {
|
||||
t.Fatal("new placement ignored the old sibling")
|
||||
}
|
||||
ask.Intent = authority.IntentRefreshEndpoint
|
||||
ask.ExpectCurrent = &authority.ExpectedLine{ReplicaID: line.ReplicaID, Epoch: line.Epoch,
|
||||
DataAddr: line.DataAddr, CtrlAddr: line.CtrlAddr}
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-v-replacement", "v", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := r.m.admitWorkspacePublicationNow(ask, func() error { t.Error("old refresh admitted"); return nil }); err == nil {
|
||||
t.Fatal("refresh ignored its own old report")
|
||||
}
|
||||
}
|
||||
|
||||
// A heal of the current holder and a failover to a replica's committed
|
||||
// holder give no new placement to their server: an old sibling process there
|
||||
// does not refuse them; the volume's own old process does.
|
||||
func TestFormatReassignUsesItsOwnReportDespiteAnOldSibling(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
r := formatReviewLineRig(t)
|
||||
if _, err := r.m.Lifecycle().Placements.ApplyPlan(lifecycle.PlacementPlan{VolumeID: "v", DesiredRF: 2, Candidates: []lifecycle.PlacementCandidate{
|
||||
{VolumeID: "v", ServerID: "node-b", ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica},
|
||||
{VolumeID: "v", ServerID: "node-c", ReplicaID: "r2", Source: lifecycle.PlacementSourceExistingReplica}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for name, ask := range map[string]authority.AssignmentAsk{
|
||||
"heal": {VolumeID: "v", ReplicaID: "r1", DataAddr: hbPorts["node-b"][0], CtrlAddr: hbPorts["node-b"][1], Intent: authority.IntentReassign},
|
||||
"failover": {VolumeID: "v", ReplicaID: "r2", DataAddr: hbPorts["node-c"][0], CtrlAddr: hbPorts["node-c"][1], Intent: authority.IntentReassign},
|
||||
} {
|
||||
server := map[string]string{"r1": "node-b", "r2": "node-c"}[ask.ReplicaID]
|
||||
if err := r.fgProcessHeartbeat(server, "old-sibling", "sibling", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat(server, "new-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := r.m.admitWorkspacePublicationNow(ask, func() error { return nil }); err != nil {
|
||||
t.Fatalf("%s of a capable holder refused by its old sibling: %v", name, err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat(server, "old-v", "v", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := r.m.admitWorkspacePublicationNow(ask, func() error { t.Errorf("%s by an old process admitted", name); return nil }); err == nil {
|
||||
t.Fatalf("%s ignored its own old report", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatPlacedLineKeepsItsReportWait(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
r := formatReviewLineRig(t)
|
||||
if err := r.fgProcessHeartbeat("node-b", "reported-sibling", "sibling", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
start := time.Now()
|
||||
waits := r.m.grantWaits(start)["node-b"]
|
||||
if len(waits) != 1 || waits[0].volume != "v" {
|
||||
t.Fatalf("placed unreported holder disappeared from waits: %+v", waits)
|
||||
}
|
||||
late := r.m.grantWaits(start.Add(r.m.grantStartupWindow() + time.Second))["node-b"]
|
||||
if len(late) != 1 || late[0].volume != "v" || !late[0].late {
|
||||
t.Fatalf("placed holder has no overdue warning: %+v", late)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "reported-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if waits := r.m.grantWaits(start)["node-b"]; len(waits) != 0 {
|
||||
t.Fatalf("reported holder still waits: %+v", waits)
|
||||
}
|
||||
}
|
||||
|
||||
//go:noinline
|
||||
func queuedReviewFinalize(h *Host, result chan<- error) {
|
||||
_, _, err := h.FinalizeFormat(1)
|
||||
result <- err
|
||||
}
|
||||
|
||||
func TestQueuedFinalizeDoesNotHoldWorkspaceAdmission(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
r.m.finalizeMu.Lock() // the serializer the active durable finalize holds
|
||||
release := sync.OnceFunc(r.m.finalizeMu.Unlock)
|
||||
t.Cleanup(release)
|
||||
done := make(chan error, 1)
|
||||
go queuedReviewFinalize(r.m, done)
|
||||
for {
|
||||
stacks := make([]byte, 1<<20)
|
||||
n := runtime.Stack(stacks, true)
|
||||
waiting := false
|
||||
for _, stack := range strings.Split(string(stacks[:n]), "\n\n") {
|
||||
if strings.Contains(stack, "queuedReviewFinalize") && strings.Contains(stack, "sync.(*Mutex).lockSlow") {
|
||||
waiting = true
|
||||
}
|
||||
}
|
||||
if waiting {
|
||||
break
|
||||
}
|
||||
select {
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("second finalize never waited on serialization")
|
||||
default:
|
||||
runtime.Gosched()
|
||||
}
|
||||
}
|
||||
admitted := make(chan struct{})
|
||||
go func() { r.m.workspaceMu.Lock(); r.m.workspaceMu.Unlock(); close(admitted) }()
|
||||
select {
|
||||
case <-admitted:
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("queued finalize holds workspace admission behind the durable write")
|
||||
}
|
||||
release()
|
||||
select {
|
||||
case err := <-done:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("queued finalize did not finish")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/lifecycleclient"
|
||||
)
|
||||
|
||||
// A held persistence callback and all Host teardown stay in a bounded child.
|
||||
func finalizeServingChild(t *testing.T) bool {
|
||||
t.Helper()
|
||||
if os.Getenv("FINALIZE_SERVING_CHILD") == t.Name() {
|
||||
return true
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$", "-test.count=1")
|
||||
cmd.Env = append(os.Environ(), "FINALIZE_SERVING_CHILD="+t.Name())
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("bounded finalize child: %v\n%s", err, out)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestFinalizeRequiresTheGrantedHoldersReadReport(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
reported bool
|
||||
level uint32
|
||||
}{
|
||||
{"never-reported", false, 0}, {"stale-old", true, 0}, {"stale-capable", true, 1},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := upgradedStoreDir(t)
|
||||
disk, err := authority.NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Put(authority.DurableRecord{VolumeID: "v", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, WriteSeq: 1, DataAddr: "127.0.0.1:19301", CtrlAddr: "127.0.0.1:19302"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := newIsolationRig(t, false, dir, t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
r.place(t, "v", "node-b")
|
||||
var now atomic.Int64
|
||||
now.Store(time.Now().UnixNano())
|
||||
r.m.reads.now = func() time.Time { return time.Unix(0, now.Load()) }
|
||||
if tc.reported {
|
||||
if err := r.fgProcessHeartbeat("node-b", "holder-v", "v", tc.level); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// This is an actual level-0 grant, not just an unserved placement.
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
now.Add(int64(time.Hour)) // old report remains tied to the serving volume
|
||||
response, err := r.lc.FinalizeFormat(r.ctx, &control.FinalizeFormatRequest{Level: 1})
|
||||
if tc.level == 1 {
|
||||
if err != nil || response.GetFormatLevel() != 1 {
|
||||
t.Fatalf("reported capable holder: %v %v", response, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if reasonOf(err) != lifecycleclient.ReasonFormatHostsTooOld || !strings.Contains(err.Error(), "node-b") || !strings.Contains(err.Error(), "volume v") {
|
||||
t.Fatalf("serving holder without a level-1 report: response=%v error=%v, want typed refusal naming node-b / volume v", response, err)
|
||||
}
|
||||
if r.m.formatLevel() != 0 {
|
||||
t.Fatal("refused finalize changed the level")
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "holder-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if response, err := r.lc.FinalizeFormat(r.ctx, &control.FinalizeFormatRequest{Level: 1}); err != nil || response.GetFormatLevel() != 1 {
|
||||
t.Fatalf("capable holder cannot finalize: %v %v", response, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFinalizeSerializesTheLevelZeroPublicationBoundary(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
dir := upgradedStoreDir(t)
|
||||
disk, err := authority.NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Put(authority.DurableRecord{VolumeID: "v", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, WriteSeq: 1, DataAddr: hbPorts["node-b"][0], CtrlAddr: hbPorts["node-b"][1]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := newIsolationRig(t, false, dir, t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
r.place(t, "v", "node-b")
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.createVolume(t, "fresh")
|
||||
if _, err := r.ws.RegisterWorkspaceBinding(r.ctx, &control.WorkspaceBinding{VolumeId: "fresh", ServerId: "node-b", DataAddr: "127.0.0.1:19301", CtrlAddr: "127.0.0.1:19302"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
entered, release := make(chan struct{}), make(chan struct{})
|
||||
releaseOnce := sync.OnceFunc(func() { close(release) })
|
||||
previous := syncAttestationDir
|
||||
syncAttestationDir = func(dir string) error { close(entered); <-release; return previous(dir) }
|
||||
t.Cleanup(func() { syncAttestationDir = previous })
|
||||
t.Cleanup(releaseOnce)
|
||||
finalized := make(chan error, 1)
|
||||
go func() { _, _, err := r.m.FinalizeFormat(1); finalized <- err }()
|
||||
select {
|
||||
case <-entered:
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("finalize never reached its directory barrier")
|
||||
}
|
||||
// A valid renewal must complete while the actual durable raise is held.
|
||||
renewCtx, cancelRenew := context.WithTimeout(r.ctx, time.Second)
|
||||
_, renewErr := r.ws.RenewWorkspaceLease(renewCtx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"})
|
||||
cancelRenew()
|
||||
if renewErr != nil {
|
||||
t.Fatalf("renewal blocked by durable finalize: %v", renewErr)
|
||||
}
|
||||
// The holder restarts on a level-0 binary after the finalize check.
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-v", "v", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err == nil {
|
||||
t.Fatal("replacement old process renewed the still-live lease during finalize")
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err != nil {
|
||||
t.Fatalf("capable process could not resume memory-only renewal during finalize: %v", err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-v", "v", 0); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.PlaceWorkspace(r.ctx, &control.WorkspacePlacement{VolumeId: "fresh", ServerId: "node-b", ReplicaId: "r1"}); reasonOf(err) != lifecycleclient.ReasonBinaryTooOld {
|
||||
t.Fatalf("known-old placement bypassed finalize intent: %v", err)
|
||||
}
|
||||
preview, err := r.ws.PreviewWorkspaceMove(r.ctx, &control.WorkspaceMove{RequestId: "during-finalize", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "forced", Force: true})
|
||||
if err != nil || preview.GetAdmitted() || preview.GetReasonCode() != lifecycleclient.ReasonBinaryTooOld {
|
||||
t.Fatalf("old guarded move bypassed finalize intent: %v %v", preview, err)
|
||||
}
|
||||
granted := make(chan error, 1)
|
||||
var published atomic.Bool
|
||||
go func() {
|
||||
granted <- r.m.admitWorkspacePublication(authority.AssignmentAsk{VolumeID: "v", ReplicaID: "r1", DataAddr: hbPorts["node-b"][0], CtrlAddr: hbPorts["node-b"][1], Intent: authority.IntentBind}, func() error { published.Store(true); return nil })
|
||||
}()
|
||||
// The intent must reject the old publication before the held write ends.
|
||||
select {
|
||||
case err := <-granted:
|
||||
if err == nil || published.Load() || !strings.Contains(err.Error(), "binary_too_old") {
|
||||
t.Fatalf("level-0 publication crossed the finalize barrier: published=%v error=%v", published.Load(), err)
|
||||
}
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("publication waited for the durable write instead of checking the intent")
|
||||
}
|
||||
releaseOnce()
|
||||
select {
|
||||
case err := <-finalized:
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("finalize did not finish")
|
||||
}
|
||||
// Completing the durable raise keeps the renewal proof gate. Unknown
|
||||
// move targets remain placeable and still face the ordinary lease barrier.
|
||||
r.m.reads.forget("node-b")
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err == nil {
|
||||
t.Fatal("unreported process renewed after finalize completed")
|
||||
}
|
||||
preview, err = r.ws.PreviewWorkspaceMove(r.ctx, &control.WorkspaceMove{RequestId: "after-finalize", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "forced", Force: true})
|
||||
if err != nil || !strings.Contains(preview.GetReason(), "lease expiry plus clock-skew") {
|
||||
t.Fatalf("unreported guarded move did not reach its existing lease barrier: %v %v", preview, err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
preview, err = r.ws.PreviewWorkspaceMove(r.ctx, &control.WorkspaceMove{RequestId: "after-finalize-capable", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "forced", Force: true})
|
||||
if err != nil || preview.GetReasonCode() == lifecycleclient.ReasonFormatHostsTooOld || !strings.Contains(preview.GetReason(), "lease expiry plus clock-skew") {
|
||||
t.Fatalf("reported capable guarded move did not reach its existing lease barrier: %v %v", preview, err)
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,14 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout"
|
||||
"github.com/seaweedfs/seaweed-block/core/lifecycle"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
@@ -36,9 +38,10 @@ type readsLevels struct {
|
||||
}
|
||||
|
||||
type procLevel struct {
|
||||
level uint32
|
||||
process string
|
||||
seen time.Time
|
||||
level uint32
|
||||
process string
|
||||
seen time.Time
|
||||
revision *atomic.Uint64
|
||||
}
|
||||
|
||||
func newReadsLevels(window time.Duration) *readsLevels {
|
||||
@@ -52,13 +55,26 @@ func (r *readsLevels) note(server, volume, process string, level uint32) {
|
||||
if r.procs[server] == nil {
|
||||
r.procs[server] = map[string]procLevel{}
|
||||
}
|
||||
r.procs[server][volume] = procLevel{level: level, process: process, seen: r.now()}
|
||||
previous, known := r.procs[server][volume]
|
||||
revision := previous.revision
|
||||
if revision == nil {
|
||||
revision = &atomic.Uint64{}
|
||||
}
|
||||
if !known || previous.level != level || previous.process != process {
|
||||
revision.Add(1)
|
||||
}
|
||||
r.procs[server][volume] = procLevel{level: level, process: process, seen: r.now(), revision: revision}
|
||||
}
|
||||
|
||||
// forget drops every entry of server (a retired host).
|
||||
func (r *readsLevels) forget(server string) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
for _, e := range r.procs[server] {
|
||||
if e.revision != nil {
|
||||
e.revision.Add(1)
|
||||
}
|
||||
}
|
||||
delete(r.procs, server)
|
||||
}
|
||||
|
||||
@@ -69,6 +85,9 @@ func (r *readsLevels) liveLocked(server string, served map[string]bool) map[stri
|
||||
cutoff := r.now().Add(-r.window)
|
||||
for v, e := range r.procs[server] {
|
||||
if e.seen.Before(cutoff) && !served[v] {
|
||||
if e.revision != nil {
|
||||
e.revision.Add(1)
|
||||
}
|
||||
delete(r.procs[server], v)
|
||||
}
|
||||
}
|
||||
@@ -171,12 +190,21 @@ type formatLevelState struct{ v atomic.Uint32 }
|
||||
// finalizes the v1.1 format.
|
||||
func (h *Host) formatLevel() uint32 { return h.format.v.Load() }
|
||||
|
||||
// Admission follows the target level during the in-flight finalize; replies
|
||||
// and persisted data still use the durable format level until it commits.
|
||||
func (h *Host) admissionFormatLevel() uint32 {
|
||||
if h.formatFinalizing.Load() {
|
||||
return 1
|
||||
}
|
||||
return h.formatLevel()
|
||||
}
|
||||
|
||||
// formatEligible reports whether server may be GRANTED work (an authority
|
||||
// line published to it, and with it its lease) at the cluster's format
|
||||
// level: its own report says its binary reads that level; no report means
|
||||
// no grant (NoStrand holds at the grant). At level 0 every server is.
|
||||
func (h *Host) formatEligible(server string) bool {
|
||||
level := h.formatLevel()
|
||||
level := h.admissionFormatLevel()
|
||||
if level == 0 {
|
||||
return true
|
||||
}
|
||||
@@ -203,7 +231,7 @@ func (h *Host) grantStartupWindow() time.Duration {
|
||||
}
|
||||
|
||||
// grantWaitEntry is a placed volume whose holder process on a server has
|
||||
// not reported (no grant before its report) and that has no line yet.
|
||||
// not reported (no serving grant before its report), even if a line was placed.
|
||||
type grantWaitEntry struct {
|
||||
volume string
|
||||
waited time.Duration
|
||||
@@ -212,9 +240,10 @@ type grantWaitEntry struct {
|
||||
|
||||
// grantWaits computes, once per status snapshot, the complete set of
|
||||
// (server, volume) grant waits at a level above 0: every placed slot without
|
||||
// an authority line whose own process on its server has not reported. The
|
||||
// a report from its own process on its server. A placed line is not a serving grant;
|
||||
// it waits on the line's owner only (a move leaves the placement). The
|
||||
// first-seen times are reconciled against that one set: an entry that left
|
||||
// it (granted, reported, unplaced, removed) is dropped, a new one starts
|
||||
// it (reported, moved, unplaced, removed) is dropped, a new one starts
|
||||
// now. The key is server and volume, so waits on different servers never
|
||||
// reset each other.
|
||||
func (h *Host) grantWaits(now time.Time) map[string][]grantWaitEntry {
|
||||
@@ -239,17 +268,23 @@ func (h *Host) grantWaits(now time.Time) map[string][]grantWaitEntry {
|
||||
if h.formatLevel() > 0 {
|
||||
window := h.grantStartupWindow()
|
||||
for _, p := range placements {
|
||||
if _, granted := h.Publisher().VolumeAuthorityLine(p.VolumeID); granted {
|
||||
continue
|
||||
var servers []string
|
||||
if line, ok := h.Publisher().PublishedAuthorityLine(p.VolumeID); ok {
|
||||
// A move does not rewrite the placement: a line waits on its owner.
|
||||
servers = []string{h.workspaceLineOwner(line, p.VolumeID, line.ReplicaID, line.Epoch)}
|
||||
} else {
|
||||
for _, slot := range p.Slots {
|
||||
servers = append(servers, slot.ServerID)
|
||||
}
|
||||
}
|
||||
for _, slot := range p.Slots {
|
||||
if slot.ServerID == "" {
|
||||
for _, server := range servers {
|
||||
if server == "" {
|
||||
continue
|
||||
}
|
||||
if _, reported := h.reads.entry(slot.ServerID, p.VolumeID, h.servedBy(slot.ServerID)); reported {
|
||||
if _, reported := h.reads.entry(server, p.VolumeID, h.servedBy(server)); reported {
|
||||
continue
|
||||
}
|
||||
key := slot.ServerID + "\x00" + p.VolumeID
|
||||
key := server + "\x00" + p.VolumeID
|
||||
live[key] = true
|
||||
first, seen := h.grantWait[key]
|
||||
if !seen {
|
||||
@@ -260,7 +295,7 @@ func (h *Host) grantWaits(now time.Time) map[string][]grantWaitEntry {
|
||||
if waited < 0 { // a caller's now taken before another snapshot started this wait
|
||||
waited = 0
|
||||
}
|
||||
out[slot.ServerID] = append(out[slot.ServerID], grantWaitEntry{volume: p.VolumeID, waited: waited, late: waited > window})
|
||||
out[server] = append(out[server], grantWaitEntry{volume: p.VolumeID, waited: waited, late: waited > window})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,9 +314,9 @@ func (h *Host) grantWaits(now time.Time) map[string][]grantWaitEntry {
|
||||
// (create, move, restore target, a failover candidate), or "" when it may:
|
||||
// only a KNOWN-old report refuses. An unknown server is placeable,
|
||||
// since with one process per volume and create-then-start a placement target
|
||||
// cannot have reported yet; the grant (formatTooOld) still needs its report.
|
||||
// cannot have reported yet; a serving deadline still needs its own report.
|
||||
func (h *Host) placementTooOld(server string) string {
|
||||
level := h.formatLevel()
|
||||
level := h.admissionFormatLevel()
|
||||
if level == 0 {
|
||||
return ""
|
||||
}
|
||||
@@ -304,26 +339,6 @@ func (h *Host) formatRefusal(prefix, server string) error {
|
||||
return lifecycleclient.WithReason(status.New(codes.FailedPrecondition, prefix+why), lifecycleclient.ReasonBinaryTooOld).Err()
|
||||
}
|
||||
|
||||
// grantTooOld names why the process that will serve volume on server may not
|
||||
// be granted its line, or "" when it may: the grant reads that process's own
|
||||
// report (the (server, volume) entry), never a sibling process's, since
|
||||
// with one process per volume a sibling's report says nothing about this
|
||||
// one's binary. No report means no grant; a lower one is binary_too_old.
|
||||
func (h *Host) grantTooOld(server, volume string) string {
|
||||
level := h.formatLevel()
|
||||
if level == 0 {
|
||||
return ""
|
||||
}
|
||||
reads, ok := h.reads.entry(server, volume, h.servedBy(server))
|
||||
if !ok {
|
||||
return fmt.Sprintf("node %q has not reported the format read level of its process for volume %q; the cluster's format level is %d (no grant before that process's report)", server, volume, level)
|
||||
}
|
||||
if reads < level {
|
||||
return fmt.Sprintf("node %q's process for volume %q reads format level %d; the cluster's format level is %d (binary_too_old)", server, volume, reads, level)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// formatTooOld names why server is not format-eligible, or "" when it is.
|
||||
func (h *Host) formatTooOld(server string) string {
|
||||
if h.formatEligible(server) {
|
||||
@@ -432,7 +447,7 @@ func (e errFormatHostsTooOld) Error() string {
|
||||
for i, b := range e.hosts {
|
||||
named[i] = fmt.Sprintf("%s (%s)", b.server, b.detail)
|
||||
}
|
||||
return fmt.Sprintf("format finalize refused: processes holding volumes report a level below 1: %s; upgrade each one, or move its volumes (sw-block ops workspace move)", strings.Join(named, ", "))
|
||||
return fmt.Sprintf("format finalize refused: processes holding volumes have not reported reading level 1: %s; upgrade each named volume process to v1.1.x and let it report, or move/release its volumes, then retry", strings.Join(named, ", "))
|
||||
}
|
||||
|
||||
// metadata keys each refused host, and each host not confirmed, for the
|
||||
@@ -474,9 +489,10 @@ func (e errHostHoldsWork) metadata() map[string]string {
|
||||
}
|
||||
|
||||
// FinalizeFormat raises the cluster's format level to 1 (FormatGate:
|
||||
// Finalize; FormatGateMaster: the one durable step). It is refused only while
|
||||
// a process that holds work reports a lower level (finalizeCheck); the hosts
|
||||
// it cannot confirm are answered, not blocking. Otherwise, in order: the
|
||||
// Finalize; FormatGateMaster: the one durable step). The existing known-old
|
||||
// work check remains; a possibly-serving current lease also needs its own
|
||||
// level-1 report. An admission intent closes level-0 grants during the store
|
||||
// write without holding either publisher grant lock. Otherwise, in order: the
|
||||
// attestation envelope is written durably (the level, and the fence against
|
||||
// v1.0.x masters, in one write); the publisher switches to level 1 under its
|
||||
// locks; then the answer. At level 1 it writes nothing (already).
|
||||
@@ -484,24 +500,72 @@ func (h *Host) FinalizeFormat(level uint32) (already bool, unconfirmed []hostBel
|
||||
if level != 1 {
|
||||
return false, nil, fmt.Errorf("format finalize: level %d; the only level to finalize is 1", level)
|
||||
}
|
||||
// Match RetireHost's lock order. Wait for serialization without holding
|
||||
// workspaceMu, so another finalize cannot block publications over this I/O.
|
||||
// Release workspaceMu before the store
|
||||
// write; the intent then makes every serving deadline use the level-1 gate.
|
||||
h.finalizeMu.Lock()
|
||||
defer h.finalizeMu.Unlock()
|
||||
h.workspaceMu.Lock()
|
||||
if h.formatLevel() >= 1 {
|
||||
h.workspaceMu.Unlock()
|
||||
return true, nil, nil
|
||||
}
|
||||
blocking, unconfirmed := h.finalizeCheck(1)
|
||||
byServer := map[string][]string{}
|
||||
for _, b := range h.Publisher().BeginFormatFinalize(h.finalizeReadProofs(), len(blocking) == 0) {
|
||||
byServer[b.Server] = append(byServer[b.Server], b.Detail)
|
||||
}
|
||||
servers := make([]string, 0, len(byServer))
|
||||
for server := range byServer {
|
||||
servers = append(servers, server)
|
||||
}
|
||||
sort.Strings(servers)
|
||||
for _, server := range servers {
|
||||
merged := false
|
||||
for i := range blocking {
|
||||
if blocking[i].server == server {
|
||||
blocking[i].detail += "; " + strings.Join(byServer[server], "; ")
|
||||
merged = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !merged {
|
||||
blocking = append(blocking, hostBelow{server, strings.Join(byServer[server], "; ")})
|
||||
}
|
||||
}
|
||||
sort.Slice(blocking, func(i, j int) bool { return blocking[i].server < blocking[j].server })
|
||||
if len(blocking) > 0 {
|
||||
h.workspaceMu.Unlock()
|
||||
return false, unconfirmed, errFormatHostsTooOld{hosts: blocking, unconfirmed: unconfirmed}
|
||||
}
|
||||
h.formatFinalizing.Store(true)
|
||||
h.workspaceMu.Unlock()
|
||||
if _, err := h.attest.finalize(); err != nil {
|
||||
var uncertain *attestationWriteUncertain
|
||||
if errors.As(err, &uncertain) {
|
||||
h.failUncertainFormatFinalize(err)
|
||||
}
|
||||
h.Publisher().CancelFormatFinalize()
|
||||
h.formatFinalizing.Store(false)
|
||||
return false, unconfirmed, fmt.Errorf("format finalize: %w", err)
|
||||
}
|
||||
h.Publisher().FinalizeFormatLevel()
|
||||
h.format.v.Store(1)
|
||||
h.formatFinalizing.Store(false)
|
||||
h.log.Printf("blockmaster: cluster format level finalized at 1 (%d hosts unconfirmed, not blocking)", len(unconfirmed))
|
||||
return false, unconfirmed, nil
|
||||
}
|
||||
|
||||
// failUncertainFormatFinalize never reopens level-0 grants over a file whose
|
||||
// rename may already have raised the durable level. Arm exit before logging:
|
||||
// diagnostic delivery is best effort if the sink or its output lock is blocked.
|
||||
func (h *Host) failUncertainFormatFinalize(err error) {
|
||||
time.AfterFunc(time.Second, func() { os.Exit(authority.ExitDurabilityUnknown) })
|
||||
h.log.Printf("ERROR format finalize persistence failure store=%q error=%q; exiting so the supervisor restarts from durable state", h.attest.path, err)
|
||||
os.Exit(authority.ExitDurabilityUnknown)
|
||||
}
|
||||
|
||||
// RetireHost removes server from the node inventory, so it no longer counts
|
||||
// for the format finalize or for placement. It is refused while server
|
||||
// holds a lease or an assignment for any volume (FormatGate r2: a retire
|
||||
@@ -516,6 +580,8 @@ func (h *Host) RetireHost(server, confirm string) error {
|
||||
}
|
||||
h.finalizeMu.Lock()
|
||||
defer h.finalizeMu.Unlock()
|
||||
h.workspaceMu.Lock()
|
||||
defer h.workspaceMu.Unlock()
|
||||
if _, ok := h.lifecycle.Nodes.GetNode(server); !ok {
|
||||
return fmt.Errorf("retire refused: host %q is not registered", server)
|
||||
}
|
||||
@@ -570,9 +636,8 @@ func (s *services) FormatLevel(ctx context.Context, _ *control.FormatLevelReques
|
||||
return &control.FormatLevelResponse{FormatLevel: s.host.formatLevel()}, nil
|
||||
}
|
||||
|
||||
// RetireHost is the RPC of Host.RetireHost. It holds the workspace lock, as
|
||||
// a placement does, so no placement onto the host lands between its check
|
||||
// and the removal.
|
||||
// RetireHost is the RPC of Host.RetireHost. The host method holds the workspace
|
||||
// lock across its check and removal, after acquiring finalize serialization.
|
||||
func (s *services) RetireHost(ctx context.Context, req *control.RetireHostRequest) (*control.RetireHostResponse, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
@@ -582,8 +647,6 @@ func (s *services) RetireHost(ctx context.Context, req *control.RetireHostReques
|
||||
return nil, workspaceError(err)
|
||||
}
|
||||
}
|
||||
s.host.workspaceMu.Lock()
|
||||
defer s.host.workspaceMu.Unlock()
|
||||
err := s.host.RetireHost(req.GetServerId(), req.GetConfirm())
|
||||
var holds errHostHoldsWork
|
||||
var storage errRetireStorage
|
||||
@@ -597,3 +660,33 @@ func (s *services) RetireHost(ctx context.Context, req *control.RetireHostReques
|
||||
}
|
||||
return &control.RetireHostResponse{ServerId: req.GetServerId()}, nil
|
||||
}
|
||||
|
||||
// formatReadProof is captured before the publisher's grant locks. A concurrent
|
||||
// process/read-level change invalidates it through the atomic revision.
|
||||
func (h *Host) formatReadProof(volume, replica, server string, epoch uint64) authority.FormatReadProof {
|
||||
h.reads.mu.Lock()
|
||||
defer h.reads.mu.Unlock()
|
||||
entry, ok := h.reads.procs[server][volume]
|
||||
return authority.FormatReadProof{Server: server, Process: entry.process, Replica: replica, Epoch: epoch, Reads: entry.level, Reported: ok, Revision: entry.revision, Version: formatReportVersion(entry)}
|
||||
}
|
||||
|
||||
func (h *Host) finalizeReadProofs() map[string]authority.FormatReadProof {
|
||||
out := map[string]authority.FormatReadProof{}
|
||||
// workspaceMu is held, so placement and line-owner changes cannot race this
|
||||
// projection. Publisher validates the current line and lease under its locks.
|
||||
h.reads.mu.Lock()
|
||||
defer h.reads.mu.Unlock()
|
||||
for volume, line := range h.Publisher().PublishedAuthorityLines() {
|
||||
server := h.workspaceLineOwner(line, volume, line.ReplicaID, line.Epoch)
|
||||
e, ok := h.reads.procs[server][volume]
|
||||
out[volume] = authority.FormatReadProof{Server: server, Process: e.process, Replica: line.ReplicaID, Epoch: line.Epoch, Reads: e.level, Reported: ok, Revision: e.revision, Version: formatReportVersion(e)}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func formatReportVersion(e procLevel) uint64 {
|
||||
if e.revision == nil {
|
||||
return 0
|
||||
}
|
||||
return e.revision.Load()
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func binaryTooOld(err error) bool {
|
||||
// Every binary's heartbeat is taken and its read level recorded, at level 0
|
||||
// and at level 1 alike (the refusal is at the grant, never at the
|
||||
// heartbeat); at level 1 a host whose process reads only level 0 is then
|
||||
// known old, so placement skips it (its grant is refused at the publication
|
||||
// known old, so placement skips it (publication is refused at the admission
|
||||
// boundary: TestThePublicationBoundaryRefusesAnAskForAnOldServer).
|
||||
func TestFormatGateRecordsAnOldBinarysHeartbeatAtLevel1(t *testing.T) {
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
@@ -69,8 +69,9 @@ func TestFormatGateRecordsAnOldBinarysHeartbeatAtLevel1(t *testing.T) {
|
||||
}
|
||||
|
||||
// At level 1 no new work goes to a host that does not read it: a workspace
|
||||
// placement and a move onto an old host (or one that never reported) are
|
||||
// refused; at level 0 they are not refused for the format (FormatGate:
|
||||
// placement and a move onto a known-old host are
|
||||
// refused; an unreported target is allowed. At level 0 neither is refused
|
||||
// for the format (FormatGate:
|
||||
// Assign, NoStrand).
|
||||
func TestFormatGateRefusesPlacementAndMoveOntoAnOldHost(t *testing.T) {
|
||||
for _, level := range []uint32{1, 0} {
|
||||
@@ -93,10 +94,15 @@ func TestFormatGateRefusesPlacementAndMoveOntoAnOldHost(t *testing.T) {
|
||||
_, placeErr := r.ws.PlaceWorkspace(r.ctx, &control.WorkspacePlacement{VolumeId: "fresh", ServerId: "node-b", ReplicaId: "r1"})
|
||||
_, moveErr := r.ws.MoveWorkspace(r.ctx, &control.WorkspaceMove{RequestId: "m1", VolumeId: "placed", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "clean"})
|
||||
if level == 0 || !reported {
|
||||
// level 0, or an unknown (silent) host at level 1: placeable
|
||||
// (placement refuses only a known-old report; the
|
||||
// grant needs the holder's report).
|
||||
if level == 1 && !reported {
|
||||
// Neither placement nor a move record grants a serving deadline.
|
||||
// An unreported target may pass this placement check.
|
||||
if placeErr != nil || (moveErr != nil && strings.Contains(moveErr.Error(), "format")) {
|
||||
t.Fatalf("silent target: placement=%v move=%v", placeErr, moveErr)
|
||||
}
|
||||
return
|
||||
}
|
||||
if level == 0 {
|
||||
if placeErr != nil {
|
||||
t.Fatalf("%s: placement refused: %v", name, placeErr)
|
||||
}
|
||||
@@ -376,24 +382,32 @@ func TestRetireHostRefusesAHostThatHoldsWork(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A finalize whose durable write fails changes no level: the publisher and
|
||||
// the master stay at 0 (the switch follows the write; FormatGateMaster
|
||||
// finalize_not_atomic).
|
||||
// A failure before the rename leaves both levels at 0, reopens admission,
|
||||
// and permits a later finalize retry once the obstruction is removed.
|
||||
func TestAFailedFinalizeWriteLeavesLevel0(t *testing.T) {
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
for _, s := range []string{"node-a", "node-b"} {
|
||||
if err := r.fgHeartbeat(s, 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
r := finalizeFailureRig(t)
|
||||
obstruction := r.m.attest.path + ".tmp"
|
||||
if err := os.Mkdir(obstruction, 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
saved := syncAttestationDir
|
||||
t.Cleanup(func() { syncAttestationDir = saved })
|
||||
syncAttestationDir = func(string) error { return errors.New("injected directory fsync failure") }
|
||||
if _, err := r.lc.FinalizeFormat(r.ctx, &control.FinalizeFormatRequest{Level: 1}); status.Code(err) != codes.Internal {
|
||||
t.Fatalf("a finalize whose envelope write failed: %v, want Internal (a failure, not a transient answer)", err)
|
||||
t.Fatalf("pre-rename failure: %v, want Internal", err)
|
||||
}
|
||||
if r.m.formatLevel() != 0 || r.m.Publisher().FormatLevel() != 0 {
|
||||
t.Fatalf("a failed finalize switched the level: master %d, publisher %d", r.m.formatLevel(), r.m.Publisher().FormatLevel())
|
||||
if r.m.formatLevel() != 0 || r.m.Publisher().FormatLevel() != 0 || r.m.formatFinalizing.Load() {
|
||||
t.Fatal("pre-rename failure changed level or left host intent set")
|
||||
}
|
||||
// A no-report level-0 deadline proves the publisher intent is clear too.
|
||||
if _, err := r.m.Publisher().RenewWorkspaceLease(r.ctx, "v", "r1", 1); err != nil {
|
||||
t.Fatalf("publisher intent was not cleared after pre-rename failure: %v", err)
|
||||
}
|
||||
if err := os.Remove(obstruction); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, _, err := r.m.FinalizeFormat(1); err != nil || r.m.formatLevel() != 1 || r.m.Publisher().FormatLevel() != 1 || r.m.formatFinalizing.Load() {
|
||||
t.Fatalf("finalize could not retry after removing obstruction: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,8 +530,7 @@ func TestThePublicationBoundaryRefusesAnAskForAnOldServer(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
old, silent bool
|
||||
}{{"old-process", true, false}, {"silent (no report: no grant)", false, true}, {"control", false, false}} {
|
||||
old := tc.old || tc.silent
|
||||
}{{"old-process", true, false}, {"silent (placement only)", false, true}, {"control", false, false}} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
@@ -538,10 +551,7 @@ func TestThePublicationBoundaryRefusesAnAskForAnOldServer(t *testing.T) {
|
||||
if tc.old && (err == nil || published || !strings.Contains(err.Error(), "binary_too_old")) {
|
||||
t.Fatalf("level 1, node-b's process reads 0: err %v, published %v; want refused before the publish", err, published)
|
||||
}
|
||||
if tc.silent && (err == nil || published || !strings.Contains(err.Error(), "has not reported")) {
|
||||
t.Fatalf("level 1, node-b never reported: err %v, published %v; want no grant (refused before the publish)", err, published)
|
||||
}
|
||||
if !old && (err != nil || !published) {
|
||||
if !tc.old && (err != nil || !published) {
|
||||
t.Fatalf("control: err %v, published %v; want published", err, published)
|
||||
}
|
||||
})
|
||||
@@ -576,8 +586,8 @@ func TestEveryVolumeOfAHeartbeatKeepsItsLevel(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.m.format.v.Store(1)
|
||||
if why := r.m.grantTooOld("node-b", "vb"); !strings.Contains(why, "binary_too_old") {
|
||||
t.Fatalf("level 1: the grant for vb, held by the silent old process: %q, want binary_too_old", why)
|
||||
if proof := r.m.formatReadProof("vb", "r-b", "node-b", 1); !proof.Reported || proof.Reads != 0 || proof.Process != "old-proc" {
|
||||
t.Fatalf("the grant proof lost vb's own stale old report: %+v", proof)
|
||||
}
|
||||
r.m.format.v.Store(0)
|
||||
resp, err := r.lc.FinalizeFormat(r.ctx, &control.FinalizeFormatRequest{Level: 1})
|
||||
@@ -841,7 +851,7 @@ func upgradedStoreDir(t *testing.T) string {
|
||||
// two servers report the same volume and replica at different endpoints, one
|
||||
// process reading level 1 and one reading level 0; the ask at the first's
|
||||
// endpoints is published, the ask at the second's is refused binary_too_old,
|
||||
// and an ask at endpoints nobody reports is not granted (no report).
|
||||
// and an ask at unreported endpoints may publish, but grants no deadline.
|
||||
func TestAnOwnerlessGrantIsJudgedOnTheServerAtTheAsksEndpoints(t *testing.T) {
|
||||
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
|
||||
if r.m.formatLevel() != 1 {
|
||||
@@ -865,8 +875,8 @@ func TestAnOwnerlessGrantIsJudgedOnTheServerAtTheAsksEndpoints(t *testing.T) {
|
||||
if published, err := grant("127.0.0.1:19601", "127.0.0.1:19602"); err == nil || published || !strings.Contains(err.Error(), "binary_too_old") {
|
||||
t.Fatalf("the ask at node-c's endpoints (its process reads 0): err %v, published %v; want refused binary_too_old", err, published)
|
||||
}
|
||||
if published, err := grant("127.0.0.1:19701", "127.0.0.1:19702"); err == nil || published || !strings.Contains(err.Error(), "has not reported") {
|
||||
t.Fatalf("the ask at endpoints no server reports: err %v, published %v; want no grant", err, published)
|
||||
if published, err := grant("127.0.0.1:19701", "127.0.0.1:19702"); err != nil || !published {
|
||||
t.Fatalf("the ask at unreported endpoints: err %v, published %v; want placement accepted", err, published)
|
||||
}
|
||||
if published, err := grant("127.0.0.1:19501", "127.0.0.1:19502"); err != nil || !published {
|
||||
t.Fatalf("the ask at node-b's endpoints (its process reads 1): err %v, published %v; want granted", err, published)
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// fgV100Heartbeat sends a heartbeat shaped as a v1.0 holder sends it: a slot
|
||||
// with no incarnation and no reads level.
|
||||
func (r *isolationRig) fgV100Heartbeat(server, vol string) error {
|
||||
_, err := r.obs.ReportHeartbeat(r.ctx, &control.HeartbeatReport{ServerId: server, SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: vol, ReplicaId: "r1", DataAddr: hbPorts[server][0], CtrlAddr: hbPorts[server][1]}}})
|
||||
return err
|
||||
}
|
||||
|
||||
// v100IdentityRig is a level-1 cluster whose volume v is held on node-b by a
|
||||
// capable process (its own report reads 1) with a live lease.
|
||||
func v100IdentityRig(t *testing.T) *isolationRig {
|
||||
t.Helper()
|
||||
dir := upgradedStoreDir(t)
|
||||
disk, err := authority.NewFileAuthorityStore(dir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Put(authority.DurableRecord{VolumeID: "v", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1, WriteSeq: 1, DataAddr: hbPorts["node-b"][0], CtrlAddr: hbPorts["node-b"][1]}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := disk.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := newIsolationRig(t, false, dir, t.TempDir())
|
||||
r.createVolume(t, "v")
|
||||
r.place(t, "v", "node-b")
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Identity check (2) of the v1.1.2 bound: a v1.0-shaped heartbeat from a new
|
||||
// process on the holder's server supersedes the cached report of the capable
|
||||
// predecessor (as unreported or level 0), so that process's renewals are
|
||||
// refused at level 1 and during the finalize intent; it never renews on its
|
||||
// predecessor's proof. The capable process's next report renews again (twin).
|
||||
func TestAV100HeartbeatSupersedesTheCachedReportSoItsRenewalsAreRefused(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
for _, phase := range []string{"level-1", "finalize-intent"} {
|
||||
t.Run(phase, func(t *testing.T) {
|
||||
r := v100IdentityRig(t)
|
||||
renew := func() error {
|
||||
_, err := r.ws.RenewWorkspaceLease(r.ctx, &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", Epoch: 1, ServerId: "node-b"})
|
||||
return err
|
||||
}
|
||||
switch phase {
|
||||
case "level-1":
|
||||
if _, _, err := r.m.FinalizeFormat(1); err != nil || r.m.formatLevel() != 1 {
|
||||
t.Fatalf("finalize: level %d, %v", r.m.formatLevel(), err)
|
||||
}
|
||||
case "finalize-intent":
|
||||
// A real finalize, held at its durable barrier: the intent is
|
||||
// open (the publisher's own flag set by BeginFormatFinalize),
|
||||
// the level still 0 on disk.
|
||||
entered, release := make(chan struct{}), make(chan struct{})
|
||||
releaseOnce := sync.OnceFunc(func() { close(release) })
|
||||
previous := syncAttestationDir
|
||||
syncAttestationDir = func(dir string) error { close(entered); <-release; return previous(dir) }
|
||||
t.Cleanup(func() { syncAttestationDir = previous })
|
||||
finalized := make(chan error, 1)
|
||||
go func() { _, _, err := r.m.FinalizeFormat(1); finalized <- err }()
|
||||
t.Cleanup(func() {
|
||||
releaseOnce()
|
||||
select {
|
||||
case <-finalized:
|
||||
case <-time.After(10 * time.Second):
|
||||
t.Error("finalize did not finish")
|
||||
}
|
||||
})
|
||||
select {
|
||||
case <-entered:
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("finalize never reached its durable barrier")
|
||||
}
|
||||
if r.m.formatLevel() != 0 || !r.m.formatFinalizing.Load() {
|
||||
t.Fatalf("not in the intent: level %d finalizing %v", r.m.formatLevel(), r.m.formatFinalizing.Load())
|
||||
}
|
||||
}
|
||||
if err := renew(); err != nil {
|
||||
t.Fatalf("the capable holder could not renew: %v", err)
|
||||
}
|
||||
// A replacement process on a v1.0 binary reports before renewing.
|
||||
if err := r.fgV100Heartbeat("node-b", "v"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reads, reported := r.m.reads.entry("node-b", "v", r.m.servedBy("node-b")); reported && reads >= 1 {
|
||||
t.Fatalf("the v1.0-shaped heartbeat left the predecessor's report (reads %d) for the volume", reads)
|
||||
}
|
||||
if err := renew(); err == nil {
|
||||
t.Fatal("a v1.0 replacement renewed on its predecessor's proof")
|
||||
}
|
||||
// Twin: the capable process reports again and renews.
|
||||
if err := r.fgProcessHeartbeat("node-b", "capable-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := renew(); err != nil {
|
||||
t.Fatalf("the capable process could not renew after reporting again: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -72,8 +72,8 @@ func TestANewClusterStartsAtTheCurrentFormatLevel(t *testing.T) {
|
||||
// On a new cluster (level 1) a node that has not reported is placeable (one
|
||||
// process per volume, created then started, cannot have reported at its
|
||||
// placement) and shows as awaiting report; it is not granted until its own
|
||||
// report: the publication of its line is refused and its publish never runs;
|
||||
// after its first heartbeat (reads level 1) the line is published and the
|
||||
// report: publication alone grants no serving deadline; after its own first
|
||||
// heartbeat (reads level 1), its lease renewal grants a deadline and the
|
||||
// condition is gone.
|
||||
func TestANewClusterPlacesAnUnreportedNodeAndGrantsAfterItsReport(t *testing.T) {
|
||||
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
|
||||
@@ -109,14 +109,22 @@ func TestANewClusterPlacesAnUnreportedNodeAndGrantsAfterItsReport(t *testing.T)
|
||||
func() error { published = true; return nil })
|
||||
return published, err
|
||||
}
|
||||
if published, err := grant(); err == nil || published {
|
||||
t.Fatalf("the grant before node-b's report: err %v, published %v; want no grant", err, published)
|
||||
if published, err := grant(); err != nil || !published {
|
||||
t.Fatalf("publication before node-b's report: err %v, published %v; want placed", err, published)
|
||||
}
|
||||
if err := r.m.Controller().SubmitAssignmentAsk(authority.AssignmentAsk{VolumeID: "fresh", ReplicaID: "r1", DataAddr: "127.0.0.1:19321", CtrlAddr: "127.0.0.1:19322", Intent: authority.IntentBind}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
line := waitAuthorityLine(t, r.m.Publisher(), "fresh")
|
||||
id := &control.WorkspaceIdentity{VolumeId: "fresh", ReplicaId: "r1", ServerId: "node-b", Epoch: line.Epoch}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err == nil {
|
||||
t.Fatal("unreported process obtained its first serving deadline")
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "proc-b", "fresh", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if published, err := grant(); err != nil || !published {
|
||||
t.Fatalf("the grant after node-b's report: err %v, published %v; want granted", err, published)
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err != nil {
|
||||
t.Fatalf("first deadline after node-b's report: %v", err)
|
||||
}
|
||||
if awaiting() {
|
||||
t.Fatal("node-b still shows awaiting report after its first heartbeat")
|
||||
@@ -175,7 +183,7 @@ func TestAnEmptyAuthorityStoreOverAnExistingInventoryStartsAtLevel0(t *testing.T
|
||||
|
||||
// The grant reads the holder's own report: on a server whose process for
|
||||
// volume u reported level 1, a new process for volume v that has not
|
||||
// reported yet is not granted v's line; once v's own process reports level
|
||||
// reported yet receives no serving deadline; once v's own process reports level
|
||||
// 1 it is (a sibling's report says nothing about this process's binary).
|
||||
func TestTheGrantReadsTheHoldersOwnReportNotASiblings(t *testing.T) {
|
||||
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
|
||||
@@ -192,14 +200,22 @@ func TestTheGrantReadsTheHoldersOwnReportNotASiblings(t *testing.T) {
|
||||
func() error { published = true; return nil })
|
||||
return published, err
|
||||
}
|
||||
if published, err := grant(); err == nil || published {
|
||||
t.Fatalf("v's grant on u's report only: err %v, published %v; want no grant", err, published)
|
||||
if published, err := grant(); err != nil || !published {
|
||||
t.Fatalf("v's placement on an unreported process: err %v, published %v", err, published)
|
||||
}
|
||||
if err := r.m.Controller().SubmitAssignmentAsk(authority.AssignmentAsk{VolumeID: "v", ReplicaID: "r1", DataAddr: "127.0.0.1:19331", CtrlAddr: "127.0.0.1:19332", Intent: authority.IntentBind}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
line := waitAuthorityLine(t, r.m.Publisher(), "v")
|
||||
id := &control.WorkspaceIdentity{VolumeId: "v", ReplicaId: "r1", ServerId: "node-b", Epoch: line.Epoch}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err == nil {
|
||||
t.Fatal("v's first deadline used u's report")
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "proc-v", "v", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if published, err := grant(); err != nil || !published {
|
||||
t.Fatalf("v's grant after v's own report: err %v, published %v; want granted", err, published)
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, id); err != nil {
|
||||
t.Fatalf("v's first deadline after its own report: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,6 +314,40 @@ func TestGrantWaitsAreReconciledPerServerAndVolume(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A move does not rewrite the placement: the moved line waits on its new
|
||||
// holder until that process reports, and the former host's slot never waits
|
||||
// once its report for the volume expired.
|
||||
func TestAMovedLineWaitsOnItsNewHolderOnly(t *testing.T) {
|
||||
r := newIsolationRig(t, false, t.TempDir(), t.TempDir())
|
||||
r.issueMove(t, "v", "m1")
|
||||
r.m.reads.forget("node-b")
|
||||
r.m.format.v.Store(1)
|
||||
now := time.Now().Add(r.m.reads.window + time.Second)
|
||||
r.m.reads.now = func() time.Time { return now }
|
||||
if _, ok := r.m.reads.entry("node-a", "v", r.m.servedBy("node-a")); ok {
|
||||
t.Fatal("fixture: node-a's report for the moved volume is still live")
|
||||
}
|
||||
late := now.Add(r.m.grantStartupWindow() + time.Second)
|
||||
waiting := func(at time.Time, server string) bool {
|
||||
for _, w := range r.m.grantWaits(at)[server] {
|
||||
if w.volume == "v" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
if waiting(now, "node-a") || waiting(late, "node-a") {
|
||||
t.Fatal("the former host waits for the moved volume's report")
|
||||
}
|
||||
if !waiting(now, "node-b") {
|
||||
t.Fatal("the moved line's unreported holder shows no wait")
|
||||
}
|
||||
r.m.reads.note("node-b", "v", "proc-v", 1)
|
||||
if waiting(late, "node-a") || waiting(late, "node-b") {
|
||||
t.Fatal("a wait outlived the new holder's report")
|
||||
}
|
||||
}
|
||||
|
||||
// A status snapshot that read the placements before a newer one never
|
||||
// reconciles after it: snapshot A holds its read (no placement yet) while
|
||||
// vb is placed on an unreported node and snapshot B is started; B must wait
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package master
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/authority"
|
||||
"github.com/seaweedfs/seaweed-block/core/frontend"
|
||||
"github.com/seaweedfs/seaweed-block/core/host/volume"
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
)
|
||||
|
||||
// The move's stored lease is a reservation, not the target's permission to
|
||||
// serve. Only an accepted renewal reply can open the production lease guard.
|
||||
func TestFormatMoveRecordCannotServeBeforeReportedRenewal(t *testing.T) {
|
||||
if !finalizeServingChild(t) {
|
||||
return
|
||||
}
|
||||
for _, phase := range []string{"intent", "committed"} {
|
||||
t.Run(phase, func(t *testing.T) { formatMoveRecordCannotServe(t, phase) })
|
||||
}
|
||||
}
|
||||
|
||||
func formatMoveRecordCannotServe(t *testing.T, phase string) {
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
r.createVolume(t, "moved")
|
||||
r.place(t, "moved", "node-a")
|
||||
if err := ingestV11(r.m, authority.Observation{ServerID: "node-a", ObservedAt: time.Now().UTC(),
|
||||
Slots: []authority.SlotFact{{VolumeID: "moved", ReplicaID: "r1", DataAddr: "127.0.0.1:19131", CtrlAddr: "127.0.0.1:19132"}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.m.RunLifecycleProductTick(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitAuthorityLine(t, r.m.Publisher(), "moved")
|
||||
source := &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "moved", ReplicaId: "r1", Epoch: 1}
|
||||
if _, err := r.ws.RenewWorkspaceLease(r.ctx, source); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.RevokeWorkspace(r.ctx, source); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := r.ws.AckWorkspaceRevoked(r.ctx, &control.WorkspaceRevocationAck{Identity: source, HeadGen: 9}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
entered, release := make(chan struct{}), make(chan struct{})
|
||||
releaseOnce := sync.OnceFunc(func() { close(release) })
|
||||
previous := syncAttestationDir
|
||||
if phase == "intent" {
|
||||
syncAttestationDir = func(dir string) error { close(entered); <-release; return previous(dir) }
|
||||
t.Cleanup(func() { syncAttestationDir = previous })
|
||||
}
|
||||
finished := make(chan error, 1)
|
||||
go func() { _, _, err := r.m.FinalizeFormat(1); finished <- err }()
|
||||
joined := false
|
||||
t.Cleanup(func() {
|
||||
releaseOnce()
|
||||
if !joined {
|
||||
<-finished // the entire scenario is isolated in a bounded child
|
||||
}
|
||||
})
|
||||
if phase == "intent" {
|
||||
select {
|
||||
case <-entered:
|
||||
case <-r.ctx.Done():
|
||||
t.Fatal("finalize did not reach the held write")
|
||||
}
|
||||
} else {
|
||||
if err := <-finished; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
joined = true
|
||||
}
|
||||
// This target has never reported. Publication/move is Place, not a
|
||||
// serving deadline; both the intent and level 1 must allow the move.
|
||||
moved, err := r.ws.MoveWorkspace(r.ctx, &control.WorkspaceMove{RequestId: "lease-record-only", VolumeId: "moved", ExpectedReplicaId: "r1", ExpectedEpoch: 1,
|
||||
TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "clean"})
|
||||
if err != nil || !moved.GetIssued() {
|
||||
t.Fatalf("unreported target move refused during %s: %v %v", phase, moved, err)
|
||||
}
|
||||
ws, err := r.ws.QueryWorkspace(r.ctx, &control.WorkspaceVolume{VolumeId: "moved"})
|
||||
if err != nil || ws.GetLease().GetEpoch() != moved.GetNewEpoch() || ws.GetLease().GetExpiresAtNs() <= time.Now().UnixNano() {
|
||||
t.Fatalf("move did not issue a possibly-live lease record: %v %v", ws, err)
|
||||
}
|
||||
// The issued move and its positive lease record exist, but no renewal
|
||||
// reply has reached the guard, and the target still has no report.
|
||||
id := &control.WorkspaceIdentity{VolumeId: "moved", ReplicaId: "r1", ServerId: "node-b", Epoch: moved.GetNewEpoch()}
|
||||
guard, err := volume.NewWorkspaceLeaseGuard(workspaceRPCView{frontend.Projection{VolumeID: "moved", ReplicaID: "r1", Epoch: moved.GetNewEpoch(), Healthy: true}}, r.ws, id,
|
||||
func(context.Context) (uint64, error) {
|
||||
t.Fatal("a refused first renewal must not drain an ungranted guard")
|
||||
return 0, nil
|
||||
}, time.Now)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if guard.Held() || guard.Projection().Healthy {
|
||||
t.Fatal("issued move record opened serving before a renewal reply")
|
||||
}
|
||||
if err := guard.Refresh(r.ctx); err == nil || guard.Held() || guard.Projection().Healthy {
|
||||
t.Fatalf("unreported target obtained serving from the issued record: %v", err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "", "moved", 1); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := guard.Refresh(r.ctx); err != nil || !guard.Held() || !guard.Projection().Healthy {
|
||||
t.Fatalf("reported target did not serve after an accepted renewal: %v", err)
|
||||
}
|
||||
releaseOnce()
|
||||
if !joined {
|
||||
if err := <-finished; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
joined = true
|
||||
}
|
||||
}
|
||||
@@ -276,8 +276,8 @@ func TestAttestationEnvelopeIsSyncedAtEveryStart(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := s.finalize(); err == nil || s.level() != 0 {
|
||||
t.Fatalf("a failed directory fsync of the finalize's envelope: err=%v level=%d (want an error, level 0)", err, s.level())
|
||||
if _, err := s.finalize(); err == nil || s.level() != 1 {
|
||||
t.Fatalf("a failed directory fsync keeps the possibly-written envelope selected until fail-stop: err=%v level=%d", err, s.level())
|
||||
}
|
||||
// The process restarts: the envelope is on disk (the rename happened).
|
||||
s, err = loadStoreAttestations(dir)
|
||||
|
||||
@@ -174,6 +174,7 @@ type Host struct {
|
||||
grantWaitMu sync.Mutex // one status snapshot reads and reconciles the grant waits at a time
|
||||
grantWait map[string]time.Time // "server\x00volume" -> first seen waiting for its grant without its process's report (format_gate.go grantWaits)
|
||||
format formatLevelState // the cluster's format level (format_gate.go)
|
||||
formatFinalizing atomic.Bool // admission intent while durable format raise is in flight
|
||||
finalizeMu sync.Mutex // serializes the format finalize and host retires (format_gate.go)
|
||||
// testGrantWaitsRead, when a test sets it, runs after a status snapshot
|
||||
// has read its placements, still holding grantWaitMu.
|
||||
@@ -322,6 +323,7 @@ func New(cfg Config) (*Host, error) {
|
||||
return nil, fmt.Errorf("master.New: Bootstrap: %w", err)
|
||||
}
|
||||
holder.set(boot.Publisher)
|
||||
boot.Publisher.RequireFormatReadProofs()
|
||||
// Bootstrap creates a fresh store directory: sample its file system only
|
||||
// now, or a first start would compare against an unknown device forever.
|
||||
// An unknown identity (stat error, unsupported platform) never matches.
|
||||
|
||||
@@ -52,6 +52,7 @@ func (r *isolationRig) issueMove(t *testing.T, vol, requestID string) (*control.
|
||||
}
|
||||
q := &control.WorkspaceMove{RequestId: requestID, VolumeId: vol, ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-b", TargetDataAddr: "127.0.0.1:19301", TargetCtrlAddr: "127.0.0.1:19302", Kind: "clean"}
|
||||
r.m.reads.note("node-b", vol, "", 1) // the move target reports before its grant
|
||||
grant, err := r.ws.MoveWorkspace(r.ctx, q)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestObservationReportsACleanlyStoppedVolumeStopped(t *testing.T) {
|
||||
h, c, ctx := reviewBindingHost(t)
|
||||
reviewLegacyBind(t, h, c, ctx, "vs")
|
||||
p := h.Publisher()
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "vs", "r1", 1); err != nil {
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "vs", "r1", 1, h.formatReadProof("vs", "r1", "node-a", 1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.BeginWorkspaceRevocation(ctx, "vs", "r1", 1); err != nil {
|
||||
@@ -58,6 +58,7 @@ func TestObservationReportsACleanlyStoppedVolumeStopped(t *testing.T) {
|
||||
if err := h.lifecycle.WorkspaceBindings.Register(target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.reads.note("node-b", "vs", "", 1) // capable target process, before move grant
|
||||
moved, err := p.MoveWorkspace(ctx, authority.WorkspaceMoveRequest{RequestID: "move-1", VolumeID: "vs", ExpectedReplicaID: "r1", ExpectedHost: "node-a", ExpectedEpoch: 1, TargetReplicaID: "r1", TargetHost: target.ServerID, TargetDataAddr: target.DataAddr, TargetCtrlAddr: target.CtrlAddr, Kind: "clean"}, head)
|
||||
if err != nil || !moved.Issued {
|
||||
t.Fatalf("move: %+v %v", moved, err)
|
||||
@@ -79,7 +80,7 @@ func TestObservationDeletionOutranksStoppedAndRetiredTopology(t *testing.T) {
|
||||
})
|
||||
reviewLegacyBind(t, h, c, ctx, "vs")
|
||||
p := h.Publisher()
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "vs", "r1", 1); err != nil {
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "vs", "r1", 1, h.formatReadProof("vs", "r1", "node-a", 1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.BeginWorkspaceRevocation(ctx, "vs", "r1", 1); err != nil {
|
||||
|
||||
@@ -191,6 +191,7 @@ func TestRF1RefreshDecidedBeforeACrossHostMoveIsNotApplied(t *testing.T) {
|
||||
if _, err = ws.RegisterWorkspaceBinding(ctx, dst); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.reads.note("node-b", "rt", "", 1) // target report precedes move grant
|
||||
grant, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "clean-1", VolumeId: "rt", ExpectedReplicaId: "r1", ExpectedEpoch: line.Epoch,
|
||||
TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: dst.DataAddr, TargetCtrlAddr: dst.CtrlAddr, Kind: "clean"})
|
||||
if err != nil || !grant.Issued {
|
||||
|
||||
@@ -72,6 +72,7 @@ func TestDisplayedPrimaryIsTheIssuedHolderNotThePlacementSlot(t *testing.T) {
|
||||
if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.reads.note("node-a", "a2", "", 1) // target report precedes move grant
|
||||
g, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "to-a", VolumeId: "a2", ExpectedReplicaId: "r1", ExpectedEpoch: a2.Epoch,
|
||||
TargetReplicaId: "r1", TargetServerId: "node-a", TargetDataAddr: "127.0.0.1:19111", TargetCtrlAddr: "127.0.0.1:19112", Kind: "clean"})
|
||||
if err != nil || !g.Issued || g.NewHost != "node-a" {
|
||||
|
||||
@@ -205,7 +205,10 @@ func (s *storeAttestations) finalize() (already bool, err error) {
|
||||
}
|
||||
s.enveloped = true
|
||||
if err := s.persist(s.vols); err != nil {
|
||||
s.enveloped = false
|
||||
var uncertain *attestationWriteUncertain
|
||||
if !errors.As(err, &uncertain) {
|
||||
s.enveloped = false
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return false, nil
|
||||
@@ -537,9 +540,17 @@ func (s *storeAttestations) persist(vols map[string]attestedStores) error {
|
||||
_ = os.Remove(temp)
|
||||
return fmt.Errorf("store attestations: %w", werr)
|
||||
}
|
||||
return syncAttestationDir(filepath.Dir(s.path))
|
||||
if err := syncAttestationDir(filepath.Dir(s.path)); err != nil {
|
||||
return &attestationWriteUncertain{err}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// attestationWriteUncertain means the rename landed but its durability is unknown.
|
||||
type attestationWriteUncertain struct{ error }
|
||||
|
||||
func (e *attestationWriteUncertain) Unwrap() error { return e.error }
|
||||
|
||||
// ingestStoreAttestation records a heartbeat's attestation when the
|
||||
// reporting server holds the volume's published primary line at the
|
||||
// attested epoch (the line's replica and owner). Anything else is not a
|
||||
|
||||
@@ -126,7 +126,7 @@ func TestReserveVolumeDeletionLiveLeaseIsDefiniteAndKeepsRenewing(t *testing.T)
|
||||
h, conn, ctx := reviewBindingHost(t)
|
||||
reviewLegacyBind(t, h, conn, ctx, "live-delete")
|
||||
establishVolume(t, h, "live-delete") // a volume past creation keeps the live-lease refusal
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "live-delete", "r1", 1); err != nil {
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "live-delete", "r1", 1, h.formatReadProof("live-delete", "r1", "node-a", 1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
lc := control.NewLifecycleServiceClient(conn)
|
||||
@@ -136,7 +136,7 @@ func TestReserveVolumeDeletionLiveLeaseIsDefiniteAndKeepsRenewing(t *testing.T)
|
||||
if h.lifecycle.Deletions.Reserved("live-delete") {
|
||||
t.Fatal("refusal persisted a reservation")
|
||||
}
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "live-delete", "r1", 1); err != nil {
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "live-delete", "r1", 1, h.formatReadProof("live-delete", "r1", "node-a", 1)); err != nil {
|
||||
t.Fatalf("refused delete interrupted renewal: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -281,18 +281,40 @@ func (h *Host) admitWorkspacePublicationNow(ask authority.AssignmentAsk, publish
|
||||
epoch = line.Epoch
|
||||
}
|
||||
server := h.workspaceSourceHost(ask.VolumeID, ask.ReplicaID, epoch)
|
||||
// The format gate at the grant: an authority line is published
|
||||
// only to a server whose own report reads the cluster's level; no report
|
||||
// means no grant (the ask waits for it), and an ask decided on
|
||||
// observations taken before its server reported a lower level is not
|
||||
// published.
|
||||
// A line with no recorded owner (a static topology's) goes to the process
|
||||
// the facts show at the ask's endpoints; its server is the one judged.
|
||||
grantServer := server
|
||||
if grantServer == "" && h.obs != nil {
|
||||
grantServer, _ = h.obs.Store().ServerOfSlotAt(ask.VolumeID, ask.ReplicaID, ask.DataAddr, ask.CtrlAddr)
|
||||
// Publication places an authority line; only a renewal reply authorizes
|
||||
// serving. During finalize and at level 1, place only refuses known-old
|
||||
// targets. Resolve the target at the ask's endpoints, not another source.
|
||||
placeServer := ""
|
||||
if h.obs != nil {
|
||||
placeServer, _ = h.obs.Store().ServerOfSlotAt(ask.VolumeID, ask.ReplicaID, ask.DataAddr, ask.CtrlAddr)
|
||||
}
|
||||
if why := h.grantTooOld(grantServer, ask.VolumeID); why != "" {
|
||||
if placeServer == "" {
|
||||
placeServer = server
|
||||
}
|
||||
why := h.placementTooOld(placeServer)
|
||||
// A same-owner endpoint refresh, or a reassign (heal, failover) to the
|
||||
// replica's committed holder, gives no new placement to this server.
|
||||
// Judge this volume's process rather than an unrelated sibling process.
|
||||
// Publisher still checks ExpectCurrent atomically before changing the line.
|
||||
line, ok := h.Publisher().VolumeAuthorityLine(ask.VolumeID)
|
||||
held := ok && line.Assigned && h.workspaceSourceHost(ask.VolumeID, ask.ReplicaID, line.Epoch) == placeServer
|
||||
if ask.Intent == authority.IntentRefreshEndpoint && ask.ExpectCurrent != nil {
|
||||
expected := ask.ExpectCurrent
|
||||
held = held && line.ReplicaID == ask.ReplicaID &&
|
||||
line.Epoch == expected.Epoch && line.ReplicaID == expected.ReplicaID &&
|
||||
line.DataAddr == ask.DataAddr && line.CtrlAddr == ask.CtrlAddr &&
|
||||
line.DataAddr == expected.DataAddr && line.CtrlAddr == expected.CtrlAddr
|
||||
} else if ask.Intent != authority.IntentReassign {
|
||||
held = false
|
||||
}
|
||||
if held {
|
||||
reads, reported := h.reads.entry(placeServer, ask.VolumeID, h.servedBy(placeServer))
|
||||
why = ""
|
||||
if reported && reads < h.admissionFormatLevel() {
|
||||
why = fmt.Sprintf("node %q's process for volume %q reads format level %d (binary_too_old)", placeServer, ask.VolumeID, reads)
|
||||
}
|
||||
}
|
||||
if why != "" {
|
||||
return fmt.Errorf("workspace publication: %s", why)
|
||||
}
|
||||
b := lifecycle.WorkspaceBinding{VolumeID: ask.VolumeID, ServerID: server, DataAddr: ask.DataAddr, CtrlAddr: ask.CtrlAddr}
|
||||
|
||||
@@ -71,7 +71,8 @@ func bindingReconcileHistory(t *testing.T, legacySource bool) *Host {
|
||||
p := h.Publisher()
|
||||
ack := func(epoch uint64, server string) authority.WorkspaceHead {
|
||||
t.Helper()
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "recover", "r1", epoch); err != nil {
|
||||
h.reads.note(server, "recover", "history-"+server, 1)
|
||||
if _, err := p.RenewWorkspaceLease(ctx, "recover", "r1", epoch, h.formatReadProof("recover", "r1", server, epoch)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := p.BeginWorkspaceRevocation(ctx, "recover", "r1", epoch); err != nil {
|
||||
@@ -89,6 +90,7 @@ func bindingReconcileHistory(t *testing.T, legacySource bool) *Host {
|
||||
epoch := uint64(i + 1)
|
||||
source := []string{"node-a", "node-b", "node-c"}[i]
|
||||
head := ack(epoch, source)
|
||||
h.reads.note(target.ServerID, "recover", "history-"+target.ServerID, 1)
|
||||
moved, err := p.MoveWorkspace(ctx, authority.WorkspaceMoveRequest{RequestID: fmt.Sprintf("move-%d", i), VolumeID: "recover", ExpectedReplicaID: "r1", ExpectedHost: source, ExpectedEpoch: epoch, TargetReplicaID: "r1", TargetHost: target.ServerID, TargetDataAddr: target.DataAddr, TargetCtrlAddr: target.CtrlAddr, Kind: "clean"}, head)
|
||||
if err != nil || !moved.Issued || moved.NewEpoch != epoch+1 {
|
||||
t.Fatalf("history move: %+v %v", moved, err)
|
||||
|
||||
@@ -167,6 +167,7 @@ func workspaceBindingsMove(t *testing.T, forced bool) {
|
||||
if _, err = client.MoveWorkspace(ctx, q); err == nil {
|
||||
t.Fatal("explicit volume fell back to legacy node pair")
|
||||
}
|
||||
h.reads.note("node-b", vol, "", 1) // prepared target reports before the grant
|
||||
q.RequestId = vol + "-move"
|
||||
q.TargetDataAddr = target.DataAddr
|
||||
q.TargetCtrlAddr = target.CtrlAddr
|
||||
|
||||
@@ -138,6 +138,7 @@ func TestWorkspaceExitedHolderForcedMoveThenCleanDelete(t *testing.T) {
|
||||
if _, err := lc.MarkVolumeDeleting(ctx, &control.MarkVolumeDeletingRequest{VolumeId: "vol-a", Token: "del-early"}); err == nil || !strings.Contains(err.Error(), "live authority requires clean revocation ACK") {
|
||||
t.Fatalf("delete under the exited holder's live authority: %v; want the clean revocation ACK refusal", err)
|
||||
}
|
||||
m.reads.note("node-b", "vol-a", "", 1) // target report before the move grant
|
||||
move := &control.WorkspaceMove{RequestId: "clean-1", VolumeId: "vol-a", ExpectedReplicaId: "r1", ExpectedEpoch: oldLine.Epoch, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-b", TargetDataAddr: dst.DataAddr, TargetCtrlAddr: dst.CtrlAddr, Kind: "clean"}
|
||||
if _, err := ws.MoveWorkspace(ctx, move); err == nil {
|
||||
@@ -161,6 +162,7 @@ func TestWorkspaceExitedHolderForcedMoveThenCleanDelete(t *testing.T) {
|
||||
case <-ctx.Done():
|
||||
t.Fatal(ctx.Err())
|
||||
}
|
||||
m.reads.note("node-b", "vol-a", "", 1) // unserved target keeps reporting across the lease wait
|
||||
grant, err := ws.MoveWorkspace(ctx, move)
|
||||
if err != nil {
|
||||
t.Fatal("forced move after the horizon:", err)
|
||||
|
||||
@@ -26,6 +26,7 @@ func TestWorkspaceLineOwnerIssuedAndHistorical(t *testing.T) {
|
||||
if _, err := ws.RegisterWorkspaceBinding(ctx, target); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.reads.note("node-b", "v", "", 1) // target report before the move grant
|
||||
grant, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "owner-move", VolumeId: "v", ExpectedReplicaId: "r1", ExpectedEpoch: 1, TargetReplicaId: "r1", TargetServerId: "node-b", TargetDataAddr: target.DataAddr, TargetCtrlAddr: target.CtrlAddr, Kind: "clean"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -99,6 +99,7 @@ func forcedMoveHost(t *testing.T, cfg Config) (*Host, func(), control.WorkspaceS
|
||||
if _, err := client.RenewWorkspaceLease(ctx, &control.WorkspaceIdentity{ServerId: "node-a", VolumeId: "vol-f", ReplicaId: "r1", Epoch: line.Epoch}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h.reads.note("node-b", "vol-f", "", 1) // capable target before the move grant
|
||||
return h, stop, client, &control.WorkspaceMove{RequestId: "force-1", VolumeId: "vol-f", ExpectedReplicaId: "r1", ExpectedEpoch: line.Epoch, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-b", TargetDataAddr: target.DataAddr, TargetCtrlAddr: target.CtrlAddr, Kind: "forced", Force: true}
|
||||
}
|
||||
@@ -165,6 +166,7 @@ func TestWorkspaceForcedMoveLostRangeOverRPC(t *testing.T) {
|
||||
case <-ctx.Done():
|
||||
t.Fatal(ctx.Err())
|
||||
}
|
||||
h.reads.note("node-b", "vol-f", "", 1) // unserved target keeps reporting across the lease wait
|
||||
pv2, err := client.PreviewWorkspaceMove(ctx, move)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -120,6 +120,7 @@ func TestWorkspaceMoveRefusalNamesTheMissingPrecondition(t *testing.T) {
|
||||
}
|
||||
// Slot-0 and slot-1 targets on the node's host pass these preconditions
|
||||
// (they fail later, at the clean-move ACK check, for a different reason).
|
||||
m.reads.note("node-b", "placed", "", 1) // isolate the endpoint and clean-ACK checks
|
||||
for _, data := range []string{"127.0.0.1:19301", "127.0.0.1:19311"} {
|
||||
_, err = ws.MoveWorkspace(ctx, move("placed", "node-b", data, "127.0.0.1:19312"))
|
||||
if err == nil || strings.Contains(err.Error(), "move target") || strings.Contains(err.Error(), "move source") {
|
||||
|
||||
@@ -85,6 +85,7 @@ func TestWorkspaceMoveToAnotherSlotOnTheTargetHost(t *testing.T) {
|
||||
if _, err := ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 9}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.reads.note("node-a", "a2", "", 1) // isolate target endpoint/collision checks
|
||||
move := func(req, data, ctrl string) *control.WorkspaceMove {
|
||||
return &control.WorkspaceMove{RequestId: req, VolumeId: "a2", ExpectedReplicaId: "r1", ExpectedEpoch: a2.Epoch, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-a", TargetDataAddr: data, TargetCtrlAddr: ctrl, Kind: "clean"}
|
||||
|
||||
@@ -171,7 +171,7 @@ func (s *services) RenewWorkspaceLease(ctx context.Context, q *control.Workspace
|
||||
}
|
||||
return nil, status.Error(codes.FailedPrecondition, text)
|
||||
}
|
||||
l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch())
|
||||
l, err := s.host.Publisher().RenewWorkspaceLease(ctx, q.GetVolumeId(), q.GetReplicaId(), q.GetEpoch(), s.host.formatReadProof(q.GetVolumeId(), q.GetReplicaId(), q.GetServerId(), q.GetEpoch()))
|
||||
if errors.Is(err, authority.ErrWorkspaceRevoked) {
|
||||
return nil, leaseRefusal(fmt.Sprintf("volume %s was moved or revoked; inspect sw-block ops workspace show --master MASTER --volume %s, complete the intended move, and leave this old unit stopped", q.GetVolumeId(), q.GetVolumeId()), control.WorkspaceLeaseRefusal_FINAL, 0)
|
||||
}
|
||||
@@ -465,7 +465,7 @@ func (s *services) workspaceMoveCheckLocked(q *control.WorkspaceMove) (req autho
|
||||
refusal.text = fmt.Sprintf("move target node %q shares the authority store's file system (strict journal isolation)", target.ServerID)
|
||||
case !replay && s.host.placementTooOld(target.ServerID) != "":
|
||||
// Only a known-old report refuses a move target; the
|
||||
// target's line is granted only after its own report.
|
||||
// target receives a serving deadline only after its own report.
|
||||
refusal = moveRefusal{"move target " + s.host.placementTooOld(target.ServerID), s.host.formatTooOldReason(target.ServerID)}
|
||||
case !matched:
|
||||
refusal.text = fmt.Sprintf("move target endpoints %s/%s on %q are not registered (%s)", q.GetTargetDataAddr(), q.GetTargetCtrlAddr(), target.ServerID, registeredTargetEndpoints(target, bindings, explicit))
|
||||
|
||||
@@ -142,6 +142,7 @@ func TestWorkspaceRPCCleanMovePreservesReplicaIdentity(t *testing.T) {
|
||||
if err != nil || len(unchanged.GetMoves()) != 0 || unchanged.GetRevocationAck().GetHeadGen() != 9 {
|
||||
t.Fatal("refusal consumed ACK or wrote a move", unchanged, err)
|
||||
}
|
||||
h.reads.note("node-b", "vol-a", "", 1) // target process report before the grant
|
||||
q.TargetReplicaId = "r2"
|
||||
generation.Store(10) // operator metadata changed after the recorded ACK
|
||||
grant, err := client.MoveWorkspace(ctx, q)
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestWorkspaceMoveUnknownPrecedesAdmissionRefusals(t *testing.T) {
|
||||
return authority.WorkspaceHead{Gen: 9, Epoch: 1, Holder: "node-a/r1", RemoteLSN: 42, Detached: true}, nil
|
||||
})
|
||||
reviewLegacyBind(t, h, c, ctx, "v")
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "v", "r1", 1); err != nil {
|
||||
if _, err := h.Publisher().RenewWorkspaceLease(ctx, "v", "r1", 1, h.formatReadProof("v", "r1", "node-a", 1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
client := control.NewWorkspaceServiceClient(c)
|
||||
|
||||
@@ -105,6 +105,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) {
|
||||
if _, err = ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: oldID, HeadGen: seed.Gen}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.reads.note("node-b", "vol-a", "", 1) // target process report before the grant
|
||||
clean, err := ws.MoveWorkspace(ctx, &control.WorkspaceMove{RequestId: "clean-1", VolumeId: "vol-a", ExpectedReplicaId: "r1", ExpectedEpoch: oldLine.Epoch, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-b", TargetDataAddr: dst.DataAddr, TargetCtrlAddr: dst.CtrlAddr, Kind: "clean"})
|
||||
if err != nil {
|
||||
@@ -125,6 +126,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) {
|
||||
|
||||
// node-b dies before renewing or claiming. Before expiry plus skew the
|
||||
// forced move is refused, and HEAD is not read for it.
|
||||
m.reads.note("node-c", "vol-a", "", 1) // target process report before the forced grant
|
||||
forced := &control.WorkspaceMove{RequestId: "forced-1", VolumeId: "vol-a", ExpectedReplicaId: "r1", ExpectedEpoch: grantee, TargetReplicaId: "r1",
|
||||
TargetServerId: "node-c", TargetDataAddr: third.DataAddr, TargetCtrlAddr: third.CtrlAddr, Kind: "forced", Force: true}
|
||||
before := reads.Load()
|
||||
@@ -140,6 +142,7 @@ func TestWorkspaceUnclaimedGrantForcedReassignOverRPC(t *testing.T) {
|
||||
case <-ctx.Done():
|
||||
t.Fatal(ctx.Err())
|
||||
}
|
||||
m.reads.note("node-c", "vol-a", "", 1) // unserved target keeps reporting across the lease wait
|
||||
grant, err := ws.MoveWorkspace(ctx, forced)
|
||||
if err != nil {
|
||||
t.Fatal("forced move after the issued lease expired:", err)
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/format"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// These are outcome classes of the typed body, not permission to infer
|
||||
// non-admission from HTTP 409 alone. Even an attempt refusal can refer to
|
||||
// an operation whose durable admission or earlier work already exists.
|
||||
var chunkConflictClasses = map[string]string{
|
||||
`"cut_busy"`: "attempt_refused",
|
||||
`"operation_conflict"`: "existing_operation",
|
||||
"codeHeadConflict": "attempt_refused",
|
||||
"codeFenced": "attempt_refused",
|
||||
"codeInProgress": "upgrade_pass_running",
|
||||
`"plain_detach_busy"`: "attempt_refused",
|
||||
`"precopy_unknown"`: "work_may_have_run",
|
||||
`"precopy_not_converged"`: "work_may_have_run",
|
||||
"codeDetachAborted": "abort_confirmed",
|
||||
`"snapshot_delete_requires_operation"`: "attempt_refused",
|
||||
"chunkstore.CodeGeometryMismatch": "attempt_refused",
|
||||
"chunkstore.CodeSnapshotLimit": "attempt_refused",
|
||||
"chunkstore.CodeSnapshotExists": "existing_operation",
|
||||
`"layout_refused"`: "attempt_refused",
|
||||
`"format_level_below_head_version"`: "attempt_refused",
|
||||
"codeLSNBehind": "attempt_refused",
|
||||
"codeAwaitingAssignment": "attempt_refused",
|
||||
"codeNotPrimary": "attempt_refused",
|
||||
"codeEpochStale": "attempt_refused",
|
||||
"codeBaseInstalling": "attempt_refused",
|
||||
"codeReconciling": "attempt_refused",
|
||||
"codeClosing": "attempt_refused",
|
||||
`"frozen_detach_unsupported"`: "attempt_refused",
|
||||
`"frozen_tail_too_large"`: "attempt_refused",
|
||||
"chunkstore.CodeQueueFull": "attempt_refused",
|
||||
`"layout_busy"`: "attempt_refused",
|
||||
"chunkstore.CodeNotChunkVolume": "attempt_refused",
|
||||
// Dynamic bodies must remain authoritative. catalogStatus has an open
|
||||
// default-to-409 code space; remembered refusals retain their own status.
|
||||
"catalogStatus(ce.Code):ce.Code": "typed_body_required",
|
||||
"remembered.status:remembered.code": "typed_body_required",
|
||||
}
|
||||
|
||||
func unclassifiedChunkConflicts(source []byte) ([]string, error) {
|
||||
fs := token.NewFileSet()
|
||||
file, err := parser.ParseFile(fs, "chunk_control.go", source, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
render := func(n ast.Node) string {
|
||||
var out bytes.Buffer
|
||||
_ = format.Node(&out, fs, n)
|
||||
return out.String()
|
||||
}
|
||||
var missing []string
|
||||
found := false
|
||||
for _, decl := range file.Decls {
|
||||
fn, ok := decl.(*ast.FuncDecl)
|
||||
if !ok || fn.Name.Name != "chunkErrorCode" {
|
||||
continue
|
||||
}
|
||||
found = true
|
||||
ast.Inspect(fn.Body, func(n ast.Node) bool {
|
||||
ret, ok := n.(*ast.ReturnStmt)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
if len(ret.Results) != 3 {
|
||||
missing = append(missing, "unreviewed delegated mapper return")
|
||||
return true
|
||||
}
|
||||
status, code := render(ret.Results[0]), render(ret.Results[1])
|
||||
key := code
|
||||
switch status {
|
||||
case "http.StatusConflict":
|
||||
case "catalogStatus(ce.Code)", "remembered.status":
|
||||
key = status + ":" + code
|
||||
default:
|
||||
// Only these exact selector ASTs prove a reviewed non-409
|
||||
// status. A computed expression with the same textual prefix
|
||||
// (including StatusConflict + 0) needs classification.
|
||||
allowed := false
|
||||
if sel, ok := ret.Results[0].(*ast.SelectorExpr); ok {
|
||||
if pkg, ok := sel.X.(*ast.Ident); ok && pkg.Name == "http" {
|
||||
switch sel.Sel.Name {
|
||||
case "StatusGone", "StatusServiceUnavailable", "StatusNotFound", "StatusBadRequest", "StatusInternalServerError":
|
||||
allowed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !allowed {
|
||||
missing = append(missing, "unreviewed status: "+status)
|
||||
}
|
||||
return true
|
||||
}
|
||||
class := chunkConflictClasses[key]
|
||||
switch class {
|
||||
case "attempt_refused", "existing_operation", "upgrade_pass_running", "work_may_have_run", "abort_confirmed", "typed_body_required":
|
||||
default:
|
||||
missing = append(missing, fmt.Sprintf("%s has no outcome class", key))
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
if !found {
|
||||
return nil, fmt.Errorf("chunkErrorCode not found")
|
||||
}
|
||||
return missing, nil
|
||||
}
|
||||
|
||||
func TestChunkConflictStatusRowsHaveOutcomeClasses(t *testing.T) {
|
||||
source, err := os.ReadFile("chunk_control.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
missing, err := unclassifiedChunkConflicts(source)
|
||||
if err != nil || len(missing) != 0 {
|
||||
t.Fatalf("unclassified 409 rows: %v (%v)", missing, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkConflictCensusRejectsANewUnclassifiedCode(t *testing.T) {
|
||||
source, err := os.ReadFile("chunk_control.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Negative control: a new mapper row cannot silently inherit an admission
|
||||
// claim from its HTTP status. No production source is modified.
|
||||
mutated := bytes.Replace(source, []byte(`return http.StatusConflict, "cut_busy", true`), []byte(`return http.StatusConflict, "new_conflict", true`), 1)
|
||||
if bytes.Equal(source, mutated) {
|
||||
t.Fatal("negative control did not mutate the mapper")
|
||||
}
|
||||
missing, err := unclassifiedChunkConflicts(mutated)
|
||||
if err != nil || len(missing) != 1 || !strings.Contains(missing[0], "new_conflict") {
|
||||
t.Fatalf("new code escaped census: %v (%v)", missing, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkConflictCensusRejectsComputedStatus(t *testing.T) {
|
||||
source, err := os.ReadFile("chunk_control.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mutated := bytes.Replace(source, []byte(`return http.StatusConflict, "cut_busy", true`), []byte(`return http.StatusConflict + 0, "cut_busy", true`), 1)
|
||||
if bytes.Equal(source, mutated) {
|
||||
t.Fatal("computed-status control did not mutate the mapper")
|
||||
}
|
||||
missing, err := unclassifiedChunkConflicts(mutated)
|
||||
if err != nil || len(missing) != 1 || !strings.Contains(missing[0], "unreviewed status") {
|
||||
t.Fatalf("computed 409 escaped census: %v (%v)", missing, err)
|
||||
}
|
||||
}
|
||||
@@ -227,6 +227,12 @@ type Host struct {
|
||||
cancel context.CancelFunc
|
||||
wg sync.WaitGroup
|
||||
started atomic.Bool
|
||||
// heartbeatAnswered closes when the master first answers this process's
|
||||
// heartbeat (which names its incarnation): until then the master holds
|
||||
// only a predecessor's report for the volume, so the lease runtime does
|
||||
// not renew before it (identity check (1) of the format finalize bound).
|
||||
heartbeatAnswered chan struct{}
|
||||
heartbeatAnsweredOnce sync.Once
|
||||
|
||||
workspaceLeaseStarted atomic.Bool
|
||||
// Guard installation and terminal host fencing share this lock. Order:
|
||||
@@ -354,6 +360,8 @@ func New(cfg Config) (*Host, error) {
|
||||
conn: conn,
|
||||
obsCli: control.NewObservationServiceClient(conn),
|
||||
asnCli: control.NewAssignmentServiceClient(conn),
|
||||
|
||||
heartbeatAnswered: make(chan struct{}),
|
||||
}
|
||||
h.incarnation = newIncarnation()
|
||||
h.mw = newMasterWait(nil, lg.Printf)
|
||||
@@ -792,6 +800,9 @@ func (h *Host) runHeartbeat(ctx context.Context) {
|
||||
rpcCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
_, err := h.obsCli.ReportHeartbeat(rpcCtx, h.buildReport())
|
||||
if err == nil {
|
||||
h.heartbeatAnsweredOnce.Do(func() { close(h.heartbeatAnswered) })
|
||||
}
|
||||
if ctx.Err() == nil {
|
||||
h.mw.call(err)
|
||||
// The wait's reason reaches the journal on a change and every
|
||||
|
||||
@@ -22,7 +22,9 @@ const masterWaitLogEvery = 10 * time.Minute
|
||||
|
||||
// MasterWait is why a workspace primary is not yet granted, for /status.
|
||||
// Reason is unreachable (no reply), credentials (the master refused the
|
||||
// node's credentials), barrier (Until is the master's barrier time),
|
||||
// node's credentials), first_heartbeat_unanswered (assigned, but the master
|
||||
// has not answered this process's first heartbeat within one lease
|
||||
// validity; Until is the startup wait's bound when it has one), barrier (Until is the master's barrier time),
|
||||
// no_assignment, refused, moved or deleted. Until is zero while the wait
|
||||
// has no bound.
|
||||
type MasterWait struct {
|
||||
@@ -48,6 +50,7 @@ type masterWait struct {
|
||||
start time.Time // when the startup wait began (after the local open); zero before
|
||||
window time.Time // the first reply at or after start in the current run of replies
|
||||
barrier time.Time // T: request start + retry_after of the latest BARRIER refusal
|
||||
firstHB time.Time // start of a first-heartbeat wait past its bound; zero when none
|
||||
final string // "moved" or "deleted": a permanent refusal
|
||||
finalDetail string
|
||||
logged string // the reason last logged
|
||||
@@ -149,6 +152,17 @@ func (w *masterWait) call(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// firstHeartbeatOverdue records that the lease runtime has waited past its
|
||||
// bound for the master to answer this process's first heartbeat, since the
|
||||
// wait began at since; zero clears it (the heartbeat was answered). An
|
||||
// observation only: it names the wait, and changes no bound or decision (the
|
||||
// startup wait's bound, when it has one, is reported with it).
|
||||
func (w *masterWait) firstHeartbeatOverdue(since time.Time) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
w.firstHB = since
|
||||
}
|
||||
|
||||
// identityDecay ends an identity refusal that is not repeated: replies keep
|
||||
// coming and no call was refused on identity for this long.
|
||||
const identityDecay = 30 * time.Second
|
||||
@@ -279,6 +293,11 @@ func (w *masterWait) snapshot(assigned bool) MasterWait {
|
||||
if w.down.IsZero() {
|
||||
out.Since = now
|
||||
}
|
||||
case !w.firstHB.IsZero():
|
||||
// The master replies, but has not answered this process's first
|
||||
// heartbeat (a master that gives no reply at all is unreachable). The
|
||||
// startup wait's bound, when it has one, still applies and is shown.
|
||||
out = MasterWait{Reason: "first_heartbeat_unanswered", Since: w.firstHB, Until: w.deadlineLocked()}
|
||||
case w.barrier.After(now):
|
||||
out = MasterWait{Reason: "barrier", Since: w.contact, Until: w.barrier}
|
||||
case w.window.IsZero():
|
||||
|
||||
@@ -485,3 +485,35 @@ func TestRecordedRevocationFinalRequiresTypedFailedPrecondition(t *testing.T) {
|
||||
t.Fatal("log text became a terminal verdict")
|
||||
}
|
||||
}
|
||||
|
||||
// The overdue first-heartbeat wait is named only while the master replies: a
|
||||
// master that gives no reply at all is unreachable, overdue wait or not. It
|
||||
// reports the startup wait's bound, which still runs on refused heartbeats.
|
||||
func TestTheUnansweredFirstHeartbeatReasonNeedsAReplyingMaster(t *testing.T) {
|
||||
now := time.Date(2026, 12, 6, 12, 0, 0, 0, time.UTC)
|
||||
w := newMasterWait(func() time.Time { return now }, func(string, ...any) {})
|
||||
start := now.Add(-40 * time.Second)
|
||||
w.firstHeartbeatOverdue(start)
|
||||
w.call(status.Error(codes.Unavailable, "master down"))
|
||||
if got := w.snapshot(true); got.Reason != "unreachable" {
|
||||
t.Fatalf("a master that gives no reply: reason %q, want unreachable", got.Reason)
|
||||
}
|
||||
if got := w.snapshot(true); !got.Until.IsZero() {
|
||||
t.Fatalf("no reply yet: the startup wait has no bound, got until %s", got.Until)
|
||||
}
|
||||
w.begin(now.Add(-time.Second)) // the startup wait began; its window opens at the first reply after it
|
||||
w.call(status.Error(codes.Internal, "ingest error"))
|
||||
got := w.snapshot(true)
|
||||
if got.Reason != "first_heartbeat_unanswered" || !got.Since.Equal(start) {
|
||||
t.Fatalf("a replying master that refuses the first heartbeat: %+v, want first_heartbeat_unanswered since %s", got, start)
|
||||
}
|
||||
// A refused heartbeat is still a reply: the startup wait's bound runs, and
|
||||
// the reason reports it rather than claiming none.
|
||||
if want := now.Add(MasterWaitLimit); !got.Until.Equal(want) {
|
||||
t.Fatalf("the overdue first-heartbeat wait reports until %s, want the startup wait's bound %s", got.Until, want)
|
||||
}
|
||||
w.firstHeartbeatOverdue(time.Time{})
|
||||
if got := w.snapshot(true); got.Reason == "first_heartbeat_unanswered" {
|
||||
t.Fatalf("after the answer the reason is still %q", got.Reason)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,485 @@
|
||||
package volume
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// orderServer is a master's two holder-facing services on one listener: it
|
||||
// records the order in which a holder's heartbeats and lease renewals
|
||||
// arrive, and holds the FIRST heartbeat open until released (a slow first
|
||||
// report, as after a master restart or a congested link). entered closes
|
||||
// when that first heartbeat is inside the handler: from then on the
|
||||
// heartbeat is in flight and not yet answered.
|
||||
type orderServer struct {
|
||||
control.UnimplementedObservationServiceServer
|
||||
control.UnimplementedWorkspaceServiceServer
|
||||
mu sync.Mutex
|
||||
events []string
|
||||
heartbeat int
|
||||
entered chan struct{}
|
||||
release chan struct{}
|
||||
}
|
||||
|
||||
func newOrderServer() *orderServer {
|
||||
return &orderServer{entered: make(chan struct{}), release: make(chan struct{})}
|
||||
}
|
||||
|
||||
func (s *orderServer) record(e string) {
|
||||
s.mu.Lock()
|
||||
s.events = append(s.events, e)
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
func (s *orderServer) ReportHeartbeat(ctx context.Context, r *control.HeartbeatReport) (*control.HeartbeatAck, error) {
|
||||
s.mu.Lock()
|
||||
s.heartbeat++
|
||||
first := s.heartbeat == 1
|
||||
s.mu.Unlock()
|
||||
if first {
|
||||
close(s.entered)
|
||||
select {
|
||||
case <-s.release:
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
}
|
||||
incarnation := ""
|
||||
if slots := r.GetSlots(); len(slots) > 0 {
|
||||
incarnation = slots[0].GetIncarnation()
|
||||
}
|
||||
s.record("heartbeat incarnation=" + incarnation)
|
||||
return &control.HeartbeatAck{}, nil
|
||||
}
|
||||
|
||||
func (s *orderServer) RenewWorkspaceLease(_ context.Context, id *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) {
|
||||
s.record("renewal")
|
||||
ttl := 5 * time.Second
|
||||
return &control.WorkspaceLeaseFact{VolumeId: id.VolumeId, ReplicaId: id.ReplicaId, Epoch: id.Epoch, ValidForNs: int64(ttl), ExpiresAtNs: time.Now().Add(ttl).UnixNano()}, nil
|
||||
}
|
||||
|
||||
func (s *orderServer) snapshot() []string {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return append([]string(nil), s.events...)
|
||||
}
|
||||
|
||||
func (s *orderServer) renewed() bool {
|
||||
for _, e := range s.snapshot() {
|
||||
if e == "renewal" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// firstHeartbeatRig starts an already-assigned holder (epoch 3, so the lease
|
||||
// runtime may start at once) against s: its heartbeat loop and its lease
|
||||
// runtime. started is when the lease runtime was started; done closes when it
|
||||
// returns (any number of readers). Cleanup cancels the runtime and joins it
|
||||
// within a bound, before the host and the server close; a failed join stops
|
||||
// the test binary (joinOrFailStop), so nothing is torn down under it.
|
||||
func firstHeartbeatRig(t *testing.T, s *orderServer) (h *Host, started time.Time, done <-chan struct{}) {
|
||||
t.Helper()
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
control.RegisterObservationServiceServer(srv, s)
|
||||
control.RegisterWorkspaceServiceServer(srv, s)
|
||||
go srv.Serve(ln)
|
||||
t.Cleanup(srv.Stop)
|
||||
h = workspaceRuntimeHost(t, ln.Addr().String(), true) // its cleanup closes the host (joins the heartbeat loop)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ch := make(chan struct{})
|
||||
h.Start()
|
||||
started = time.Now()
|
||||
go func() {
|
||||
defer close(ch)
|
||||
_ = h.RunWorkspaceLease(ctx, func(context.Context, *control.WorkspaceIdentity) (uint64, error) { return 0, nil })
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
joinOrFailStop(ch, 10*time.Second)
|
||||
})
|
||||
return h, started, ch
|
||||
}
|
||||
|
||||
// joinOrFailStop waits for done within bound. On timeout it ends the test
|
||||
// binary at once (os.Exit, no unwinding): a panic would still run the
|
||||
// cleanups after it (testing runs the rest when one panics), which close the
|
||||
// host and the server and restore shared settings under a lease runtime
|
||||
// that is still running.
|
||||
func joinOrFailStop(done <-chan struct{}, bound time.Duration) {
|
||||
select {
|
||||
case <-done:
|
||||
case <-time.After(bound):
|
||||
fmt.Fprintln(os.Stderr, "the lease runtime did not return within "+bound.String()+" of its cancellation; refusing teardown under a live worker")
|
||||
os.Exit(3)
|
||||
}
|
||||
}
|
||||
|
||||
// The rig's join fail-stops before teardown. A child test binary registers a
|
||||
// teardown cleanup (it writes a marker file) and, after it, the join: with a
|
||||
// worker that never returns the child exits with status 3 and the marker is
|
||||
// absent (no teardown ran); with a worker that returned it passes and the
|
||||
// marker is present.
|
||||
func TestAFailedRuntimeJoinFailStopsBeforeTeardown(t *testing.T) {
|
||||
if marker := os.Getenv("JOIN_FAILSTOP_MARKER"); marker != "" {
|
||||
t.Cleanup(func() { _ = os.WriteFile(marker, []byte("teardown ran"), 0o644) }) // the later teardown
|
||||
done := make(chan struct{})
|
||||
if os.Getenv("JOIN_FAILSTOP_JOINED") == "true" {
|
||||
close(done)
|
||||
}
|
||||
t.Cleanup(func() { joinOrFailStop(done, 50*time.Millisecond) }) // runs first
|
||||
return
|
||||
}
|
||||
for _, joined := range []bool{false, true} {
|
||||
marker := filepath.Join(t.TempDir(), "teardown-ran")
|
||||
// The child is bounded: a join that hangs is killed at the deadline
|
||||
// and fails here as a timeout, never as the expected exit 3.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$", "-test.count=1", "-test.timeout=20s")
|
||||
cmd.WaitDelay = 5 * time.Second
|
||||
cmd.Env = append(os.Environ(), "JOIN_FAILSTOP_MARKER="+marker, "JOIN_FAILSTOP_JOINED="+strconv.FormatBool(joined))
|
||||
out, err := cmd.CombinedOutput() // returns only after the child is reaped (killed at the deadline if need be)
|
||||
timedOut := ctx.Err() != nil
|
||||
cancel()
|
||||
if timedOut {
|
||||
t.Fatalf("joined=%v: the child did not finish within 30s (killed): %v\n%s", joined, err, out)
|
||||
}
|
||||
_, statErr := os.Stat(marker)
|
||||
var exit *exec.ExitError
|
||||
switch {
|
||||
case joined && (err != nil || statErr != nil):
|
||||
t.Fatalf("a returned worker: child %v, teardown marker %v\n%s", err, statErr, out)
|
||||
case !joined && !(errors.As(err, &exit) && exit.ExitCode() == 3):
|
||||
t.Fatalf("a worker that never returned: child %v, want exit status 3\n%s", err, out)
|
||||
case !joined && statErr == nil:
|
||||
t.Fatalf("a worker that never returned: the later teardown ran\n%s", out)
|
||||
case !joined && !strings.Contains(string(out), "refusing teardown under a live worker"):
|
||||
t.Fatalf("a worker that never returned: no cause in the output\n%s", out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Identity check (1) of the v1.1.2 bound: a v1.1 holder's first lease
|
||||
// renewal on start follows its first ANSWERED heartbeat, which names its
|
||||
// incarnation. Until then the master holds only its predecessor's report for
|
||||
// the volume, and a renewal would be judged on that report. The window is
|
||||
// witnessed open: the first heartbeat is inside the master's handler, held
|
||||
// there, while the lease runtime has every chance to renew; once it is
|
||||
// answered, a renewal follows.
|
||||
func TestAHolderRenewsOnlyAfterItsFirstHeartbeatWithItsIncarnation(t *testing.T) {
|
||||
s := newOrderServer()
|
||||
h, _, _ := firstHeartbeatRig(t, s)
|
||||
select {
|
||||
case <-s.entered:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the holder's first heartbeat never reached the master")
|
||||
}
|
||||
// The heartbeat is in flight and unanswered: the window is open.
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
if s.renewed() {
|
||||
t.Fatalf("the holder renewed its lease while its first heartbeat was in flight: %v", s.snapshot())
|
||||
}
|
||||
close(s.release)
|
||||
runtimeAwait(t, "a renewal after the first heartbeat", s.renewed)
|
||||
events := s.snapshot()
|
||||
if len(events) == 0 || events[0] == "renewal" {
|
||||
t.Fatalf("first event %v, want the first heartbeat", events)
|
||||
}
|
||||
if events[0] != "heartbeat incarnation="+h.incarnation || h.incarnation == "" {
|
||||
t.Fatalf("the first heartbeat %q does not name this process's incarnation %q", events[0], h.incarnation)
|
||||
}
|
||||
}
|
||||
|
||||
// A holder whose first heartbeat is never answered does not renew and does
|
||||
// not serve, and keeps waiting: no guard is installed, so nothing fences it
|
||||
// for good. Past the bound (one lease validity; shortened here), no sooner
|
||||
// and not much later, /status names the wait first_heartbeat_unanswered.
|
||||
// The wait is measured from its own start (a test hook); the tolerance covers
|
||||
// the runtime's 50 ms poll.
|
||||
func TestAHolderWhoseHeartbeatIsNeverAnsweredWaitsUnservedWithATypedReason(t *testing.T) {
|
||||
const bound, tolerance = 300 * time.Millisecond, 500 * time.Millisecond
|
||||
previous, previousHook := firstHeartbeatWait, firstHeartbeatWaitStarted
|
||||
waitStarted := make(chan time.Time, 1)
|
||||
firstHeartbeatWaitStarted = func(at time.Time) {
|
||||
select {
|
||||
case waitStarted <- at:
|
||||
default:
|
||||
}
|
||||
}
|
||||
t.Cleanup(func() { firstHeartbeatWait, firstHeartbeatWaitStarted = previous, previousHook })
|
||||
// The master replies, refusing every heartbeat (an ingest error), until told.
|
||||
s := &refusingServer{refuse: 1 << 30, code: codes.Internal}
|
||||
h, done := refusingRigDone(t, s, bound)
|
||||
var start time.Time
|
||||
select {
|
||||
case start = <-waitStarted:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the lease runtime never started waiting for the first answered heartbeat")
|
||||
}
|
||||
overdue := func() bool {
|
||||
w := h.MasterWaitStatus()
|
||||
return w != nil && w.Reason == "first_heartbeat_unanswered"
|
||||
}
|
||||
for !overdue() {
|
||||
if time.Since(start) > bound+tolerance {
|
||||
t.Fatalf("no first_heartbeat_unanswered wait reason %s after the wait began (bound %s): %+v", time.Since(start), bound, h.MasterWaitStatus())
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if waited := time.Since(start); waited < bound {
|
||||
t.Fatalf("the wait was reported overdue after %s, before its %s bound", waited, bound)
|
||||
}
|
||||
if w := h.MasterWaitStatus(); !w.Since.Equal(start) {
|
||||
t.Fatalf("the overdue wait reports since %s, want the wait's start %s", w.Since, start)
|
||||
}
|
||||
time.Sleep(2 * bound) // well past the bound: still waiting, nothing installed
|
||||
select {
|
||||
case <-done:
|
||||
t.Fatal("the lease runtime returned instead of waiting for the first answered heartbeat")
|
||||
default:
|
||||
}
|
||||
if g := h.view.workspaceGuard.Load(); g != nil {
|
||||
t.Fatalf("a guard was installed before the first heartbeat was answered: %v", g.FenceCause())
|
||||
}
|
||||
if s.renewed() {
|
||||
t.Fatal("a holder with no answered heartbeat renewed")
|
||||
}
|
||||
if h.ProjectionView().Projection().Healthy {
|
||||
t.Fatal("a holder with no answered heartbeat serves")
|
||||
}
|
||||
s.answerFromNow() // answered late: the guard is installed and renews, without a restart
|
||||
runtimeAwait(t, "a renewal after the late answer", s.renewed)
|
||||
if overdue() {
|
||||
t.Fatal("the wait reason stays first_heartbeat_unanswered after the answer")
|
||||
}
|
||||
}
|
||||
|
||||
// refusingServer is a master that refuses a holder's first refuse heartbeats
|
||||
// with code (default Unavailable: its store slow or failing over; Internal:
|
||||
// an ingest error, which is a reply) and answers the later ones. A renewal is granted, or refused as moved when moved is set
|
||||
// (the assignment moved while the heartbeats were refused), or refused with
|
||||
// renewErr when set.
|
||||
type refusingServer struct {
|
||||
control.UnimplementedObservationServiceServer
|
||||
control.UnimplementedWorkspaceServiceServer
|
||||
refuse int
|
||||
code codes.Code
|
||||
// waitStarted receives when the lease runtime began waiting for the first
|
||||
// answered heartbeat (the rig's firstHeartbeatWaitStarted hook).
|
||||
waitStarted chan time.Time
|
||||
moved bool
|
||||
renewErr error
|
||||
mu sync.Mutex
|
||||
beats int
|
||||
answered time.Time
|
||||
renewals int
|
||||
}
|
||||
|
||||
func (s *refusingServer) ReportHeartbeat(context.Context, *control.HeartbeatReport) (*control.HeartbeatAck, error) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.beats++
|
||||
if s.beats <= s.refuse {
|
||||
code := s.code
|
||||
if code == codes.OK {
|
||||
code = codes.Unavailable
|
||||
}
|
||||
return nil, status.Error(code, "master refuses the heartbeat")
|
||||
}
|
||||
if s.answered.IsZero() {
|
||||
s.answered = time.Now()
|
||||
}
|
||||
return &control.HeartbeatAck{}, nil
|
||||
}
|
||||
|
||||
func (s *refusingServer) RenewWorkspaceLease(_ context.Context, id *control.WorkspaceIdentity) (*control.WorkspaceLeaseFact, error) {
|
||||
s.mu.Lock()
|
||||
s.renewals++
|
||||
moved, renewErr := s.moved, s.renewErr
|
||||
s.mu.Unlock()
|
||||
if renewErr != nil {
|
||||
return nil, renewErr
|
||||
}
|
||||
if moved {
|
||||
st, err := status.New(codes.FailedPrecondition, "workspace moved to holder node-b at epoch 4").WithDetails(&control.WorkspaceLeaseRefusal{Kind: control.WorkspaceLeaseRefusal_MOVED})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, st.Err()
|
||||
}
|
||||
ttl := 5 * time.Second
|
||||
return &control.WorkspaceLeaseFact{VolumeId: id.VolumeId, ReplicaId: id.ReplicaId, Epoch: id.Epoch, ValidForNs: int64(ttl), ExpiresAtNs: time.Now().Add(ttl).UnixNano()}, nil
|
||||
}
|
||||
|
||||
// answerFromNow makes the master answer every later heartbeat.
|
||||
func (s *refusingServer) answerFromNow() {
|
||||
s.mu.Lock()
|
||||
s.refuse = s.beats
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
func (s *refusingServer) renewed() bool { _, n := s.state(); return n > 0 }
|
||||
|
||||
func (s *refusingServer) state() (answered time.Time, renewals int) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.answered, s.renewals
|
||||
}
|
||||
|
||||
// refuseThenAnswer waits (bounded) for the lease runtime to report the start
|
||||
// of its first-heartbeat wait, then lets s refuse every heartbeat until three
|
||||
// bounds past that start, checking that the holder neither renews nor serves
|
||||
// (the projection is read before the server state, which cannot change:
|
||||
// nothing is answered yet), then makes s answer from now on. The answer comes
|
||||
// after the runtime's own bound, whenever the runtime started.
|
||||
func refuseThenAnswer(t *testing.T, h *Host, s *refusingServer, bound time.Duration) {
|
||||
t.Helper()
|
||||
var start time.Time
|
||||
select {
|
||||
case start = <-s.waitStarted:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the lease runtime never started waiting for the first answered heartbeat")
|
||||
}
|
||||
for end := start.Add(3 * bound); time.Now().Before(end); time.Sleep(time.Millisecond) {
|
||||
healthy := h.ProjectionView().Projection().Healthy
|
||||
if answered, renewals := s.state(); !answered.IsZero() || renewals > 0 || healthy {
|
||||
t.Fatalf("before any answer: answered=%v renewals=%d healthy=%v", !answered.IsZero(), renewals, healthy)
|
||||
}
|
||||
}
|
||||
s.answerFromNow()
|
||||
}
|
||||
|
||||
// refusingRig starts an assigned holder (epoch 3) with a 20 ms heartbeat
|
||||
// against s, its first-heartbeat bound shortened to bound, and its lease
|
||||
// runtime. Cleanup cancels the runtime and joins it before teardown.
|
||||
func refusingRig(t *testing.T, s *refusingServer, bound time.Duration) *Host {
|
||||
t.Helper()
|
||||
h, _ := refusingRigDone(t, s, bound)
|
||||
return h
|
||||
}
|
||||
|
||||
// refusingRigDone is refusingRig, also returning the lease runtime's done.
|
||||
func refusingRigDone(t *testing.T, s *refusingServer, bound time.Duration) (*Host, <-chan struct{}) {
|
||||
t.Helper()
|
||||
previous := firstHeartbeatWait
|
||||
firstHeartbeatWait = bound
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
control.RegisterObservationServiceServer(srv, s)
|
||||
control.RegisterWorkspaceServiceServer(srv, s)
|
||||
go srv.Serve(ln)
|
||||
t.Cleanup(srv.Stop)
|
||||
t.Cleanup(func() { firstHeartbeatWait = previous })
|
||||
// Record the runtime's wait start for refuseThenAnswer, after any hook the
|
||||
// test installed (both are told).
|
||||
s.waitStarted = make(chan time.Time, 1)
|
||||
previousHook := firstHeartbeatWaitStarted
|
||||
firstHeartbeatWaitStarted = func(at time.Time) {
|
||||
if previousHook != nil {
|
||||
previousHook(at)
|
||||
}
|
||||
select {
|
||||
case s.waitStarted <- at:
|
||||
default:
|
||||
}
|
||||
}
|
||||
t.Cleanup(func() { firstHeartbeatWaitStarted = previousHook })
|
||||
h := workspaceRuntimeHostEvery(t, ln.Addr().String(), true, 20*time.Millisecond)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
done := make(chan struct{})
|
||||
h.Start()
|
||||
go func() {
|
||||
defer close(done)
|
||||
_ = h.RunWorkspaceLease(ctx, func(context.Context, *control.WorkspaceIdentity) (uint64, error) { return 0, nil })
|
||||
}()
|
||||
t.Cleanup(func() {
|
||||
cancel()
|
||||
joinOrFailStop(done, 10*time.Second)
|
||||
})
|
||||
return h, done
|
||||
}
|
||||
|
||||
// A holder whose first heartbeats are refused for longer than the bound (the
|
||||
// master's store failing over) neither renews nor serves while they are
|
||||
// refused, and serves once this process's own heartbeat is answered and a
|
||||
// renewal is granted: no restart. (v1.1.2 rc: the guard was installed fenced
|
||||
// at the bound, for good.)
|
||||
func TestAHolderWhoseFirstHeartbeatsAreRefusedPastTheBoundServesOnceAnswered(t *testing.T) {
|
||||
const bound = 100 * time.Millisecond
|
||||
s := &refusingServer{refuse: 1 << 30} // Unavailable until told
|
||||
h := refusingRig(t, s, bound)
|
||||
refuseThenAnswer(t, h, s, bound)
|
||||
runtimeAwait(t, "serving after the first answered heartbeat and a granted renewal", func() bool {
|
||||
return h.ProjectionView().Projection().Healthy
|
||||
})
|
||||
if _, renewals := s.state(); renewals == 0 {
|
||||
t.Fatal("the holder serves without a granted renewal")
|
||||
}
|
||||
if g := h.view.workspaceGuard.Load(); g == nil || g.FenceCause() != "" {
|
||||
t.Fatalf("the serving holder's guard is missing or fenced: %v", g)
|
||||
}
|
||||
}
|
||||
|
||||
// Twin: the assignment moves while the first heartbeats are refused. The
|
||||
// late answer leads to a renewal, which the master refuses as moved: the
|
||||
// holder never serves.
|
||||
func TestAHolderWhoseAssignmentMovedWhileItsFirstHeartbeatsWereRefusedNeverServes(t *testing.T) {
|
||||
const bound = 100 * time.Millisecond
|
||||
s := &refusingServer{refuse: 1 << 30, moved: true}
|
||||
h := refusingRig(t, s, bound)
|
||||
refuseThenAnswer(t, h, s, bound)
|
||||
runtimeAwait(t, "a renewal after the late answer", func() bool { _, n := s.state(); return n > 0 })
|
||||
end := time.Now().Add(time.Second)
|
||||
for time.Now().Before(end) {
|
||||
if h.ProjectionView().Projection().Healthy {
|
||||
t.Fatal("a holder whose assignment moved serves after its late first heartbeat answer")
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
// Once this process's first heartbeat is answered, the wait is no longer
|
||||
// named first_heartbeat_unanswered, also while the renewal that follows is
|
||||
// refused (a busy store, not a final refusal). The renewal counter shows the
|
||||
// renewal reached the master; the check is only that the old reason is gone.
|
||||
func TestAnAnsweredFirstHeartbeatEndsTheUnansweredWaitReason(t *testing.T) {
|
||||
const bound = 100 * time.Millisecond
|
||||
s := &refusingServer{refuse: 1 << 30, code: codes.Internal, renewErr: status.Error(codes.Aborted, "master store busy")}
|
||||
h := refusingRig(t, s, bound)
|
||||
runtimeAwait(t, "first_heartbeat_unanswered while the heartbeats are refused past the bound", func() bool {
|
||||
w := h.MasterWaitStatus()
|
||||
return w != nil && w.Reason == "first_heartbeat_unanswered"
|
||||
})
|
||||
s.answerFromNow() // only after the reason was seen
|
||||
runtimeAwait(t, "a renewal after the late answer", func() bool { _, n := s.state(); return n > 0 })
|
||||
if w := h.MasterWaitStatus(); w == nil || w.Reason == "first_heartbeat_unanswered" {
|
||||
t.Fatalf("after the answer the wait reason is %+v, want it no longer first_heartbeat_unanswered", w)
|
||||
}
|
||||
if h.ProjectionView().Projection().Healthy {
|
||||
t.Fatal("a holder whose renewal was refused serves")
|
||||
}
|
||||
}
|
||||
@@ -240,6 +240,9 @@ func (g *WorkspaceLeaseGuard) heldLocked() bool {
|
||||
return !g.fenced && !g.until.IsZero()
|
||||
}
|
||||
|
||||
// maxRenewalValidity is the longest validity Refresh accepts in a reply.
|
||||
const maxRenewalValidity = 30 * time.Second
|
||||
|
||||
// Refresh anchors validity to the request START. Reply latency can only shorten
|
||||
// the client's usable lease, never extend it past the master's grant window.
|
||||
// ValidForNs already excludes half the master-configured clock-skew margin;
|
||||
@@ -293,7 +296,7 @@ func (g *WorkspaceLeaseGuard) Refresh(ctx context.Context) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
if reply.GetVolumeId() != g.id.VolumeId || reply.GetReplicaId() != g.id.ReplicaId || reply.GetEpoch() != g.id.Epoch || reply.GetValidForNs() <= 0 || reply.GetValidForNs() > int64(30*time.Second) {
|
||||
if reply.GetVolumeId() != g.id.VolumeId || reply.GetReplicaId() != g.id.ReplicaId || reply.GetEpoch() != g.id.Epoch || reply.GetValidForNs() <= 0 || reply.GetValidForNs() > int64(maxRenewalValidity) {
|
||||
g.mu.Lock()
|
||||
g.fenceLocked(fmt.Sprintf("invalid lease reply (volume=%q replica=%q epoch=%d validForNs=%d)", reply.GetVolumeId(), reply.GetReplicaId(), reply.GetEpoch(), reply.GetValidForNs()))
|
||||
g.mu.Unlock()
|
||||
|
||||
@@ -26,12 +26,32 @@ func (h *Host) runWorkspaceLease(ctx context.Context, stop func(context.Context,
|
||||
}
|
||||
tick := time.NewTicker(50 * time.Millisecond)
|
||||
defer tick.Stop()
|
||||
var heartbeatWaitStart time.Time
|
||||
for {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
p := h.view.Projection()
|
||||
if p.Epoch > 0 {
|
||||
// The first renewal waits for this process's first answered heartbeat:
|
||||
// before it the master holds only a predecessor's report. No guard is
|
||||
// installed while it waits, so the view stays gated (no renewal, no
|
||||
// serving). Past one lease validity the wait is a typed master-wait
|
||||
// reason; it is not a fence, so a later answer (the master's store
|
||||
// back, the host re-registered) still installs the guard without a
|
||||
// restart.
|
||||
if p.Epoch > 0 && !h.firstHeartbeatAnswered() {
|
||||
if heartbeatWaitStart.IsZero() {
|
||||
heartbeatWaitStart = time.Now()
|
||||
if hook := firstHeartbeatWaitStarted; hook != nil {
|
||||
hook(heartbeatWaitStart)
|
||||
}
|
||||
}
|
||||
if time.Since(heartbeatWaitStart) >= firstHeartbeatWait {
|
||||
h.mw.firstHeartbeatOverdue(heartbeatWaitStart)
|
||||
}
|
||||
}
|
||||
if p.Epoch > 0 && h.firstHeartbeatAnswered() {
|
||||
h.mw.firstHeartbeatOverdue(time.Time{})
|
||||
id := &control.WorkspaceIdentity{VolumeId: h.cfg.VolumeID, ReplicaId: h.cfg.ReplicaID, ServerId: h.cfg.ServerID, Epoch: p.Epoch}
|
||||
guard, err := NewWorkspaceLeaseGuard(h.view, control.NewWorkspaceServiceClient(h.conn), id, func(c context.Context) (uint64, error) { return stop(c, id) }, nil)
|
||||
if err != nil {
|
||||
@@ -65,6 +85,35 @@ func (h *Host) runWorkspaceLease(ctx context.Context, stop func(context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
// firstHeartbeatWait is how long the wait for the first answered heartbeat
|
||||
// lasts before it is reported as the master-wait reason
|
||||
// first_heartbeat_unanswered (one lease validity). The lease runtime's wait
|
||||
// has no bound of its own and never fences or exits; the chunk startup wait
|
||||
// keeps its own bound (MasterWaitLimit after the first reply), which the
|
||||
// reason reports as Until. Tests shorten it.
|
||||
var firstHeartbeatWait = maxRenewalValidity
|
||||
|
||||
// firstHeartbeatWaitStarted, when set (tests only), is told when the lease
|
||||
// runtime starts waiting for the first answered heartbeat.
|
||||
var firstHeartbeatWaitStarted func(time.Time)
|
||||
|
||||
// firstHeartbeatAnswered reports whether the lease runtime may renew: the
|
||||
// master has answered this process's first heartbeat (with its incarnation),
|
||||
// so a renewal is judged on this process's own report, never on a
|
||||
// predecessor's. A host whose heartbeat loop never started (Start not called)
|
||||
// has nothing to wait for.
|
||||
func (h *Host) firstHeartbeatAnswered() bool {
|
||||
if !h.started.Load() {
|
||||
return true
|
||||
}
|
||||
select {
|
||||
case <-h.heartbeatAnswered:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// WorkspaceStopPending is called when a graceful stop of volumeID has begun
|
||||
// (its chunk layer is being detached): the lease guard renews at once and
|
||||
// then sleeps at most stopPendingPoll between renewals, instead of its normal
|
||||
|
||||
@@ -22,7 +22,14 @@ import (
|
||||
|
||||
func workspaceRuntimeHost(t *testing.T, addr string, required bool) *Host {
|
||||
t.Helper()
|
||||
h, err := New(Config{MasterAddr: addr, ServerID: "node-a", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:9100", CtrlAddr: "127.0.0.1:9101", EnableT1Readiness: true, WorkspaceLease: required})
|
||||
return workspaceRuntimeHostEvery(t, addr, required, 0)
|
||||
}
|
||||
|
||||
// workspaceRuntimeHostEvery is workspaceRuntimeHost with a heartbeat cadence
|
||||
// (0: the default).
|
||||
func workspaceRuntimeHostEvery(t *testing.T, addr string, required bool, heartbeat time.Duration) *Host {
|
||||
t.Helper()
|
||||
h, err := New(Config{MasterAddr: addr, ServerID: "node-a", VolumeID: "v1", ReplicaID: "r1", DataAddr: "127.0.0.1:9100", CtrlAddr: "127.0.0.1:9101", EnableT1Readiness: true, WorkspaceLease: required, HeartbeatInterval: heartbeat})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -19,12 +19,14 @@ func CertificatePool(raw []byte, now time.Time) (*x509.CertPool, error) {
|
||||
break
|
||||
}
|
||||
rest = remaining
|
||||
if block.Type != "CERTIFICATE" {
|
||||
if block.Type != "CERTIFICATE" || len(block.Headers) != 0 {
|
||||
continue
|
||||
}
|
||||
cert, err := x509.ParseCertificate(block.Bytes)
|
||||
if err != nil {
|
||||
return nil, LocalCredential(err)
|
||||
// Match AppendCertsFromPEM: an unusable alternative does not
|
||||
// invalidate the certificates that the pool can actually load.
|
||||
continue
|
||||
}
|
||||
if err := ValidateCertificate(cert, now); err != nil {
|
||||
if dateErr == nil {
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package answer_test
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/auth/authtest"
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/answer"
|
||||
)
|
||||
|
||||
func TestCertificatePoolSkipsUnparseableAlternatives(t *testing.T) {
|
||||
good := authtest.NewCA(t, "bundle-good")
|
||||
malformed := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: []byte("not a certificate")})
|
||||
block, _ := pem.Decode(good.PEM)
|
||||
block.Headers = map[string]string{"Ignored": "header"}
|
||||
header := pem.EncodeToMemory(block)
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
bundle []byte
|
||||
valid bool
|
||||
}{
|
||||
{"valid-before-malformed", append(append([]byte{}, good.PEM...), malformed...), true},
|
||||
{"valid-after-malformed", append(append([]byte{}, malformed...), good.PEM...), true},
|
||||
{"valid-beside-header", append(append([]byte{}, good.PEM...), header...), true},
|
||||
{"malformed-only", malformed, false},
|
||||
{"header-only", header, false},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
baseline := x509.NewCertPool()
|
||||
if got := baseline.AppendCertsFromPEM(row.bundle); got != row.valid {
|
||||
t.Fatalf("baseline loaded=%v want=%v", got, row.valid)
|
||||
}
|
||||
pool, err := answer.CertificatePool(row.bundle, time.Now())
|
||||
if row.valid {
|
||||
if err != nil || !pool.Equal(baseline) {
|
||||
t.Fatalf("pool=%v err=%v; want the baseline pool", pool, err)
|
||||
}
|
||||
} else {
|
||||
if err == nil {
|
||||
t.Fatal("bundle without a loadable certificate accepted")
|
||||
}
|
||||
policy, check := answer.PolicyOf(err)
|
||||
if check != nil || policy.Exit != 78 || policy.Retryable {
|
||||
t.Fatalf("policy=%+v check=%v err=%v", policy, check, err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// A header-bearing current certificate must not make an otherwise expired
|
||||
// loadable bundle pass local date validation: AppendCertsFromPEM ignores it.
|
||||
func TestCertificatePoolHeaderDoesNotMakeExpiredRootsCurrent(t *testing.T) {
|
||||
now := time.Now()
|
||||
good := authtest.NewCA(t, "current-header-only")
|
||||
block, _ := pem.Decode(good.PEM)
|
||||
block.Headers = map[string]string{"Ignored": "header"}
|
||||
header := pem.EncodeToMemory(block)
|
||||
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expired := *good.Cert
|
||||
expired.PublicKey = &key.PublicKey
|
||||
expired.NotBefore, expired.NotAfter = now.Add(-2*time.Hour), now.Add(-time.Hour)
|
||||
der, err := x509.CreateCertificate(rand.Reader, &expired, &expired, &key.PublicKey, key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expiredPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der})
|
||||
bundle := append(append([]byte{}, expiredPEM...), header...)
|
||||
baseline, onlyExpired := x509.NewCertPool(), x509.NewCertPool()
|
||||
if !baseline.AppendCertsFromPEM(bundle) || !onlyExpired.AppendCertsFromPEM(expiredPEM) || !baseline.Equal(onlyExpired) {
|
||||
t.Fatal("fixture must load only the expired root")
|
||||
}
|
||||
pool, err := answer.CertificatePool(bundle, now)
|
||||
if err == nil || pool != nil {
|
||||
t.Fatalf("header-bearing certificate rescued expired roots: pool=%v err=%v", pool, err)
|
||||
}
|
||||
policy, check := answer.PolicyOf(err)
|
||||
if check != nil || policy.Exit != 78 || policy.Retryable || policy.Retry != answer.Never {
|
||||
t.Fatalf("policy=%+v check=%v err=%v", policy, check, err)
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,14 @@ func HTTPStatusFailure(status int, cause error) error {
|
||||
}
|
||||
// The response status belongs to this attempt; a nested body-read
|
||||
// failure cannot replace it. Keep outer operation records authoritative.
|
||||
return &failure{phase: PossiblyAdmitted, kind: httpStatusKind(status), cause: &httpStatusFailure{status: status, cause: cause}}
|
||||
kind := httpStatusKind(status)
|
||||
if _, listed := registry[key{PossiblyAdmitted, kind}]; !listed {
|
||||
// A proxy status outside the registry cannot establish the origin's
|
||||
// outcome. Use the canonical unknown policy for every wire contract;
|
||||
// keep the actual HTTP status and cause in the error chain.
|
||||
kind = rpcKindKey(codes.Unknown)
|
||||
}
|
||||
return &failure{phase: PossiblyAdmitted, kind: kind, cause: &httpStatusFailure{status: status, cause: cause}}
|
||||
}
|
||||
|
||||
type httpStatusFailure struct {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package answer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHTTPStatusFailureRetainsStatusAndCause(t *testing.T) {
|
||||
for _, code := range []int{401, 408, 501, 520, 524, 599} {
|
||||
t.Run(fmt.Sprint(code), func(t *testing.T) {
|
||||
cause := errors.New("proxy body was unreadable")
|
||||
original := HTTPStatusFailure(code, cause)
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
err error
|
||||
}{
|
||||
{"direct", original},
|
||||
{"wrapped", fmt.Errorf("snapshot observation: %w", original)},
|
||||
{"chunk", Present(original, Chunk)},
|
||||
{"failover", Present(original, Failover)},
|
||||
{"ops", Present(original, Ops)},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
var received *httpStatusFailure
|
||||
if !errors.As(row.err, &received) {
|
||||
t.Fatalf("HTTP response record missing from error chain: %v", row.err)
|
||||
}
|
||||
if received.status != code {
|
||||
t.Fatalf("stored status=%d want=%d", received.status, code)
|
||||
}
|
||||
if !errors.Is(row.err, cause) {
|
||||
t.Fatalf("original cause missing from error chain: %v", row.err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package answer_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweed-block/core/rpc/answer"
|
||||
)
|
||||
|
||||
func TestUnlistedHTTPStatusPreservesUnknownOutcome(t *testing.T) {
|
||||
for _, code := range []int{408, 418, 421, 423, 431, 499, 505, 520, 524, 599} {
|
||||
t.Run(fmt.Sprint(code), func(t *testing.T) {
|
||||
cause := errors.New("proxy returned an HTML error after the POST")
|
||||
err := answer.HTTPStatusFailure(code, cause)
|
||||
if answer.DefiniteAnswer(err) || !errors.Is(err, cause) {
|
||||
t.Fatalf("definite=%v cause preserved=%v", answer.DefiniteAnswer(err), errors.Is(err, cause))
|
||||
}
|
||||
for _, contract := range []answer.Contract{answer.Chunk, answer.Workspace, answer.Cluster, answer.Restore, answer.Failover, answer.VolumeJob, answer.VolumeStop, answer.VolumePlacement, answer.Shell, answer.Ops} {
|
||||
p, check := answer.PolicyOf(err, contract)
|
||||
if check != nil || p.Code != "outcome_unknown" || !p.Retryable || p.Retry != answer.Recover || p.Exit != 3 {
|
||||
t.Fatalf("contract=%s policy=%+v check=%v", contract, p, check)
|
||||
}
|
||||
}
|
||||
for _, row := range []struct {
|
||||
contract answer.Contract
|
||||
exit int
|
||||
retry answer.RetryRule
|
||||
}{
|
||||
{answer.ChunkVerify, 1, answer.Resend},
|
||||
{answer.VolumeCreate, 75, answer.Recover},
|
||||
{answer.VolumeResolve, 75, answer.Recover},
|
||||
} {
|
||||
p, check := answer.PolicyOf(err, row.contract)
|
||||
if check != nil || p.Code != "outcome_unknown" || !p.Retryable || p.Retry != row.retry || p.Exit != row.exit {
|
||||
t.Fatalf("legacy contract=%s policy=%+v check=%v", row.contract, p, check)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ func TestPresentationPreservesProtocolErrorChain(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUnlistedHTTPStatusFailsPolicyCheck(t *testing.T) {
|
||||
if _, err := answer.PolicyOf(answer.HTTPStatusFailure(599, errors.New("unlisted HTTP status"))); err == nil {
|
||||
if _, err := answer.Lookup(answer.PossiblyAdmitted, answer.Kind{Name: "http/599"}); err == nil {
|
||||
t.Fatal("unlisted HTTP status passed the registry")
|
||||
}
|
||||
}
|
||||
@@ -63,14 +63,19 @@ func TestMasterLinkCARotationUsesTheVerifiedChain(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
name string
|
||||
from, until time.Time
|
||||
malformed bool
|
||||
}{
|
||||
{"expired", now.Add(-2 * time.Hour), now.Add(-time.Hour)},
|
||||
{"future", now.Add(time.Hour), now.Add(2 * time.Hour)},
|
||||
{"expired", now.Add(-2 * time.Hour), now.Add(-time.Hour), false},
|
||||
{"future", now.Add(time.Hour), now.Add(2 * time.Hour), false},
|
||||
{"malformed", now.Add(-2 * time.Hour), now.Add(-time.Hour), true},
|
||||
} {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
good := authtest.NewCA(t, "rotation-good")
|
||||
badPEM, badClient, badKey := datedRotationRoot(t, dir, row.from, row.until)
|
||||
if row.malformed {
|
||||
badPEM = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: []byte("not an X.509 certificate")})
|
||||
}
|
||||
caPath := filepath.Join(dir, "rotation-ca.pem")
|
||||
if err := os.WriteFile(caPath, append(append([]byte{}, good.PEM...), badPEM...), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -80,6 +85,9 @@ func TestMasterLinkCARotationUsesTheVerifiedChain(t *testing.T) {
|
||||
// A transmitted chain may retain an unused alternative too.
|
||||
// The peer builds its own chain; only our leaf is locally dated.
|
||||
for _, path := range []string{sc, cc} {
|
||||
if row.malformed {
|
||||
continue // The malformed alternative belongs only in the CA bundle.
|
||||
}
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="580" viewBox="0 0 1200 580" font-family="-apple-system, Segoe UI, Helvetica, Arial, sans-serif" role="img" aria-labelledby="title desc">
|
||||
<title id="title">Seaweed Block: the write path and the background path</title>
|
||||
<desc id="desc">Left, the write path: an agent sandbox or microVM writes to a plain virtio block disk; NVMe/TCP or iSCSI carries the request to blockvolume, which completes the write and fsync on its local WAL and acknowledges. A write does not wait on SeaweedFS, except that a restored volume fetches each chunk from its snapshot on its first read or write. Right, the background path: a cut (by default one scheduled snapshot a day; periodic cuts are optional) uploads only the changed 4 MiB chunks to your SeaweedFS and then updates the volume's HEAD root with a conditional update on generation and epoch. A snapshot names a root and shares its chunks; a restore makes a new volume that reads chunks on first use; a move lets another host take over at a higher epoch, and a stale holder's update is refused. Above both, blockmaster issues epochs and leases. The same core serves Kubernetes volumes through the CSI driver (alpha).</desc>
|
||||
<style>
|
||||
.bg { fill: #fcfcfb; }
|
||||
.box { fill: #ffffff; stroke: #d6d5d0; stroke-width: 1.2; }
|
||||
.panel { fill: #f3f2ef; }
|
||||
.ink { fill: #0b0b0b; }
|
||||
.ink2 { fill: #52514e; }
|
||||
.sync { stroke: #2a78d6; }
|
||||
.bgp { stroke: #eb6834; }
|
||||
.ctl { stroke: #8a8984; }
|
||||
.syncfill { fill: #2a78d6; }
|
||||
.bgfill { fill: #eb6834; }
|
||||
.ctlfill { fill: #8a8984; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.bg { fill: #1a1a19; }
|
||||
.box { fill: #262624; stroke: #45443f; }
|
||||
.panel { fill: #211f1e; }
|
||||
.ink { fill: #f0efec; }
|
||||
.ink2 { fill: #c3c2b7; }
|
||||
.sync { stroke: #3987e5; }
|
||||
.bgp { stroke: #d95926; }
|
||||
.ctl { stroke: #8f8e88; }
|
||||
.syncfill { fill: #3987e5; }
|
||||
.bgfill { fill: #d95926; }
|
||||
.ctlfill { fill: #8f8e88; }
|
||||
}
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="aS" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="syncfill" d="M0,0 L10,5 L0,10 z"/></marker>
|
||||
<marker id="aB" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="bgfill" d="M0,0 L10,5 L0,10 z"/></marker>
|
||||
<marker id="aC" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ctlfill" d="M0,0 L10,5 L0,10 z"/></marker>
|
||||
</defs>
|
||||
|
||||
<rect class="bg" width="1200" height="580" rx="16"/>
|
||||
<text class="ink" x="40" y="48" font-size="26" font-weight="700">Seaweed Block</text>
|
||||
<text class="ink2" x="40" y="74" font-size="15">Writes complete on the host's local disk; snapshots, restore and moves go through your SeaweedFS in the background.</text>
|
||||
|
||||
<!-- blockmaster -->
|
||||
<rect class="box" x="430" y="96" width="340" height="58" rx="10"/>
|
||||
<text class="ink" x="600" y="120" font-size="15" font-weight="600" text-anchor="middle">blockmaster: the epoch authority</text>
|
||||
<text class="ink2" x="600" y="141" font-size="12.5" text-anchor="middle">assigns each volume's holder · issues epochs and leases</text>
|
||||
|
||||
<!-- panels -->
|
||||
<rect class="panel" x="30" y="176" width="560" height="340" rx="12"/>
|
||||
<rect class="panel" x="610" y="176" width="560" height="340" rx="12"/>
|
||||
<line class="sync" x1="50" y1="200" x2="74" y2="200" stroke-width="4" stroke-linecap="round"/>
|
||||
<text class="ink" x="84" y="205" font-size="14" font-weight="700">WRITE PATH (synchronous)</text>
|
||||
<line class="bgp" x1="630" y1="200" x2="654" y2="200" stroke-width="4" stroke-linecap="round" stroke-dasharray="7 5"/>
|
||||
<text class="ink" x="664" y="205" font-size="14" font-weight="700">BACKGROUND PATH (cuts)</text>
|
||||
|
||||
<!-- write path chain -->
|
||||
<rect class="box" x="60" y="222" width="270" height="52" rx="9"/>
|
||||
<text class="ink" x="195" y="244" font-size="14" font-weight="600" text-anchor="middle">agent sandbox or microVM</text>
|
||||
<text class="ink2" x="195" y="263" font-size="12" text-anchor="middle">a plain virtio block disk</text>
|
||||
<line class="sync" x1="195" y1="274" x2="195" y2="296" stroke-width="2" marker-end="url(#aS)"/>
|
||||
<rect class="box" x="60" y="298" width="270" height="40" rx="9"/>
|
||||
<text class="ink" x="195" y="323" font-size="13.5" text-anchor="middle">NVMe/TCP or iSCSI</text>
|
||||
<line class="sync" x1="195" y1="338" x2="195" y2="360" stroke-width="2" marker-end="url(#aS)"/>
|
||||
<rect class="box" x="60" y="362" width="270" height="40" rx="9"/>
|
||||
<text class="ink" x="195" y="387" font-size="13.5" font-weight="600" text-anchor="middle">blockvolume (one per volume)</text>
|
||||
<line class="sync" x1="195" y1="402" x2="195" y2="424" stroke-width="2" marker-end="url(#aS)"/>
|
||||
<rect class="box" x="60" y="426" width="270" height="52" rx="9"/>
|
||||
<text class="ink" x="195" y="448" font-size="13.5" font-weight="600" text-anchor="middle">local WAL + extent</text>
|
||||
<text class="ink2" x="195" y="467" font-size="12" text-anchor="middle">walstore, on the host's disk</text>
|
||||
<!-- ack, on the left of the chain -->
|
||||
<path class="sync" d="M60,452 H44 V248 H56" fill="none" stroke-width="2" marker-end="url(#aS)"/>
|
||||
<text class="ink2" x="378" y="244" font-size="12.5">a write does not wait on</text>
|
||||
<text class="ink2" x="378" y="262" font-size="12.5">SeaweedFS (a restored volume</text>
|
||||
<text class="ink2" x="378" y="280" font-size="12.5">fetches each chunk</text>
|
||||
<text class="ink2" x="378" y="298" font-size="12.5">on first read or write)</text>
|
||||
<text class="ink" x="378" y="446" font-size="13" font-weight="600">ack (left arrow)</text>
|
||||
<text class="ink2" x="378" y="464" font-size="12.5">write and fsync complete</text>
|
||||
<text class="ink2" x="378" y="482" font-size="12.5">on the local WAL</text>
|
||||
|
||||
<!-- background chain -->
|
||||
<rect class="box" x="640" y="222" width="290" height="52" rx="9"/>
|
||||
<text class="ink" x="785" y="244" font-size="14" font-weight="600" text-anchor="middle">cut</text>
|
||||
<text class="ink2" x="785" y="263" font-size="12" text-anchor="middle">daily snapshot by default; optional periodic cuts</text>
|
||||
<line class="bgp" x1="785" y1="274" x2="785" y2="296" stroke-width="2" stroke-dasharray="6 4" marker-end="url(#aB)"/>
|
||||
<rect class="box" x="640" y="298" width="290" height="40" rx="9"/>
|
||||
<text class="ink" x="785" y="323" font-size="13.5" text-anchor="middle">only the changed 4 MiB chunks</text>
|
||||
<line class="bgp" x1="785" y1="338" x2="785" y2="360" stroke-width="2" stroke-dasharray="6 4" marker-end="url(#aB)"/>
|
||||
<rect class="box" x="640" y="362" width="290" height="40" rx="9"/>
|
||||
<text class="ink" x="785" y="387" font-size="13.5" font-weight="600" text-anchor="middle">your SeaweedFS</text>
|
||||
<line class="bgp" x1="785" y1="402" x2="785" y2="424" stroke-width="2" stroke-dasharray="6 4" marker-end="url(#aB)"/>
|
||||
<rect class="box" x="640" y="426" width="290" height="52" rx="9"/>
|
||||
<text class="ink" x="785" y="448" font-size="13.5" font-weight="600" text-anchor="middle">HEAD root (about 2 KB)</text>
|
||||
<text class="ink2" x="785" y="467" font-size="12" text-anchor="middle">conditional update on {gen, epoch}</text>
|
||||
<!-- background side notes -->
|
||||
<text class="ink" x="948" y="244" font-size="13" font-weight="600">snapshot</text>
|
||||
<text class="ink2" x="948" y="262" font-size="12">names a root; chunks are shared</text>
|
||||
<text class="ink" x="948" y="300" font-size="13" font-weight="600">restore</text>
|
||||
<text class="ink2" x="948" y="318" font-size="12">a new volume that reads the</text>
|
||||
<text class="ink2" x="948" y="334" font-size="12">snapshot's chunks on first use</text>
|
||||
<text class="ink" x="948" y="372" font-size="13" font-weight="600">move</text>
|
||||
<text class="ink2" x="948" y="390" font-size="12">another host takes over at a</text>
|
||||
<text class="ink2" x="948" y="406" font-size="12">higher epoch; a stale holder's</text>
|
||||
<text class="ink2" x="948" y="422" font-size="12">HEAD update is refused</text>
|
||||
|
||||
<!-- blockvolume to cut -->
|
||||
<path class="bgp" d="M330,392 H600 V248 H636" fill="none" stroke-width="2" stroke-dasharray="6 4" marker-end="url(#aB)"/>
|
||||
|
||||
<!-- control lines from blockmaster -->
|
||||
<path class="ctl" d="M430,125 H352 V372 H334" fill="none" stroke-width="1.5" stroke-dasharray="2 4" marker-end="url(#aC)"/>
|
||||
<text class="ink2" x="360" y="340" font-size="11.5">epoch, lease</text>
|
||||
<path class="ctl" d="M720,154 V170 H1110 V478 H934" fill="none" stroke-width="1.5" stroke-dasharray="2 4" marker-end="url(#aC)"/>
|
||||
<text class="ink2" x="1030" y="190" font-size="11.5">epoch fencing</text>
|
||||
|
||||
<!-- footer -->
|
||||
<text class="ink2" x="40" y="548" font-size="13">The same core serves Kubernetes volumes through the CSI driver (iSCSI or NVMe/TCP; alpha).</text>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 8.6 KiB |
@@ -1,113 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1080" height="490" viewBox="0 0 1080 490" role="img" aria-labelledby="title description">
|
||||
<title id="title">Seaweed Block: run locally, persist incrementally, resume anywhere</title>
|
||||
<desc id="description">The Seaweed Block lifecycle in three steps. One, run locally: agent VMs on host A write to the host's local disk, where writes and fsync complete with no network round trip. Two, persist incrementally: checkpoints send only the changed 4 MiB chunks to your SeaweedFS in the background, and named snapshots share those chunks. Three, 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; changed chunks go out at checkpoints, and a restored or moved volume fetches chunks on first read.</desc>
|
||||
<defs>
|
||||
<marker id="arrowTeal" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M 0 0 L 10 5 L 0 10 z" fill="#187b67"/>
|
||||
</marker>
|
||||
</defs>
|
||||
|
||||
<rect width="1080" height="490" rx="20" fill="#f5f9f8"/>
|
||||
<g font-family="Arial, Helvetica, sans-serif">
|
||||
<text x="40" y="43" fill="#0f766e" font-size="15" font-weight="700" letter-spacing="2">SEAWEED BLOCK</text>
|
||||
<text x="40" y="86" fill="#163832" font-size="32" font-weight="700">Run locally. Persist incrementally. Resume anywhere.</text>
|
||||
<text x="40" y="118" fill="#48635e" font-size="18">Local-first block storage for AI agents</text>
|
||||
|
||||
<!-- step headers -->
|
||||
<g font-size="20" font-weight="700" fill="#163832">
|
||||
<circle cx="117" cy="160" r="13" fill="#187b67"/>
|
||||
<text x="117" y="166" text-anchor="middle" fill="#fff" font-size="15">1</text>
|
||||
<text x="138" y="167">Run locally</text>
|
||||
<circle cx="424" cy="160" r="13" fill="#187b67"/>
|
||||
<text x="424" y="166" text-anchor="middle" fill="#fff" font-size="15">2</text>
|
||||
<text x="445" y="167">Persist incrementally</text>
|
||||
<circle cx="805" cy="160" r="13" fill="#187b67"/>
|
||||
<text x="805" y="166" text-anchor="middle" fill="#fff" font-size="15">3</text>
|
||||
<text x="826" y="167">Resume anywhere</text>
|
||||
</g>
|
||||
|
||||
<!-- 1. Host A: agents run on the local disk -->
|
||||
<g>
|
||||
<rect x="40" y="184" width="290" height="226" rx="14" fill="#fff" stroke="#cbded8"/>
|
||||
<text x="58" y="208" fill="#75928e" font-size="11" font-weight="700" letter-spacing="1.5">HOST A</text>
|
||||
<g fill="#eef6f3" stroke="#187b67" stroke-width="1.8">
|
||||
<rect x="74" y="218" width="66" height="48" rx="8"/>
|
||||
<rect x="152" y="218" width="66" height="48" rx="8"/>
|
||||
<rect x="230" y="218" width="66" height="48" rx="8"/>
|
||||
</g>
|
||||
<g text-anchor="middle">
|
||||
<g fill="#48635e" font-size="12">
|
||||
<text x="107" y="237">agent</text>
|
||||
<text x="185" y="237">agent</text>
|
||||
<text x="263" y="237">agent</text>
|
||||
</g>
|
||||
<g fill="#163832" font-size="16" font-weight="700">
|
||||
<text x="107" y="256">VM</text>
|
||||
<text x="185" y="256">VM</text>
|
||||
<text x="263" y="256">VM</text>
|
||||
</g>
|
||||
</g>
|
||||
<g stroke="#187b67" stroke-width="2.2">
|
||||
<path d="M107 268V294" marker-end="url(#arrowTeal)"/>
|
||||
<path d="M185 268V294" marker-end="url(#arrowTeal)"/>
|
||||
<path d="M263 268V294" marker-end="url(#arrowTeal)"/>
|
||||
</g>
|
||||
<rect x="75" y="300" width="220" height="36" rx="18" fill="#eef6f3" stroke="#187b67" stroke-width="1.5"/>
|
||||
<text x="185" y="323" text-anchor="middle" fill="#163832" font-size="15" font-weight="700">the host's local disk</text>
|
||||
<g text-anchor="middle" fill="#305c50" font-size="15">
|
||||
<text x="185" y="366">writes and fsync complete here,</text>
|
||||
<text x="185" y="387">with no network round trip</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- host A to SeaweedFS: changed chunks, in the background -->
|
||||
<path d="M334 300H424" stroke="#187b67" stroke-width="2.4" stroke-dasharray="7 5" marker-end="url(#arrowTeal)"/>
|
||||
<g text-anchor="middle" fill="#266354" font-size="13">
|
||||
<text x="380" y="276">only changed</text>
|
||||
<text x="380" y="292">chunks</text>
|
||||
<text x="380" y="320">in the</text>
|
||||
<text x="380" y="336">background</text>
|
||||
</g>
|
||||
|
||||
<!-- 2. SeaweedFS: checkpoints and snapshots -->
|
||||
<g>
|
||||
<rect x="430" y="184" width="220" height="226" rx="14" fill="#163e35"/>
|
||||
<text x="540" y="218" text-anchor="middle" fill="#fff" font-size="20" font-weight="700">your SeaweedFS</text>
|
||||
<rect x="452" y="238" width="176" height="42" rx="10" fill="#245446"/>
|
||||
<text x="540" y="265" text-anchor="middle" fill="#fff" font-size="16" font-weight="700">checkpoints</text>
|
||||
<rect x="452" y="292" width="176" height="42" rx="10" fill="#245446"/>
|
||||
<text x="540" y="319" text-anchor="middle" fill="#fff" font-size="16" font-weight="700">named snapshots</text>
|
||||
<g text-anchor="middle" fill="#cfe4dc" font-size="14">
|
||||
<text x="540" y="366">sharing the same</text>
|
||||
<text x="540" y="385">4 MiB chunks</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<!-- SeaweedFS to host B: restore or planned move -->
|
||||
<path d="M654 300H744" stroke="#187b67" stroke-width="2.4" marker-end="url(#arrowTeal)"/>
|
||||
<g text-anchor="middle" fill="#266354" font-size="13">
|
||||
<text x="700" y="292">lazy restore</text>
|
||||
<text x="700" y="320">or planned</text>
|
||||
<text x="700" y="336">move</text>
|
||||
</g>
|
||||
|
||||
<!-- 3. Host B: the workspace resumes -->
|
||||
<g>
|
||||
<rect x="750" y="184" width="290" height="226" rx="14" fill="#e4f5ee" stroke="#187b67" stroke-width="1.5"/>
|
||||
<text x="768" y="208" fill="#75928e" font-size="11" font-weight="700" letter-spacing="1.5">HOST B</text>
|
||||
<rect x="851" y="218" width="88" height="48" rx="8" fill="#fff" stroke="#187b67" stroke-width="1.8"/>
|
||||
<text x="895" y="237" text-anchor="middle" fill="#48635e" font-size="12">agent</text>
|
||||
<text x="895" y="256" text-anchor="middle" fill="#163832" font-size="16" font-weight="700">VM</text>
|
||||
<path d="M895 268V294" stroke="#187b67" stroke-width="2.2" marker-end="url(#arrowTeal)"/>
|
||||
<rect x="785" y="300" width="220" height="36" rx="18" fill="#fff" stroke="#187b67" stroke-width="1.5"/>
|
||||
<text x="895" y="323" text-anchor="middle" fill="#163832" font-size="15" font-weight="700">the host's local disk</text>
|
||||
<g text-anchor="middle" fill="#163832" font-size="15">
|
||||
<text x="895" y="366">serves at once, and fetches</text>
|
||||
<text x="895" y="387">chunks on first read</text>
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<text x="540" y="446" text-anchor="middle" fill="#48635e" font-size="15">Normal I/O to locally available data stays on the host. Changed chunks go out at checkpoints,</text>
|
||||
<text x="540" y="468" text-anchor="middle" fill="#48635e" font-size="15">and a restored or moved volume fetches chunks on first read.</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,41 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="780" height="330" viewBox="0 0 780 330" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Checkpointed local block (supported)</title>
|
||||
<desc id="d">The guest writes over NVMe/TCP or iSCSI to blockvolume on the same host, which completes write and fsync on its local write-ahead log and extent. In the background, checkpoints send the changed 4 MiB chunks to SeaweedFS (master, filer and volume servers), which also holds the HEAD records. blockmaster issues epochs and leases to blockvolume. Snapshots, restore and planned moves use the chunks in SeaweedFS.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#3987e5"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#c3c2b7"/></marker></defs>
|
||||
<rect width="780" height="330" fill="#1a1a19"/>
|
||||
<text x="16" y="26" font-size="15" font-weight="600" text-anchor="start" fill="#f0efec">Checkpointed local block (supported)</text>
|
||||
<text x="16" y="44" font-size="12" font-weight="400" text-anchor="start" fill="#c3c2b7">Writes and fsync complete on the host; changed chunks go to SeaweedFS in the background.</text>
|
||||
<rect x="16" y="62" width="400" height="250" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host</text>
|
||||
<rect x="36" y="96" width="130" height="70" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="101.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">Guest</text>
|
||||
<text x="101.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">VM, sandbox or</text>
|
||||
<text x="101.0" y="151" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">container</text>
|
||||
<rect x="236" y="96" width="160" height="70" rx="8" fill="#1f2a3a" stroke="#3987e5" stroke-width="1.5"/>
|
||||
<text x="316.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="316.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">local WAL + extent</text>
|
||||
<line x1="166" y1="131" x2="236" y2="131" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="201.0" y="124" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">NVMe/TCP</text>
|
||||
<text x="201" y="148" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">or iSCSI</text>
|
||||
<text x="316" y="190" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">write and fsync</text>
|
||||
<text x="316" y="204" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">complete here</text>
|
||||
<rect x="236" y="226" width="160" height="62" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="316.0" y="248" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">sw-block</text>
|
||||
<text x="316.0" y="266" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">operator CLI</text>
|
||||
<rect x="520" y="72" width="230" height="92" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="635.0" y="94" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">SeaweedFS</text>
|
||||
<text x="635.0" y="112" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">weed master, filer, volume</text>
|
||||
<text x="635.0" y="127" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">chunks and HEAD records</text>
|
||||
<text x="635.0" y="142" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">snapshots share chunks</text>
|
||||
<rect x="520" y="210" width="230" height="80" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="635.0" y="232" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockmaster</text>
|
||||
<text x="635.0" y="250" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">epochs, leases, placement</text>
|
||||
<text x="635.0" y="265" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">state on local files</text>
|
||||
<line x1="396" y1="118" x2="520" y2="108" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="458.0" y="101" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">changed 4 MiB chunks</text>
|
||||
<text x="458" y="132" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">in the background</text>
|
||||
<line x1="396" y1="150" x2="520" y2="238" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="448" y="214" font-size="11" font-weight="400" text-anchor="end" fill="#c3c2b7">heartbeat, lease</text>
|
||||
<line x1="396" y1="262" x2="520" y2="262" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="458.0" y="255" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">control API</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,41 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="780" height="330" viewBox="0 0 780 330" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Checkpointed local block (supported)</title>
|
||||
<desc id="d">The guest writes over NVMe/TCP or iSCSI to blockvolume on the same host, which completes write and fsync on its local write-ahead log and extent. In the background, checkpoints send the changed 4 MiB chunks to SeaweedFS (master, filer and volume servers), which also holds the HEAD records. blockmaster issues epochs and leases to blockvolume. Snapshots, restore and planned moves use the chunks in SeaweedFS.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#2a78d6"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#52514e"/></marker></defs>
|
||||
<rect width="780" height="330" fill="#fcfcfb"/>
|
||||
<text x="16" y="26" font-size="15" font-weight="600" text-anchor="start" fill="#0b0b0b">Checkpointed local block (supported)</text>
|
||||
<text x="16" y="44" font-size="12" font-weight="400" text-anchor="start" fill="#52514e">Writes and fsync complete on the host; changed chunks go to SeaweedFS in the background.</text>
|
||||
<rect x="16" y="62" width="400" height="250" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host</text>
|
||||
<rect x="36" y="96" width="130" height="70" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="101.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">Guest</text>
|
||||
<text x="101.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">VM, sandbox or</text>
|
||||
<text x="101.0" y="151" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">container</text>
|
||||
<rect x="236" y="96" width="160" height="70" rx="8" fill="#e8f0fb" stroke="#2a78d6" stroke-width="1.5"/>
|
||||
<text x="316.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="316.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">local WAL + extent</text>
|
||||
<line x1="166" y1="131" x2="236" y2="131" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="201.0" y="124" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">NVMe/TCP</text>
|
||||
<text x="201" y="148" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">or iSCSI</text>
|
||||
<text x="316" y="190" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">write and fsync</text>
|
||||
<text x="316" y="204" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">complete here</text>
|
||||
<rect x="236" y="226" width="160" height="62" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="316.0" y="248" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">sw-block</text>
|
||||
<text x="316.0" y="266" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">operator CLI</text>
|
||||
<rect x="520" y="72" width="230" height="92" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="635.0" y="94" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">SeaweedFS</text>
|
||||
<text x="635.0" y="112" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">weed master, filer, volume</text>
|
||||
<text x="635.0" y="127" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">chunks and HEAD records</text>
|
||||
<text x="635.0" y="142" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">snapshots share chunks</text>
|
||||
<rect x="520" y="210" width="230" height="80" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="635.0" y="232" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockmaster</text>
|
||||
<text x="635.0" y="250" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">epochs, leases, placement</text>
|
||||
<text x="635.0" y="265" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">state on local files</text>
|
||||
<line x1="396" y1="118" x2="520" y2="108" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="458.0" y="101" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">changed 4 MiB chunks</text>
|
||||
<text x="458" y="132" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">in the background</text>
|
||||
<line x1="396" y1="150" x2="520" y2="238" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="448" y="214" font-size="11" font-weight="400" text-anchor="end" fill="#52514e">heartbeat, lease</text>
|
||||
<line x1="396" y1="262" x2="520" y2="262" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="458.0" y="255" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">control API</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,67 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="900" height="420" viewBox="0 0 900 420" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Seaweed Block: block storage for SeaweedFS, in two modes</title>
|
||||
<desc id="d">One blockmaster per cluster issues epochs and leases and decides failover; the sw-block CLI talks to it. Left, checkpointed local block (supported): on a host, the guest writes over NVMe/TCP or iSCSI to blockvolume, which completes write and fsync on its local write-ahead log and extent and checkpoints the changed 4 MiB chunks to SeaweedFS (master, volume servers and filer) in the background; blockmaster reads the HEAD records from the filer. Right, replicated network block (preview): the guest writes to the primary blockvolume, which sends every write to replica blockvolumes on other hosts; SeaweedFS is not used.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#3987e5"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#c3c2b7"/></marker></defs>
|
||||
<rect width="900" height="420" fill="#1a1a19"/>
|
||||
<text x="16" y="26" font-size="16" font-weight="600" text-anchor="start" fill="#f0efec">Block storage for SeaweedFS, in two modes</text>
|
||||
<text x="16" y="45" font-size="12" font-weight="400" text-anchor="start" fill="#c3c2b7">One control plane; each volume is either checkpointed to SeaweedFS or replicated to other hosts.</text>
|
||||
<rect x="330" y="62" width="240" height="62" rx="8" fill="#1f2a3a" stroke="#3987e5" stroke-width="1.5"/>
|
||||
<text x="450.0" y="84" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockmaster</text>
|
||||
<text x="450.0" y="102" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">epochs, leases, failover</text>
|
||||
<rect x="640" y="62" width="150" height="62" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="715.0" y="84" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">sw-block</text>
|
||||
<text x="715.0" y="102" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">operator CLI</text>
|
||||
<line x1="640" y1="93" x2="570" y2="93" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="605.0" y="86" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">control API</text>
|
||||
<text x="16" y="156" font-size="13" font-weight="600" text-anchor="start" fill="#f0efec">Checkpointed local block (supported)</text>
|
||||
<rect x="16" y="166" width="410" height="120" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="186" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host</text>
|
||||
<rect x="30" y="198" width="110" height="66" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="85.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">Guest</text>
|
||||
<text x="85.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">VM, sandbox</text>
|
||||
<rect x="200" y="198" width="200" height="66" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="300.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="300.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">WAL + extent</text>
|
||||
<text x="300.0" y="253" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">fsync completes here</text>
|
||||
<line x1="140" y1="231" x2="200" y2="231" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="170.0" y="224" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">NVMe/TCP</text>
|
||||
<text x="170" y="248" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">or iSCSI</text>
|
||||
<rect x="120" y="318" width="280" height="76" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="260.0" y="340" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">SeaweedFS</text>
|
||||
<text x="260.0" y="358" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">weed master, volume, filer</text>
|
||||
<text x="260.0" y="373" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">chunks and HEAD records</text>
|
||||
<line x1="300" y1="264" x2="300" y2="318" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="308" y="296" font-size="11" font-weight="400" text-anchor="start" fill="#c3c2b7">changed 4 MiB chunks</text>
|
||||
<line x1="300" y1="198" x2="400" y2="124" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="330" y="166" font-size="11" font-weight="400" text-anchor="end" fill="#c3c2b7">lease</text>
|
||||
<line x1="400" y1="340" x2="470" y2="124" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="455" y="150" font-size="11" font-weight="400" text-anchor="end" fill="#c3c2b7">HEAD records</text>
|
||||
<text x="478" y="156" font-size="13" font-weight="600" text-anchor="start" fill="#f0efec">Replicated network block (preview)</text>
|
||||
<rect x="478" y="166" width="406" height="120" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="490" y="186" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host A</text>
|
||||
<rect x="492" y="198" width="110" height="66" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="547.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">Guest</text>
|
||||
<text x="547.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">VM, container</text>
|
||||
<rect x="662" y="198" width="200" height="66" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="762.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="762.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">primary</text>
|
||||
<text x="762.0" y="253" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">local store</text>
|
||||
<line x1="602" y1="231" x2="662" y2="231" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="632.0" y="224" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">NVMe/TCP</text>
|
||||
<text x="632" y="248" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">or iSCSI</text>
|
||||
<rect x="478" y="306" width="196" height="100" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="490" y="326" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host B</text>
|
||||
<rect x="490" y="334" width="172" height="56" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="576.0" y="356" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="576.0" y="374" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">replica</text>
|
||||
<rect x="688" y="306" width="196" height="100" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="700" y="326" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host C</text>
|
||||
<rect x="700" y="334" width="172" height="56" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="786.0" y="356" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="786.0" y="374" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">replica</text>
|
||||
<line x1="720" y1="264" x2="600" y2="334" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="640" y="296" font-size="11" font-weight="400" text-anchor="end" fill="#c3c2b7">every write</text>
|
||||
<line x1="780" y1="264" x2="786" y2="334" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<line x1="700" y1="198" x2="560" y2="124" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="600" y="140" font-size="11" font-weight="400" text-anchor="start" fill="#c3c2b7">epochs</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,67 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="900" height="420" viewBox="0 0 900 420" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Seaweed Block: block storage for SeaweedFS, in two modes</title>
|
||||
<desc id="d">One blockmaster per cluster issues epochs and leases and decides failover; the sw-block CLI talks to it. Left, checkpointed local block (supported): on a host, the guest writes over NVMe/TCP or iSCSI to blockvolume, which completes write and fsync on its local write-ahead log and extent and checkpoints the changed 4 MiB chunks to SeaweedFS (master, volume servers and filer) in the background; blockmaster reads the HEAD records from the filer. Right, replicated network block (preview): the guest writes to the primary blockvolume, which sends every write to replica blockvolumes on other hosts; SeaweedFS is not used.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#2a78d6"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#52514e"/></marker></defs>
|
||||
<rect width="900" height="420" fill="#fcfcfb"/>
|
||||
<text x="16" y="26" font-size="16" font-weight="600" text-anchor="start" fill="#0b0b0b">Block storage for SeaweedFS, in two modes</text>
|
||||
<text x="16" y="45" font-size="12" font-weight="400" text-anchor="start" fill="#52514e">One control plane; each volume is either checkpointed to SeaweedFS or replicated to other hosts.</text>
|
||||
<rect x="330" y="62" width="240" height="62" rx="8" fill="#e8f0fb" stroke="#2a78d6" stroke-width="1.5"/>
|
||||
<text x="450.0" y="84" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockmaster</text>
|
||||
<text x="450.0" y="102" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">epochs, leases, failover</text>
|
||||
<rect x="640" y="62" width="150" height="62" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="715.0" y="84" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">sw-block</text>
|
||||
<text x="715.0" y="102" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">operator CLI</text>
|
||||
<line x1="640" y1="93" x2="570" y2="93" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="605.0" y="86" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">control API</text>
|
||||
<text x="16" y="156" font-size="13" font-weight="600" text-anchor="start" fill="#0b0b0b">Checkpointed local block (supported)</text>
|
||||
<rect x="16" y="166" width="410" height="120" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="186" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host</text>
|
||||
<rect x="30" y="198" width="110" height="66" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="85.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">Guest</text>
|
||||
<text x="85.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">VM, sandbox</text>
|
||||
<rect x="200" y="198" width="200" height="66" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="300.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="300.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">WAL + extent</text>
|
||||
<text x="300.0" y="253" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">fsync completes here</text>
|
||||
<line x1="140" y1="231" x2="200" y2="231" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="170.0" y="224" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">NVMe/TCP</text>
|
||||
<text x="170" y="248" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">or iSCSI</text>
|
||||
<rect x="120" y="318" width="280" height="76" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="260.0" y="340" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">SeaweedFS</text>
|
||||
<text x="260.0" y="358" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">weed master, volume, filer</text>
|
||||
<text x="260.0" y="373" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">chunks and HEAD records</text>
|
||||
<line x1="300" y1="264" x2="300" y2="318" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="308" y="296" font-size="11" font-weight="400" text-anchor="start" fill="#52514e">changed 4 MiB chunks</text>
|
||||
<line x1="300" y1="198" x2="400" y2="124" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="330" y="166" font-size="11" font-weight="400" text-anchor="end" fill="#52514e">lease</text>
|
||||
<line x1="400" y1="340" x2="470" y2="124" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)"/>
|
||||
<text x="455" y="150" font-size="11" font-weight="400" text-anchor="end" fill="#52514e">HEAD records</text>
|
||||
<text x="478" y="156" font-size="13" font-weight="600" text-anchor="start" fill="#0b0b0b">Replicated network block (preview)</text>
|
||||
<rect x="478" y="166" width="406" height="120" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="490" y="186" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host A</text>
|
||||
<rect x="492" y="198" width="110" height="66" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="547.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">Guest</text>
|
||||
<text x="547.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">VM, container</text>
|
||||
<rect x="662" y="198" width="200" height="66" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="762.0" y="220" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="762.0" y="238" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">primary</text>
|
||||
<text x="762.0" y="253" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">local store</text>
|
||||
<line x1="602" y1="231" x2="662" y2="231" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="632.0" y="224" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">NVMe/TCP</text>
|
||||
<text x="632" y="248" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">or iSCSI</text>
|
||||
<rect x="478" y="306" width="196" height="100" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="490" y="326" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host B</text>
|
||||
<rect x="490" y="334" width="172" height="56" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="576.0" y="356" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="576.0" y="374" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">replica</text>
|
||||
<rect x="688" y="306" width="196" height="100" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="700" y="326" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host C</text>
|
||||
<rect x="700" y="334" width="172" height="56" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="786.0" y="356" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="786.0" y="374" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">replica</text>
|
||||
<line x1="720" y1="264" x2="600" y2="334" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="640" y="296" font-size="11" font-weight="400" text-anchor="end" fill="#52514e">every write</text>
|
||||
<line x1="780" y1="264" x2="786" y2="334" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<line x1="700" y1="198" x2="560" y2="124" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="600" y="140" font-size="11" font-weight="400" text-anchor="start" fill="#52514e">epochs</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,39 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="780" height="330" viewBox="0 0 780 330" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Replicated network block (preview)</title>
|
||||
<desc id="d">The guest writes over NVMe/TCP or iSCSI to the primary blockvolume on its host. The primary sends every write to replica blockvolumes on other hosts; with sync-quorum or sync-all, fsync completes once a quorum or every replica has it. Each replica keeps a local store. blockmaster issues epochs, decides failover and names the new primary. No SeaweedFS is involved and there are no snapshots, restore or moves in this mode yet.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#3987e5"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#c3c2b7"/></marker></defs>
|
||||
<rect width="780" height="330" fill="#1a1a19"/>
|
||||
<text x="16" y="26" font-size="15" font-weight="600" text-anchor="start" fill="#f0efec">Replicated network block (preview)</text>
|
||||
<text x="16" y="44" font-size="12" font-weight="400" text-anchor="start" fill="#c3c2b7">Every write goes to the replicas; fsync waits for a quorum (sync-quorum), all (sync-all) or none (best-effort, the default).</text>
|
||||
<rect x="16" y="62" width="400" height="140" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host A</text>
|
||||
<rect x="36" y="96" width="130" height="70" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="101.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">Guest</text>
|
||||
<text x="101.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">VM or container</text>
|
||||
<rect x="236" y="96" width="160" height="70" rx="8" fill="#1f2a3a" stroke="#3987e5" stroke-width="1.5"/>
|
||||
<text x="316.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="316.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">primary</text>
|
||||
<text x="316.0" y="151" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">local store</text>
|
||||
<line x1="166" y1="131" x2="236" y2="131" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="201.0" y="124" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">NVMe/TCP</text>
|
||||
<text x="201" y="148" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">or iSCSI</text>
|
||||
<rect x="520" y="62" width="240" height="110" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="532" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host B</text>
|
||||
<rect x="540" y="92" width="200" height="62" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="640.0" y="114" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="640.0" y="132" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">replica, local store</text>
|
||||
<rect x="520" y="186" width="240" height="110" rx="10" fill="#20201f" stroke="#5a5955" stroke-dasharray="4 3"/>
|
||||
<text x="532" y="206" font-size="12" font-weight="600" text-anchor="start" fill="#c3c2b7">Host C</text>
|
||||
<rect x="540" y="216" width="200" height="62" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="640.0" y="238" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockvolume</text>
|
||||
<text x="640.0" y="256" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">replica, local store</text>
|
||||
<line x1="396" y1="120" x2="540" y2="123" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="468.0" y="112" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">every write</text>
|
||||
<line x1="396" y1="150" x2="540" y2="245" stroke="#3987e5" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<rect x="36" y="226" width="360" height="70" rx="8" fill="#242423" stroke="#5a5955" stroke-width="1.5"/>
|
||||
<text x="216.0" y="248" font-size="13" font-weight="600" text-anchor="middle" fill="#f0efec">blockmaster</text>
|
||||
<text x="216.0" y="266" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">epochs, failover: names the new primary</text>
|
||||
<text x="216.0" y="281" font-size="11" font-weight="400" text-anchor="middle" fill="#c3c2b7">state on local files</text>
|
||||
<line x1="316" y1="226" x2="316" y2="166" stroke="#c3c2b7" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="330" y="200" font-size="11" font-weight="400" text-anchor="start" fill="#c3c2b7">epochs</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,39 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="780" height="330" viewBox="0 0 780 330" role="img" aria-labelledby="t d" font-family="-apple-system,Segoe UI,Helvetica,Arial,sans-serif">
|
||||
<title id="t">Replicated network block (preview)</title>
|
||||
<desc id="d">The guest writes over NVMe/TCP or iSCSI to the primary blockvolume on its host. The primary sends every write to replica blockvolumes on other hosts; with sync-quorum or sync-all, fsync completes once a quorum or every replica has it. Each replica keeps a local store. blockmaster issues epochs, decides failover and names the new primary. No SeaweedFS is involved and there are no snapshots, restore or moves in this mode yet.</desc>
|
||||
<defs><marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#2a78d6"/></marker><marker id="m" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="#52514e"/></marker></defs>
|
||||
<rect width="780" height="330" fill="#fcfcfb"/>
|
||||
<text x="16" y="26" font-size="15" font-weight="600" text-anchor="start" fill="#0b0b0b">Replicated network block (preview)</text>
|
||||
<text x="16" y="44" font-size="12" font-weight="400" text-anchor="start" fill="#52514e">Every write goes to the replicas; fsync waits for a quorum (sync-quorum), all (sync-all) or none (best-effort, the default).</text>
|
||||
<rect x="16" y="62" width="400" height="140" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="28" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host A</text>
|
||||
<rect x="36" y="96" width="130" height="70" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="101.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">Guest</text>
|
||||
<text x="101.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">VM or container</text>
|
||||
<rect x="236" y="96" width="160" height="70" rx="8" fill="#e8f0fb" stroke="#2a78d6" stroke-width="1.5"/>
|
||||
<text x="316.0" y="118" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="316.0" y="136" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">primary</text>
|
||||
<text x="316.0" y="151" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">local store</text>
|
||||
<line x1="166" y1="131" x2="236" y2="131" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)" marker-start="url(#a)"/>
|
||||
<text x="201.0" y="124" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">NVMe/TCP</text>
|
||||
<text x="201" y="148" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">or iSCSI</text>
|
||||
<rect x="520" y="62" width="240" height="110" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="532" y="82" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host B</text>
|
||||
<rect x="540" y="92" width="200" height="62" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="640.0" y="114" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="640.0" y="132" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">replica, local store</text>
|
||||
<rect x="520" y="186" width="240" height="110" rx="10" fill="#f3f2ef" stroke="#b9b8b3" stroke-dasharray="4 3"/>
|
||||
<text x="532" y="206" font-size="12" font-weight="600" text-anchor="start" fill="#52514e">Host C</text>
|
||||
<rect x="540" y="216" width="200" height="62" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="640.0" y="238" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockvolume</text>
|
||||
<text x="640.0" y="256" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">replica, local store</text>
|
||||
<line x1="396" y1="120" x2="540" y2="123" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<text x="468.0" y="112" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">every write</text>
|
||||
<line x1="396" y1="150" x2="540" y2="245" stroke="#2a78d6" stroke-width="1.6" marker-end="url(#a)"/>
|
||||
<rect x="36" y="226" width="360" height="70" rx="8" fill="#ffffff" stroke="#b9b8b3" stroke-width="1.5"/>
|
||||
<text x="216.0" y="248" font-size="13" font-weight="600" text-anchor="middle" fill="#0b0b0b">blockmaster</text>
|
||||
<text x="216.0" y="266" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">epochs, failover: names the new primary</text>
|
||||
<text x="216.0" y="281" font-size="11" font-weight="400" text-anchor="middle" fill="#52514e">state on local files</text>
|
||||
<line x1="316" y1="226" x2="316" y2="166" stroke="#52514e" stroke-width="1.6" stroke-dasharray="5 4" marker-end="url(#m)" marker-start="url(#m)"/>
|
||||
<text x="330" y="200" font-size="11" font-weight="400" text-anchor="start" fill="#52514e">epochs</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -1,110 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1080" height="640" viewBox="0 0 1080 640" role="img" aria-labelledby="title description">
|
||||
<title id="title">Seaweed Block: local-speed execution, portable workspace state</title>
|
||||
<desc id="description">Three ways to give an agent VM a disk. Local disk: all I/O stays on the host, so it is 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. In SeaweedFS: incremental checkpoints of changed 4 MiB chunks, named snapshots with lazy restore, and planned moves fenced by epochs and leases.</desc>
|
||||
<defs>
|
||||
<marker id="arrow" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M 0 0 L 10 5 L 0 10 z" fill="#75928e"/>
|
||||
</marker>
|
||||
<marker id="arrowTeal" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M 0 0 L 10 5 L 0 10 z" fill="#187b67"/>
|
||||
</marker>
|
||||
<marker id="arrowBlue" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2676a3"/>
|
||||
</marker>
|
||||
<!-- a disk: 56 wide, 48 tall, drawn at its top-left -->
|
||||
<g id="disk" stroke-width="2">
|
||||
<path d="M0 8v32c0 4.4 12.5 8 28 8s28-3.6 28-8V8"/>
|
||||
<path d="M0 24c0 4.4 12.5 8 28 8s28-3.6 28-8" fill="none"/>
|
||||
<ellipse cx="28" cy="8" rx="28" ry="8"/>
|
||||
</g>
|
||||
<path id="check" d="M0 7l5 5 10-11" fill="none" stroke="#187b67" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="cross" d="M1 1l11 11M12 1L1 12" fill="none" stroke="#b45309" stroke-width="2.6" stroke-linecap="round"/>
|
||||
</defs>
|
||||
|
||||
<rect width="1080" height="640" rx="20" fill="#f5f9f8"/>
|
||||
<g font-family="Arial, Helvetica, sans-serif">
|
||||
<text x="40" y="43" fill="#0f766e" font-size="15" font-weight="700" letter-spacing="2">SEAWEED BLOCK</text>
|
||||
<text x="40" y="86" fill="#163832" font-size="32" font-weight="700">Local-speed execution. Portable workspace state.</text>
|
||||
<text x="40" y="118" fill="#48635e" font-size="18">Three ways to give an agent VM its disk</text>
|
||||
|
||||
<!-- 1. Local disk: fast, but the state stays on one host -->
|
||||
<g>
|
||||
<rect x="40" y="140" width="320" height="300" rx="14" fill="#fff" stroke="#cbded8"/>
|
||||
<text x="62" y="176" fill="#163832" font-size="22" font-weight="700">Local disk</text>
|
||||
<rect x="60" y="192" width="280" height="92" rx="10" fill="#f5f9f8" stroke="#cbded8" stroke-dasharray="5 4"/>
|
||||
<text x="72" y="208" fill="#75928e" font-size="11" font-weight="700" letter-spacing="1.5">HOST</text>
|
||||
<rect x="78" y="216" width="84" height="54" rx="8" fill="#eef6f3" stroke="#187b67" stroke-width="1.8"/>
|
||||
<text x="120" y="238" text-anchor="middle" fill="#48635e" font-size="12">agent</text>
|
||||
<text x="120" y="257" text-anchor="middle" fill="#163832" font-size="17" font-weight="700">VM</text>
|
||||
<path d="M168 243H246" stroke="#75928e" stroke-width="2.2" marker-end="url(#arrow)"/>
|
||||
<text x="207" y="236" text-anchor="middle" fill="#48635e" font-size="13">all I/O</text>
|
||||
<use href="#disk" x="262" y="219" fill="#fff" stroke="#48635e"/>
|
||||
<rect x="80" y="318" width="240" height="36" rx="18" fill="#fff" stroke="#cbded8" stroke-dasharray="5 4"/>
|
||||
<text x="200" y="341" text-anchor="middle" fill="#75928e" font-size="15">nothing leaves the host</text>
|
||||
<use href="#check" x="62" y="381"/>
|
||||
<text x="88" y="393" fill="#305c50" font-size="17">Local speed</text>
|
||||
<use href="#cross" x="63" y="410"/>
|
||||
<text x="88" y="421" fill="#305c50" font-size="17">State tied to one host</text>
|
||||
</g>
|
||||
|
||||
<!-- 2. Network block storage: state off the host, network on every I/O -->
|
||||
<g>
|
||||
<rect x="380" y="140" width="320" height="300" rx="14" fill="#fff" stroke="#cbded8"/>
|
||||
<text x="402" y="176" fill="#163832" font-size="22" font-weight="700">Network block storage</text>
|
||||
<rect x="400" y="192" width="280" height="92" rx="10" fill="#f5f9f8" stroke="#cbded8" stroke-dasharray="5 4"/>
|
||||
<text x="412" y="208" fill="#75928e" font-size="11" font-weight="700" letter-spacing="1.5">HOST</text>
|
||||
<rect x="498" y="216" width="84" height="54" rx="8" fill="#eef6f3" stroke="#187b67" stroke-width="1.8"/>
|
||||
<text x="540" y="238" text-anchor="middle" fill="#48635e" font-size="12">agent</text>
|
||||
<text x="540" y="257" text-anchor="middle" fill="#163832" font-size="17" font-weight="700">VM</text>
|
||||
<path d="M540 272V312" stroke="#2676a3" stroke-width="2.6" marker-end="url(#arrowBlue)"/>
|
||||
<text x="552" y="295" fill="#2676a3" font-size="13">I/O, typically</text>
|
||||
<text x="552" y="310" fill="#2676a3" font-size="13">over the network</text>
|
||||
<rect x="440" y="318" width="200" height="36" rx="18" fill="#fff" stroke="#2676a3" stroke-width="1.5"/>
|
||||
<text x="540" y="341" text-anchor="middle" fill="#163832" font-size="15" font-weight="700">remote volume</text>
|
||||
<use href="#cross" x="403" y="382"/>
|
||||
<text x="428" y="393" fill="#305c50" font-size="17">Network in the I/O path</text>
|
||||
<use href="#check" x="402" y="409"/>
|
||||
<text x="428" y="421" fill="#305c50" font-size="17">State lives off the host</text>
|
||||
</g>
|
||||
|
||||
<!-- 3. Seaweed Block: local execution, background persistence -->
|
||||
<g>
|
||||
<rect x="720" y="140" width="320" height="300" rx="14" fill="#e4f5ee" stroke="#187b67" stroke-width="1.5"/>
|
||||
<text x="742" y="176" fill="#163832" font-size="22" font-weight="700">Seaweed Block</text>
|
||||
<rect x="740" y="192" width="280" height="92" rx="10" fill="#fff" stroke="#9cc8b9" stroke-dasharray="5 4"/>
|
||||
<text x="752" y="208" fill="#75928e" font-size="11" font-weight="700" letter-spacing="1.5">HOST</text>
|
||||
<rect x="758" y="216" width="84" height="54" rx="8" fill="#eef6f3" stroke="#187b67" stroke-width="1.8"/>
|
||||
<text x="800" y="238" text-anchor="middle" fill="#48635e" font-size="12">agent</text>
|
||||
<text x="800" y="257" text-anchor="middle" fill="#163832" font-size="17" font-weight="700">VM</text>
|
||||
<path d="M848 243H926" stroke="#187b67" stroke-width="2.2" marker-end="url(#arrowTeal)"/>
|
||||
<text x="887" y="236" text-anchor="middle" fill="#266354" font-size="13">local I/O</text>
|
||||
<use href="#disk" x="942" y="219" fill="#fff" stroke="#187b67"/>
|
||||
<path d="M970 270V312" stroke="#187b67" stroke-width="2.2" stroke-dasharray="6 4" marker-end="url(#arrowTeal)"/>
|
||||
<text x="960" y="303" text-anchor="end" fill="#266354" font-size="13">changed chunks, in the background</text>
|
||||
<rect x="780" y="318" width="236" height="36" rx="18" fill="#163e35"/>
|
||||
<text x="898" y="341" text-anchor="middle" fill="#fff" font-size="15" font-weight="700">your SeaweedFS</text>
|
||||
<use href="#check" x="742" y="372"/>
|
||||
<text x="768" y="384" fill="#163832" font-size="17" font-weight="700">Near-local speed</text>
|
||||
<use href="#check" x="742" y="398"/>
|
||||
<text x="768" y="410" fill="#163832" font-size="17" font-weight="700">State outlives the host,</text>
|
||||
<text x="768" y="430" fill="#163832" font-size="15">to its last checkpoint</text>
|
||||
</g>
|
||||
|
||||
<!-- what lands in SeaweedFS -->
|
||||
<path d="M880 440v26" stroke="#75928e" stroke-width="2" marker-end="url(#arrow)"/>
|
||||
<rect x="40" y="470" width="1000" height="140" rx="16" fill="#163e35"/>
|
||||
<text x="540" y="504" text-anchor="middle" fill="#fff" font-size="22" font-weight="700">In your SeaweedFS</text>
|
||||
<g fill="#fff" font-size="19" font-weight="700" text-anchor="middle">
|
||||
<text x="213" y="542">Incremental checkpoints</text>
|
||||
<text x="540" y="542">Named snapshots</text>
|
||||
<text x="867" y="542">Planned moves</text>
|
||||
</g>
|
||||
<path d="M376 523v34 M704 523v34" stroke="#497266"/>
|
||||
<g fill="#cfe4dc" font-size="16" text-anchor="middle">
|
||||
<text x="213" y="566">only the changed 4 MiB chunks</text>
|
||||
<text x="540" y="566">lazy restore into a new volume</text>
|
||||
<text x="867" y="566">fenced by epochs and leases</text>
|
||||
</g>
|
||||
<text x="540" y="595" text-anchor="middle" fill="#9cc8b9" font-size="14">A lost host loses only the writes since its last checkpoint.</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 8.4 KiB |
@@ -415,7 +415,6 @@ Not done yet:
|
||||
- **The control plane (blockmaster)** authenticates with mutual TLS when it is configured (required off loopback): client certificates verified against `--tls-client-ca`, pinned roles from `--role-file` (viewer, operator, admin, node), and an append-only `--audit-log` ([operator guide](../operator-guide.md#authenticate-the-control-api)).
|
||||
- **No authentication** on the status and chunk control endpoints (loopback-only by default), the replication channel or the filer client. Anyone who can reach the filer can read or change any volume's entries ([core known issues](block-design.md#24-known-issues-and-work-in-progress)).
|
||||
- No encryption of chunks in SeaweedFS or of traffic to it.
|
||||
- The NVMe/TCP H2CData bound check can wrap and panic the process on one malformed PDU; it is reachable from loopback ([core known issues](block-design.md#24-known-issues-and-work-in-progress)).
|
||||
- ublk at high density: unprivileged per-volume servers need a privileged control broker, which is not done.
|
||||
|
||||
## 9. Invariants
|
||||
|
||||
@@ -233,9 +233,55 @@ and deadline causes with zero census calls.
|
||||
|
||||
## Local certificate dates during rotation
|
||||
|
||||
CA bundle loading follows `x509.CertPool.AppendCertsFromPEM`: skip blocks
|
||||
that are not header-free, parseable certificates and retain usable roots.
|
||||
An unusable alternative does not reject the entire bundle. If no certificate
|
||||
loads, credential construction refuses locally with exit 78.
|
||||
|
||||
CA bundles may retain unused expired or not-yet-valid certificates when the
|
||||
bundle also contains a certificate valid at the current time. Local key-pair
|
||||
loading checks the identity leaf's dates; unused supplied chain alternatives
|
||||
do not block it. TLS still validates the chain it selects. A CA bundle with
|
||||
no currently valid certificate, or an expired local identity leaf, is a local
|
||||
configuration refusal (exit 78).
|
||||
|
||||
## Unusable chunk conflict answers
|
||||
|
||||
At the snapshot-admission and non-plain-detach `chunkPostUntil` boundary,
|
||||
an initial HTTP 409 does not establish non-admission. Its typed
|
||||
body can describe an existing operation, work already performed, or a refusal.
|
||||
If the body cannot be read or validated, the boundary records
|
||||
`PossiblyAdmitted` with the existing connection-failure policy:
|
||||
`outcome_unknown`, exit 3. A snapshot is recovered with its original request
|
||||
ID and unchanged parameters, including its original absolute expiry, or an
|
||||
already obtained handle. Non-plain detach supplies no ID or handle: keep the
|
||||
writer stopped and inspect the holder's HEAD/logs for a confirmed seal or
|
||||
abort; insufficient evidence requires investigation. The separate cut and
|
||||
plain-detach observer does not use this classification path. A supplied request ID is
|
||||
retained in the diagnostic and in any bounded same-request retry.
|
||||
Complete typed answers retain their code and retry flag.
|
||||
|
||||
`TestChunkConflictStatusRowsHaveOutcomeClasses` inventories the direct and
|
||||
delegated 409 returns in `chunkErrorCode`. Each direct code expression needs
|
||||
an explicit outcome class; dynamic stored and catalog answers require their
|
||||
typed body. The negative control rejects an unclassified new 409 code. These
|
||||
classes never authorize a non-admission inference from status alone.
|
||||
|
||||
## Unlisted HTTP response statuses
|
||||
|
||||
A failed HTTP response whose status has no registry row does not prove the
|
||||
origin refused the operation. The shared HTTP boundary retains the received
|
||||
status and cause and selects the existing possibly-admitted unknown policy.
|
||||
Snapshot/non-plain-detach POST and failover answers are `outcome_unknown`,
|
||||
retryable, exit 3. Recovery depends on the operation:
|
||||
|
||||
- Snapshot: recover the original request with its replay key and unchanged
|
||||
parameters, or poll an already obtained handle.
|
||||
- Non-plain detach has no replay key or handle: keep the writer stopped and
|
||||
inspect the original holder's HEAD/logs for a confirmed seal or abort.
|
||||
Preserve diagnostics and investigate if the outcome remains unproven.
|
||||
- Failover: read the current authority line before another move.
|
||||
|
||||
Documented contract-specific legacy exits remain in the single exit projection.
|
||||
Listed statuses retain their existing policies, including 401/403 auth
|
||||
refusals and 501 unsupported. A typed domain reply remains authoritative.
|
||||
@@ -374,7 +374,6 @@ The reason is an unhealthy, not-eligible fact; blockmaster does not promote or s
|
||||
|
||||
These are tracked for fixes. Most were raised by an independent review of this repository. Gaps specific to one product line are in that line's document: [agent workspace known gaps](agent-workspace-design.md#14-known-gaps) and [Kubernetes known gaps](kubernetes-block-design.md#12-known-gaps).
|
||||
|
||||
- **NVMe/TCP H2CData offset overflow.** The `DATAO + length` bound check is done in 32-bit arithmetic and can wrap, so one malformed PDU can panic the process (`core/frontend/nvme/session.go` `recvH2CData`). Reachable from loopback by default. **Planned fix:** 64-bit arithmetic, offset and R2T consistency checks, and bounds on wire-supplied allocations.
|
||||
- **Process notes in source comments.** #162 removed reviewer names and decision timestamps from code comments. A few comments still cite internal review labels (for example "ruling F1") where a neutral design rationale would be clearer.
|
||||
- **fsync latency.** #173 removed the idle group-commit wait: a lone `Sync` no longer waits out the collection delay, and guest `fsync` fell from about 5.5 ms to a median of 3.23 ms against 2.74 ms local (ublk; see [workspace measurements](../workspace-measurements.md)). Remaining lead: the checkpoint superblock `fsync` runs under the exclusive store lock, stalling reads and writes each flush cycle.
|
||||
- **Forged records in user data.** WAL records are not bound to a store incarnation or lap, so bytes inside user data that happen to decode as a valid record could be replayed by the defensive scan. **Planned:** an incarnation nonce and lap in the next format, plus a clean-shutdown marker in the meantime.
|
||||
|
||||
@@ -390,7 +390,9 @@ One host at a time holds a workspace volume's HEAD in SeaweedFS. The sequence di
|
||||
stateDiagram-v2
|
||||
state "Lease guard (host)" as G {
|
||||
[*] --> NoLease
|
||||
NoLease --> Valid: renewal reply for this volume, replica and epoch
|
||||
NoLease --> Valid: first heartbeat answered, then a renewal reply for this volume, replica and epoch
|
||||
NoLease --> NoLease: first heartbeat not yet answered (past one lease validity: wait reason first_heartbeat_unanswered)
|
||||
NoLease --> Fenced: invalid reply, revoking, or shutdown
|
||||
Valid --> Valid: renewal before the local deadline
|
||||
Valid --> StopPending: detach started (renew at once)
|
||||
StopPending --> StopPending: renewal, then sleep at most 250 ms
|
||||
@@ -417,8 +419,8 @@ stateDiagram-v2
|
||||
|
||||
| From | To | Guard | Enforced in | Protects |
|
||||
|---|---|---|---|---|
|
||||
| NoLease, Valid | Valid | the reply names this `{volume, replica, epoch}`, its validity is positive and at most 30 s, and it arrives before the old deadline; the new deadline is anchored to the request start | `core/host/volume/workspace_lease.go` `Refresh` | `INV-WS-LEASE-001`, `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001` |
|
||||
| NoLease, Valid, StopPending | Fenced | the local deadline passes (checked on every projection read), the reply is invalid, the lease is revoking, or synchronous host shutdown fences through the guard; first cause is kept and a fenced guard never reopens | `core/host/volume/workspace_lease.go` `permits`, `Refresh`, `fenceLocked`; `core/host/volume/workspace_runtime.go` `FenceWorkspaceLease` | `INV-WS-LEASE-001` |
|
||||
| NoLease, Valid | Valid | from NoLease, a renewal is sent only after this process's first heartbeat was answered; the reply names this `{volume, replica, epoch}`, its validity is positive and at most 30 s, and it arrives before the old deadline; the new deadline is anchored to the request start | `core/host/volume/workspace_runtime.go` `runWorkspaceLease`, `firstHeartbeatAnswered`; `core/host/volume/workspace_lease.go` `Refresh` | `INV-WS-LEASE-001`, `INV-WS-FORCED-MOVE-001`, `INV-WS-FORCED-MOVE-HALF-SKEW-001` |
|
||||
| NoLease, Valid, StopPending | Fenced | the local deadline passes (checked on every projection read), the reply is invalid, the lease is revoking, or synchronous host shutdown fences through the guard. An unanswered first heartbeat is not a cause: NoLease waits without a guard (gated, no renewal, no serving), named `first_heartbeat_unanswered` in /status past `firstHeartbeatWait` (one lease validity, 30 s) while the master replies (a master giving no reply is `unreachable`), with the chunk startup wait's own bound as Until; the lease runtime adds no bound, fence or exit, and leaves for Valid only through a renewal after the answer; first cause is kept and a fenced guard never reopens | `core/host/volume/workspace_lease.go` `permits`, `Refresh`, `fenceLocked`; `core/host/volume/workspace_runtime.go` `FenceWorkspaceLease`, `runWorkspaceLease` | `INV-WS-LEASE-001`, `INV-FMT-FINALIZE-001` |
|
||||
| Valid | StopPending | a chunk detach of this volume starts (before its drain); the guard renews at once. Scheduling only: StopPending admits, fences and ACKs exactly as Valid | `core/frontend/durable/provider_chunk.go` `DetachVolume`; `core/host/volume/workspace_runtime.go` `WorkspaceStopPending`; `core/host/volume/workspace_lease.go` `StopPending` | `INV-WS-STOP-PENDING-001` |
|
||||
| StopPending | StopPending | each sleep after a completed renewal is at most `stopPendingPoll` (250 ms); a renewal already in flight is not interrupted | `core/host/volume/workspace_lease.go` `renewDelay`, `Run` | `INV-WS-STOP-PENDING-001` |
|
||||
| StopPending | Valid | only the latest detach attempt, provably not applied, with serving resumed; an applied, fenced or unknown outcome, or an older attempt's resume, leaves StopPending | `core/frontend/durable/provider_chunk.go` `resumeAfterDetach`; `core/host/volume/workspace_runtime.go` `WorkspaceStopResumed`; `core/host/volume/workspace_lease.go` `ClearStopPending` | `INV-WS-STOP-PENDING-001` |
|
||||
@@ -804,6 +806,25 @@ Name-only snapshot deletion is a legacy-format transition only: it refuses a v1.
|
||||
| Terminal retained | Retired | at least this handle's Wc since its end; next admission or poll scans bounded table | retireManualCutsLocked | INV-CUT-HANDLE-LIFETIME-001 |
|
||||
|
||||
|
||||
### M-format. Cluster format finalize
|
||||
|
||||
```mermaid
|
||||
stateDiagram-v2
|
||||
Level0 --> Finalizing: check possible live leases and set intent under grant locks
|
||||
Finalizing --> Level1: durable envelope succeeds, then publish level 1
|
||||
Finalizing --> Level0: proven pre-rename failure, then clear intent
|
||||
Finalizing --> Exited74: uncertain post-rename failure, keep intent and fail-stop
|
||||
```
|
||||
|
||||
| From | To | Guard / action | Enforced in | Invariant |
|
||||
|---|---|---|---|---|
|
||||
| Level 0 | Finalizing | Preserve the existing known-old work check. Under Publisher mu then leaseMu, exclude unserved lines, clean ACKed releases and proven-ended leases; require the latest level-1 report received for each remaining volume (a delayed report can stand in for a newer process; the operations manual's finalize rule covers that) and set the admission intent. Report changes invalidate captured proofs. | `core/authority/format_finalize.go` `BeginFormatFinalize`; `core/host/master/format_gate.go` `FinalizeFormat` | `INV-FMT-FINALIZE-001` |
|
||||
| Finalizing | Finalizing | Move and publication are placement: refuse only known-old targets. First serving deadlines, live renewals and regrants require the latest level-1 report received for the volume during intent and at level 1 (a delayed report is covered by the operations manual's finalize rule). A stored move lease alone permits no serving. Capable renewals stay memory-only; no grant lock spans the durable write. | `core/host/master/workspace_binding.go` `admitWorkspacePublication`; `core/authority/workspace_lease_view.go` `firstWorkspaceGrant`, `regrantWorkspaceLease` | `INV-FMT-FINALIZE-001`, `INV-WS-RENEW-NONBLOCKING-001` |
|
||||
| Finalizing | Level 1 / Level 0 | On durable success publish level 1 under the grant locks; on a proven pre-rename failure clear the intent; an uncertain post-rename persistence failure retains the intent and fail-stops for recovery. The in-memory intent is not a persisted format or a new authority fact. | `core/authority/workspace_lease_v100.go` `FinalizeFormatLevel`; `core/authority/format_finalize.go` `CancelFormatFinalize` | `INV-FMT-LEVEL-001`, `INV-FMT-FINALIZE-001` |
|
||||
|
||||
FormatGate r12 (checked outside the repository) models this interval as Begin, durable raise and Abort, refining r11's atomic `Finalize`.
|
||||
The intent closes level-0 serving admission while the store write runs outside the grant locks. It neither grants authority nor raises a holder's effective level.
|
||||
|
||||
## Part B. Invariant ledger
|
||||
|
||||
|
||||
@@ -1052,8 +1073,8 @@ Notes:
|
||||
| `INV-WS-RESTART-GRACE-001` | At format level 1, a renewal writes nothing durable. A forced move, an expired re-grant and a no-live-lease proof wait for this process's deadline plus skew: its latest grant, or after a restart the restart floor (restart + TTL); no lease value an earlier process wrote is read. | M2 Granted → Granted; Expired → Moved (forced); Expired → Granted; any → DeleteReserved | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `regrantWorkspaceLease`, `newWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`, `AckWorkspaceRevocation`; `core/authority/authority.go` `reloadFromStore` (the restart floor) | `TestRenewalWritesNothingDurable`, `TestForcedAdmissionIgnoresAPersistedHorizon` (`core/authority/workspace_restart_grace_test.go`); `TestWorkspaceLeaseGuardServesThroughAStalledStore` (`core/host/master/workspace_lease_horizon_test.go`); `TestAfterARestartADifferentHolderIsRefusedUntilTheRestartFloor`, `TestAfterARestartTheSameLiveHolderRenewsAtOnce` (`core/authority/workspace_restart_barrier_test.go`) | `LeaseRestart` `OneServer` (grace design) | ACTIVE |
|
||||
| `INV-WS-AUTH-RECORD-V2-001` | The format finalize writes the store's attestation file as format 2 (`INV-FMT-LEVEL-001`), on which a v1.0.x master refuses its whole start; from then on its authority records are envelope version 2 (a v1.0.x master would skip them); before it, both are v1.0's. It reads both forms of each. | M2 every workspace write; master start | `core/host/master/store_attestation.go` `ensureEnvelope`, `decodeStoreAttestations`; `core/host/master/host.go` `New`; `core/authority/authority_store.go` `storeEnvelopeVersion`, `encodeEnvelope`, `decodeEnvelope` | `TestAV100MasterRefusesTheAttestationEnvelope`, `TestAttestationsWriteTheV100FileUntilTheFinalize`, `TestAttestationsReadTheV100File` (`core/host/master/golden_v100_test.go`); `TestARecordWrittenNowFailsTheV100Decoder` (`core/authority/workspace_restart_grace_test.go`); `TestAuthorityStoreWritesTheV100Files`, `TestAuthorityStoreReadsTheV100Files` (`core/authority/golden_v100_test.go`) | — | ACTIVE |
|
||||
| `INV-FMT-LEVEL-001` | The cluster's format level is the attestation file's form: v1.0.x's bare map is level 0, the envelope (format 2, format_level 1) level 1. It only rises: the finalize is its only writer, and an envelope below level 1 is refused at start. | FormatGate Finalize (level 0 → 1) | `core/host/master/store_attestation.go` `decodeStoreAttestations`, `finalize`, `persist`, `level`; `core/host/master/host.go` `New` | `TestFinalizeFormatBlocksOnAnOldHolderAndIsDurable`, `TestAnAttestationEnvelopeBelowLevel1IsRefused` (`core/host/master/format_gate_test.go`); `TestAttestationsWriteTheV100FileUntilTheFinalize`, `TestAV100MasterRefusesTheAttestationEnvelope` (`core/host/master/golden_v100_test.go`) | `FormatGate` `OneWay` (mutation `level_lowered`) | ACTIVE |
|
||||
| `INV-FMT-FINALIZE-001` | The finalize is refused, naming them, only while a fresh report of a process holding a volume reads below 1; hosts with no or a stale report are listed, not blocking. Else it writes the envelope durably, then switches the publisher under both its locks, then answers; a failed write leaves level 0. | FormatGate Finalize | `core/host/master/format_gate.go` `FinalizeFormat`, `finalizeCheck`; `core/authority/workspace_lease_v100.go` `FinalizeFormatLevel` | `TestFinalizeFormatBlocksOnAnOldHolderAndIsDurable`, `TestFinalizeFormatListsTheHostsItCannotConfirm`, `TestAFailedFinalizeWriteLeavesLevel0`, `TestAHolderRestartedOnAnOldBinaryIsNotReissuedItsLine` (`core/host/master/format_gate_test.go`); `TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted` (`core/host/volume/line_incarnation_test.go`); `TestClusterFinalizeFormat` (`cmd/sw-block/cluster_format_test.go`); `TestClusterFinalizeFormatTypedAnswer` (`cmd/sw-block/cluster_format_json_test.go`) | `FormatGate` `FinalizeKeepsHosts` (mutation `finalize_ignores_reports`); `FormatGateMaster` (mutations `old_starts_after_finalize`, `finalize_not_atomic`) | ACTIVE |
|
||||
| `INV-FMT-ELIGIBLE-001` | At level L no new work goes to a server known to read below L: no placement or move target (binary_too_old). An unreported server is placeable; no line is granted to a holder process before its own report. Heartbeats are recorded, never refused. Placed work stays. Every assignment carries L. | FormatGate Assign (placement, move, failover) | `core/host/master/format_gate.go` `formatEligible`, `formatTooOld`, `placementTooOld`, `grantTooOld`; `core/host/master/journal_isolation.go` `newWorkRefused`, `reconcilePlacements`; `core/host/master/workspace_binding.go` `PlaceWorkspace`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/services.go` `ReportHeartbeat`, `assignmentFact` | `TestFormatGateRecordsAnOldBinarysHeartbeatAtLevel1`, `TestFormatGateRefusesPlacementAndMoveOntoAnOldHost`, `TestFormatGateProductLoopPlacesOnlyOnHostsThatReadTheLevel`, `TestAssignmentFactCarriesTheFormatLevel` (`core/host/master/format_gate_test.go`) | `FormatGate` `NoStrand` (mutation `place_ignores_reads_level`) | ACTIVE |
|
||||
| `INV-FMT-FINALIZE-001` | Finalize checks possibly-live leases and sets a memory intent under grant locks. First grants, renewals and regrants require the latest level-1 report during intent and at level 1. Move/publication is Place. I/O holds no grant lock; pre-rename failure clears intent; uncertain persistence fail-stops. | FormatGate Finalize | `core/host/master/format_gate.go` `FinalizeFormat`, `finalizeCheck`; `core/authority/workspace_lease_v100.go` `FinalizeFormatLevel`; `core/authority/format_finalize.go` `BeginFormatFinalize`, `CancelFormatFinalize` | `TestFinalizeFormatBlocksOnAnOldHolderAndIsDurable`, `TestFinalizeFormatListsTheHostsItCannotConfirm`, `TestAFailedFinalizeWriteLeavesLevel0`, `TestAHolderRestartedOnAnOldBinaryIsNotReissuedItsLine` (`core/host/master/format_gate_test.go`); `TestHost_ApplyFact_LineIssuedForAnotherProcessIsNotAdopted` (`core/host/volume/line_incarnation_test.go`); `TestClusterFinalizeFormat` (`cmd/sw-block/cluster_format_test.go`); `TestClusterFinalizeFormatTypedAnswer` (`cmd/sw-block/cluster_format_json_test.go`); `TestFinalizeRequiresTheGrantedHoldersReadReport`, `TestFinalizeSerializesTheLevelZeroPublicationBoundary` (`core/host/master/format_finalize_serving_test.go`); `TestFormatFinalizeIntentRequiresRegrantReport`, `TestFormatFinalizeCountsOnlyPossiblyLiveCurrentLeases`, `TestFormatFinalizeIntentDoesNotSurviveProcessExit`, `TestFormatFinalizeFailedCheckLeavesLevelZeroGrantsOpen`, `TestFormatFinalizeLiveRenewalChecksCurrentProcess`, `TestFormatFinalizeDeadlineProofSurvivesIntentCompletion` (`core/authority/format_finalize_test.go`); `TestFormatMoveRecordCannotServeBeforeReportedRenewal` (`core/host/master/format_place_lease_test.go`); `TestFormatFinalizeUncertainWriteFailStops` (`core/host/master/format_finalize_failure_test.go`); `TestQueuedFinalizeDoesNotHoldWorkspaceAdmission` (`core/host/master/format_finalize_review_test.go`); `TestAV100HeartbeatSupersedesTheCachedReportSoItsRenewalsAreRefused` (`core/host/master/format_identity_v100_test.go`); `TestAHolderRenewsOnlyAfterItsFirstHeartbeatWithItsIncarnation`, `TestAHolderWhoseHeartbeatIsNeverAnsweredWaitsUnservedWithATypedReason`, `TestAHolderWhoseFirstHeartbeatsAreRefusedPastTheBoundServesOnceAnswered`, `TestAHolderWhoseAssignmentMovedWhileItsFirstHeartbeatsWereRefusedNeverServes`, `TestAnAnsweredFirstHeartbeatEndsTheUnansweredWaitReason`, `TestTheUnansweredFirstHeartbeatReasonNeedsAReplyingMaster` (`core/host/volume/workspace_first_heartbeat_test.go`) | FormatGate r12 FinalizeBegin, FinalizeCommit, FinalizeAbort, Grant, Renew / ServersReported, GrantReport, NoStrand; serve_across_restart and grant_unchecked_in_intent are refused; move/publication is Place, and only a checked renewal reply grants serving | ACTIVE |
|
||||
| `INV-FMT-ELIGIBLE-001` | At level L no new work goes to a server known to read below L: no placement or move target (binary_too_old). An unreported target may be placed or moved; its serving deadline requires its own report. Heartbeats are recorded, never refused. Placed work stays. Every assignment carries L. | FormatGate Assign (placement, move, failover) | `core/host/master/format_gate.go` `formatEligible`, `formatTooOld`, `placementTooOld`; `core/host/master/journal_isolation.go` `newWorkRefused`, `reconcilePlacements`; `core/host/master/workspace_binding.go` `PlaceWorkspace`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/services.go` `ReportHeartbeat`, `assignmentFact` | `TestFormatGateRecordsAnOldBinarysHeartbeatAtLevel1`, `TestFormatGateRefusesPlacementAndMoveOntoAnOldHost`, `TestFormatGateProductLoopPlacesOnlyOnHostsThatReadTheLevel`, `TestAssignmentFactCarriesTheFormatLevel` (`core/host/master/format_gate_test.go`); `TestFormatRefreshUsesItsOwnReportDespiteAnOldSibling`, `TestFormatReassignUsesItsOwnReportDespiteAnOldSibling`, `TestFormatPlacedLineKeepsItsReportWait` (`core/host/master/format_finalize_review_test.go`); `TestAMovedLineWaitsOnItsNewHolderOnly` (`core/host/master/format_level_new_cluster_test.go`) | `FormatGate` `NoStrand` (mutation `place_ignores_reads_level`) | ACTIVE |
|
||||
| `INV-FMT-LEVEL0-V100-001` | At format level 0 the master writes as v1.0: grants clamp to the persisted horizon, an extender keeps it current, forced moves and re-grants wait for the later of horizon and deadline plus skew, records are version 1. Every grant raises the deadline at both levels. | M2 Granted → Granted; Expired → Moved (forced); Expired → Granted (level 0) | `core/authority/workspace_lease_v100.go` `renewV100Locked`, `extendWorkspaceLease`, `forcedMoveBarrierV100Locked`, `ackValidityLocked`, `envelopeVersionLocked`; `core/authority/workspace_lease_view.go` `RenewWorkspaceLease` | `TestALevel0RenewalKeepsTheHorizonCurrent`, `TestALevel0GrantIsClampedToTheHorizon`, `TestTheForcedBarrierFollowsTheFormatLevel`, `TestRecordEnvelopeVersionFollowsTheFormatLevel` (`core/authority/workspace_format_level_test.go`) | `FormatGateMaster` `OneServer`, `GraceOnlyFinal` (mutations `level0_no_horizon`, `old_starts_after_finalize`) | ACTIVE |
|
||||
| `INV-FMT-RETIRE-001` | A host retire, the node registry's only writer after start, is refused, naming the volumes, while the host holds a placement or a live line, and unless confirm repeats the id. A retired id is unregistered; if the host returns it registers again at its reported level. | FormatGate Retire | `core/host/master/format_gate.go` `RetireHost`; `core/host/master/journal_isolation.go` `volumesServedBy` | `TestRetireHostRefusesAHostThatHoldsWork` (`core/host/master/format_gate_test.go`); `TestACleanMoveReleasesTheTopologyHome`, `TestTheTopologyHomeHoldsTheVolumeBeforeAMove`, `TestTheTopologyHomeAloneHoldsTheVolumeBeforeAMove` (`core/host/master/served_topology_move_test.go`); `TestClusterRetireHost` (`cmd/sw-block/cluster_format_test.go`); `TestNodeRegistryIsWrittenOnlyAtStartup` (`cmd/blockmaster/node_registry_guard_test.go`) | `FormatGate` r2 `OneServer` (mutation `retire_holding_host`) | ACTIVE |
|
||||
| `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE |
|
||||
@@ -1305,7 +1326,12 @@ Notes:
|
||||
| `INV-SNAPSHOT-REPLAY-FLAG-001` | A successful same-ID snapshot admission reports replayed true without changing HEAD or its retained outcome. First creation reports false; the flag decorates only the response. | M9 snapshot outcome projection | `core/host/volume/snapshot_operation.go`, `chunk_control.go`; `cmd/sw-block/snapshot_operation.go` | `TestSnapshotReplayFlagDoesNotRewriteOutcome`, `TestSnapshotCLIUsesReplayedAdmissionAnswer` | SnapOps.Poll; SnapOps.Start (no transition change) | STUB |
|
||||
| `INV-CLI-UNSENT-REQUEST-001` | An observed operation's initial typed dial failure sends no admission and is remote_unavailable (75) through the shared classifier. A lost answer after send, or a dial failure while polling an admitted handle, retains outcome_unknown. | CLI pre-admission error projection; no server transition | `cmd/sw-block/cut_progress_poll.go` `chunkObserveHandle`; `chunkTransportFailure`, `chunkFail` | `TestPlainDetachRefusedDialIsRemoteUnavailable`, `TestPlainDetachLostAnswerAfterSendStaysUnknown`, `TestPlainDetachPollDialFailureKeepsAdmittedOutcomeUnknown`, `TestOpsChunk_ErrorsAreJSONOnStdout` | CutTime Poll/CliGiveUp boundary; pre-admission transport proof | ACTIVE |
|
||||
| `INV-CLI-MINI-EXECUTABLE-001` | Mini records and launches the executable selected by --weed without changing symlink/.. resolution; fresh and legacy runs use an absolute path. | TrialLauncher path wiring, no protocol transition | `cmd/sw-block/mini.go` `miniExecutablePath`, `mini`, `reuseMiniRecord` | `TestMiniWeedSymlinkParentKeepsSelectedExecutable`, `TestMiniRelativeWeedIsRecordedAndPrintedAbsolutely` (`cmd/sw-block`); `TestMiniCleanupFailStopAndSettlement` (`cmd/blockvolume`: failed-start proof rejects watchdog intervention; settled capture completes and live residue refuses cleanup) | NONE (path selection and test ownership only; fresh Linux qualification pending) | STUB |
|
||||
| `INV-CLI-CATALOG-ERROR-001` | The chunk CLI preserves admission evidence and definite domain/certificate answers. Possibly-sent requests require replay/poll. Incomplete verify never exits 3; non-retryable server answers never exit 75. Absent snapshot delete is snapshot_not_found. | M9 client error projection; M4 census refusal, no transition change | `core/rpc/answer` `Lookup`; `cmd/sw-block/chunk_answer.go` `chunkAnswer`; `cmd/sw-block/chunk.go` `chunkResult`; `cmd/sw-block/catalog_snapshot_operation.go` `catalogSnapshotDeleteRefusal`; `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `core/frontend/chunkstore/layout/delete.go` `RunMarkDeleting` | `TestOpsChunkTransportFailureMatrix`, `TestOpsChunkVerifyUnreachableCensusPreservesTransport`, `TestCheckSingleFilerKeepsTransportCause`, `TestSingleFilerConfigurationErrorDeadlineBetweenReads`, `TestCheckSingleFilerSlowDialOrdering`, `TestDialBCatalogKeepsCustomCallerDeadline`, `TestMasterCensusKeepsCustomCallerDeadline`, `TestCheckSingleFilerValidatesAllMasterAddressesBeforeCensus`; `TestOpsChunkCatalogUnavailableIsTyped`, `TestCatalogTransportClassificationKeepsDefiniteAnswers`, `TestSnapshotDeleteAbsentCLIUsesContractCodeAndKeepsReceipt`; `TestLinkNeverTurnsASentRequestIntoSafeResend`; `TestChunkHTTPPostLostAnswerIsUnknown`; `TestCommandFamilyTransportGrid`; `TestLocalCredentialsFailBeforeDialWithTypedPolicy`; `TestHTTPCancellationBeforeDispatchKeepsOperationPhase`; `TestDeclaredDomainCodesHaveRegistryRows`; `TestOwnedClientTransportsKeepAdmissionEvidence`; `TestPresentationFailsClosedForUnknownContract`; `TestUnsentRPCWithMixedPeerFailuresIsRetryable`; `TestRPCPeerCertificateFailureDoesNotHideHandshakeTimeout`; `TestRPCSucceedsOnGoodPeerAfterBadCertificate`; `TestPeerCertificateProofRequiresEveryFreshCompletedAttempt`; `TestPeerDiagnosticTruncationNeverAuthorizesTerminalClassification`; `TestTypedRemoteUnavailableRespectsRetryable`; `TestNonRetryableServerAnswerNeverInvitesTemporaryRetry`; `TestVerifyStartCheckLostAnswerNeverLooksLikeFindings`; `TestVerifyIncompleteTransportPreservesPartialProgress`; `TestOpsFailoverUsesSharedDefiniteExitProjection`; `TestBlobHTTPAnswerSurvivesLayoutFetch`; `TestPlaintextPrefaceFailureKeepsUnsentRetryAndTLSHint`; `TestHTTPPartialCustomTraceCannotProveUnsentAfterReceivedPOST`; `TestHTTPRegisteredProtocolCannotProveUnsentAfterReceivedPOST`; `TestHTTPOwnedTransportDoesNotInheritRegisteredDefault`; `TestDelayedPeerNotificationCannotRefreshAnOldTLSFailure`; `TestObservedTLSForwardsPerCallAuthorityValidation`; `TestChunkCensusPreflightPreservesOpaqueContextCause`; `TestSingleFilerReviewPreservesDefiniteAndCallerWinner`; `TestReviewContextAndDefiniteAnswerPrecedence`; `TestReviewOldPickerCannotBorrowNewPeerGeneration`; `TestReviewContractProjectionAndReadOnlyRecovery`; `TestReviewAdmittedPollTLSFailureKeepsOperationRecoverable`; `TestReviewPickerCannotReplaceCustomCallerDeadline`; `TestReviewSelectedTLSCannotReplaceCallerCompletion`; `TestReviewHTTPStatusOverridesNestedTransport`; `TestReviewVerifyPreservesServerRetryRefusal`; `TestReviewInitialPostBodyFailurePreservesStatus`; `TestReviewForceMovePreservesServerPolicyExit`; `TestReviewFailoverDomainAnswerRequiresRecovery`; `TestSnapshotOperationCLIInterruptThenResumeUsesPrintedID`; `TestSnapshotOperationCLIInterruptedTLSKeepsUnknownAndHandle`; `TestReviewCompleteBodyKeepsStatusAndAdmission`; `TestReviewInvalidAdmissionKeepsOriginalRequest`; `TestReviewUnsafeSnapshotLocationKeepsOriginalUnknown`; `TestReviewAdmittedMissingResultKeepsUnknown`; `TestCutBusyHasItsOwnLegacyExitClass`; `TestCutCLIBusyIsDistinctAndDoesNotStartAnotherCut` | SnapOps.Poll; CutTime.Poll; CutTime.CliGiveUp (result projection; no new transition) | STUB |
|
||||
| `INV-CLI-UNLISTED-HTTP-001` | An HTTP failure status absent from the registry is possibly admitted and projects outcome_unknown with recovery of the same operation. | Answer policy (pure function) | `core/rpc/answer/http_status.go` `HTTPStatusFailure` | `TestUnlistedHTTPStatusPreservesUnknownOutcome` (`core/rpc/answer/http_unlisted_test.go`); `TestSnapshotProxyUnlistedHTTPStatusIsUnknown`, `TestOperatorUnlistedHTTPStatusIsUnknown` (`cmd/sw-block/http_unlisted_test.go`) | NONE (pure error projection; no protocol transition) | ACTIVE |
|
||||
| `INV-CLI-UNLISTED-HTTP-002` | HTTP failure projection preserves the received status and original cause. | Answer policy (pure function) | `core/rpc/answer/http_status.go` `HTTPStatusFailure` | `TestHTTPStatusFailureRetainsStatusAndCause` (`core/rpc/answer/http_status_retention_test.go`) | NONE (pure error projection; no protocol transition) | ACTIVE |
|
||||
| `INV-CLI-UNLISTED-HTTP-003` | Documented contract-specific legacy exits remain in the global exit projection. | Answer policy (pure function) | `core/rpc/answer/http_status.go` `HTTPStatusFailure` | `TestUnlistedHTTPStatusPreservesUnknownOutcome` (`core/rpc/answer/http_unlisted_test.go`) | NONE (pure error projection; no protocol transition) | ACTIVE |
|
||||
| `INV-CLI-UNLISTED-HTTP-004` | Listed HTTP failure statuses retain their existing policy. | Answer policy (pure function) | `core/rpc/answer/http_status.go` `HTTPStatusFailure` | `TestProducedHTTPStatusPolicyRows` (`core/rpc/answer/http_status_test.go`); `TestReviewCompleteBodyKeepsStatusAndAdmission` (`cmd/sw-block/review_complete_answer_test.go`) | NONE (pure error projection; no protocol transition) | ACTIVE |
|
||||
| `INV-TLS-CA-BUNDLE-PARSE-001` | CA loading skips unparseable or PEM-header certificate blocks, retaining loadable alternatives as AppendCertsFromPEM does. No loadable root is a local credential refusal; the selected TLS chain still must verify. | Local credential parsing (pure function) | `core/rpc/answer/credentials.go` `CertificatePool`; `core/rpc/link/tls.go` `pool` | `TestCertificatePoolSkipsUnparseableAlternatives` (`core/rpc/answer/credentials_bundle_test.go`); `TestMasterLinkCARotationUsesTheVerifiedChain/malformed` (`core/rpc/link/ca_rotation_test.go`) | NONE (pure certificate parsing; no protocol transition) | ACTIVE |
|
||||
| `INV-CLI-CATALOG-ERROR-001` | The chunk CLI preserves admission evidence and definite domain/certificate answers. Possibly-sent requests require replay/poll. Incomplete verify never exits 3; non-retryable server answers never exit 75. Absent snapshot delete is snapshot_not_found. | M9 client error projection; M4 census refusal, no transition change | `core/rpc/answer` `Lookup`; `cmd/sw-block/chunk_answer.go` `chunkAnswer`; `cmd/sw-block/chunk.go` `chunkResult`; `cmd/sw-block/catalog_snapshot_operation.go` `catalogSnapshotDeleteRefusal`; `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `core/frontend/chunkstore/layout/delete.go` `RunMarkDeleting` | `TestOpsChunkTransportFailureMatrix`, `TestOpsChunkVerifyUnreachableCensusPreservesTransport`, `TestCheckSingleFilerKeepsTransportCause`, `TestSingleFilerConfigurationErrorDeadlineBetweenReads`, `TestCheckSingleFilerSlowDialOrdering`, `TestDialBCatalogKeepsCustomCallerDeadline`, `TestMasterCensusKeepsCustomCallerDeadline`, `TestCheckSingleFilerValidatesAllMasterAddressesBeforeCensus`; `TestOpsChunkCatalogUnavailableIsTyped`, `TestCatalogTransportClassificationKeepsDefiniteAnswers`, `TestSnapshotDeleteAbsentCLIUsesContractCodeAndKeepsReceipt`; `TestLinkNeverTurnsASentRequestIntoSafeResend`; `TestChunkHTTPPostLostAnswerIsUnknown`; `TestCommandFamilyTransportGrid`; `TestLocalCredentialsFailBeforeDialWithTypedPolicy`; `TestHTTPCancellationBeforeDispatchKeepsOperationPhase`; `TestDeclaredDomainCodesHaveRegistryRows`; `TestOwnedClientTransportsKeepAdmissionEvidence`; `TestPresentationFailsClosedForUnknownContract`; `TestUnsentRPCWithMixedPeerFailuresIsRetryable`; `TestRPCPeerCertificateFailureDoesNotHideHandshakeTimeout`; `TestRPCSucceedsOnGoodPeerAfterBadCertificate`; `TestPeerCertificateProofRequiresEveryFreshCompletedAttempt`; `TestPeerDiagnosticTruncationNeverAuthorizesTerminalClassification`; `TestTypedRemoteUnavailableRespectsRetryable`; `TestNonRetryableServerAnswerNeverInvitesTemporaryRetry`; `TestVerifyStartCheckLostAnswerNeverLooksLikeFindings`; `TestVerifyIncompleteTransportPreservesPartialProgress`; `TestOpsFailoverUsesSharedDefiniteExitProjection`; `TestBlobHTTPAnswerSurvivesLayoutFetch`; `TestPlaintextPrefaceFailureKeepsUnsentRetryAndTLSHint`; `TestHTTPPartialCustomTraceCannotProveUnsentAfterReceivedPOST`; `TestHTTPRegisteredProtocolCannotProveUnsentAfterReceivedPOST`; `TestHTTPOwnedTransportDoesNotInheritRegisteredDefault`; `TestDelayedPeerNotificationCannotRefreshAnOldTLSFailure`; `TestObservedTLSForwardsPerCallAuthorityValidation`; `TestChunkCensusPreflightPreservesOpaqueContextCause`; `TestSingleFilerReviewPreservesDefiniteAndCallerWinner`; `TestReviewContextAndDefiniteAnswerPrecedence`; `TestReviewOldPickerCannotBorrowNewPeerGeneration`; `TestReviewContractProjectionAndReadOnlyRecovery`; `TestReviewAdmittedPollTLSFailureKeepsOperationRecoverable`; `TestReviewPickerCannotReplaceCustomCallerDeadline`; `TestReviewSelectedTLSCannotReplaceCallerCompletion`; `TestReviewHTTPStatusOverridesNestedTransport`; `TestReviewVerifyPreservesServerRetryRefusal`; `TestReviewInitialPostBodyFailurePreservesStatus`; `TestReviewForceMovePreservesServerPolicyExit`; `TestReviewFailoverDomainAnswerRequiresRecovery`; `TestSnapshotOperationCLIInterruptThenResumeUsesPrintedID`; `TestSnapshotOperationCLIInterruptedTLSKeepsUnknownAndHandle`; `TestReviewCompleteBodyKeepsStatusAndAdmission`; `TestChunkUnusableConflictAnswerIsUnknown`; `TestChunkConflictLoopKeepsOriginalRequest`; `TestReviewInvalidAdmissionKeepsOriginalRequest`; `TestReviewUnsafeSnapshotLocationKeepsOriginalUnknown`; `TestReviewAdmittedMissingResultKeepsUnknown`; `TestCutBusyHasItsOwnLegacyExitClass`; `TestCutCLIBusyIsDistinctAndDoesNotStartAnotherCut` | SnapOps.Poll; CutTime.Poll; CutTime.CliGiveUp (result projection; no new transition) | STUB |
|
||||
| `INV-CLI-CHUNK-LOOP-001` | Above the per-request bound, sw-block ops chunk snapshot\|detach repeats the SAME request (same name and request id) only after a retryable or outcome_unknown answer. Manual cut and plain detach use the separate one-POST/read-only-poll contract. | client (no state machine): the CLI side of M5 requests | `cmd/sw-block/chunk_loop.go` `chunkPostLoop`; `cmd/sw-block/chunk.go` `chunkPostUntil` | `TestChunkSnapshotRepeatsTimedOutRequestsWithTheSameBody`, `TestChunkSnapshotLoopReusesTheGeneratedRequestID`, `TestChunkLoopRepeatsAnOutcomeUnknownNotMarkedRetryable` (`cmd/sw-block`) | — | ACTIVE |
|
||||
| `INV-CLI-CHUNK-LOOP-002` | Above the per-request bound, sw-block ops chunk snapshot\|detach stops at the first definite answer (success or non-retryable refusal). | client (no state machine): the CLI side of M5 cut requests | `cmd/sw-block/chunk_loop.go` `chunkPostLoop` | `TestChunkLoopStopsOnANonRetryableRefusal`, `TestChunkDetachOutcomeUnknownSettles` (`cmd/sw-block`) | — | ACTIVE |
|
||||
| `INV-CLI-CHUNK-LOOP-003` | Non-plain detach and snapshot admission obey a positive total --timeout. Snapshot observation keeps the same ID with bounded calls and no total deadline. Manual cut and plain detach use the separate inactivity-window contract. | client (no state machine): the CLI side of M5 cut requests | `cmd/sw-block/chunk_loop.go` `chunkPostLoop`; `cmd/sw-block/chunk.go` `chunkPostUntil` | `TestChunkLoopEndsAtTheTimeout`, `TestChunkLoopHeldProgressReadSendsNoRequestAfterTheTimeout`, `TestChunkLoopSlowAnswersAreBoundedByTheTimeout`, `TestChunkNonPositiveTimeoutIsRefused` (`cmd/sw-block`) | — | ACTIVE |
|
||||
@@ -1319,6 +1345,8 @@ Notes:
|
||||
|
||||
- Answer-entry controls: `TestAnswerEntryBackupFailureTable`, `TestAnswerEntryRestoreFailureTable`, `TestAnswerEntryPlacementFailureTable` and `TestAnswerEntryShellInspectionFailureTable` exercise production command workflows with received HTTP/RPC answers, independent expected exits, call counts and recovery checks. `TestAnswerLegacyStopKeepsAcquiredCutHandle` and `TestAnswerLegacyPublicationUnknownNamesExistingTarget` pin the retained operation identity when a documented outer business refusal wraps an unknown outcome. These controls do not activate `INV-CLI-CATALOG-ERROR-001` without the remaining census review and Linux qualification.
|
||||
|
||||
- At `chunkPostUntil` (snapshot admission and non-plain detach), an unusable HTTP 409 body maps to outcome_unknown/3; status cannot establish non-admission. Snapshot recovery uses the original request ID with unchanged parameters, or an already obtained handle. Non-plain detach has neither identifier: keep the writer stopped and inspect the original holder's HEAD and logs for a confirmed seal or abort; if unproven, preserve diagnostics for investigation rather than guessing via a new operation. The separate cut/plain-detach observer is unchanged; a readable malformed initial reply can report unsupported_api_version/3 without proving an outcome. The existing bounded loop preserves its original request body; complete typed 409 answers keep their own code and retry flag (`INV-CLI-CATALOG-ERROR-001`, `INV-CLI-CHUNK-LOOP-001`). `TestChunkConflictStatusRowsHaveOutcomeClasses` and `TestChunkConflictCensusRejectsANewUnclassifiedCode` require an explicit class for every 409 mapper row, including typed-body-required delegates; status alone never substitutes for that body.
|
||||
|
||||
- `INV-CLI-CATALOG-ERROR-001`: Linux qualification remains pending; native CLI and receipt controls alone do not activate this row. A failed NoLiveLease observation keeps its transport cause under ErrHolderActive: the wrapper refuses progress but does not prove a live holder. Only proven-unsent failures whose policy permits resend may be resent; caller cancellation forbids automatic retry, and certificate rejection remains terminal until corrected. Possibly-admitted failures require replay or polling; actual authority refusals stay definite. The existing volume-delete retry window now presents its exhausted remote failure as remote_unavailable rather than unavailable.
|
||||
- `INV-CUT-TIMER-RESTART-001`, `INV-CUT-TIMER-SKIP-001`: cuts are identified and ordered by the layer's in-process `CutSeq`, never by the `LastCutNs` wall stamp: a `CutSeq` not seen before is a success at the moment it is observed, and a periodic decision is skipped once `CutSeq` has moved; at start the existing value is not new, so a restart keeps the startup phase. The scheduled-snapshot worker (`INV-SNAP-SCHEDULED-KEEP-001`) runs on the same monotonic time: a new attachment seeds its due time at the next stable per-volume grid slot after HEAD's newest scheduled snapshot, or is due immediately without scheduled history. Future creation times are clamped to now. A re-armed loop on the same handle keeps its schedule (failures, retry time); a restart restores the last success and overdue age from HEAD. Tests: `TestScheduledSnapshotLoop_TakesEachSlotOnMonotonicTime`, `_RearmKeepsTheSchedule`, `_OverdueWithNoSuccess`, `TestSnapshotSchedule_SlotsAreOffsetPerVolume`.
|
||||
- Not reachable in this release: `INV-WS-FREEZE-ACCOUNTING-001` (except its estimate and quiesce-slack report, which every successful cut returns) and `INV-CUT-PRECOPY-001`. `/chunk/detach` refuses `frozen` (`INV-CUT-FROZEN-DETACH-REFUSED-001`) and blockvolume refuses `--chunk-detach-precopy` (`INV-CUT-PRECOPY-FLAG-REFUSED-001`), so neither the frozen admission nor the pre-copy admission runs in a released process. Their code is kept and their tests below the HTTP handler still assert them, so their status stays ACTIVE. For the same reason the pre-copy policy that `INV-CUT-PLAIN-DETACH-001` keeps for an absent or false `plain` field is always off. `INV-WS-FREEZE-REFUSAL-001` stays reachable: its HTTP400 validation runs before the refusal. So do `INV-WS-FREEZE-REFUSAL-INPUTS-001` and `INV-WS-FREEZE-REFUSAL-PRECEDENCE-001`.
|
||||
|
||||
@@ -250,6 +250,27 @@ holder is not supported. (The v1.0.2 notes' "CLI last" applied to upgrades withi
|
||||
**Authentication.** For production, set up mutual TLS for the control API ([authenticate the control
|
||||
API](operator-guide.md#authenticate-the-control-api)). The examples here run on loopback without it.
|
||||
|
||||
**Network trust.** blockmaster's control API authenticates callers with mutual TLS and authorizes them by role
|
||||
(viewer, operator, admin, node) when `--tls-cert`, `--tls-key`, `--tls-client-ca`, `--role-file` and `--audit-log`
|
||||
are all set. The audit log records volume create and delete, failback, workspace binding registration, placement, move and
|
||||
revoke, format finalize and host retirement before they run, and refuses such a call when it cannot record it; other
|
||||
calls by people are recorded after they run, as far as the log allows. Without these flags blockmaster accepts only loopback connections. Nothing else is encrypted, and only
|
||||
the iSCSI target authenticates its clients:
|
||||
- the volume host's status and chunk control HTTP endpoints have no authentication and listen on loopback unless
|
||||
`--allow-external-status-bind` is set, which a volume host that authenticates to blockmaster (`--master-tls-cert`)
|
||||
refuses;
|
||||
- the replication channel between replicas (replicated volumes, preview) has no authentication;
|
||||
- the connection to the SeaweedFS filer and volume servers has no authentication of its own: anyone who can reach
|
||||
the filer can read or change any volume's metadata and chunks, which are stored unencrypted;
|
||||
- the NVMe/TCP target has no authentication and listens on loopback unless `--allow-external-nvme-bind` is set;
|
||||
- the iSCSI target listens off loopback only with `--allow-external-iscsi-bind`, which requires CHAP
|
||||
(`--iscsi-chap-username`, `--iscsi-chap-secret`) for normal sessions; discovery sessions are not authenticated, so
|
||||
any initiator that reaches the port can list the target name and portal; on loopback CHAP is optional; its traffic
|
||||
is not encrypted.
|
||||
|
||||
Run these on a trusted network only, and keep blockmaster's key files, role file and audit log readable only by its
|
||||
service user.
|
||||
|
||||
## 2. Cluster spec and blockmaster
|
||||
|
||||
blockmaster needs two things: a cluster spec and a lifecycle store. The cluster spec lists the nodes, and each volume
|
||||
@@ -671,7 +692,81 @@ writing the v1.0 format until you finalize. Until then you can go back.
|
||||
**Going back** before the finalize: reinstall the v1.0.x binaries in reverse order (each holder, then
|
||||
blockmaster), restarting each the same way. The v1.1 CLI can stay.
|
||||
|
||||
5. **Finalize** once every holder runs v1.1:
|
||||
5. **Finalize** once every holder runs v1.1.
|
||||
|
||||
**Hard rule: from the end of the upgrade until `sw-block cluster finalize-format` completes, no v1.0.x volume process
|
||||
may run on any host, and none may start.**
|
||||
|
||||
Check it on **every host itself**. blockmaster's view cannot show it, so do not rely on it.
|
||||
|
||||
`blockvolume --version` prints the build's revision, not a release number:
|
||||
`blockvolume revision=<commit> modified=<true|false|unknown>`. Compare every line with the line the v1.1.x binary
|
||||
you installed on that host prints.
|
||||
|
||||
```sh
|
||||
# 0. The reference line: the v1.1.x blockvolume binary you installed on this host.
|
||||
/usr/local/bin/blockvolume --version
|
||||
# 1. Every RUNNING volume process: /proc/<pid>/exe runs the image that process is running,
|
||||
# even if an upgrade has since replaced the file on disk.
|
||||
for pid in $(pgrep -x blockvolume); do printf '%s ' "$pid"; sudo /proc/"$pid"/exe --version; done
|
||||
# 2. The binary each unit would start on a restart: every unit, loaded or not and under any name, that
|
||||
# mentions blockvolume. That covers a copy of the shipped unit (such as archive-volume.service), an
|
||||
# instance enabled by a link, and an instance-only override (such as
|
||||
# sw-blockvolume@v1.service.d/override.conf); an enabled but stopped unit is not loaded, so the unit
|
||||
# paths are searched as well as the loaded list. systemctl cat <unit> shows the unit with its drop-ins.
|
||||
units=$( { for p in $(systemd-analyze unit-paths); do grep -RlE blockvolume "$p" 2>/dev/null; done |
|
||||
sed -n 's#.*/\([^/]*\.service\)\(\.d/[^/]*\)\{0,1\}$#\1#p'
|
||||
systemctl list-units --all --type=service --no-legend --plain | cut -d' ' -f1 |
|
||||
while read -r u; do systemctl cat "$u" 2>/dev/null | grep -q blockvolume && echo "$u"; done
|
||||
} | sort -u)
|
||||
# Every non-empty ExecStart, ExecStartPre, ExecStartPost and ExecReload value of every selected unit is
|
||||
# checked, including values a later drop-in overrides (systemd allows blanks around "="; an empty value
|
||||
# only resets that list). Only a binary
|
||||
# named exactly blockvolume is run, with --version. Anything else (a renamed binary, a wrapper such as env
|
||||
# or /bin/sh -c, a site script, no binary) is never run: its line says "NOT a blockvolume binary", which is
|
||||
# not the reference line, so the rule below stops on it until you have confirmed that unit by hand.
|
||||
for u in $units; do
|
||||
systemctl cat "$u" |
|
||||
sed -n 's/^[[:blank:]]*Exec\(Start\|StartPre\|StartPost\|Reload\)[[:blank:]]*=[[:blank:]]*//p' |
|
||||
while IFS= read -r v; do
|
||||
[ -n "$v" ] || continue
|
||||
b=$(printf '%s\n' "$v" | sed 's/^[-@+!:]*//; s/[[:blank:]].*//')
|
||||
if [ "${b##*/}" = blockvolume ]; then
|
||||
printf '%s %s ' "$u" "$b"; "$b" --version </dev/null
|
||||
else
|
||||
printf '%s %s NOT a blockvolume binary: confirm by hand\n' "$u" "${b:-<no-binary>}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
```
|
||||
|
||||
Every line of steps 1 and 2 must end with exactly the reference line (after the pid, or the unit and path), with
|
||||
`modified=false`. A line with another
|
||||
revision, `modified=true` or `modified=unknown`, an error, or no output means that the process or unit cannot be
|
||||
shown to run v1.1.x: stop that volume (or fix that unit) and upgrade it before the finalize. Do not roll any host
|
||||
back while the finalize runs.
|
||||
|
||||
Steps 1 and 2 are helpers, not the rule. They find units by the text `blockvolume`, so a unit or script that
|
||||
starts a renamed binary without naming it is not found. **Confirm that no other unit or script on this host
|
||||
starts a v1.0.x volume binary** before the finalize.
|
||||
|
||||
**Also:** wait at least 30 seconds after the last start or restart of any volume process before running the
|
||||
finalize. In that time a running process normally reports its read level, and the finalize refuses while the latest
|
||||
report for a volume shows an older level, so the wait usually catches a process that was missed. A report can be
|
||||
delayed without bound (see "What remains"), so the wait does not replace the hard rule.
|
||||
|
||||
**What remains (stated, not closed in v1.1.2):**
|
||||
- The finalize judges each serving volume by the last heartbeat report blockmaster received for that volume.
|
||||
- A report delayed in the network or inside blockmaster can arrive after a newer process's report and stand in for
|
||||
it. No wait bounds that delay. The delayed report can come from a process that has since stopped, including an
|
||||
old one.
|
||||
- What keeps the finalize safe in that case is which process can still serve: with no v1.0.x process running or
|
||||
able to start, every process that can serve a volume reads the v1.1 format, whatever report blockmaster received
|
||||
last.
|
||||
- A later release (planned with v1.2) carries the process identity on every lease renewal and at the finalize,
|
||||
which removes this rule.
|
||||
|
||||
Then:
|
||||
|
||||
```sh
|
||||
sw-block cluster finalize-format --master 127.0.0.1:9180 --json
|
||||
@@ -680,9 +775,20 @@ writing the v1.0 format until you finalize. Until then you can go back.
|
||||
- **Refused** (exit 2, `FORMAT_HOSTS_TOO_OLD`) while a holder still runs v1.0.x. That holder reports format
|
||||
level 0 and is named in `hosts` (for example `"reported":"volume v1 reads level 0"`). Upgrade it, or move its
|
||||
volume, and run the finalize again.
|
||||
- **`listed`** names the hosts the master cannot confirm but that do not block the finalize: a held volume with no
|
||||
report or a stale one, a host with no report, and an old process that holds no volume.
|
||||
- **Exit codes:** **0** finalized or already finalized; **2** typed precondition/argument refusal; **75** proven unsent remote failure; **3** unknown answer (read the current level before retrying); **5** authentication rejection; **78** local credential/configuration failure; **4** unproven integrity readout; **1** other definite failure or caller cancellation/deadline before send. An unknown answer does not prove the level unchanged.
|
||||
- A process with a possibly-live lease must have reported reading level 1. No report or an old report from a
|
||||
serving process refuses the finalize and names its host and volume. A clean release or an ended lease does not
|
||||
block. The finalize judges each volume by the last report blockmaster received (see "What remains"). A volume
|
||||
moved to a new host is not served there until the new process starts, reports, and obtains a checked renewal
|
||||
reply.
|
||||
- **`listed`** names other hosts the master cannot confirm but that do not block the finalize: an unserved
|
||||
placement with no report, a host with no work or report, a stale report at any level, or a fresh level-0 report
|
||||
from a process that holds no volume.
|
||||
- **Persistence fault.** If the attestation replacement may have landed, blockmaster retains the admission
|
||||
intent and exits 74 so its supervisor restarts from disk. Run it under a restarting supervisor.
|
||||
ERROR delivery is best effort if logging is blocked; termination remains bounded. Inspect `format-level`
|
||||
after recovery before retrying. A failure before replacement leaves level 0 and can be retried.
|
||||
- **Exit codes:** **0** finalized or already finalized; **2** typed precondition or server argument refusal; **75** proven unsent remote failure; **3** unknown answer (read the current level before retrying); **5** authentication rejection; **78** local credential/configuration failure; **4** unproven integrity readout; **1** local usage error (a missing, unknown or extra argument), other definite failure, or caller cancellation/deadline before send. An unknown answer does not prove the level unchanged.
|
||||
After a persistence fault the recovered level may be 0 or 1.
|
||||
- **JSON only.** The typed codes (`FORMAT_HOSTS_TOO_OLD`, and `HOST_HOLDS_WORK` below) appear only with `--json`.
|
||||
Plain output says `refused`.
|
||||
|
||||
@@ -838,7 +944,7 @@ Volume status (`/status?volume=<id>`, heartbeats, cluster status):
|
||||
| `io_error` | A local I/O error latched the store. | Check the disk. Restart the volume once the disk is healthy. |
|
||||
| `store_format_newer`, `head_newer_version` (exit 78) | A later version wrote the store or HEAD. | Run the later version. The unit does not restart after a final exit. |
|
||||
|
||||
`sw-block` commands. The JSON answer carries a typed `code` or `reason`. ordinary definite `ops chunk` refusals exit 1; server argument refusals exit 2, authentication rejections 5, and local credential/configuration failures 78. A possibly admitted unknown answer exits 3, except incomplete verify uses 1 so it cannot be mistaken for completed findings; retryable unknown answers from `ops volume create` and `ops volume resolve` retain exit 75 under their documented same-operation rules. These two commands also retain exit 78 for server argument (`InvalidArgument`) and authentication/authorization (`PermissionDenied` or `Unauthenticated`, including certificate rejection) refusals, instead of the general exits 2 and 5. Local argument parsing still exits 2. See the [full compatibility table](releases/v1.1.2.md#cli-answer-classification).
|
||||
`sw-block` commands. The JSON answer carries a typed `code` or `reason`. ordinary definite `ops chunk` refusals exit 1; server argument refusals exit 2, authentication rejections 5, and local credential/configuration failures 78. A possibly admitted unknown answer exits 3, except incomplete verify uses 1 so it cannot be mistaken for completed findings; retryable unknown answers from `ops volume create` and `ops volume resolve` retain exit 75 under their documented same-operation rules. These two commands also retain exit 78 for server argument (`InvalidArgument`) and authentication/authorization (`PermissionDenied` or `Unauthenticated`, including certificate rejection) refusals, instead of the general exits 2 and 5. Local argument parsing still exits 2. See the [full compatibility table](releases/v1.1.2.md#full-exit-code-inventory).
|
||||
|
||||
| Code or reason | Seen from | Meaning | What to do |
|
||||
|---|---|---|---|
|
||||
@@ -851,12 +957,14 @@ Volume status (`/status?volume=<id>`, heartbeats, cluster status):
|
||||
| `internal` | `ops chunk` commands with `--chunk-filer` | v1.1.0 only: also what an unreachable filer gives, and `ops chunk verify` and `ops chunk snapshot-delete` instead answer `bad_request: ... needs exactly one filer ... connection refused` (exit 2) after 30-60 s. From v1.1.1 these are `remote_unavailable`. | Check the filer address and that the filer runs, then retry. |
|
||||
| `not_admitted` | restore | The target is not in the cluster spec. The printed cure (`--lifecycle-product-loop-interval`) does not apply to this setup. | Add the target without `size_bytes` and restart blockmaster (section 5). |
|
||||
| `not_admitted ... live until <time>` | volume-delete | The volume's lease horizon has not passed. In v1.1.1 the answer's `retryable` field says which case applies: `true` (exit 75) means the delete is admitted and waits for its final lease barrier; `false` (exit 1, "stop the volume first") means a serving holder still holds the lease, so the delete was not admitted. | `true`: repeat with the same request id after that time. `false`: stop the holder (section 6, steps 1 and 2), then repeat (section 6). |
|
||||
| `outcome_unknown` (retryable, exit 3; v1.1.2) | snapshot admission; non-plain detach | `HTTP 409 body is unusable`: the answer was cut off, unreadable, malformed or too large to relay. HTTP 409 alone cannot establish non-admission or that nothing was applied. | Snapshot: keep the same request id and original parameters, including absolute expiry; see below. Non-plain detach has no request id or handle: keep the writer stopped and inspect the original holder's HEAD/logs for a confirmed seal or abort; unresolved evidence requires investigation. |
|
||||
| `unsupported_api_version` (non-retryable, exit 3) | initial cut or plain-detach observer reply | A readable malformed or unsupported-version answer does not establish the operation's outcome. | If a handle was already printed, query that handle. Without one, cut can be repeated for a later durable point (not proof of the original cut); for detach, keep the writer stopped and establish the original seal or abort from HEAD/logs before proceeding. |
|
||||
| `remote_full` | cuts, snapshots | The chunk store has no space. | Add capacity, then retry. |
|
||||
| `queue_full` | cuts, snapshots | Reclamation work must drain before another producer publishes. | Retry later. |
|
||||
| `format_level_below_head_version` | cuts, in the holder log | The holder still runs at the format level it attached at, from before the finalize. | A v1.1.1 holder adopts the finalized level at its next lease renewal; restart a v1.1.0 holder (section 7). |
|
||||
| `no_progress` (retryable) | snapshot, snapshot-delete | The operation has not settled: a snapshot stalled (for example right after a finalize, section 7), or a snapshot delete's work did not finish in this call. Retrying a snapshot with the same request id settles it, which can take several minutes. | For snapshot, keep retrying with the same id. For snapshot-delete, do not resume it by hand: a resume can stop the volume's snapshot deletes and cleaning (see the snapshot delete known issue in the [v1.1.1 notes](releases/v1.1.1.md)). |
|
||||
| `no_progress` (retryable) | snapshot, snapshot-delete | The operation has not settled: a snapshot stalled (for example right after a finalize, section 7), or a snapshot delete's work did not finish in this call. Retrying a snapshot with the same request id settles it, which can take several minutes. | For snapshot, keep retrying with the same id. For snapshot-delete, every run prints its own line `chunkstore: metadata change guard:`, and the first run also prints `snapshot-delete NAME@G request id ...`. Repeat it with the same request id and `--gen G` only if all of these hold: the volume's holder reports `metadata_guard` `filer_chunk_condition` in its `/status/chunk`, and so did every holder process of this volume since the first run; no run of this delete came from a v1.1.1 `sw-block`; every run so far printed `filer_chunk_condition` (SeaweedFS 4.41 or later). Otherwise, or as soon as a run prints `page_reread_only` or no such line, do not repeat it by hand: a resume can stop the volume's snapshot deletes and cleaning (see the snapshot delete known issue in the [v1.1.2 notes](releases/v1.1.2.md)). Without `--gen` a repeat whose original receipt has retired resolves NAME again and can delete a newer snapshot of the same name. |
|
||||
| `snapshot_has_dependents` (exit 1) | snapshot-delete | A restored volume depends on the snapshot. Not retryable: retrying does not help until that volume is deleted. | Delete the dependent volume first (section 6), then run the same command with the same request id; or keep the snapshot. |
|
||||
| `layout_busy` (retryable, exit 1) | snapshot-delete | `layout: another transaction is open`: an earlier snapshot delete on the same volume waits for its cleaning pass, which can take up to `--chunk-maintenance-interval` (1 h). | Keep retrying with the same id; it settles after that pass. If it does not settle after a cleaning pass, see the snapshot delete known issue in the [v1.1.1 notes](releases/v1.1.1.md). |
|
||||
| `layout_busy` (retryable, exit 1) | snapshot-delete | `layout: another transaction is open`: an earlier snapshot delete on the same volume waits for its cleaning pass, which can take up to `--chunk-maintenance-interval` (1 h). | An earlier delete of this volume is waiting for its cleaning pass. Wait for that pass, then follow the `no_progress` row above: repeat with the same id only under its conditions. If `layout_busy` persists after a cleaning pass, the volume may have the stuck record described in the snapshot delete known issue in the [v1.1.2 notes](releases/v1.1.2.md); repeating does not clear it. |
|
||||
| `outcome_unknown` | various | The request may or may not have taken effect. | See below. |
|
||||
| `snapshot_exists`, `snapshot_limit` | snapshot | The name is taken, or there are too many snapshots. | Use another name, or delete old snapshots. |
|
||||
| `snapshot_not_found` | restore | No snapshot has that name. (To see it, you need a target in the spec; there is no need to provoke it.) | Check `ops chunk snapshots`. |
|
||||
@@ -872,9 +980,21 @@ Volume status (`/status?volume=<id>`, heartbeats, cluster status):
|
||||
|
||||
- **Commands with `--request-id`** (`ops chunk snapshot`, `snapshot-delete`, `restore`, `volume-delete`,
|
||||
`ops workspace move` with or without `--clean`, and `ops workspace force-move`): repeat the command with the same
|
||||
request id until it answers. The answer settles what happened. This can take several minutes. Do not repeat an
|
||||
interrupted `snapshot-delete` by hand: a resume can stop the volume's snapshot deletes and cleaning (see the snapshot
|
||||
delete known issue in the [v1.1.1 notes](releases/v1.1.1.md)).
|
||||
request id and unchanged original parameters until it answers (for snapshot expiry, see below). The answer settles what happened. This can take several minutes. Exception: repeat an interrupted `snapshot-delete` only under the conditions in the `no_progress` row, and always
|
||||
with `--gen G` from the first run's `snapshot-delete NAME@G` line. Otherwise do not repeat it by hand.
|
||||
- **Snapshots with `--expires`:** re-running that relative duration computes a new absolute
|
||||
`expiresAtNs`, so even the same request id can be refused as a changed fingerprint. For a replay, replace
|
||||
`--expires` with `--expires-at-ns N`, using the original absolute value and all the other original parameters.
|
||||
If it was not recorded, use `ops chunk show --master MASTER --volume VOLUME --chunk-filer FILER --chunk-path CHUNK_PATH`
|
||||
to read the named entry under `head.Snapshots`. Only when its `Meta.Operation.id` matches the original request id
|
||||
may you take its `Meta.ExpiresNs` as that request's expiry. A successful original receipt/result, if already available,
|
||||
also contains `expiresAtNs`. The `ops chunk snapshots` name list does not expose the expiry. If the matching published
|
||||
entry/result is absent and the absolute value was not saved, do not invent one or repeat `--expires`: preserve the
|
||||
request id and diagnostics for investigation. A missing list entry does not prove non-admission. For future commands
|
||||
that may need replay, choose and record `--expires-at-ns` before the first attempt.
|
||||
- **Non-plain detach** has no request id or handle. Keep the writer stopped and the original holder running while
|
||||
inspecting its HEAD and logs for a confirmed seal or abort. Do not interpret a new detach's answer as the original
|
||||
outcome; if neither outcome can be established, preserve diagnostics for investigation.
|
||||
- **`ops chunk cut`** has no request id. Repeat the cut: a later cut gives a later durable point. It does not tell you
|
||||
whether the earlier cut committed; for that, check the volume's snapshots and its last cut in status.
|
||||
- **`volume stop`**: run the same `sudo /usr/local/bin/sw-block volume stop <volume>` again. Before its cut succeeds
|
||||
|
||||
@@ -4,6 +4,31 @@ v1.1.1 is released (2026-12-04).
|
||||
|
||||
v1.1.1 is a fix release of the v1.1 line. None of its changes alters a stored format.
|
||||
|
||||
## Known issue: plain detach can abort during a periodic checkpoint
|
||||
|
||||
- **Trigger:** a periodic checkpoint's already-issued HEAD update lands while `sw-block ops chunk detach --plain` is stopping background work.
|
||||
- **Effect:** a confirmed `detach_aborted` means no sealed HEAD was published and serving resumed on the same holder. The CLI can instead report `outcome_unknown` (exit 3); that answer alone proves neither an abort nor resumed guest I/O. If the holder's detach outcome is still unresolved, I/O stays stopped while it settles.
|
||||
- **What to do:** confirm the original handle before treating this as a retryable abort. The holder keeps the handle only for about `--timeout` plus 5 s after the detach ends, and the CLI gives up about that long after its last progress, so query right after the CLI exits, or from a second shell while it still waits. The CLI prints the id (`sw-block ops chunk detach: id <id>` on stderr) only when the detach is still running after `--timeout`; an abort that ends sooner is answered on the detach request itself, with no id. If no id was printed, skip this GET and follow the unresolved-outcome procedure below, keeping guest I/O stopped. On the holder's host, query the same status address and volume used by the detach, with the id printed by the CLI:
|
||||
|
||||
```sh
|
||||
STATUS_ADDR='<status address or URL used by the detach>'
|
||||
case "$STATUS_ADDR" in
|
||||
*://*) ;;
|
||||
*) STATUS_ADDR="http://$STATUS_ADDR" ;;
|
||||
esac
|
||||
VOLUME_ID='<volume-id>'
|
||||
CUT_ID='<id printed by the detach CLI>'
|
||||
curl --silent --show-error --max-time 5 --get \
|
||||
--data-urlencode "volumeID=$VOLUME_ID" \
|
||||
--data-urlencode "cutID=$CUT_ID" \
|
||||
--write-out '\nHTTP %{http_code}\n' \
|
||||
"${STATUS_ADDR%/}/chunk/cut"
|
||||
```
|
||||
|
||||
HTTP 200 with `apiVersion: 1`, the same `cutID` and a valid detach result means the detach completed. Keep the writer stopped, verify the detached HEAD against the holder, epoch and claim recorded before detach, and record its generation and position as in [step 3](../volume-lifecycle.md#planned-hand-over) before continuing. HTTP 202 with `apiVersion: 1`, the same `cutID` and `code: "in_progress"` means it is still running: keep guest I/O stopped and repeat only this read-only GET, not the detach POST.
|
||||
|
||||
HTTP 409 with `apiVersion: 1`, the same `cutID`, `code: "detach_aborted"` and `retryable: true` confirms this abort. The retained handle still occupies the detach slot until about `--timeout` plus 5 s after the abort. After either status or log confirmation, [repeat steps 1 and 2](../volume-lifecycle.md#planned-hand-over) immediately before a retry: require a granted lease for the same holder/epoch and save its current HEAD claim. Wait for that retention to expire before retrying the plain detach; if the retry answers `cut_busy` with reason `detach_in_progress`, wait and retry after expiry. This GET does not start another operation. Handles are transient: HTTP 404 `unknown_cut_id` (including after expiry or a holder restart), a failed query, or an unsettled answer does not confirm an abort. In that case keep guest I/O stopped, preserve the CLI output and holder logs, and follow [Recover an unknown plain detach](../volume-lifecycle.md#recover-an-unknown-plain-detach) before resuming I/O or moving the volume. A repeat may complete the intended final detach only with the guest writer stopped and kept stopped by the operator and authority unchanged; `plain_detach_busy` is not proof of a stopped writer. See the [repeat preconditions](../volume-lifecycle.md#recover-an-unknown-plain-detach). This repeat does not establish what the first attempt did; inspect `ops chunk show` for the resulting seal. A definite retryable CLI answer for this case is planned for v1.1.3.
|
||||
|
||||
## Known issue: `sw-block mini` as a non-root user (fixed in v1.1.2)
|
||||
|
||||
v1.1.2's `mini` keeps the volume lock under `--dir`, needs no `sudo` to start, prints absolute paths, and names the
|
||||
@@ -48,7 +73,7 @@ v1.1.2's `mini` keeps the volume lock under `--dir`, needs no `sudo` to start, p
|
||||
|
||||
- Affects volumes on the walstore engine run by `sw-blockvolume.service`, `sw-blockvolume@.service` or `sw-blockvolume-ublk.service` (`StartLimitBurst=10` in 600 s, `RestartSec=5s`). Chunk-store volumes wait for blockmaster in process and are not affected.
|
||||
- A walstore volume that starts while blockmaster is unreachable exits with 75 after about 10 s and is restarted by systemd. After about 10 attempts (about 150 s) the unit stays failed, even once blockmaster is back.
|
||||
- No data is lost. Recover with `systemctl reset-failed <unit>`, then `systemctl start <unit>`. A fix is planned for v1.1.2.
|
||||
- No data is lost. Recover with `systemctl reset-failed <unit>`, then `systemctl start <unit>`. A fix is planned for a later v1.1.x release.
|
||||
|
||||
## Known issue: startup retirement reads can delay blockmaster
|
||||
|
||||
|
||||
@@ -2,52 +2,149 @@
|
||||
|
||||
v1.1.2 is not yet released.
|
||||
|
||||
## Fixed
|
||||
v1.1.2 is a fix release of the v1.1 line. It changes no stored format. Upgrade in the usual order, the CLI first, then
|
||||
blockmaster, then each holder (see [Upgrade notes](#upgrade-notes)).
|
||||
|
||||
- **Replicated volumes (preview): a queued rebalance no longer undoes an operator failover.** blockmaster's automatic
|
||||
rebalance and failover name the volume's line they were decided against, and blockmaster refuses one when that line
|
||||
moved since (another replica or epoch, or other addresses). A rebalance decided just before `sw-block ops failover`
|
||||
is no longer applied after it. This was a v1.1.1 known issue.
|
||||
## Fixed v1.1.1 known issues
|
||||
|
||||
## Known issue: blockmaster restart can stall on a busy filesystem
|
||||
- **`sw-block mini` as a non-root user.** `mini` now starts as any user with no `sudo` step. It keeps the volume lock
|
||||
under `--dir`. It prints every command with the absolute paths of `sw-block` and `weed`. After a failed start, it
|
||||
prints the `--reuse` command that starts again on the same `--dir`. It no longer takes a scheduled snapshot; take
|
||||
one with the `sw-block ops chunk snapshot` command it prints.
|
||||
- **Restarting blockmaster with many declared volumes**, on a dedicated or lightly written state filesystem. At
|
||||
startup blockmaster now rewrites only the node and placement records whose declaration changed, and keeps the
|
||||
others as stored. A restart with hundreds of unchanged declared volumes no longer runs past the running volumes'
|
||||
leases. A node's stored observation time is kept when its declaration is unchanged, so a restart does not make a
|
||||
silent node look fresh. On a state filesystem with heavy writes, a start can still wait: see
|
||||
[the busy-filesystem known issue](#known-issue-blockmaster-restart-can-stall-on-a-busy-filesystem).
|
||||
- **Startup retirement reads can delay blockmaster.** Retiring the metadata of deleted volumes now runs in the
|
||||
background after blockmaster starts serving, on its own connection, and is paced. A slow filer no longer delays
|
||||
the start, and a retirement outage no longer slows other calls such as a restore.
|
||||
- **Replicated volumes (preview): a queued rebalance can undo an operator failover.** blockmaster's automatic
|
||||
rebalance and failover name the volume line they were decided against. blockmaster refuses one when that line
|
||||
moved since (another replica or epoch, or other addresses). A rebalance decided just before
|
||||
`sw-block ops failover` is no longer applied after it.
|
||||
- **Resuming an interrupted snapshot delete can stop the volume's snapshot deletes and cleaning.** With a filer that
|
||||
enforces the chunk condition (SeaweedFS 4.41 or later) when every writer of the volume runs v1.1.2 (see the known
|
||||
issue below), a snapshot delete no longer publishes an intent whose page lost its data.
|
||||
- Metadata changes (blockvolume's and `sw-block`'s) send the filer's chunk write condition, so a stale change
|
||||
cannot land on an object deleted and created again since it was read.
|
||||
- Publication also re-reads each intent page.
|
||||
- blockvolume and the writing `sw-block` commands check at start whether the filer enforces the condition.
|
||||
- On a filer that does not enforce it, only the re-read protects the delete. That narrows the issue but does not
|
||||
close it: see [the remaining known issue](#known-issue-resuming-an-interrupted-snapshot-delete-can-stop-the-volumes-snapshot-deletes-and-cleaning).
|
||||
- A volume that already shows the v1.1.1 issue still needs the repair planned for a later release.
|
||||
|
||||
- **Trigger:** blockmaster's state filesystem also holds heavy writes, such as the holders' local data.
|
||||
- **Effect:** blockmaster's start syncs its state directories, which can wait for the filesystem journal. When the import has changed records, it also runs a `syncfs` for each store with changed records on ext4, XFS, btrfs or tmpfs (Linux 5.8 or later), which waits for every pending write on that filesystem, including the holders' data. Starts took from about 20 seconds to over 150 seconds in our tests (one start was not ready after 2 minutes); this is not an upper bound. A volume whose lease expires stops serving until blockmaster is back; it is then granted again on the same holder, with its data. A forced move during that time can lose writes after the last published HEAD (see [forced move](../volume-lifecycle.md#after-a-crash)).
|
||||
- **What to do:** In v1.1.2, with the state directory on its own filesystem, blockmaster's start no longer syncs any directory on the shared filesystem. Under one buffered-write load, three starts per case measured shared warm/cold medians of 31.3/122.9 seconds and dedicated medians of 1.6/2.5 seconds, with a dedicated warm maximum of 13.2 seconds. Warm directory fsyncs fell from 30 to 15; shared root-filesystem directory fsyncs fell from 30 to 0. These are measurements under that load, not a start-time promise. Run `sync` after creating and mounting the state filesystem. For a new install, install the units, then mount it and configure its persistent mount and the unit's mount dependency before the first start. Migrating existing state stops service; volumes fence once the downtime outlasts their leases. Stop and disable blockmaster (with v1.1.0 volume units, stop and disable the host's volumes first), copy all state preserving ownership and permissions, verify and sync the copy, then move the unmounted original directory aside (if it is a mount point itself, unmount it, keep that filesystem as the backup, and move the directory it uncovers aside too) and create an empty mount point. Configure the persistent mount and the unit's `RequiresMountsFor` plus `AssertPathIsMountPoint` drop-in, mount the copy, verify its stores and run `sync`. Enable and start blockmaster and confirm that it opens the copied stores and reloads existing records; only then remove the moved original. Never leave stale stores beneath the mount or start against an empty replacement. Follow the [state migration steps](../operations-manual.md#1-install-the-binaries-and-units). Keep holders' data off the state filesystem; a different directory on it is not enough. Restart blockmaster at low write load on the state filesystem, including when the cluster spec has not changed. If device lookup fails, a logged fallback retains the full ancestor walk.
|
||||
## Behaviour changes
|
||||
|
||||
## CLI answer classification
|
||||
### A failover blockmaster decided now completes
|
||||
|
||||
A remote connectivity failure for a request the CLI can prove was never
|
||||
sent exits 75: retry the same command after connectivity recovers. If the request may have reached the
|
||||
server, it exits 3 (`outcome_unknown`): recover the original operation with
|
||||
its request id, or read the current state, before starting anything new.
|
||||
Typed server refusals and the command-specific exceptions below keep their
|
||||
own exits.
|
||||
Before, a failover could stall with no publication in two cases:
|
||||
- a volume whose primary served before blockmaster's first check and then died;
|
||||
- a primary on a node that reads an older format level than the cluster.
|
||||
|
||||
A certificate, trust or name rejection exits 5 only when fresh, complete
|
||||
evidence from this call proves rejection on every attempted endpoint; cached
|
||||
failures or a changed endpoint set cannot establish that proof.
|
||||
A mix of certificate rejection and an unreachable endpoint stays retryable
|
||||
when nothing was sent. An unsent plaintext-client connection failure exits
|
||||
75 with a hint to check the TLS settings. If sending cannot be ruled out,
|
||||
the outcome stays unknown (exit 3). This corrects v1.1.1's unproven terminal
|
||||
exit 5 for that case.
|
||||
Both now reach a publication. blockmaster's log also follows each failover decision with what happened to it
|
||||
(queued, already pending, or not submitted and why) and logs every publication.
|
||||
|
||||
A CA bundle may keep expired or not-yet-valid certificates during rotation
|
||||
as long as one is currently valid. A bundle with none, or an expired client
|
||||
certificate, exits 78.
|
||||
### Format finalize refuses while a serving process has not reported
|
||||
|
||||
Default failure exits are listed below; documented command exceptions follow.
|
||||
`sw-block cluster finalize-format` now refuses with `FORMAT_HOSTS_TOO_OLD` (exit 2) while a volume process that may
|
||||
still serve has not reported reading format level 1. The answer names the host and volume. Upgrade that host's
|
||||
volume process to v1.1.2 and let it report (one heartbeat), or move the volume away, then retry. A volume whose
|
||||
holder released it cleanly, or whose lease has ended, does not block. A placement on a host with an old process still
|
||||
blocks until that process is upgraded or the placement moves.
|
||||
|
||||
| Failure class | Exit | Same-operation action |
|
||||
The finalize judges each volume by the last report blockmaster received. A delayed report can stand in for a newer
|
||||
process, so this operator rule still applies:
|
||||
|
||||
- **Format finalize: operator rule.** From the end of the upgrade until `sw-block cluster finalize-format` completes:
|
||||
- no v1.0.x volume process may run or start on any host. Check it on each host from the running processes
|
||||
(`/proc/<pid>/exe --version`) and the units' binaries, each printing exactly the revision of the v1.1.x binary
|
||||
you installed with `modified=false`, not from blockmaster;
|
||||
- wait 30 seconds after the last volume process start before finalizing.
|
||||
|
||||
The finalize now refuses while a serving volume process reports an older read level. A delayed heartbeat report
|
||||
can still stand in for a newer process, and the rule covers that case. A later release (planned with v1.2)
|
||||
removes the rule. See the
|
||||
operations manual.
|
||||
|
||||
### Persistence faults exit 74
|
||||
|
||||
If blockmaster cannot be sure a write of its lifecycle records reached disk (a put, the startup import, the open
|
||||
barrier), it now exits 74 instead of 1, so that its supervisor restarts it from disk. A finalize that fails after it
|
||||
replaced the format file does the same; one that fails before that reports the error and leaves level 0. Run
|
||||
blockmaster under a restarting supervisor, as the shipped unit does. After blockmaster exits 74 during a finalize,
|
||||
check `sw-block cluster format-level` once it is back, before retrying: it can be 0 or 1.
|
||||
|
||||
### Recovery after an unusable chunk conflict answer
|
||||
|
||||
For snapshot admission and non-plain detach, an unusable HTTP 409 body
|
||||
reports `outcome_unknown` (exit 3); status alone cannot prove non-admission.
|
||||
A snapshot replay must keep the original request ID and parameters, including
|
||||
its absolute expiry; re-running a relative `--expires` changes that value.
|
||||
Non-plain detach provides no request ID or handle: keep the writer stopped
|
||||
and inspect the original holder's HEAD/logs for a confirmed seal or abort;
|
||||
if unproven, preserve diagnostics for investigation. See the
|
||||
[recovery guidance](../operations-manual.md#10-typed-errors-and-what-to-do) for obtaining a
|
||||
published snapshot's expiry. Within the existing command window, retries
|
||||
retain the original request body and ID. Complete typed replies keep their
|
||||
own code and retry flag. The separate cut/plain-detach observer is unchanged.
|
||||
|
||||
### Exit codes: one rule for every command
|
||||
|
||||
Every command now classifies a failure by whether its request may have reached the server:
|
||||
|
||||
| Exit | Meaning | What to do |
|
||||
| --- | --- | --- |
|
||||
| Ordinary definite refusal, or caller cancellation/deadline before sending | 1 | Follow the stated cure or inspect the caller's chosen window before resuming. |
|
||||
| Command syntax or typed server argument refusal | 2 | Correct the arguments before retrying. |
|
||||
| Possibly admitted `outcome_unknown` | 3 | Replay the original key or poll/read; do not start another operation. |
|
||||
| Unproven integrity readout, `readout_unproven` | 4 | Inspect integrity evidence before proceeding; `cut_busy` is a separate documented use of 4 below. |
|
||||
| Certificate, trust or name rejection, `not_authorized` | 5 | Fix authentication/configuration first. A failed status poll still leaves its earlier operation unresolved. |
|
||||
| Proven unsent `remote_unavailable` | 75 | Retry the same operation after connectivity recovers. |
|
||||
| Typed local credential or connection configuration failure | 78 | Fix local files/configuration before dialing. This is distinct from command syntax or a typed server argument refusal. |
|
||||
| 0 | Success | — |
|
||||
| 1 | Ordinary definite refusal, or the caller ended the attempt before sending | Read the answer |
|
||||
| 2 | Usage error, or the server refused an argument | Fix the command |
|
||||
| 3 | `outcome_unknown`: the request may have been admitted | Recover the original operation by its request id, or read the current state, before starting another, except snapshot-delete under `page_reread_only`; see the [known issue](#known-issue-resuming-an-interrupted-snapshot-delete-can-stop-the-volumes-snapshot-deletes-and-cleaning) |
|
||||
| 4 | Integrity readout not proven | Inspect before acting |
|
||||
| 5 | Authentication rejected (certificate, trust, name or role) | Fix the credentials |
|
||||
| 75 | The request was proven not sent, or the server's answer permits a retry | Retry the same operation |
|
||||
| 78 | Local credential or connection configuration is wrong | Fix the local setup |
|
||||
|
||||
Exceptions kept from v1.1.x:
|
||||
- `ops chunk verify` exits 1 for an incomplete answer; 3 there means a completed scan with findings.
|
||||
- `ops failover` exits 3 for an unsent failure or a caller deadline before sending (read the line before another
|
||||
move).
|
||||
- `ops volume create` and `ops volume resolve` keep 75 for a retryable unknown and 78 for definite refusals.
|
||||
- `cluster finalize-format` and `cluster retire-host` keep 2 for their typed preconditions, and exit 1, not 2,
|
||||
for a local usage error (a missing, unknown or extra argument).
|
||||
- A manual cut or plain detach answering `cut_busy` exits 4, a documented use separate from an integrity readout.
|
||||
- `volume restore --abort` exits 1 for any failure, also when the step it ran answered 3 or 75, and 2 when its
|
||||
check refuses the target.
|
||||
|
||||
Changes from v1.1.1 that scripts are most likely to see:
|
||||
|
||||
| Command / failure | v1.1.1 | v1.1.2 |
|
||||
| --- | --- | --- |
|
||||
| Workspace commands: connection never made (refused, DNS, handshake timeout) | 3 | 75 |
|
||||
| Workspace commands: plaintext client at a TLS endpoint (failed preface) | 5 | 75 when nothing was sent, with a hint to check the TLS settings; 3 when sending cannot be ruled out |
|
||||
| Workspace and cluster commands: certificate, trust or name rejection | 3, 1 or 75 | 5 |
|
||||
| Workspace and cluster commands: local credential or configuration error | 2 | 78 |
|
||||
| Cluster commands: request possibly admitted | 75 or 1 | 3 |
|
||||
| `ops chunk`: request possibly admitted, including snapshot polls | 75 | 3 |
|
||||
| `ops chunk`: server error code the CLI does not know | 1 | 3 |
|
||||
| `ops chunk`: server argument refusal (`bad_request`) | 1 | 2 |
|
||||
| `ops chunk detach --plain`: malformed seal result after admission | 1 | 3 |
|
||||
| Snapshot observation: answered "succeeded" without a valid result | 1 | 3 |
|
||||
| `ops chunk` snapshot and non-plain detach: unusable HTTP 409 answer body | 1 | 3 |
|
||||
| `ops chunk`: retryable `not_admitted` outside volume-delete | 1 | 75 |
|
||||
| `ops chunk`, `volume restore`, `ops chunk restore`: authentication rejection | 1 or 2 | 5 |
|
||||
| `volume restore`: typed server refusal | 2 | 1; a server argument refusal (`bad_request`), a placement conflict found by the placement check and a local settings refusal stay 2. `volume backup` refusals stay 2 |
|
||||
| `volume restore`, `volume backup`: ambiguous answer | 1 or 2 | 3, except `volume restore --abort` |
|
||||
| `volume restore`, `volume backup`: request proven not sent | 1 | 75, except `volume restore --abort` |
|
||||
| Any command: caller deadline or cancel before sending | 75 or 3 | 1; an `ops failover` deadline before sending stays 3 |
|
||||
| `ops volume create` / `resolve`: DataLoss | 75 / 78 | 4 |
|
||||
| `ops failover`: DataLoss | 3 | 4 |
|
||||
| `cluster finalize-format` / `retire-host` | 0, 1, 2, 75 | also 3 with `--json` result `unknown` when the request may have been admitted; 5 not authorized; 78 local credential error; 2 with result `failed` for a server argument refusal (a typed precondition is still 2 with `refused`) |
|
||||
|
||||
Every command family and the compatibility exceptions are in the [full inventory](#full-exit-code-inventory)
|
||||
below.
|
||||
|
||||
#### Full exit-code inventory
|
||||
|
||||
The table below compares the shipped v1.1.1 CLI (the compatibility baseline)
|
||||
with this correction. Admission phase is evidence, not the gRPC status name.
|
||||
@@ -80,15 +177,18 @@ second non-idempotent operation after an uncertain answer.
|
||||
| Chunk: caller cancellation/deadline before send | 75 on gRPC/HTTP paths | 1 | Caller ended the attempt. Possible admission instead means UNKNOWN/3. |
|
||||
| Snapshot observation: changed operation ID | 1 | 3 with `outcome_unknown` | Recover the original request id/handle; the mismatched answer does not settle it. |
|
||||
| Snapshot observation: succeeded without a result, at admission or poll | 1 | 3 with `outcome_unknown` | Recover the original request id/handle; the incomplete observation does not settle it. |
|
||||
| Plain detach: malformed seal result | 1 | 3 with `outcome_unknown` | Retry the same plain detach to settle it; the reply does not prove the sealed HEAD. |
|
||||
| Plain detach: malformed seal result | 1 | 3 with `outcome_unknown` | The operator must stop and keep the guest writer stopped, with authority unchanged, a granted lease for the same holder and epoch, and the same HEAD claim recorded before the first attempt. Recheck all prerequisites in the [repeat procedure](../volume-lifecycle.md#recover-an-unknown-plain-detach). Under those conditions, repeat the same plain detach to complete the intended final detach: if already sealed it publishes nothing and answers the sealed HEAD from a fresh read; otherwise it can complete the seal. `plain_detach_busy` is not proof that the writer is stopped. The repeat does not establish what the first attempt did; inspect `ops chunk show` for the resulting seal. |
|
||||
| Snapshot observation: JSON decoder failure | 75 | 3 with `outcome_unknown` | Recover the original operation; malformed data does not settle it. |
|
||||
| Initial HTTP answer: complete malformed or oversized failure body | 1 | 1 / 2 / 3 / 5 | Received 4xx other than 429 retains its auth/argument/refusal class; 429, 5xx, other non-200 answers and an oversized successful/admission answer are UNKNOWN/3. An unreadable body never erases the response status or proves the sent operation failed. |
|
||||
| Snapshot/non-plain-detach initial HTTP answer: unusable listed 4xx body, except 409/429 | 1 | 1 / 2 / 5 | Preserve the received auth/argument/refusal class; do not infer it from a nested transport error. |
|
||||
| Snapshot/non-plain-detach initial HTTP answer: unusable 409/429, 5xx except 501, unlisted HTTP status (including 408/421/423/431/499), other non-200 answer excluding listed 4xx and 501, or oversized success/admission | 1 | 3 with `outcome_unknown` | Snapshot: recover with the original request id and unchanged parameters or an already obtained handle. Non-plain detach has no such identifier: keep the writer stopped and inspect the original holder HEAD/logs for a confirmed seal or abort; unproven outcomes require investigation. An unusable 409 never proves non-admission. |
|
||||
| Snapshot/non-plain-detach initial HTTP answer: unusable 501 body | 1 | 1 with `unsupported` | The server does not implement the operation; use a server that supports it. This status is excluded from the unknown-response row above. |
|
||||
| Cut/plain-detach observer: readable malformed initial 409 or unsupported version | 3 | 3 with `unsupported_api_version`, non-retryable | The observer cannot establish the original outcome. Query a previously printed handle if available; without one, cut may establish a later durable point, while detach requires confirming the original seal or abort from holder HEAD/logs before proceeding. |
|
||||
| Snapshot admission: invalid identity/body or unsafe operation URL | 1 | 3 with `outcome_unknown` | Refuse the unsafe URL and retain the original request id; retry that id against the original status address. |
|
||||
| Snapshot observation: interrupted after admission | 1 | 3 with `outcome_unknown` | Preserve the original request id and handle; resume that operation instead of starting another one. A valid terminal answer still takes precedence. |
|
||||
| Chunk verify: incomplete lost answer | 75 for transport; 1 for other incomplete failure | 1 with JSON `outcome_unknown` | Read-only retry is safe; **3 is reserved for a completed scan with findings**. Proven unsent/retryable remote failure remains 75. |
|
||||
| Chunk verify: authentication/configuration/argument/integrity failure | 1 or 2 | 5 / 78 / 2 / 4 | These exits correspond to authentication, configuration, arguments and integrity respectively. A failed walk may discard prior findings and return no partial result. Final HEAD confirmation failure instead returns the ordinary incomplete result, possibly without a code, and exits 1. No incomplete path uses findings exit 3. |
|
||||
| Chunk blob HTTP failure through layout adapters | usually 1 (or 75 for recognized outage) | 500/503: 3 (verify incomplete: 1); 401/403: 5; 400: 2 | HTTP response facts use the same registry; 404/409 protocol-state handling is unchanged. |
|
||||
| `volume restore`: typed refusal, including placement step | 2 | 1 | Resolve the stated prerequisite; no new restore after an unknown result. |
|
||||
| `volume restore`: typed refusal, including placement step | 2 | 1; 2 for a server argument refusal (`bad_request`), a local settings refusal or a placement conflict found by the placement check | Resolve the stated prerequisite; no new restore after an unknown result. |
|
||||
| `volume restore`: PermissionDenied/Unauthenticated, including placement | 2 | 5 | Fix the caller role/certificate. |
|
||||
| `volume restore` and interrupted backup: ambiguous transport/workflow answer | 1 or 2 | 3 | Keep the original derived request identity and resume/abort instructions. |
|
||||
| `ops chunk restore`: authentication or TLS certificate rejection | 1 or 2 | 5 | Fix role/certificate. |
|
||||
@@ -146,6 +246,191 @@ still exits 2. No authority, lease or cleanup guard is relaxed by this change.
|
||||
For transport evidence, certificate handling and the shared registry's design,
|
||||
see [shared failure policy](../design/answer-classification.md).
|
||||
|
||||
## Lifecycle persistence failures
|
||||
### blockmaster on its own state filesystem
|
||||
|
||||
A blockmaster lifecycle put, import or open-barrier persistence failure exits with durability-unknown status 74 instead of generic status 1. Both immediate termination and the one-second fallback use that status. The best-effort ERROR diagnostic names `lifecycle_persist_failed`. Run blockmaster under supervision so a failed process restarts from durable state; record ordering, recovery barriers and import syncfs selection are unchanged.
|
||||
With blockmaster's state directory on its own filesystem, its start no longer syncs any directory of the shared
|
||||
filesystem above it. Under one buffered-write load, three starts per case gave these medians:
|
||||
|
||||
| State directory | Warm start | Cold start |
|
||||
| --- | --- | --- |
|
||||
| On the shared filesystem | 31.3 s | 122.9 s |
|
||||
| On its own filesystem | 1.6 s (maximum 13.2 s) | 2.5 s |
|
||||
|
||||
These are measurements under that load, not a start-time promise. If blockmaster cannot read a directory's
|
||||
device, it logs that and falls back to syncing every ancestor up to `/`, as before. To move existing state, follow
|
||||
the
|
||||
[state migration steps](../operations-manual.md#1-install-the-binaries-and-units). Migration stops service:
|
||||
volumes fence once blockmaster's downtime outlasts their leases.
|
||||
|
||||
## Known issues
|
||||
|
||||
### Known issue: format finalize still relies on the operator rule
|
||||
|
||||
See [Format finalize](#format-finalize-refuses-while-a-serving-process-has-not-reported): a delayed heartbeat report
|
||||
can stand in for a newer process. A later release (planned with v1.2) carries the process identity on every renewal and removes the rule.
|
||||
|
||||
### Known issue: resuming an interrupted snapshot delete can stop the volume's snapshot deletes and cleaning
|
||||
|
||||
From v1.1.1; fixed only with a SeaweedFS filer that enforces the chunk condition.
|
||||
|
||||
- **Fixed with SeaweedFS 4.41 or later when every writer is v1.1.2 and guarded.** `sw-block` probes the filer
|
||||
before a snapshot delete and prints `chunkstore: metadata change guard: filer_chunk_condition`. It then writes a
|
||||
delete's metadata only while the objects it read are unchanged, so an earlier run's late update cannot leave the
|
||||
broken record. The condition binds only writers that send it, and the volume host's cleaner is one of them.
|
||||
Resuming with the same `--request-id` (and `--gen G`, from the first run's `snapshot-delete NAME@G` line) is safe
|
||||
when:
|
||||
- the volume's holder reports `metadata_guard` `filer_chunk_condition` in `/status/chunk`, as did every holder
|
||||
process of the volume since the first run;
|
||||
- no earlier run of that delete came from a v1.1.1 `sw-block`;
|
||||
- every run, the resume included, printed `filer_chunk_condition`.
|
||||
- **Narrowed with an older filer** (`page_reread_only`). The delete re-reads its page before publishing it, which
|
||||
refuses a page that is already gone. A page whose data the filer is still freeing can pass that check, so the
|
||||
record can still form. Do not resume an interrupted snapshot delete by hand there.
|
||||
- **Recovery:** still none. A volume that already shows the symptom (every snapshot delete answers `layout_busy`, and
|
||||
cleaning has stopped) needs the repair planned for v1.1.3. Its data and other snapshots stay readable.
|
||||
|
||||
### Known issue: deleting a fully overwritten restored volume can leave its source snapshot undeletable
|
||||
|
||||
The delete releases only the sources that the volume's data still references. If every chunk was overwritten, the
|
||||
source snapshot keeps the deleted volume as a dependent, and its delete keeps answering `snapshot_has_dependents`. No
|
||||
data is lost: the snapshot is kept. To release it, run
|
||||
`sw-block ops chunk release --master MASTER --source S --target T --chunk-filer FILER`, where T is the deleted volume.
|
||||
Then run the snapshot delete again with the same request id and `--gen G`, only under the conditions in the operations
|
||||
manual's `no_progress` row: the rerun resumes the interrupted delete.
|
||||
|
||||
### Known issue: blockmaster restart can stall on a busy filesystem
|
||||
|
||||
When blockmaster's state filesystem also holds heavy writes, such as the holders' local data, its start can wait
|
||||
for the filesystem journal. Under one buffered-write load with the state directory on the shared filesystem, warm
|
||||
starts had a median of 31.3 seconds (13.6 to 75.7 seconds over three starts), and cold starts a median of
|
||||
122.9 seconds (120.0 to 124.8 seconds). These are not upper bounds. A volume whose lease expires stops serving until
|
||||
blockmaster is back; it is then granted again on the same holder, with its data. A forced move during that time can
|
||||
lose writes after the last published HEAD (see [forced move](../volume-lifecycle.md#after-a-crash)). Keep the
|
||||
holders' data off blockmaster's state filesystem (see
|
||||
[above](#blockmaster-on-its-own-state-filesystem)). Restart blockmaster at low write load on that filesystem.
|
||||
|
||||
### Known issue: blockmaster needs its filer to start (checkpointed volumes)
|
||||
|
||||
This applies when blockmaster runs with `--workspace-rpc`, the setting checkpointed volumes need. A cluster that
|
||||
serves only replicated volumes can run without it, and blockmaster then opens no filer connection.
|
||||
|
||||
blockmaster checks that its filer answers before it starts. If the filer is unreachable, blockmaster stops with an
|
||||
error after about 60 s. Running volumes stop when their leases run out. Start or fix the filer first.
|
||||
|
||||
### Known issue: a walstore volume unit can reach its systemd start limit while blockmaster is unreachable
|
||||
|
||||
Unchanged from [v1.1.1](v1.1.1.md#known-issue-a-walstore-volume-unit-can-reach-its-systemd-start-limit-while-blockmaster-is-unreachable).
|
||||
Recover with `systemctl reset-failed <unit>`, then `systemctl start <unit>`. A fix is planned for a later v1.1.x
|
||||
release.
|
||||
|
||||
### Known issue: `sw-block ops chunk detach --plain` waits for a scheduled periodic cut
|
||||
|
||||
Unchanged from v1.1.1. No data is lost. A fix is planned for a later v1.1.x release.
|
||||
|
||||
### Known issue: plain detach can abort during a periodic checkpoint
|
||||
|
||||
- **Trigger:** a periodic checkpoint's already-issued HEAD update lands while `sw-block ops chunk detach --plain` is stopping background work.
|
||||
- **Effect:** a confirmed `detach_aborted` means no sealed HEAD was published and serving resumed on the same holder. The CLI can instead report `outcome_unknown` (exit 3); that answer alone proves neither an abort nor resumed guest I/O. If the holder's detach outcome is still unresolved, I/O stays stopped while it settles.
|
||||
- **What to do:** confirm the original handle before treating this as a retryable abort. The holder keeps the handle only for about `--timeout` plus 5 s after the detach ends, and the CLI gives up about that long after its last progress, so query right after the CLI exits, or from a second shell while it still waits. The CLI prints the id (`sw-block ops chunk detach: id <id>` on stderr) only when the detach is still running after `--timeout`; an abort that ends sooner is answered on the detach request itself, with no id. If no id was printed, skip this GET and follow the unresolved-outcome procedure below, keeping guest I/O stopped. On the holder's host, query the same status address and volume used by the detach, with the id printed by the CLI:
|
||||
|
||||
```sh
|
||||
STATUS_ADDR='<status address or URL used by the detach>'
|
||||
case "$STATUS_ADDR" in
|
||||
*://*) ;;
|
||||
*) STATUS_ADDR="http://$STATUS_ADDR" ;;
|
||||
esac
|
||||
VOLUME_ID='<volume-id>'
|
||||
CUT_ID='<id printed by the detach CLI>'
|
||||
curl --silent --show-error --max-time 5 --get \
|
||||
--data-urlencode "volumeID=$VOLUME_ID" \
|
||||
--data-urlencode "cutID=$CUT_ID" \
|
||||
--write-out '\nHTTP %{http_code}\n' \
|
||||
"${STATUS_ADDR%/}/chunk/cut"
|
||||
```
|
||||
|
||||
HTTP 200 with `apiVersion: 1`, the same `cutID` and a valid detach result means the detach completed. Keep the writer stopped, verify the detached HEAD against the holder, epoch and claim recorded before detach, and record its generation and position as in [step 3](../volume-lifecycle.md#planned-hand-over) before continuing. HTTP 202 with `apiVersion: 1`, the same `cutID` and `code: "in_progress"` means it is still running: keep guest I/O stopped and repeat only this read-only GET, not the detach POST.
|
||||
|
||||
HTTP 409 with `apiVersion: 1`, the same `cutID`, `code: "detach_aborted"` and `retryable: true` confirms this abort. The retained handle still occupies the detach slot until about `--timeout` plus 5 s after the abort. After either status or log confirmation, [repeat steps 1 and 2](../volume-lifecycle.md#planned-hand-over) immediately before a retry: require a granted lease for the same holder/epoch and save its current HEAD claim. Wait for that retention to expire before retrying the plain detach; if the retry answers `cut_busy` with reason `detach_in_progress`, wait and retry after expiry. This GET does not start another operation. Handles are transient: HTTP 404 `unknown_cut_id` (including after expiry or a holder restart), a failed query, or an unsettled answer does not confirm an abort. In that case keep guest I/O stopped, preserve the CLI output and holder logs, and follow [Recover an unknown plain detach](../volume-lifecycle.md#recover-an-unknown-plain-detach) before resuming I/O or moving the volume. A repeat may complete the intended final detach only with the guest writer stopped and kept stopped by the operator and authority unchanged; `plain_detach_busy` is not proof of a stopped writer. See the [repeat preconditions](../volume-lifecycle.md#recover-an-unknown-plain-detach). This repeat does not establish what the first attempt did; inspect `ops chunk show` for the resulting seal. A definite retryable CLI answer for this case is planned for v1.1.3.
|
||||
|
||||
### Known issue: SeaweedFS rack or data center outage
|
||||
|
||||
**SeaweedFS rack or data center outage (SeaweedFS releases up to 4.56).** When a SeaweedFS data center or rack is down
|
||||
and the chunk replication cannot be placed, SeaweedFS does not refuse the upload; each upload waits until it times out.
|
||||
|
||||
- **Guest I/O** continues.
|
||||
- **Checkpoints and snapshots** cannot complete:
|
||||
- a cut answers `cut_stalled` (retryable) after its progress window;
|
||||
- a snapshot reports `no_progress`; repeat it with the same `--request-id` after recovery;
|
||||
- nothing partial is published.
|
||||
- **A restore** answers `outcome_unknown` and leaves its target pending; resume it with the same request ID after
|
||||
recovery.
|
||||
- **A plain detach** stops guest I/O while its final cut runs, then answers `cut_stalled` with the text
|
||||
`detach outcome unknown; I/O stays stopped`. Its `--timeout` (120 s by default) is a no-progress window: each
|
||||
completed step renews it. With no upload progress the stop lasts about `--timeout`; with partial progress it can
|
||||
last longer.
|
||||
- That text describes the moment of the answer. Next, the volume host proves that nothing was published, resumes
|
||||
serving and logs `durable: detach of volume=V aborted, nothing published; serving resumed`.
|
||||
- This is a log-confirmed abort, as in [Recover an unknown plain detach](../volume-lifecycle.md#recover-an-unknown-plain-detach).
|
||||
- After the outage, wait for the old handle's retention to expire, repeat steps 1 and 2 and detach again.
|
||||
- If that log line does not appear, for example because the filer is also unreachable, keep the writer stopped and
|
||||
leave the volume host running. It keeps retrying the settlement, and resumes serving or reports the seal once the
|
||||
filer answers.
|
||||
|
||||
Do not start plain detaches or restores during the outage. SeaweedFS releases that carry degraded volume growth
|
||||
complete these operations with fewer copies.
|
||||
|
||||
## Network trust
|
||||
|
||||
**Network trust.** blockmaster's control API authenticates callers with mutual TLS and authorizes them by role
|
||||
(viewer, operator, admin, node) when `--tls-cert`, `--tls-key`, `--tls-client-ca`, `--role-file` and `--audit-log`
|
||||
are all set. The audit log records volume create and delete, failback, workspace binding registration, placement, move and
|
||||
revoke, format finalize and host retirement before they run, and refuses such a call when it cannot record it; other
|
||||
calls by people are recorded after they run, as far as the log allows. Without these flags blockmaster accepts only loopback connections. Nothing else is encrypted, and only
|
||||
the iSCSI target authenticates its clients:
|
||||
- the volume host's status and chunk control HTTP endpoints have no authentication and listen on loopback unless
|
||||
`--allow-external-status-bind` is set, which a volume host that authenticates to blockmaster (`--master-tls-cert`)
|
||||
refuses;
|
||||
- the replication channel between replicas (replicated volumes, preview) has no authentication;
|
||||
- the connection to the SeaweedFS filer and volume servers has no authentication of its own: anyone who can reach
|
||||
the filer can read or change any volume's metadata and chunks, which are stored unencrypted;
|
||||
- the NVMe/TCP target has no authentication and listens on loopback unless `--allow-external-nvme-bind` is set;
|
||||
- the iSCSI target listens off loopback only with `--allow-external-iscsi-bind`, which requires CHAP
|
||||
(`--iscsi-chap-username`, `--iscsi-chap-secret`) for normal sessions; discovery sessions are not authenticated, so
|
||||
any initiator that reaches the port can list the target name and portal; on loopback CHAP is optional; its traffic
|
||||
is not encrypted.
|
||||
|
||||
Run these on a trusted network only, and keep blockmaster's key files, role file and audit log readable only by its
|
||||
service user.
|
||||
|
||||
A CA bundle block that does not parse is skipped without a log line, as in v1.1.1. Each process reads its CA
|
||||
bundle only when it starts; only its own certificate and key are read again at each connection. To rotate a root:
|
||||
1. Check the new root on its own (`openssl x509 -in new-root.pem -noout`).
|
||||
2. Add it to every CA bundle and confirm that each installed bundle lists it (`openssl crl2pkcs7 -nocrl -certfile
|
||||
<bundle> | openssl pkcs7 -print_certs -noout`).
|
||||
3. Restart every process that uses a bundle: blockmaster, each volume host, and the CLI hosts' long-running commands.
|
||||
From now on each trusts both roots.
|
||||
4. Issue each process a certificate from the new root: blockmaster's server certificate and every client certificate
|
||||
(volume hosts and CLI). blockmaster authorizes each client by its certificate's fingerprint in `--role-file`, so
|
||||
before a client uses its new certificate, add the new certificate's fingerprint to the role file with the same role
|
||||
and id, send blockmaster `SIGHUP`, and check that its log says `role file ... reloaded`. Keep the old entries. Each
|
||||
certificate is read again at its next connection. Confirm both directions: every client connects with its new
|
||||
certificate and its role, and verifies blockmaster's new certificate.
|
||||
5. Remove the old root from every bundle, then restart every process again: until it restarts, a process still trusts
|
||||
the old root. Confirm that a connection with a certificate from the old root now fails. Then remove the old
|
||||
certificates' fingerprints from the role file and send blockmaster `SIGHUP`.
|
||||
|
||||
OpenSSL accepts some certificates that sw-block rejects (for example a negative serial number), so the connection
|
||||
checks in steps 4 and 5 are the proof.
|
||||
|
||||
## Upgrade notes
|
||||
|
||||
- **Order:** the CLI first, then blockmaster, then each holder, as in
|
||||
[section 7](../operations-manual.md#7-upgrade-and-finalize-the-v11-format).
|
||||
- **Scripts that check exit codes:** see [Exit codes](#exit-codes-one-rule-for-every-command). The most likely
|
||||
differences are 75 (not 3) for a connection never made, 3 (not 75) for a request that may have been admitted, and
|
||||
5 for an authentication rejection. `ops failover`, `ops volume create` and `ops volume resolve` keep the exceptions
|
||||
listed there (failover 3 for an unsent request; create and resolve 75 for a retryable unknown answer, while a
|
||||
non-retryable typed unknown stays 3, and 78 for a refusal, authentication included).
|
||||
- **Finalize from v1.1.0:** follow the operator rule above until `sw-block cluster finalize-format` completes.
|
||||
- **Supervision:** run blockmaster under a restarting supervisor, so an exit 74 restarts it from disk.
|
||||
- **`mini` users:** the two `sudo install` lines of the v1.1.1 Quick Start are no longer needed.
|
||||
@@ -198,6 +198,7 @@ core/frontend/nvmerdma/target.go providerBackend.Sync context.WithTimeout 1 per-
|
||||
core/frontend/ublk/device_linux.go openWhenPresent time.Now().Add 1 per-call NONE: no model row maps this file yet one ublk device open wait
|
||||
core/frontend/ublk/lifecycle.go settleQueues time.NewTimer 1 per-call NONE: no model row maps this file yet one bounded wait
|
||||
core/frontend/write_budget.go WithWriteBudget context.WithDeadline 1 per-call NONE: no model row maps this file yet one guest write command's budget
|
||||
core/host/master/format_gate.go Host.failUncertainFormatFinalize time.AfterFunc 1 availability-contract FormatGate.Finalize one-second fail-stop fallback independent of a blocked diagnostic sink
|
||||
core/host/master/host.go New http.Server.ReadHeaderTimeout 1 per-call NONE: no model row maps this file yet one HTTP request or connection
|
||||
core/host/master/host.go New http.Server.ReadTimeout 1 per-call NONE: no model row maps this file yet one HTTP request or connection
|
||||
core/host/master/host.go New http.Server.WriteTimeout 1 per-call NONE: no model row maps this file yet one HTTP request or connection
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 50 and column 123.
|
@@ -30,10 +30,14 @@ Snapshots, retention and restore are in
|
||||
|
||||
## The three records, and what each proves
|
||||
|
||||
In the HEAD commands below, `CHUNK_PATH` is the volume's configured
|
||||
`--chunk-path` (`SWB_CHUNK_PATH` with the example unit). Use that same path
|
||||
for the pre-detach record and recovery; do not assume `/swblock/chunks`.
|
||||
|
||||
| Record | How to read it | What it proves |
|
||||
|---|---|---|
|
||||
| The lease | `sw-block ops workspace show --master MASTER --volume v1`: `replica:`, `epoch:`, `lease state:`, `holder: r1@E` | Which holder blockmaster lets serve. `granted`, `revoking` or `expired` is the host validity at query time, not permission to move |
|
||||
| HEAD | `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER`: `head.Gen`, `head.Epoch`, `head.Holder`, `head.ClaimID`, `head.Position`, `head.State`, `head.Current` | The committed image through `Position`. `State` `detached` names the holder's stopped image; there is no separate `detachedBy` field |
|
||||
| HEAD | `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER --chunk-path CHUNK_PATH`: `head.Gen`, `head.Epoch`, `head.Holder`, `head.ClaimID`, `head.Position`, `head.State`, `head.Current` | The committed image through `Position`. `State` `detached` names the holder's stopped image; there is no separate `detachedBy` field |
|
||||
| The ACK | the same `show`: `recorded ACK: r1@E HEAD generation G` | The old holder drained and closed after reading the sealed HEAD G. A clean move needs it |
|
||||
|
||||
`ops chunk show` prints JSON with `volume` and `head` objects. The HEAD view
|
||||
@@ -245,6 +249,18 @@ Copy `replica:` (`R`) and `epoch:` (`E`). `lease state:` must be `granted`.
|
||||
**2. Stop the writer.** Stop the guest or unmount the file system, so that no
|
||||
I/O is in flight. Leave `blockvolume` running: the seal runs inside it.
|
||||
|
||||
Before detach, save the current HEAD:
|
||||
|
||||
```bash
|
||||
sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER --chunk-path CHUNK_PATH
|
||||
```
|
||||
|
||||
Record `head.Holder`, `head.Epoch` and the nonempty `head.ClaimID` (`C`).
|
||||
The HEAD must be live (`head.State` is `""`) and name the holder and epoch
|
||||
read in step 1. If it does not, stop and inspect the changed assignment.
|
||||
Keep this output with the detach's CLI output; it identifies the original
|
||||
claim if the detach's outcome later becomes unknown.
|
||||
|
||||
**3. Seal (plain detach)**, while the lease is granted:
|
||||
|
||||
```bash
|
||||
@@ -254,12 +270,18 @@ sw-block ops chunk detach --plain --volume v1 --status-addr STATUS --timeout 120
|
||||
Exit 0: stdout is JSON with `volumeID`, `cutLSN`, `headGen`, `headEpoch` and
|
||||
`lastWrittenLSN`; stderr has `sealed HEAD generation: G`. Copy `G`. From now on
|
||||
the volume refuses I/O on this host. Do not go on after any other answer (see
|
||||
the table below). Repeating the command is safe: it answers from the sealed
|
||||
HEAD.
|
||||
the table below). After a confirmed successful seal, repeating the command
|
||||
answers from the sealed HEAD. For a malformed seal result, the CLI may say
|
||||
`retry the same plain detach to settle it`: this is allowed to complete the
|
||||
intended final detach only if the operator has stopped and keeps the guest
|
||||
writer stopped and authority is unchanged. It does not establish what the
|
||||
first attempt did; inspect `ops chunk show` for the resulting seal. See
|
||||
[Recover an unknown plain detach](#recover-an-unknown-plain-detach) for the
|
||||
preconditions and the separate read-only investigation of the first outcome.
|
||||
|
||||
To check: `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER` shows
|
||||
To check: `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER --chunk-path CHUNK_PATH` shows
|
||||
`head.State` `detached`, `head.Holder` `s1/R`, `head.Epoch` E, a nonempty
|
||||
`head.ClaimID`, `head.Gen` G and a non-null `head.Current`. Its `head.Position`
|
||||
`head.ClaimID` equal to C, `head.Gen` G and a non-null `head.Current`. Its `head.Position`
|
||||
is the sealed position L; the HEAD itself is the stop proof, with no `detachedBy`.
|
||||
|
||||
**4. Revoke**, giving the generation you copied:
|
||||
@@ -531,7 +553,7 @@ continues. If the no-progress window expires, the answer has `code: remote_unava
|
||||
`retryable: true`, and the progress, blocked object and cause. Already-absent
|
||||
objects count as done. Permanent refusals retain their existing codes.
|
||||
Keep the `--request-id` and use the same one if you have to run the command again.
|
||||
Afterwards `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER` shows
|
||||
Afterwards `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER --chunk-path CHUNK_PATH` shows
|
||||
`head.State` `deleted`. The HEAD view has no `chunkCount` field; use the
|
||||
volume's object listing or verification report to check its remaining objects.
|
||||
|
||||
@@ -604,13 +626,83 @@ A Busy condition that persists beyond the host's retry budget can still become
|
||||
an I/O error and needs diagnosis; readiness observation does not reserve future
|
||||
admission. Permanent and lineage errors are not converted to retryable errors.
|
||||
|
||||
## Recover an unknown plain detach
|
||||
|
||||
Keep the guest or writer stopped and leave the original holder running so it
|
||||
can settle its outstanding HEAD write. Do not revoke, move or restart the
|
||||
holder during this recovery.
|
||||
|
||||
To complete the intended final detach after a malformed seal result, the
|
||||
operator may repeat the same plain detach only while keeping the guest writer
|
||||
stopped throughout and authority unchanged. Before repeating, require the
|
||||
same holder and epoch with a granted lease (step 1) and the same HEAD claim
|
||||
`C` recorded before the first attempt (step 2). `plain_detach_busy` is not
|
||||
proof that the writer is stopped; the operator must stop it independently.
|
||||
If the volume already sealed, the repeat publishes nothing and answers that
|
||||
sealed HEAD from a fresh read; otherwise it can complete the intended seal.
|
||||
A retained handle may first return `cut_busy`; wait for its retention to
|
||||
expire and recheck the preconditions. Check the resulting seal with
|
||||
`ops chunk show` before proceeding to revoke.
|
||||
|
||||
The repeat completes the intended operation but does not establish what the
|
||||
first attempt did. To investigate that original outcome, use the read-only
|
||||
checks below. To prove the first outcome from HEAD, observe it before any
|
||||
repeat; a HEAD read after repeating proves only the resulting final seal.
|
||||
A new detach answer is not evidence of the earlier attempt.
|
||||
|
||||
If the CLI printed a cut id, query that original handle promptly using the
|
||||
[read-only status query](releases/v1.1.1.md#known-issue-plain-detach-can-abort-during-a-periodic-checkpoint).
|
||||
HTTP 200 with version 1, the same `cutID` and a valid detach result means the
|
||||
detach completed: verify the detached HEAD against the original holder,
|
||||
epoch and claim `C` saved in step 2, record its generation and position as in
|
||||
step 3, and then continue the hand-over. HTTP 202 with version 1, the same
|
||||
`cutID` and `code: "in_progress"` means it is still running: keep guest I/O
|
||||
stopped and query that handle again later, without another detach POST.
|
||||
A fast abort may print no id; the CLI has no supported way to look up that
|
||||
expired or unidentified handle. In that case, or if the query fails, preserve
|
||||
the CLI output and the original holder's logs for this attempt and use these
|
||||
read-only checks:
|
||||
|
||||
- Run `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER --chunk-path CHUNK_PATH`.
|
||||
A detached HEAD matching the holder, epoch and claim `C` saved in step 2
|
||||
proves the first attempt sealed only if observed before any repeat. A matching
|
||||
HEAD observed after a repeat proves the intended final seal, not which attempt
|
||||
produced it. Record its generation and position as in step 3 before continuing
|
||||
to revoke.
|
||||
- To confirm an abort, find the original holder's log for this volume and
|
||||
attempt: `durable: detach of volume=v1 aborted, nothing published; serving resumed:`.
|
||||
The provider writes this only after its settlement proved non-publication
|
||||
and it resumed serving. Correlate it with the command's time and the same
|
||||
holder process; an old line or a live HEAD alone is not confirmation. Check
|
||||
`ops workspace show` still names that holder and epoch.
|
||||
|
||||
After either a status-confirmed or log-confirmed abort, wait for the old
|
||||
handle's retention to expire, then immediately before a new detach repeat
|
||||
steps 1 and 2: require `lease state:` `granted` for that same holder and epoch
|
||||
and save its current HEAD claim. Matching holder/epoch with an expired lease
|
||||
is not enough; do not detach while the lease is expired or the assignment
|
||||
has changed. A `cut_busy` answer still means wait, not confirmation.
|
||||
|
||||
If you need to establish the first outcome and neither a matching detached
|
||||
HEAD observed before any repeat, a valid `detach_aborted` status on the original
|
||||
handle, nor an abort log unambiguously correlated with the original attempt
|
||||
is available, keep guest I/O stopped and
|
||||
preserve the diagnostics for operator investigation; this is separate from
|
||||
the conditional intended-final-detach repeat above.
|
||||
If the original claim was not recorded before this attempt, a current HEAD
|
||||
alone cannot establish that it matches the original claim; do not substitute
|
||||
a claim read after the unknown answer.
|
||||
Do not infer the outcome from elapsed time, handle expiry, a live HEAD, or a
|
||||
new detach's answer. The holder retries unresolved settlement while it remains
|
||||
running; restore filer connectivity if its logs say it is waiting for the filer.
|
||||
|
||||
## Symptoms
|
||||
|
||||
| You see | It means | Do |
|
||||
|---|---|---|
|
||||
| `sw-block ops chunk detach: plain_detach_busy: durable: plain detach requires idle frontend I/O` | I/O was in flight; nothing changed | Stop the writer, retry step 3 |
|
||||
| detach answers `detach_aborted` | Nothing was published; the volume serves here again | Retry step 3 |
|
||||
| detach answers `outcome_unknown` | The seal may have landed; I/O stays stopped | Retry step 3: it settles the outcome |
|
||||
| detach answers `detach_aborted` | Nothing was published; the volume serves here again | Wait for the retained handle to expire before a new step 3 attempt; `cut_busy` means wait |
|
||||
| detach answers `outcome_unknown` | The CLI has not established the original outcome; I/O may still be stopped | Keep the writer stopped and follow [Recover an unknown plain detach](#recover-an-unknown-plain-detach); do not retry step 3 as an outcome query |
|
||||
| volume-delete Reserve: `not_admitted` (non-retryable, exit 1): `stop the volume first: ... deletion refused before persistence: ... live until <time>: ...` | A live-holder reservation was refused; nothing was persisted. Waiting alone cannot stop a serving holder renewing its horizon. | "Delete a volume", stop procedure first. If the holder is already stopped, keep it stopped and resume the same request after the printed horizon. |
|
||||
| volume-delete final barrier: `not_admitted` (retryable, exit 75), `retry the same --request-id after <time>` | The reservation is committed and blocks new grants; waiting out the remaining lease is sufficient. | Repeat the same request ID after the printed horizon. |
|
||||
| volume-delete: `snapshot_has_dependents: ... layout: a snapshot has dependents: snapshot "s1" has 1` | A restored volume still depends on that snapshot (ordinary snapshots never refuse a delete: they are deleted with the volume). The delete had already reserved the volume: it does not serve again (`ops workspace show` answers `workspace: volume is being deleted`, exit 1), and nothing was deleted yet (`TestOpsChunkVolumeDeleteRefusedByDependentsLeavesTheVolumeReserved`) | Delete the restored volume, or release its dependence, then run the same volume-delete again with the same `--request-id` ("Delete a volume", step 3) |
|
||||
|
||||