diegosouzapw/OmniRoute · error
[DB] Periodic WAL truncate failed:
Error message
[DB] Periodic WAL truncate failed:
What it means
The periodic WAL truncate scheduler's wal_checkpoint(TRUNCATE) threw during a tick. Note the code explicitly tolerates a no-op checkpoint under concurrent write load; this warning means the checkpoint call itself errored, and the WAL file may keep growing until a later tick succeeds.
Solutions
- Check for readers/writers holding the WAL (long transactions)
- Verify disk space on the volume holding the -wal file
- Monitor WAL file size; run a manual checkpoint if it keeps growing
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/lib/db/core.ts:1016 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/ce96df1faf058de4.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/db/core.ts:1016
// file itself; only wal_checkpoint(TRUNCATE) does, and a long-running server never closes its DB.
function startWalTruncateScheduler(db: SqliteDatabase) {
clearWalTruncateScheduler();
if (isCloud || isBuildPhase || isAutomatedTestProcess()) return;
const intervalMs = getWalTruncateIntervalMs();
if (intervalMs <= 0) return;
walTruncateTimer = setInterval(() => {
try {
if (!db.open) return;
// TRUNCATE waits for readers; under concurrent write load it can no-op without
// shrinking the file. That is expected — it retries on the next tick.
if (checkpointDb(db, "TRUNCATE")) {
console.log("[DB] Periodic SQLite WAL checkpoint completed (TRUNCATE).");
}
} catch (error: unknown) {
const message = error instanceof Error ? error.message : String(error);
console.warn("[DB] Periodic WAL truncate failed:", message);
}
}, intervalMs);
walTruncateTimer.unref?.();
}
export function runManagedDbHealthCheck(options?: { autoRepair?: boolean }) {
const db = getDbInstance();
return runDbHealthCheck(db, {
autoRepair: options?.autoRepair === true,
expectedSchemaVersion: "1",
createBackupBeforeRepair: () => createHealthCheckBackup(db),
});
}
export function getDbInstance(): SqliteDatabase {
const existing = getDb();
if (existing) return existing;
View on GitHub (pinned to a179ffed5b)