Fix M5.7 compaction and failure recovery

This commit is contained in:
dingo
2026-09-26 19:40:16 -04:00
parent 56f533c738
commit a2a12fdc69
6 changed files with 187 additions and 29 deletions
+18 -10
View File
@@ -27,20 +27,27 @@ state silently. No automatic orphan deletion in this gate.
Snapshot checkpoint validates bytes by restoring them under budget before publication.
A journal commit must match the current checkpoint's exact bytes and high-water, and
pass detached replay. Only one journal segment is active per checkpoint; checkpoint
after replay to compact it. Recovery validates the selected manifest and referenced
payloads using M5.6, then replays the optional segment before returning a candidate.
Existing valid manifest stays the source until new publication completes.
pass detached replay. Only one journal segment is active per checkpoint. While one is
published, compaction accepts only the byte-identical canonical snapshot of recovery's
replayed result; command high-water alone cannot prove continuation or prevent a fork.
Recovery validates the selected manifest and referenced payloads using M5.6, then
replays the optional segment before returning a candidate. Existing valid manifest
stays the source until new publication completes. A poisoned handle refuses recovery,
reports no current generation, and requires reopen to resolve an ambiguous publication
error.
Implement the minimal native OS boundary directly: POSIX lock/write/fsync/link/rename/
directory fsync; Windows exclusive CreateFile and write-through replacement. No third
party library. Root directory is trusted and locally administered. Files are not
network-safe/authenticated; FNV detects accidental corruption only.
Provide one-shot failure injection at payload sync, manifest sync, and manifest publish
for deterministic crash-boundary tests. After injected interruption, discard the handle
and reopen. A failure before manifest replacement yields old state; after replacement
yields new state. Allocation/OS errors do not clear dirty state.
Provide one-shot failure injection at payload sync, manifest sync, manifest publish,
partial payload/manifest write (out of space), and post-replacement directory sync for
deterministic crash-boundary tests. Partial-write failures leave only an ignored temp
file and allow retry; injected interruptions poison the handle. After an interruption
or ambiguous sync failure, discard the handle and reopen. A failure before manifest
replacement yields old state; after replacement yields new state. Allocation/OS errors
do not clear dirty state.
## Alternatives Considered
In-place overwrite can destroy the old checkpoint on short write. A single manifest can
@@ -60,6 +67,7 @@ differ. Same-host files do not survive host loss. Fail-closed corruption may req
operator recovery. No production DR/RPO claim.
## Consequences
Test first checkpoint, journal, compaction, restart continuation, competing lock, corrupt
payload/manifest, every injected boundary, missing sequence and full-disk/OS errors.
Test first checkpoint, journal, exact replay compaction, divergent-state rejection,
restart continuation, competing lock, corrupt payload/manifest, every injected boundary,
partial-write recovery, missing sequence and full-disk/OS errors.
Record Linux checks separately. M5.8 performs the whole create/edit/compact/restart proof.