{"record":{"id":"ce96df1faf058de4","repo":"diegosouzapw/OmniRoute","slug":"db-periodic-wal-truncate-failed","errorCode":null,"errorMessage":"[DB] Periodic WAL truncate failed:","messagePattern":"\\[DB\\] Periodic WAL truncate failed:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/core.ts","lineNumber":1016,"sourceCode":"// file itself; only wal_checkpoint(TRUNCATE) does, and a long-running server never closes its DB.\nfunction startWalTruncateScheduler(db: SqliteDatabase) {\n  clearWalTruncateScheduler();\n  if (isCloud || isBuildPhase || isAutomatedTestProcess()) return;\n\n  const intervalMs = getWalTruncateIntervalMs();\n  if (intervalMs <= 0) return;\n\n  walTruncateTimer = setInterval(() => {\n    try {\n      if (!db.open) return;\n      // TRUNCATE waits for readers; under concurrent write load it can no-op without\n      // shrinking the file. That is expected — it retries on the next tick.\n      if (checkpointDb(db, \"TRUNCATE\")) {\n        console.log(\"[DB] Periodic SQLite WAL checkpoint completed (TRUNCATE).\");\n      }\n    } catch (error: unknown) {\n      const message = error instanceof Error ? error.message : String(error);\n      console.warn(\"[DB] Periodic WAL truncate failed:\", message);\n    }\n  }, intervalMs);\n  walTruncateTimer.unref?.();\n}\n\nexport function runManagedDbHealthCheck(options?: { autoRepair?: boolean }) {\n  const db = getDbInstance();\n  return runDbHealthCheck(db, {\n    autoRepair: options?.autoRepair === true,\n    expectedSchemaVersion: \"1\",\n    createBackupBeforeRepair: () => createHealthCheckBackup(db),\n  });\n}\n\nexport function getDbInstance(): SqliteDatabase {\n  const existing = getDb();\n  if (existing) return existing;\n","sourceCodeStart":998,"sourceCodeEnd":1034,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/core.ts#L998-L1034","documentation":"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.","triggerScenarios":"Thrown at src/lib/db/core.ts:1016 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}