* 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
()
| 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 |
no test coverage detected