diff --git a/seaweed-block/README.md b/seaweed-block/README.md index 38101ef947..57d55419b7 100644 --- a/seaweed-block/README.md +++ b/seaweed-block/README.md @@ -46,7 +46,8 @@ their invariants, the tests behind them and the known issues. - **Incremental snapshots.** A cut uploads only the changed 4 MiB chunks. Chunks are immutable; the volume's state is a HEAD root of about 2 KB, and every publish is a conditional update on `{gen, epoch}`. -- **Cheap snapshot and fork.** Both copy only the HEAD root; chunks are shared. +- **Cheap snapshot and restore.** A snapshot copies only the HEAD root; chunks + are shared. A restore makes a new volume that reads the snapshot's chunks. A two-phase, graced GC reclaims unreferenced chunks. - **Move to any host.** Another host takes over with a higher epoch and fetches chunks lazily on first read. A stale holder cannot publish. @@ -66,7 +67,7 @@ file-backed disk. The two `fsync` rows marked "ublk" come from a later run on the same host with the ublk frontend, after the group-commit fix ([#173](https://github.com/seaweedfs/seaweed-block/pull/173)). Snapshot and fork: a host-side proxy without network latency, guest `fsync` or the block -frontend. +frontend. Fork was measured before it was removed from this release. | Measurement | Seaweed Block | Local disk | |---|---|---| @@ -126,10 +127,8 @@ cluster. The `sw-block ops chunk` commands drive the lifecycle: ```bash sw-block ops chunk cut --volume v1 --status-addr # publish changed chunks, advance HEAD sw-block ops chunk snapshot --volume v1 --status-addr --name s1 # name a snapshot -sw-block ops chunk snapshots --volume v1 --chunk-filer # list snapshots -sw-block ops chunk fork --chunk-filer --source v1 --snapshot s1 --target v2 # root copy only -sw-block ops chunk restore --chunk-filer --source v1 --snapshot s1 --target v3 --status-addr # independent copy -sw-block ops chunk restore --volume v3 --status-addr --status # restore progress +sw-block ops chunk snapshots --master --volume v1 --chunk-filer # list snapshots +sw-block ops chunk restore --master --chunk-filer --source v1 --snapshot s1 --target v3 # new volume from a snapshot sw-block ops chunk detach --volume v1 --status-addr # final cut (seal); moving needs revoke + move, see docs/volume-lifecycle.md sw-block ops chunk volume-delete --volume v2 --chunk-filer --master --request-id del-v2 sw-block ops chunk verify --volume v1 --chunk-filer # read-only check of the remote image @@ -142,12 +141,11 @@ Frozen detach and the pre-copy detach are not supported in this release: a detach with `--frozen` (`frozen:true` on `POST /chunk/detach`) is refused with 409 `frozen_detach_unsupported`, and `blockvolume` refuses to start with `--chunk-detach-precopy`. -`restore` creates the target from the snapshot and, with `--status-addr` naming -the blockvolume that serves the target, starts the background restore there: -the target serves at once, copies every chunk under its own keys and becomes -independent of the source (snapshots of it are refused until then). Without -`--status-addr` it only creates the target and prints the command that starts -the restore once the target is attached. +`restore` creates the target from the snapshot; its blockvolume serves at +once and reads every chunk it has not made local from the source's snapshot +(there is no background copy). The source snapshot cannot be deleted while the +target exists. Fork is not supported in this release; the command is removed. +See [Restoring a snapshot](docs/standalone-deployment.md#restoring-a-snapshot-into-a-new-volume). The chunk path (`walstore-chunk`) is a proof of concept. It is not yet a default, a release claim or a production path. diff --git a/seaweed-block/docs/operator-guide.md b/seaweed-block/docs/operator-guide.md index 6689fed28e..5e86f7be8d 100644 --- a/seaweed-block/docs/operator-guide.md +++ b/seaweed-block/docs/operator-guide.md @@ -117,7 +117,7 @@ named like an admin client's or blockmaster's, but it cannot see a certificate's or recreate the record, then start it. A wrong-size local store left by an earlier release's first start is different: its log repeats `chunk attach check: chunkstore: geometry_mismatch` and it exits; waiting or restarting with the right flags does not help. In one sitting: stop the unit first; then check that the volume never served: - `sw-block ops chunk show --volume --chunk-filer --chunk-path ` prints `"epoch":0` and + `sw-block ops chunk show --master --volume --chunk-filer --chunk-path ` prints `"epoch":0` and `"holder":""` in its head; only then remove `.bin`, `.bin.chunkfresh`, `.bin.chunkmap` and `.replica-floor` from `--durable-root`, and start it with the right flags. If the head shows an epoch above 0 or a holder, do not remove these files; if the volume served before, its local store has its original size: correct the @@ -144,7 +144,7 @@ named like an admin client's or blockmaster's, but it cannot see a certificate's refusal names both numbers), and warns at start when the free space is below its remaining growth plus the WAL; there is no override. The refusal ends the process with status 1 (`blockvolume: durable storage open: ... needs N (size S + WAL W)`), so the shipped unit starts it again every 5 s, refusing each time, until its start limit stops - it; free space on that file system, then start the unit again. A restore or fork target refused this way exists in + it; free space on that file system, then start the unit again. A restore target refused this way exists in the catalog but cannot start, and it can be neither deleted nor moved until it has started once: a delete wants it sealed, revoked and acknowledged, and a forced move is refused because the master knows no holder of it. To recover it, free space on that file system, or start it again on the same host with `--durable-root` on a local @@ -199,10 +199,10 @@ A late upload by a dead holder into a deleted volume can remain; rerun volume-de - scheduled and manual snapshots; - deleting snapshots, and getting space back: - GC deletes the chunks after the grace (`--grace`, 1 hour by default), so a deleted snapshot's space is - reclaimed about 2 hours after the delete unless still referenced by a snapshot, fork or restore; + reclaimed about 2 hours after the delete unless still referenced by a snapshot or a restore target; - then the asynchronous SeaweedFS vacuum compacts the volume files; - `ops chunk verify`; -- forking a snapshot into a new volume that shares immutable objects, or restoring it into a new, independent volume. +- restoring a snapshot into a new volume, which reads the chunks it has not made local from that snapshot (fork is not supported in this release). A snapshot can be refused with `host_slot_busy` / `no background slot` (retryable) while every host slot is held by other volumes' cuts; retry with the same request id. With many volumes on a host, a snapshot may wait for a slot: @@ -290,7 +290,7 @@ Every command on the pages above, and the test that runs it. | `blockvolume` under systemd: exit 75 after an expired start, restart, re-grant | `TestSystemdExpiredStartupExits75ThenRegrantServes` (`cmd/blockvolume`, a real systemd manager, tag `systemd_integration`) | binary | | The shipped units' start limits (`StartLimitIntervalSec=600`, `StartLimitBurst=10`, `RestartPreventExitStatus=78`) | `TestBlockvolumeUnitsBoundStartupRetries` (`internal/testops`, reads the unit files) | unit files | | `systemctl enable`, `stop`, `disable`, `reset-failed`, `systemd-tmpfiles --create` as written on these pages | not run: the tests above start transient units, not the installed ones | not run | -| Headroom refusal at create, and both ways out (free space; `--durable-root` on a file system with room) | `TestHeadroomRefusesARestoreAndAForkTargetThenServesThem`, `TestHeadroomRefusedTargetBlastRadiusAndAnotherRoot`, `TestHeadroomRefusedRestoreTargetSurvivesItsSourceDeleteAndGC` (`cmd/blockvolume`, root, loop-mounted file systems) | binary | +| Headroom refusal at create, and both ways out (free space; `--durable-root` on a file system with room) | `TestHeadroomRefusesRestoreTargetsThenServesThem`, `TestHeadroomRefusedTargetBlastRadiusAndAnotherRoot`, `TestHeadroomRefusedRestoreTargetSurvivesItsSourceDeleteAndGC` (`cmd/blockvolume`, root, loop-mounted file systems) | binary | | A snapshot refused with `host_slot_busy` / `no background slot` while every host slot is held, retried with the same request id | `TestSnapshotLadderF1VolumesOneHost` (`cmd/blockvolume`, `F1_RUN=1`, `F1_HOST_LIMIT_DIR` set, 3 slots; `F1_SLOT_RETRY_SECONDS=0` is its negative control) | binary | | Full local disk; full `--host-limit-dir` | `TestProcedureLocalDiskFull` (`cmd/blockvolume`, root, `testdata/diskfull.sh`); what a Linux guest sees: `TestProcedureLocalDiskFullKernelInitiator` (kernel NVMe/TCP host) | binary | | A first start with the wrong `--durable-blocks`: refused before any local store is created (exit 78) | `TestWrongGeometryFlagIsRefusedBeforeTheStoreIsCreated` (`cmd/blockvolume`) | binary | diff --git a/seaweed-block/docs/standalone-deployment.md b/seaweed-block/docs/standalone-deployment.md index e7056c0b07..34cde612f1 100644 --- a/seaweed-block/docs/standalone-deployment.md +++ b/seaweed-block/docs/standalone-deployment.md @@ -521,7 +521,7 @@ The commands below use these placeholders: - **Status:** `GET STATUS/status/durable?volume=` shows the schedule under `Chunk.ScheduledSnapshot`: `lastOkNs`, `nextDueNs`, `lastFailure`, `skipped` and `snapshot_overdue`. ```bash -sw-block ops chunk snapshots --volume v1 --chunk-filer FILER # list +sw-block ops chunk snapshots --master MASTER --volume v1 --chunk-filer FILER # list sw-block ops chunk snapshot --volume v1 --name before-upgrade --status-addr STATUS # take one now ``` @@ -535,7 +535,7 @@ Space comes back in two steps. Neither is immediate. - A deleted snapshot's unshared chunks are therefore removed by the first pass after the delete. A pass waits while a snapshot is being taken (it is tried again shortly), a cut cancels a pass in progress, and a server that no longer holds the volume removes nothing. A snapshot deleted with `sw-block ops chunk` (not through the holder) is cleaned at the next periodic pass. ```bash - sw-block ops chunk snapshot-delete --volume v1 --name sched-20261120T031204Z --chunk-filer FILER + sw-block ops chunk snapshot-delete --master MASTER --volume v1 --name sched-20261120T031204Z --chunk-filer FILER # the holder's next maintenance pass removes the chunks only it named; # each pass logs "maintenance volume=... removed=N" ``` @@ -585,70 +585,35 @@ therefore see every chunk of every volume and snapshot as unreferenced. - Space is returned only by the two steps above (the holder's cleaning, then a SeaweedFS vacuum). `volume.vacuum` is safe: it compacts needles that were already deleted. -### Forking a snapshot into a new volume +### Fork and template retirement -A fork creates a new volume sharing the snapshot's immutable chunks and segments: +Fork is not supported in this release; the command is removed. Restore from a snapshot instead (below). -```bash -sw-block ops chunk fork --source v1 --snapshot before-upgrade --target v2 --chunk-filer FILER --request-id fork-v2 -``` - -Keep the request id to retry an uncertain result. The new HEAD contains a complete image map; reads do not walk back through parent volumes or snapshots. A fork of a fork preserves the original object owners without adding a backing chain. Deleting the source snapshot does not delete objects still referenced by the fork. Use restore when the target must eventually own its data independently. - -### Retiring the source of a template - -A template is an ordinary immutable snapshot, not a separate volume kind. Keep the volume holding an offered template snapshot: volume deletion refuses while any snapshot name exists. To retire the original source instead, first move the template image into a dedicated holder using existing fork and snapshot operations. - -Prerequisites: `v1` is serving, its only snapshot is `seed`, and the standalone cluster spec has new volume placements for `template-holder` and `consumer`. Neither target blockvolume has started yet. Use the same filer and chunk namespace throughout. - -1. Create the holder: - - ```bash - sw-block ops chunk fork --source v1 --snapshot seed --target template-holder --chunk-filer FILER --request-id fork-template-holder - ``` - -2. Start `template-holder` with the normal standalone blockvolume command and its own volume id, endpoints and local root. Wait for its frontend readiness; read back the seed's known data before proceeding. Take the template snapshot: - - ```bash - sw-block ops chunk snapshot --volume template-holder --status-addr HOLDER_STATUS --name template-v1 - ``` - -3. Create a consumer, start its blockvolume on its own placement and root, and verify its known data: - - ```bash - sw-block ops chunk fork --source template-holder --snapshot template-v1 --target consumer --chunk-filer FILER --request-id fork-consumer - ``` - -4. Stop the source writer. Follow [Delete a volume](volume-lifecycle.md#delete-a-volume) for `v1`: plain detach, revoke its exact replica/epoch/sealed generation, wait for its recorded ACK and natural exit, delete `seed`, then delete `v1`. Do not signal the process in place of waiting for its ACK. Require the completed delete answer and `show` state `deleted` before continuing. - -5. Verify both surviving images, including the holder's template snapshot: - - ```bash - sw-block ops chunk verify --volume template-holder --all-snapshots --depth data --timeout 2m --chunk-filer FILER - sw-block ops chunk verify --volume consumer --all-snapshots --depth data --timeout 2m --chunk-filer FILER - ``` - - Read back the known data again and repeat both verify commands after the holder's next maintenance pass. Each holder cleans only its own volume; the objects of a deleted volume are removed by the volume delete itself. - -Keep `template-holder/template-v1` while it is offered for new consumers. Retiring that snapshot later does not delete objects still referenced by existing consumers. Deleting the holder volume itself still requires the ordinary seal/revoke/ACK and snapshot-deletion procedure; do not remove its backing filer directory or object bindings by hand. +Retiring the source of a template is not supported in this release either: a restore target depends on its source snapshot for its whole life (see [Lifetime](#lifetime-of-a-restore-target)), so the source snapshot, and therefore its volume, cannot be deleted while any target exists. ### Restoring a snapshot into a new volume -A restore makes a new, independent volume from a snapshot. The source volume and its snapshot can be deleted afterwards. +A restore makes a new volume from a snapshot. The new volume reads every chunk it has not made local from the source's snapshot, so the snapshot stays in use for as long as the new volume exists. -1. **Add the target to blockmaster.** Add the target volume (for example `v2`) to blockmaster's topology, and start a blockvolume for it with the same chunk settings (`--chunk-filer`, `--chunk-path`, `--chunk-control-endpoint`) and the source's geometry. -2. **Create the restore and start it:** +1. **Add the target to blockmaster.** Add the target volume (for example `v2`) to blockmaster's topology, with the source's geometry. +2. **Create the restore:** ```bash - sw-block ops chunk restore --source v1 --snapshot sched-20261120T031204Z --target v2 --chunk-filer FILER --status-addr STATUS_OF_V2 + sw-block ops chunk restore --master MASTER --source v1 --snapshot sched-20261120T031204Z --target v2 --chunk-filer FILER --request-id restore-v2 ``` - This creates `v2` from the snapshot (idempotent by `--request-id`; the generated id is printed, so reuse it to retry) and starts the restore driver in v2's blockvolume. - - **Before the target is attached:** run the same command without `--status-addr` to create `v2`. Once its blockvolume is up, run `sw-block ops chunk restore --volume v2 --status-addr STATUS_OF_V2` to start the driver. -3. **v2 serves at once.** It reads chunks it does not hold yet from the source's snapshot. - - Meanwhile the driver fetches every chunk and re-uploads them under v2's own keys. - - It then marks v2 independent: phases `hydrating`, then `owning`, then `independent`. - - Follow it with `sw-block ops chunk restore --volume v2 --status-addr STATUS_OF_V2 --status`. - - Until v2 is independent, a snapshot of v2 is refused (`restore_incomplete`). - - While v2 still fetches chunks, its scheduled snapshots are skipped and counted as `restoring`. After that, until it is independent, they are refused like any snapshot and show as failed attempts with that code. + This creates `v2` from the snapshot and prints one JSON document. It is idempotent by `--request-id` (a generated id is printed when you omit it); reuse it to retry an uncertain result. `--master` is required: it resolves each volume's layout id. +3. **Start v2's blockvolume** with the normal standalone command, its own volume id, endpoints and local root, and the same chunk settings as the source (`--chunk-filer`, `--chunk-path`, `--chunk-control-endpoint`). v2 serves at once. +4. **Reads fill v2.** A block in a chunk that v2 does not hold yet is read from the source's snapshot; the read waits for that chunk, which is then kept locally. There is no background copy: a chunk that is never read stays in the source's snapshot. + - Progress is the volume's count of chunks still absent: `Chunk.Stats.AbsentChunks` in `GET http://STATUS_OF_V2/status/durable?volume=v2` (0 means every chunk is local). + - To make every chunk local, read the whole device once (for example with `dd` to `/dev/null`). + - **A restored volume takes no scheduled snapshot until its whole device has been read once**: while any chunk is absent, each scheduled snapshot is skipped and counted as `restoring`. + - A manual snapshot (`ops chunk snapshot`) is taken in that state too. It names the source's chunks for every chunk v2 has not made local, so, like any snapshot of v2, it cannot be restored (below). +#### Lifetime of a restore target + +- **The source snapshot cannot be deleted** while v2 exists: `ops chunk snapshot-delete` is refused with `snapshot_has_dependents`. Delete v2 first (see [Delete a volume](volume-lifecycle.md#delete-a-volume)); the snapshot can be deleted after that. +- **A snapshot of v2 cannot be restored:** it names the source's chunks, and the restore is refused with `restore_source_not_own`. Restore from the source's snapshot instead. +- **v2's own writes stay in v2:** the source's snapshot never changes. +- **Deleting v2 releases the source snapshot:** `ops chunk volume-delete` of v2 removes it from the snapshot's dependents. +- **`ops chunk release` is a repair step, not part of this procedure.** `sw-block ops chunk release --master MASTER --source v1 --target v2 --chunk-filer FILER` removes a restore target from its source snapshot's dependents. It works only when the target no longer names the source's chunks (it was deleted), or when the target never got its first HEAD (an interrupted restore). In the second case it first tombstones the target's name, so that name can never be created. A live target is refused with `target_live`. diff --git a/seaweed-block/docs/user-capabilities.md b/seaweed-block/docs/user-capabilities.md index 9ce28691e9..a1d72962e3 100644 --- a/seaweed-block/docs/user-capabilities.md +++ b/seaweed-block/docs/user-capabilities.md @@ -5,7 +5,7 @@ does today, which read-only operations commands exist, and what its status vocabulary means. This page covers Kubernetes block volumes. Agent workspace disks (chunk -snapshots, forks and host moves, a proof of concept) are described in the +snapshots, restores and host moves, a proof of concept) are described in the [README](../README.md#agent-workspace-disks-chunk-lifecycle) and the [standalone deployment](standalone-deployment.md) guide. Feature status is in [Kubernetes status](kubernetes-status.md); the exact release evidence is in diff --git a/seaweed-block/docs/volume-lifecycle.md b/seaweed-block/docs/volume-lifecycle.md index 7166736875..92ea113791 100644 --- a/seaweed-block/docs/volume-lifecycle.md +++ b/seaweed-block/docs/volume-lifecycle.md @@ -33,7 +33,7 @@ Snapshots, retention and restore are in | 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 --volume v1 --chunk-filer FILER`: `head.gen`, `head.epoch`, `head.holder`, `head.remoteLSN`, `head.state`, `head.detachedBy` | What any host can start from: every write up to `remoteLSN`. `state` `detached` with `detachedBy` means sealed by that holder | +| HEAD | `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER`: `head.gen`, `head.epoch`, `head.holder`, `head.remoteLSN`, `head.state`, `head.detachedBy` | What any host can start from: every write up to `remoteLSN`. `state` `detached` with `detachedBy` means sealed by that holder | | 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 | `MASTER` is blockmaster's `--listen` address, `FILER` the SeaweedFS filer gRPC @@ -161,10 +161,16 @@ These are rules for the operator. The product does not detect every breach. on a fresh one. - **Never revoke before the seal is confirmed** (see the hand-over steps): a revoke without an ACK cannot be undone on one node. -- **Never restore blockmaster's `--authority-store` or `--lifecycle-store` from a copy.** - They decide who may write each volume. An older copy hands out epochs the volumes have - already passed, and every start is then refused. A lost store needs a recovery +- **Never restore blockmaster's directory from an older copy** (its `--authority-store` + and `--lifecycle-store`). They decide who may write each volume. An older copy can hand + out epochs that were already used; do not do it. A lost store needs a recovery procedure, not a restore. +- **Run exactly one blockmaster per cluster.** It alone issues each volume's epochs and + leases; there is no second or standby blockmaster in this release. +- **A deleted volume's name cannot be created again.** Its record stays, deleted, and a + create under that name is refused. To start over, create the new volume under another + name. (A snapshot name is different: once its delete has finished, the name can be + taken again.) ## Which procedures run end to end @@ -221,7 +227,7 @@ 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. -To check: `sw-block ops chunk show --volume v1 --chunk-filer FILER` shows +To check: `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER` shows `head.state` `detached` and `head.detachedBy` `{"holder":"s1/R","epoch":E,"gen":G}`. **4. Revoke**, giving the generation you copied: @@ -392,8 +398,8 @@ sw-block ops workspace show --master MASTER --volume v1 **3. Delete every snapshot of the volume:** ```bash -sw-block ops chunk snapshots --volume v1 --chunk-filer FILER -sw-block ops chunk snapshot-delete --volume v1 --chunk-filer FILER --name s1 +sw-block ops chunk snapshots --master MASTER --volume v1 --chunk-filer FILER +sw-block ops chunk snapshot-delete --master MASTER --volume v1 --chunk-filer FILER --name s1 ``` Each delete answers `{"volumeID":"v1","name":"s1","state":"deleting"}`. @@ -406,7 +412,7 @@ sw-block ops chunk volume-delete --volume v1 --chunk-filer FILER --master MASTER It answers with `"admitted":true,"committed":true,"headMarked":true,"completed":true`. Keep the `--request-id` and use the same one if you have to run the command again. -Afterwards `sw-block ops chunk show --volume v1 --chunk-filer FILER` shows +Afterwards `sw-block ops chunk show --master MASTER --volume v1 --chunk-filer FILER` shows `"state": "deleted"` and `"chunkCount": 0`. **If you sealed and then stopped `blockvolume` with a signal,** the ACK was skipped @@ -425,7 +431,7 @@ follow from that order: the name does not appear in the list, yet another request for that name is refused with `snapshot_exists`, and deleting the volume is refused with `volume v1 has snapshots (NAME); delete them first`. Free it with - `sw-block ops chunk snapshot-delete --volume v1 --chunk-filer FILER --name NAME`, + `sw-block ops chunk snapshot-delete --master MASTER --volume v1 --chunk-filer FILER --name NAME`, or finish it by repeating the request with the same `--request-id`. - **After `outcome_unknown`, repeat the request with the same `--request-id` within 5 minutes.** Later, the unfinished attempt may have been swept, and the request is