spec: G6 write fence rev 4.1 after the branch review, round 1
States the fixes as built: the trip ordered against the finalization's decision (Astra P1); the finalization takes the replica (Astra P2, with the clean-release timing); the fence's own sync once an obligation is over 5 s old, new production-storage behaviour (Fable P2-1, cost in section 6); uncommitted frames covered and residual (b) removed (Fable P2-3); no coverage without L (Fable P2-4). Adds residual (d), the deferred checkpoint write, and the drill's 90 s idle control (Fable P2-2, document-only). Fable P3s: Done() before the marker PUT, residual (c) widened, reconcile as a third HA door. Follow-ups in section 7: Astra P2-3 (deferred by ruling) and two Fable P3s.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+206
−53
docs/superpowers/specs/2026-11-11-g6-write-fence-design.md+206 −53
Intent
diff --git a/docs/superpowers/specs/2026-11-11-g6-write-fence-design.md b/docs/superpowers/specs/2026-11-11-g6-write-fence-design.md| index fdb75b28d..4e409bbc5 100644 |
| --- a/docs/superpowers/specs/2026-11-11-g6-write-fence-design.md |
| +++ b/docs/superpowers/specs/2026-11-11-g6-write-fence-design.md |
| @@ -1,4 +1,4 @@ |
| -# G6 slice 2: the minimal write fence (F-C) (design, rev 4 (fallback A), 2026-11-12) |
| +# G6 slice 2: the minimal write fence (F-C) (design, rev 4.1 (fallback A), 2026-11-12) |
| Parent: region HA spec `2026-10-26-region-ha-without-claims-design.md` |
| (**RHA §n**). Evidence: `~/.cache/region-ha-next/G2-FINDINGS.md` (F-C, F-A) |
| @@ -33,6 +33,32 @@ built on branch `g6-fence` (Tasks 1 to 4). History: |
| instance control are unchanged. No further plan round; the per-task |
| reviews and the whole-branch review are the gate. |
| +**Rev 4.1, 2026-11-12: branch review round 1** (Astra |
| +`CODEX-FINDINGS-G6-FENCE-BRANCH-R1.md`, NOT READY: 1 P1, 2 P2; Fable |
| +`FABLE-FINDINGS-G6-FENCE-BRANCH-R1.md`, READY AFTER FIXES: 4 P2, 5 P3). |
| +Fixed in the build and stated below: |
| +- the fence's event and the finalization's terminal decision are ordered |
| + under one short lock: a fence that marks first poisons the release, and |
| + a fence after the decision does nothing (Astra P1, §3.1 "The trip |
| + against the finalization's decision"); |
| +- the finalization takes the replica from the monitor when it starts, so |
| + a release keeps its own deadline behind a hung upload without waiting |
| + for the fence (Astra P2, §3.1 "The finalization takes the replica"); |
| +- **new production-storage behaviour:** once the oldest obligation is |
| + more than 5 s old, the fence starts its own replica sync each second, so |
| + litestream's retry backoff cannot fence a sub-30 s outage (Fable P2-1, |
| + §3.1 "The fence's own sync", §6); |
| +- frames past the captured end that commit nothing are covered: a long |
| + spilled transaction is not fenced, and residual (b) is gone (Fable |
| + P2-3); |
| +- coverage is not consulted when `DB.Pos` could not be read (Fable P2-4); |
| +- residual (d), litestream's deferred checkpoint write, is stated, and |
| + drill 4's idle control idles more than 90 s before its cut (Fable P2-2, |
| + ruled document-only); |
| +- Fable's P3s: `Done()` timing, residual (c)'s wording, the third HA door |
| + in §3.3, and two follow-ups in §7. Astra P2-3 (a cancelled wake forgets |
| + its refusal) is deferred by ruling and listed in §7. |
| + |
| What rev 4 changes against rev 3.1: §3.1 describes the event, the gate on |
| the replica client (in place of `Replica.Stop`) and the coverage reader; |
| §3.2 drops the slice kill and the root start mark, and states how the |
| @@ -151,7 +177,9 @@ holds writes not yet proven stored, each `{t, txid, known}`: |
| WAL before this capture are in transactions up to `L`). The run's own |
| obligation is appended after this, so a write and its capture in the |
| same run are left to rule C (Fable F2). |
| -- **Rule C, the coverage reader.** On any run whose `stat` succeeded and |
| +- **Rule C, the coverage reader.** On any run whose `stat` succeeded, |
| + whose `L` was read (`DB.Pos` did not fail: an unread `L` is 0, and |
| + "covered at 0" would discharge without proof; Fable branch P2-4) and |
| that still has unknown obligations, `readCoverage` (`fencerun.go`) and |
| `walCovered` (`fence.go`) decide whether the WAL as it is now is all |
| captured, and by which TXID. They never compare file size alone: SQLite |
| @@ -166,11 +194,18 @@ holds writes not yet proven stored, each `{t, txid, known}`: |
| - the WAL header's salts differ from the LTX header's (the WAL restarted |
| since the capture): not covered; |
| - the WAL ends at or before the captured end: covered at `MaxTXID`; |
| - - a frame at the captured end carries the current salts: not covered; |
| - - otherwise the bytes past the captured end are left from before a WAL |
| - restart: covered at `MaxTXID`. |
| - End of file while reading the trailing frame means there is no frame. Any |
| - other open or read error, an unreadable LTX header, or a WAL header |
| + - otherwise the frame headers past the captured end are read in order, |
| + one at a time, at the frame stride the WAL header's page size gives, |
| + never past the `stat`'s size. The first one that is short (end of |
| + file) or carries other salts (left from before a WAL restart) ends the |
| + scan. A frame of this generation whose commit size (bytes 4..7) is not |
| + zero is a transaction not yet captured: not covered. If the scan ends |
| + without one: covered at `MaxTXID`. Frames of this generation that |
| + commit nothing are a spilled transaction still running, or one rolled |
| + back; neither is a write anyone was told is stored (Fable branch |
| + P2-3). The decision is `walCovered`'s, over a sequence of headers; |
| + `readCoverage` only reads them. |
| + Any other open or read error, an unreadable LTX header, or a WAL header |
| shorter than 32 bytes (the file was cut after the `stat`) answers not |
| covered. |
| - Obligations leave from the front only when known and `R >= txid`. |
| @@ -186,10 +221,25 @@ lost write is at most **32 s** old at the fence line (Fable F3). Each run |
| appends at most one obligation and the goroutine ends at the trip, so the |
| queue stays near 32 entries. |
| +**The fence's own sync** (Fable branch P2-1; new production-storage |
| +behaviour in rev 4.1). Litestream's replica monitor waits one tick plus a |
| +doubling backoff (1, 2, 4, 8, 16 s) after each failed sync |
| +(`replica.go:327-394`), so after a 20 s outage of fast-failing requests its |
| +next attempt can come 31 to 36 s after the write, past the fence. The |
| +fence therefore does not leave the retries to litestream: while the |
| +oldest obligation is more than 5 s old (`fenceNudgeAfter`) and `L > R`, |
| +each run starts one `Replica.Sync` if none of its own is still running. |
| +That sync is an ordinary replica call: admitted by the gate (cancelled at |
| +the event or when the finalization takes the replica, refused after), |
| +never the finalization's, and serialized with the monitor's by |
| +litestream's `syncMu`. It adds at most one sync attempt a second per |
| +instance while a write is unstored (§6), and nothing when the store is |
| +healthy (the monitor stores within the first 5 s). |
| + |
| **Trip and the event.** When the queue is non-empty and |
| `now − t_oldest > 30 s` (`fenceLimit`), `tripFence` fires the write-fence |
| event once (`fenceOnce`), whatever the renewer has already latched (plan |
| -P1-2): |
| +P1-2), unless the finalization has already decided (below): |
| 1. `Fenced()` closes; |
| 2. the gate closes (below); |
| 3. the renewer latches `lease.ErrReplicaStale` only if it has nothing |
| @@ -201,6 +251,20 @@ P1-2): |
| The goroutine then returns. If the replicator ended (`Done()`) before a |
| trip it would have fired, nothing fires. |
| +**The trip against the finalization's decision** (Astra branch P1). The |
| +finalization caches one answer (`finishErr`), and the marker's `clean` and |
| +`finalized` follow it. A trip racing it could otherwise land after that |
| +answer was cached and before the marker, so a release would be clean with |
| +the fence fired. The two are ordered under `stateMu`, a short lock held |
| +only to read and set two flags (never across I/O, never `finMu`): |
| +- a trip marks itself (`fenceFired`) before it closes anything or latches |
| + the renewer; a finalization whose decision (`decideFinal`, the last step |
| + before its answer is cached) finds the mark adds `ErrReplicaStale` to |
| + its answer, so that release is unclean and not finalized for good; |
| +- a finalization that decided first (`finalDecided`) makes a later trip a |
| + no-op: no event, no gate, no latch. Its sync succeeded or failed on its |
| + own terms, and its marker stands as it decided. |
| + |
| **The gate on the replica client** (`fenceGate`, `fencegate.go`). Rev 3.1 |
| stopped litestream's replica from the fence goroutine |
| (`Replica.MonitorEnabled = false`, `Replica.Stop(true)`). That is not safe: |
| @@ -218,46 +282,75 @@ the gate: |
| `release.go`), so the release still makes its final sync, and the |
| marker it writes is unclean if that sync fails. |
| +The gate also closes when the finalization takes the replica (below). |
| This is stricter than rev 3.1's F5: after the event, compaction, snapshot |
| and retention calls outside the finalization are refused too. Litestream's |
| own monitor is left running; its calls fail at the gate, and `DB.Close` |
| inside `finalize` still stops and joins it (`db.go:791`). |
| -**A release already waiting unblocks** (G6-1.3, G6-2.3). An ordinary |
| -`finalize` waiting in `SyncAndWait` behind a hung monitor sync |
| -(`release.go:225-235`, litestream `replica.go:134-136`) is freed by the |
| -event: the gate cancels the hung call, the monitor's sync returns, |
| -`finalize` gets `syncMu`, and makes its own attempt under its own release |
| -budget. That attempt passes the gate, fails while the store is down, and |
| -the marker is written `clean: false` because `finishErr` joins the sync |
| -error and `rn.Err()` (`release.go:254`). A failed marker PUT is kept as an |
| -owed release (RHA §5.2). No second finalizer exists, so there is one |
| -finalization owner, as today. Every replica call after the event runs |
| -inside that finalization, before the marker; none follows it. |
| - |
| -**Ending and locks.** `Done()` closes at the **end** of `finalize` (after |
| -the marker) for an HA replicator, and after `store.Close` in a non-HA |
| +**The finalization takes the replica** (G6-1.3, G6-2.3, Astra branch |
| +P2). Litestream's `Replica.Sync` takes `syncMu` without looking at its |
| +context (`replica.go:134-136`), so a `finalize` whose forced sync queued |
| +behind a hung monitor upload would wait for the fence, about 31 s, not for |
| +its own deadline. So the first `finalize`, as it takes ownership, closes |
| +the gate: the monitor's call in flight is cancelled at once, its sync |
| +returns, and every later call outside the finalization is refused. |
| +`finalize` then gets `syncMu` and makes its own attempt under its own |
| +release budget; its calls pass the gate. If the store is down that attempt |
| +fails, and the marker is written `clean: false` because `finishErr` joins |
| +the sync error (`release.go`, `finalize`). A failed marker PUT is kept as |
| +an owed release (RHA §5.2). No second finalizer exists, so there is one |
| +finalization owner, as today, and `DB.Close` still joins every monitor |
| +before the marker. |
| + |
| +For a healthy clean release (G5's held-request handovers depend on it |
| +being fast) the effect is no wait and at most one repeated upload: a |
| +monitor upload in flight is cancelled and the forced sync sends the same |
| +file again, instead of the release waiting for the monitor's upload to |
| +finish. In `TestWriteFenceCleanReleaseStaysCleanAndFast` a release with a |
| +3 s monitor upload in flight took 1 ms and was clean and finalized; with |
| +the gate left open it took 3 s. A cancelled request may still be applied |
| +by S3 after the marker: the exposure `finalize`'s comment already states |
| +for the store's monitor passes (no replicator's marker is settled). |
| + |
| +**Ending and locks.** `Done()` closes at the **end** of `finalize`, when |
| +it returns, before the release writes its marker, for an HA replicator, and after `store.Close` in a non-HA |
| `Close` or `Abandon`. The fence goroutine ends on `Done()`; `finalize` |
| never joins it. While it waits, the goroutine holds none of `rn.mu`, |
| -`finMu` or `syncMu` (it takes `rn.mu` only for the latch in `tripFence`). |
| +`finMu` or `syncMu` (it takes `stateMu` and `rn.mu` only briefly, in |
| +`tripFence`). Its own sync runs in a goroutine of its own that nothing |
| +joins; at most one runs at a time, and the gate bounds it. |
| `DB.Pos` takes only its own cache lock (`db.go:559-561`), so a hung |
| capture cannot block a sample. Closing the gate only cancels contexts. |
| An idle instance has an empty queue, so it is never fenced; its lease |
| -renewal handles an outage as today. A hung upload never raises `R`, so it |
| -trips like an error. |
| +renewal handles an outage as today. The exception is residual (d) |
| +below: litestream's own deferred checkpoint write in the minute after the |
| +last write. A hung upload never raises `R`, so it trips like an error. |
| **Residuals** (stated in code comments, `fence.go` and `fencerun.go`): |
| - (a) A write that lands between a capture's WAL read and the next sample, |
| when that capture finishes after the sample, is resolved by rule A to an |
| `L` that does not contain it. If capture then stalls and no further |
| write arrives, it is not fenced. |
| -- (b) A rolled-back transaction that spilled frames leaves frames past the |
| - captured end with the current salts that no transaction will capture. |
| - If the instance then goes idle, it is fenced spuriously. |
| -- (c) A wake whose first replica sync cannot reach the store within 30 s, |
| - and whose WAL holds frames no LTX file has proven, is fenced even with no |
| - new writes: those frames are obligations from the first look. |
| +- (b) Removed in rev 4.1. A rolled-back or still-running spilled |
| + transaction leaves frames past the captured end that commit nothing; |
| + they now count as covered (rule C). |
| +- (c) A wake whose first replica sync cannot reach the store within 30 s |
| + is fenced even with no new writes when its WAL holds frames no LTX file |
| + has proven (obligations from the first look), and also when it holds |
| + none but litestream has captured anything: `Replica.Pos` is 0 until the |
| + first sync, so `L > R` appends an obligation (Fable branch P3). |
| +- (d) Litestream's deferred checkpoint (`checkpointIfNeeded`, |
| + `db.go:1318-1343`: a PASSIVE checkpoint once a minute, |
| + `CheckpointInterval`'s default, if anything was synced since the last) |
| + writes its `_litestream_seq` row into the WAL (`db.go:2231`) and |
| + captures it. If the store goes out within about a minute of an |
| + instance's last write, that bookkeeping write is an obligation like any |
| + other, and an instance idle since is fenced about 31 s after it, with |
| + nothing of the tenant's unsynced (Fable branch P2-2; ruled |
| + document-only, `CheckpointInterval` unchanged). Such an instance would |
| + lose its lease within about 5 minutes anyway. |
| `ErrReplicaStale` is a new sentinel, distinct from `ErrLost`, so the journal |
| and metrics tell a fence from a lost lease. No caller tests |
| @@ -397,6 +490,12 @@ the stream class: |
| - Moves into an HA region stay refused (N-HA4), so a move cannot land another |
| class on an HA route. HA wake-state import (`hawake.go:838-839`) carries the |
| class it was given, which by the rail above is stream for every new route. |
| +- Provision's reconcile (`internal/provision/reconcile.go:1068-1076`) |
| + marks an existing row HA when its record says so, whatever the row's |
| + class. This is a third accepted door: an HA row reached this way with |
| + another class is unfenced, with lease-loss behaviour as today, and the |
| + flagship check above reads every pool `ha` route's class (Fable branch |
| + P3). |
| ## 4. What changes for the pool, stated plainly |
| @@ -406,8 +505,8 @@ For a stream instance on an HA box: |
| |---|---|---| |
| | Box dies | about 1 s of writes lost (RHA §5.3) | unchanged | |
| | Box loses the store, with writes arriving | every write acknowledged until the next renewal fails: 0 to about 5 min | new requests get 503 with `Retry-After: 10` from the fence line. Lost acknowledged writes are those committed from 32 s before the fence line until the requests in flight at the line finish, and no later than the ordinary stop ends the processes: 30 s after the fence line in the common case, 110 s at the worst bounded case (a sidecar start and a swap in flight). Unacknowledged background writes in that window are discarded at the unclean restore | |
| -| Box loses the store, idle | nothing lost; lease renewal handles it | unchanged | |
| -| Store outage shorter than 30 s | nothing lost | unchanged | |
| +| Box loses the store, idle | nothing lost; lease renewal handles it | unchanged, unless the outage starts within about a minute of the last write: litestream's deferred checkpoint write then fences it about 31 s later, with nothing of the tenant's lost (residual (d)) | |
| +| Store outage shorter than 30 s | nothing lost | unchanged: the fence's own sync (§3.1) stores the write within about a second of the store's return, whatever litestream's backoff | |
| | Store outage longer than 30 s, with writes, no renewal inside it | nothing lost: the sync catches up when the store returns | **the instance refuses new requests and stops through its ordinary stop, and the unsynced tail is lost** when the unclean marker lands and the instance restores from the store: the writes committed from 32 s before the fence line, plus those of requests in flight at it, until the processes end (30 s common, 110 s worst bounded, as above). The local copy is set aside as `<db>.stale` (RHA §5.3), so an operator can still recover it by hand | |
| The last row is the price Paul's ruling accepts: a bounded loss in place of an |
| @@ -416,9 +515,12 @@ its tail over cleanly. |
| A fenced release is always unclean, and never settled or finalized (RHA |
| §5.2, rev 6.7 and 6.8): its finalization fails, because `finishErr` joins |
| -`rn.Err()`, which holds `ErrReplicaStale` or the loss latched before it |
| -(`release.go`, `finalize`), so `ReleaseMarker` clears `Finalized` and every |
| -replicator's marker has `Settled` false. Under main's rule |
| +`rn.Err()`, which holds `ErrReplicaStale` or the loss latched before it, |
| +and the trip's own mark (`decideFinal`, §3.1) if it came first |
| +(`release.go`, `finalize`), so `ReleaseMarker` clears `Clean` and |
| +`Finalized` and every replicator's marker has `Settled` false. A trip |
| +after the finalization decided does nothing, and that release stands as |
| +it decided. Under main's rule |
| (`hafresh.MarkerOpensAt`, `DecideAcquire`) no box, the old holder included, |
| takes the host until a lease term (`LeaseTTL`, 15 minutes) after the |
| marker's `at`. `at` is set when the release writes the marker, after the |
| @@ -458,8 +560,10 @@ Unit tests (no AWS, run under `-run`), with the seam clock. |
| `TestFenceQueueCapturedBeforeFirstSample`, |
| `TestFenceQueueUncapturedBeforeFirstSample` (plan P1-1), |
| `TestFenceQueueOutageUnder30s`, `TestFenceQueueFallingRControl`, |
| - `TestFenceQueueMtimeOnlyChange`; |
| -- `TestWalCovered` (table, salts and the captured end, short headers). |
| + `TestFenceQueueMtimeOnlyChange`, `TestFenceQueueUnreadLNeverDischarges` |
| + (Fable branch P2-4); |
| +- `TestWalCovered` (table: salts and the captured end, short headers, |
| + uncommitted spills, a commit after a spill, stale frames). |
| `internal/lease`, the replicator (`fence_test.go`, `fencegate_test.go`, |
| `fencerun_test.go`), with `SetReplicaClientForTest` and real files: |
| @@ -467,27 +571,45 @@ Unit tests (no AWS, run under `-run`), with the seam clock. |
| only; not for batched, daily or a non-HA lease; |
| - `TestWriteFenceTripsWithFailingUploads`: `Fenced()` closes, |
| `ErrReplicaStale` (not `ErrLost`) latched, permanent; |
| -- `TestWriteFenceFiresAfterAnEarlierLoss` (plan P1-2): with `ErrLost` |
| - latched first, the event still fires, the first error is kept, the hung |
| - call is cancelled and a waiting release returns unclean or owed; |
| +- `TestWriteFenceFiresAfterAnEarlierLoss` (plan P1-2): with a renewal |
| + failure latched first, the event still fires, the first error is kept, |
| + the event alone cancels the hung upload, and a release after it |
| + returns unclean or owed within its budget; |
| - `TestWriteFenceIdleNeverTrips`, `TestWriteFenceNoDatabaseNeverTrips` |
| (no file; frameless WAL), `TestWriteFenceUncapturedAtFirstLook`, |
| `TestWriteFenceCheckpointRestartThenIdle` (WAL restarted with the same |
| size, new salts), `TestWriteFenceShortOutageNoTrip`; |
| -- `TestWriteFenceUnblocksAReleaseAlreadyWaiting` (G6-1.3, G6-2.3): a |
| - `finalize` waiting behind a hung upload returns within its budget after |
| - the event with an owed obligation; `Done()` closed; no replica write |
| - after the first marker attempt, nor after its retries; the |
| - finalization's own sync reached the client once; when the store |
| - recovers, `RetryPending` lands the marker `clean: false` at the |
| - finalization's TXID; |
| +- `TestWriteFenceReleaseKeepsItsDeadlineBehindAHungUpload` (G6-1.3, |
| + G6-2.3, Astra branch P2): a release started behind a hung upload, with |
| + fence time held at step 0, returns within its real 3 s deadline (+1 s) |
| + with no event and an owed obligation; the hung upload was cancelled by |
| + the finalization; `Done()` closed; no replica write after the first |
| + marker attempt, nor after its retries; the finalization's own sync |
| + reached the client; when the store recovers, `RetryPending` lands the |
| + marker `clean: false` at the finalization's TXID; |
| +- `TestWriteFenceCleanReleaseStaysCleanAndFast` (Astra branch P2): a |
| + release with a 3 s monitor upload in flight is clean and finalized at |
| + the local TXID, in well under a second; |
| +- `TestWriteFenceFirstPoisonsTheFinalization` and |
| + `TestWriteFenceAfterTheFinalizationIsANoOp` (Astra branch P1, both |
| + orders, driven by trip hooks): a trip marked first makes a release on a |
| + recovered store unclean and not finalized; a trip after the decision |
| + fires nothing and the release stays clean and finalized; |
| +- `TestWriteFenceRealMonitorShortOutage` (Fable branch P2-1, real 1 s |
| + capture, litestream's own backoff, the real ticker, about 40 s, skipped |
| + under `-short`): a 20 s outage with a write at its start does not fence; |
| + a 40 s one fences 30 to 35 s after the write; |
| +- `TestWriteFenceLongSpillNeverTrips` (Fable branch P2-3): a transaction |
| + that spills into the WAL and stays open for 60 steps on a healthy store |
| + is not fenced, nor after it commits; |
| - `TestWriteFenceEndsWithTheReplicator`: `Close` ends the goroutine; |
| `Fenced()` stays open; |
| - `TestFenceGateRefusesAndCancels`: in-flight calls cancelled at close, |
| later calls refused without reaching the client, the finalization's |
| calls pass, readers and iterators release on `Close`; |
| - `TestReadCoverage`: no read without frames; header and read errors; |
| - a WAL cut short or removed after the `stat`. |
| + a WAL cut short (10, 24, 31 bytes) or removed after the `stat`; a long |
| + uncommitted spill, a spill then a commit, a spill then stale frames. |
| `internal/activator` (`writefence_test.go`, modelled on |
| `haleaseloss_test.go`: `lossTestRep`, `assertLostResponse`): |
| @@ -549,16 +671,26 @@ deploy or sidecar start in the window: |
| takes the lease before then, and none before the marker without a |
| terminate; |
| - the F-A, F-B and F-D rows of the rerun still pass. |
| -3. Two controls in the same window: a 20 s cut with writes (no fence, 0 lost) |
| - and a 2-minute cut with the fixture idle (no fence). |
| +3. Two controls in the same window: a 20 s cut with writes (no fence, 0 lost), |
| + and a 2-minute cut with the fixture idle (no fence) that starts after |
| + the fixture has been idle for more than 90 s, past litestream's |
| + deferred checkpoint (residual (d)). |
| ## 6. Provider boundary and cost |
| Core only. Each second, per awake HA stream instance, the fence reads |
| litestream's in-memory positions and makes one `stat` of the WAL. On a run |
| with an unproven write it also reads local files litestream itself reads: |
| -the WAL header, the 24 bytes at the captured end, and the newest L0 LTX |
| -file's header. It makes no request and adds no S3 cost. It behaves the |
| +the WAL header, the frame headers past the captured end (24 bytes each, |
| +until the first commit frame, a stale frame or the end of the file), and |
| +the newest L0 LTX file's header. Its sampling makes no request. Its own |
| +sync (§3.1, rev 4.1) does: while a captured write is unstored and more |
| +than 5 s old, it runs one replica sync a second, at most one at a time. |
| +On a healthy store this never happens (the monitor stores within a second |
| +or two). During an outage each attempt is the requests litestream's own |
| +sync makes (a LIST when the replica position is unknown, then one PUT per |
| +missing L0 file), so about one more failed attempt a second per writing |
| +instance, and nothing once the store is back and caught up. It behaves the |
| same on MinIO or any S3-compatible store. A store whose uploads fall more |
| than 30 s behind under load would fence spuriously; the drill's 20 s |
| control and the dev metrics show the margin on AWS, and a self-hoster's |
| @@ -570,6 +702,27 @@ Late flush before release (the redesign F-C named), storage fencing (N-HA9), |
| batched and daily classes in a pool, automatic replacement of a box that lost |
| the store (RHA §9.5), and the W5 tolerance question. |
| +Follow-ups from the branch review (round 1), not built here: |
| +- **A cancelled wake forgets the fence's refusal** (Astra P2-3, deferred |
| + by ruling): after a fenced wake's cleanup deletes the entry, a new |
| + request starts an ordinary wake while the store is still out and can |
| + wait up to the wake bound for the ordinary timeout (`Retry-After: 5`, |
| + no `X-Carlos-Holder`) instead of the immediate HA refusal. Same as main |
| + for a wake that fails with the store out; no data risk. Fix: a |
| + host-level refusal that survives the failed wake's removal, cleared |
| + only by a successful recovery. |
| +- **The claims path's recovery probe** (Fable P3): `finishRecoveryProbe` |
| + (`internal/activator/recoveryprobe.go:229`) goes awake without reading |
| + `e.writeFenced`, so an event between `doClaimWake` returning and that |
| + lock leaves the entry awake until the next request stops it. |
| +- **A trip exactly as a clean finalization ends** (Fable P3): it can mark |
| + a stopping entry, and the next request latches an HA loss over a clean |
| + marker (`haleaseloss.go`). It heals itself and needs an unlikely race; |
| + since rev 4.1 a trip after the finalization's decision is a no-op in |
| + the lease, which narrows it further. |
| +- **`markerPutHook`** is a test seam read without a lock, like |
| + `finalSyncHook`. |
| + |
| ## 8. For Paul (stopping rule 2) |
| The outstanding-write age, writer cessation and release cancellation drew |