[SUB] Quarantine an SPDK extent on an uncertain write and keep it quarantined across Complete/Cancel retries
Is your feature request related to a problem?
A timed-out SPDK write is aborted like a confirmed failure: the extent is freed and a later block placed there can be overwritten when the old command lands (#1941). Quarantining the extent is not enough on its own; the Complete/Cancel retry paths must respect it too, or a retry can still finalize unflushed data, free the extent, or report "committed" for a write that never landed.
Describe the solution you'd like
flowchart LR
A["write/flush times out\n(outcome uncertain)"] --> B["1. quarantine\nextent pinned, never served,\nsurvives restart"]
B --> C["2. retry replays the abort\nfailed abort is remembered;\nretry never reaches commit"]
C --> D["3. answer by intent\nclosed handler: Cancel Ok,\nComplete refused"]
| # | Step | Before | After |
|---|---|---|---|
| 1 | Quarantine on uncertain abort | Timed-out SPDK write frees the extent | Extent pinned, block never served or removed, state survives restart; quarantined as soon as the write is known uncertain. Non-SPDK storage unchanged |
| 2 | Remember a failed abort | Retry after a transiently failed abort can finalize unflushed data or free the extent | Retry replays the same abort and returns the original error, never commits; a replica another writer finalized meanwhile is left alone |
| 3 | Answer a closed handler by intent | Any later Complete on a closed handler gets Ok, so an aborted write reads as committed | Cancel is Ok once the abort landed; Complete is refused unless this writer committed; error text stable across retries |
Rule: reserve capacity rather than reuse an extent that may still be written; never finalize unflushed data.
Describe alternatives you've considered
- Free the extent after a grace period: only a real completion bounds the device; release is a separate follow-up.
- Quarantine on every storage type: file and memory have no late-write risk.
- Let a retried Complete take the normal path: the flush context is gone, it would commit whatever is on disk.
- Keep the Ok fast path on a closed handler: that is what records a durable commit for a cancelled rewrite.
Additional context
Worker and storage-local only; the SPDK block record gains a quarantined flag (legacy records still decode), no wire change. The master still sees the block as "writing"; master visibility, replication fence, release and metrics are separate sub-tasks.
- Parent: #1941
Goal
| Sub-requirement | Problem solved |
|---|---|
| Uncertain SPDK write/flush failure quarantines the extent instead of freeing it, durably | Allocator can never reuse an extent while the old command may still land, even across a restart |
| Quarantined block is never served, never removed, and its delete is deferred on the worker | No reader sees possibly corrupted bytes; no path frees the extent by the back door |
| A failed abort is remembered and replayed on every retry, with the original error | A client retry can never finalize unflushed data or free an uncertain extent |
| A retried abort leaves a replica another writer finalized untouched | Shared block ids on non-exclusive leases do not lose a good replica |
| A closed handler answers by intent: Cancel Ok, Complete refused | A client never records a commit for data that was aborted |
Not Goal
- Releasing a quarantined extent (needs a matching terminal proof).
- Quarantine metrics, admission limits, alerts.
- Master-side handling of the quarantined state.
- Replication fence interaction and binding Complete to the opened block.
- Batch write path uncertainty handling.
- Re-persisting an in-memory quarantine whose metadata write failed.
Test Plan
| Test case | Test objective | Modules involved |
|---|---|---|
| SPDK write or flush times out, then Complete or Cancel | Block quarantined, extent not reused, state restored after restart | dataset, SPDK metadata, write handler |
| Same on file or memory storage | Plain abort, behaviour unchanged | dataset |
| Legacy on-disk block record | Still decodes, quarantined defaults to false | SPDK metadata |
| Abort or removal of an already quarantined block | Abort is a no-op, removal refused, heartbeat parks the delete once | dataset, heartbeat |
| Quarantine persist failure | In-memory state kept, error propagated, retry stays possible | dataset, write handler |
| Complete/Cancel fails and the abort fails transiently, client retries | Same abort replayed, original error returned, never commits | write handler, block store |
| Another writer finalizes the block between a failed abort and its retry | Retried abort is a no-op, finalized replica intact | write handler, block store |
| Cancel replay whose abort lands; Complete after a Cancel or after an abort; Complete after a rewrite whose flush failed | Cancel Ok, Complete refused, error text stable across retries | write handler |
| Client cancel path re-calling complete on a durable rewrite | No durable commit recorded | client, write handler |
Full worker and storage-local suites, with and without --features spdk |
No regression | all |
Dependencies
- Detector (uncertain vs confirmed SPDK failure): #1944, merged.
- Step 1: #1945. Step 2: #1969, stacked on #1945. Step 3: #1999, stacked on #1969. Together stack #1946.
- Follow-up sub-tasks: #2011 (replication abort respects quarantine), #2014 (master-visible quarantine).