MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / healOversizedWal

Method healOversizedWal

src/db/index.ts:556–567  ·  view source on GitHub ↗

* Shrink a leftover oversized WAL (#1431). A SIGKILL'd session — the #850 * liveness watchdog, OOM, a crash — leaves its WAL on disk, the next session * appends to the same file, and (pre-#1431) nothing ever truncated it: * PASSIVE checkpoints fold frames but keep the file at its high-water

()

Source from the content-addressed store, hash-verified

554 * next open retries rather than a stall.
555 */
556 async healOversizedWal(): Promise<{ healed: boolean; beforeBytes: number; afterBytes: number }> {
557 const beforeBytes = this.getWalSizeBytes();
558 if (beforeBytes <= WAL_HEAL_THRESHOLD_BYTES) {
559 return { healed: false, beforeBytes, afterBytes: beforeBytes };
560 }
561 // Single-flight: open() fires this fire-and-forget and callers may also
562 // invoke it explicitly. Two concurrent passes DEFEAT each other — each
563 // checkpoint worker sees the other as a busy reader and no-ops — so share
564 // one in-flight pass instead of racing.
565 this.walHeal ??= this.runWalHeal(beforeBytes).finally(() => { this.walHeal = null; });
566 return this.walHeal;
567 }
568
569 private walHeal: Promise<{ healed: boolean; beforeBytes: number; afterBytes: number }> | null = null;
570

Callers 2

openMethod · 0.95
wal-heal.test.tsFile · 0.80

Calls 2

getWalSizeBytesMethod · 0.95
runWalHealMethod · 0.95

Tested by

no test coverage detected