TestPillar3Slice2_EngineDriven_SameLBAArbitration was flaky (on main baca5fd,
-race -count=40: 25/40 failures at -cpu 1, 6/40 at -cpu 2, 1/40 at -cpu 4).
Root cause is a timing assumption in the test, not a product race: with a
12-LBA backlog, base copy and DrainBacklog finish in microseconds and
Sender.Run seals the recovery cut (SealBeforeBarrier) before the test pushes
its same-LBA overwrites. PushLiveWrite then returns ErrSinkBarrierSealed,
the documented 'retain the WAL entry for replay' outcome that production
FeedLiveWrite maps to LiveWriteRetained, and the test treated it as fatal.
Once in a while the whole session also finished inside waitBridgeLiveReady's
1 ms poll gap.
Tolerating the error would defeat the test (the overwrites would never ship
in-session, so convergence could not be checked), and a larger backlog would
only shift the timing. Instead add a test-only hook,
PrimaryBridge.SetPreBarrierHook: each sender runs it after base + backlog
drain and before SealBeforeBarrier. The test installs it before the probe
that starts the rebuild, waits until the sender reaches it (session live,
cut not made), pushes the overwrites, releases, and asserts convergence.
With no hook installed the sender path is unchanged.
The now-unused waitBridgeLiveReady helper in this package is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Retain deletes the exact attempt it planned: the attempt's entry is
marked deleting conditionally and the name record is removed only
while it names that attempt; a replacement is reported as replaced.
- Fork records a hold (forkholds/<name>/<attempt>/<target>) before it
reads the parent. Retain marks first, then reads the holds: a live
hold reverts the mark (fork_held); a fork holding after that read
finds the attempt deleting and refuses before installing anything.
A hold counts while its target has no HEAD and its VOLUME records the
fork, or while it is younger than the operation deadline.
- A pass stopped after a mark finishes (or reverts) it on the next run.
- Log-spaced keeps use rolling windows anchored at now.
- Exclusive bytes resolve "@owner/key" refs and count every volume's
HEAD and live snapshots as holders; documented as eligible for GC
subject to its grace period and intents.
- Retain reports confirmed deletions, the failing snapshot (uncertain
or not) and what it never reached; the CLI prints them with the
error and exits nonzero.
- chunkControl.Snapshot validates the class before any cut;
invalid_class and invalid_policy map to 400.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Controls for the six review findings on retention, failing against
stubs that restore each old behaviour:
- a same-name pinned replacement made after planning is deleted
(retain deletes by name);
- a fork that starts after the scan loses its parent; a stale hold;
a fork after the hold check;
- log-spaced keeps use calendar periods (10:20 and 09:50 both kept
at 10:30 with keep-hourly 1);
- exclusive bytes ignore a fork's "@owner/key" holders;
- a failing pass discards its partial result (catalog and CLI);
- an invalid class cuts before it is refused, and maps to 409.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05's rulings (2026-11-15 22:53Z).
Retention, policy on the VOLUME entry: keep the newest KeepNewest
unpinned snapshots, every pinned snapshot not yet past its ExpiresAtNs,
every snapshot younger than KeepYounger (a future creation time from
clock skew counts as young), the newest snapshot of each of the last
KeepHourly / KeepDaily / KeepWeekly periods, and every snapshot a fork
still needs (named by a fork whose HEAD is absent or aborted). Everything
else is deleted through DeleteSnapshot (attempt-scoped tombstones; HEAD
untouched; names freed); GC reclaims the chunks. Equal creation times
rank by name. Semantic and labeled snapshots are not exempt; a pinned
snapshot past its expiry is unpinned. Defaults: 10 newest, 1h. A dry run
plans and writes nothing. The policy is stored as extended attributes on
the VOLUME entry, conditional on a revision.
Accounting, from manifests and filer listings (no data reads; a chunk is
ChunkBlocks x BlockSize, the last clipped): live bytes from HEAD;
per-snapshot exclusive bytes (referenced by no other holder); stored
bytes from the volume's chunk-key bindings, exact for referenced keys
and a full chunk (an upper bound, flagged) for the rest. The
unreferenced-not-yet-collected bytes come from GC's preview once #140
merges; bytes uploaded since creation need a counter (follow-up).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude05's rulings (2026-11-15 22:53Z): the surfaces and the controls,
with the behavior stubbed (the planner keeps everything, the policy is
not stored, usage reports nothing, no fork needs a parent, the class is
neither validated nor stored).
- chunkstore: snapshot class (semantic / pinned) on the snapshot;
RetentionPolicy stored on the VOLUME entry (extended attributes, CAS on
a revision); planRetention / Retain [dry run]; Usage (live, per-snapshot
exclusive, stored bytes).
- volume: GET /status/chunk?volume= (usage and policy); the snapshot
route carries "class".
- sw-block: ops chunk usage, ops chunk retain [--dry-run | --set-policy
--keep-*], snapshot --class / --pin / --expires.
- controls: policy edges (newest N with name tie-break; pinned never
expired by count or age but unpinned past its expiry; semantic and
labeled snapshots not exempt; younger than T and clock skew; hourly
buckets; fork parent), an agent checkpointing every step stays bounded,
dry run writes nothing, retain keeps N + pinned and frees names, the
policy CAS, class validation, an incomplete fork's parent kept, usage
from manifests; CLI usage/retain; and a real-service test against
SeaweedFS (chunkstore_integration, CHUNKSTORE_WEED): N+5 snapshots plus
pinned ones -> retain leaves N + pinned, accounting follows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Close marks the target closed before its once-only close; a later
Start refuses before creating anything (a Start in progress holds the
target lock, so Close waits for it and then closes its device).
- teardown skips DEL_DEV only when settleQueues reports a queue whose
thread is still running (leaked); a stopped queue's error is reported
and the device is still deleted.
- A FETCH/COMMIT completion that is neither a new request nor the abort
of a stopping device ends the tag and is joined into the queue's error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r3 (6afa34ac), actual-caller controls with the old behaviour kept:
- a Start after Close must refuse (Close before Start consumed the once);
- the Close path (teardownWith, driven with a recording controller) must
delete the device when every queue thread exited, even one that ended
with an error; only a queue whose thread still runs keeps its mappings
and suppresses DEL_DEV;
- a completion that is neither a new request nor the expected abort must
be reported as the queue's error (onCQE, the loop's per-CQE path).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #139 (codex01 AMEND):
1. #133 covers open AND replay. A classifiable EnsureStorage failure now
takes the same fail-closed path as a replay failure: local readiness
blocked (frontend I/O refused), the typed reason recorded through
ReportLocalRecoveryFailure, and the process kept up serving status and
heartbeats, so a primary assignment reports it at once. An open
failure that cannot be classified exits as before.
2. io_error is documented as deliberately broad: the volume's local
storage could not be opened or read at startup. A path error such as
ENOENT, EACCES or EISDIR is io_error too, which says the storage is
unusable, not that the disk is physically damaged. The underlying
error stays in the readiness evidence and is now in the log line.
Refs #133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #139 (codex01 AMEND):
- main's durable open and replay move into openAndRecoverDurable (the
function main now runs), with the open-path behavior unchanged here:
any EnsureStorage failure still exits unreported.
- controls driving that function: a classifiable open failure (EIO path
error; and a real provider whose volume file is truncated, so the magic
read hits io.ErrUnexpectedEOF) must fault fail-closed and report
io_error; an unclassified open failure stays fatal with no report; a
replay failure faults and reports (a real provider's corrupted smartwal
volume reports wal_corrupt); a clean recovery clears the block.
- classifier controls: ENOENT and EACCES path errors are io_error by
contract (local storage unusable, not proof of disk damage); a WAL
integrity fault wrapping a path error stays wal_corrupt.
Refs #133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- No automatic reclaim: Start refuses a /dev/ublkcN already present at
the requested id, with an error naming it, before sending any command
(the device-info read, pid probe and pid-namespace questions are gone).
A device created by another starter between the check and ADD_DEV makes
ADD_DEV itself fail (EEXIST); nothing is deleted. Removing a leftover
device is a documented operator step (package doc).
- Target.Close runs the device close once; every caller, concurrent or
later, gets that result.
- A queue thread's abnormal error, including a failed ring close, is kept
and returned through the shutdown (settleQueues joins it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2 (6afa2fe0): a pre-existing ublk id must be refused with zero
commands of any kind (no automatic reclaim: GET_DEV_INFO + pid probe +
numeric STOP/DEL races a replacement device, and ESRCH across PID
namespaces is no proof of death); concurrent and repeated Target.Close
callers must all get the first close's result; a queue thread's abnormal
error (failed ring, failed ring close) must reach the shutdown result.
The old behaviour fails all four.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The short-submission and no-progress controls each use their own ring; a
call that does not return in time is reported by its own assertion and
its ring is left open, so the stuck goroutine never races the test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#133: when local durable recovery fails with a classifiable error, a
primary-assigned replica reports the typed reason immediately instead
of waiting out --recover-timeout:
- wal_corrupt: storage.RecoveryFailure of kind WALIntegrity (the
substrates' integrity fault, e.g. a WAL/extent CRC mismatch), or the
ErrWALIntegrityFault sentinel;
- io_error: kind SubstrateIO, an fs.PathError, io.ErrUnexpectedEOF or
EIO.
Anything else is not classified: it reports nothing early, and the
watchdog's recovery_timeout still covers it. The master needs no change:
the reason is an explicit unhealthy fact (Eligible=false), shown in
volume status and the timeline, and fails over only to a qualified peer.
Fixes#133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#133 (follow-up to #128 rule 6): wiring with the classifier stubbed,
plus controls.
- volume: UnhealthyWALCorrupt / UnhealthyIOError; LocalRecoveryHealthReason
(stubbed here: classifies nothing); Host.ReportLocalRecoveryFailure
records the classified reason, cleared by ClearLocalReadinessBlock; the
watchdog reports a recorded local failure for a primary-assigned
replica at once (after the G1 latch, before readiness and the timeout).
- blockvolume: a failed durable RecoverVolume calls
ReportLocalRecoveryFailure(recErr) next to BlockLocalReadiness.
- controls: the classifier maps WALIntegrity (typed or the sentinel,
wrapped or not) to wal_corrupt, SubstrateIO / fs.PathError /
io.ErrUnexpectedEOF / EIO to io_error, and anything else (WALRecycled,
untyped) to nothing; the real chain (a corrupted smartwal store ->
durable.Recover -> ReportLocalRecoveryFailure) makes a primary-assigned
replica report wal_corrupt at once, cleared by a clean recovery; a
replica that is not primary-assigned is not flagged; an unclassified
failure reports nothing early and recovery_timeout still covers it.
Refs #133
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The buffer-size control recovers a handler panic into a named failure,
and the short-submission controls bound submitAndWait with a timer, so a
missing buffer check or a lost/unconsumed SQE fails the oracle's own
assertion instead of panicking or hanging until the package timeout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review P1s:
- reclaimStale reads the device's recorded server pid (GET_DEV_INFO) and
deletes the device only if that process no longer exists (signal 0 ->
ESRCH). Owner alive, liveness unknown, never started (no pid) or info
unreadable: Start refuses and sends no STOP/DEL. A reused pid reads as
alive: refused.
- settleQueues waits until one shared deadline and releases only queues
whose thread has exited; a queue still running keeps its mappings
(leaked, fail closed) and Close reports it, and skips DEL_DEV, which
would otherwise wait forever for the char device the mappings hold.
- submitAndWait offers the ring's unconsumed SQEs again after a short
io_uring_enter until the kernel has taken all of them, then waits for
completions; a call that consumes nothing is an error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review P1s, each behind an injectable seam with the old behaviour kept:
- reclaimStale: a device found at our id is deleted only with proof its
server is dead; owner alive, owner unknown, never started, or device
info unreadable must refuse with no STOP/DEL (recording controller).
- settleQueues: a queue that did not stop must keep its mappings (leak,
fail closed), never be unmapped while its thread may run.
- uring.enter: a short io_uring_enter must not lose the unsubmitted SQEs;
a submission the kernel never consumes is an error.
The old behaviour fails all three.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ublk handler counts every received request by kind before the
backend call (reads, writes, FUA writes, flushes, other) and the requests
that completed with an error. blockvolume wires the device as the status
server's ublk source: GET /status/ublk?volume=<id> returns them, as
/status/nvme returns the NVMe target's, so the D0 gate can show every
guest fsync reaching the ublk FLUSH and Backend.Sync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--ublk-device=N (default -1, off) starts a ublk target for the volume
after the other frontends, with the same block and volume size the NVMe
target uses, and reports {"phase":"ublk-ready","device":"/dev/ublkbN"}.
--ublk-queues and --ublk-queue-depth tune it (defaults 1 and 64). Like
iSCSI and NVMe it auto-enables the readiness bridge, so the device serves
only through a healthy projection. The device closes first on shutdown;
a start failure tears down like an NVMe target failure.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- uapi.go: the ublk_cmd.h ABI (ctrl/dev-info/io-desc/io-cmd/params
structs, ioctl-encoded command numbers), checked byte for byte by
uapi_test.go against the kernel header.
- uring_linux.go: a minimal io_uring (SQE128 for URING_CMD), NOP-tested.
- device_linux.go: ADD_DEV (UBLK_F_CMD_IOCTL_ENCODE), SET_PARAMS (basic:
block size, volatile cache + FUA so the block layer sends FLUSH/FUA),
per-queue descriptor mmap and FETCH for every tag, START_DEV; each
queue is served on one locked OS thread (ublk binds a queue to the task
that fetched it) through the request dispatch. Close: STOP_DEV, wait
for the queues, DEL_DEV. A device left at the same id by a dead server
is deleted first; without UBLK_F_USER_RECOVERY a server crash fails
I/O (documented fail-closed limit).
- target.go: TargetConfig/Target opening the volume backend from a
frontend.Provider on first I/O, like the NVMe-RDMA target.
- device_unsupported.go: Start refuses off Linux.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
READ and WRITE go to Backend.Read/Write at start_sector<<9; FLUSH goes to
Backend.Sync; a WRITE with UBLK_IO_F_FUA is synced before it completes.
Any backend error or short transfer completes with -EIO. A range outside
the device, or larger than the request buffer, completes with -EINVAL
before any backend call; every other operation completes -EOPNOTSUPP.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ublk bridge keeps the frontend contract the NBD and NVMe frontends
keep: reads and writes reach the backend at the right offset, FLUSH and
write-FUA reach Backend.Sync, every backend failure completes with -EIO
(never acknowledged), an out-of-range or over-sized request never touches
the backend (-EINVAL), and discard, write-same, write-zeroes and zone
operations are refused (-EOPNOTSUPP). The handler is a stub that fails
every request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>