Skip to content

fix(db): fail closed when WAL valve cannot checkpoint past caps (#1539) - #1751

Merged
colbymchenry merged 1 commit into
mainfrom
fix/1539-wal-valve-fail-closed
Sep 8, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
fix/1539-wal-valve-fail-closed

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

  • Root cause (code path): sync() armed WalCheckpointValve but never called backpressure(), so the hard/file caps were only enforced on indexAll. Daemon catch-up (with the query pool holding read marks) could therefore grow codegraph.db-wal without a bound — matching the 64 GiB incident on a Linux-kernel-sized repo.
  • Fail-closed: after parked PASSIVE backfills cannot progress while still past the documented hard/file caps, throw WalValveAbortError instead of the old futility latch that disabled parking for 60s and allowed unbounded growth.
  • Wire backpressure into orchestrator.sync (per changed file) and both resolveReferencesBatched call sites in CodeGraph.sync.

Relation to #1583

#1583 also wires sync backpressure (among many other memory/traversal bounds) but is CONFLICTING against main and mixes unrelated changes. This PR is the focused #1539 containment + fail-closed behavior the issue asked for. #1583's memory work remains separately useful and is not superseded.

Test plan

  • npx vitest run __tests__/wal-deferral.test.ts — 24/24 under Node 22 (node:sqlite)
  • New unit tests: abort when checkpoints stay busy over file cap; abort when machinery returns null over cap; soft foldNow under caps does not abort; sync invokes backpressure on changed-file store and orphan resolution
  • tsc --noEmit clean

Refs #1539

sync() armed the WAL valve but never called backpressure(), so daemon
catch-up could grow the WAL without bound while query-pool readers pinned
frames. Wire the writer pause into sync store + batched resolution, and
abort with WalValveAbortError after parked backfills fail past the
documented hard/file caps instead of disabling parking for 60s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant