fix(memiavl): bound WAL catch-up waits and latch sync WAL write errors #150
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 328 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #150"
general
weight: 0.35
thomas-nguy
What
memiavl's WAL readers (
TraverseStateChanges,FirstStoreVersions) and the Commit-path snapshot switch share one bounded wait for the WAL to catch up. A failed sync WAL write is now latched like an async writer death.Issue
Commitbumps the version before it writes the WAL. If that write fails, the WAL never reaches the version:async-commit-buffer = -1).MultiTree.SaveVersionalso bumped commit info without a WAL write.Solution
walErris an atomic error, set by the async writer or by a failed sync write (errAsyncWriterQuit,errSyncWALWrite).-
Commitchecks it first, so it fails before saving a new version.- Waiting readers read it without
db.mtxand fail at once.-
walQuitis now just closed when the writer exits.waitForWAL):- It checks the latch before every WAL read.
- It times out after a 5s catch-up timeout. The timeout restarts whenever the WAL advances, so only a stalled WAL times out.
- The snapshot version counts only while the WAL is empty.
- The Commit path keeps its 50ns poll, since it waits under
db.mtx. Readers poll every 1ms with no lock held.- Both readers skip the wait on a read-only DB, whose WAL can't advance.
-
TraverseStateChangeswaits only up to itsendVersion, so an old range doesn't wait on later commits. It skips the wait for a reversed range.- Targets below
initialVersionskip the wait.MultiTree.SaveVersionchecks every tree for uint32 overflow before bumping anything. A failed save no longer leaves commit info, and the trees saved before it, already bumped.- Readers fail on a stalled WAL or a latched error instead of hanging.
-
FirstStoreVersions(nil)returns the latched error.- After a failed sync write,
WaitAsyncCommitandClosereturn it, as in async mode.wal.Logholds the lockLastIndexneeds, so the timeout can't bound it. This was the same on master.WALWaitTestSuitenow covers every WAL wait and WAL error case. It absorbs six older tests (TestWaitCommittedVersion,TestCommitAbortsOnAsyncWALWriteError,TestSnapshotRewriteWaitAbortsOnAsyncWALError). I checked each case by breaking the behavior it names.