Skip to content

fix(db): pause call-log rotate on SQLITE_CORRUPT - #10979

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
RaviTharuma:fix/10736-corrupt-rotate-fence
Aug 21, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.50from
RaviTharuma:fix/10736-corrupt-rotate-fence

Conversation

@RaviTharuma

Copy link
Copy Markdown
Contributor

Summary

  • On SQLITE_CORRUPT / malformed pager / SQLITE_IOERR during call-log rotation, pause further rotate writes instead of retrying DELETEs against a broken file.
  • Record the failure so /api/db/health reports integrity_check_failed (Pager reported SQLITE_CORRUPT during call-log-rotate: …).
  • Ordinary filesystem errors still log and do not pause rotation.

Does not auto-REINDEX. That remains unsafe on a live single-writer file.

Related Issues

Validation

  • Change type: DB
  • Focused tests: node --import tsx/esm --test tests/unit/call-log-rotate-corrupt.test.ts (4/4)
  • tests/unit/call-log-file-rotation.test.ts swallow-filesystem case still passes
  • npm run lint (CI)
  • Branched from origin/release/v3.8.50 (266e39d36)
  • New automated test in this PR

Tests Added Or Updated

  • tests/unit/call-log-rotate-corrupt.test.ts

Coverage Notes

  • src/lib/db/healthCheck.ts pager-note helpers + src/lib/usage/callLogRotation.ts fence covered by the new file.
  • One existing orphan-cleanup assertion in call-log-file-rotation.test.ts failed on this machine because better-sqlite3 is built for NODE_MODULE_VERSION 137 vs local 147 (sql.js fallback). Unrelated to this fence; CI image has a matching native module.

Reviewer Notes

rotateCallLogs swallowed pager corruption and kept retrying DELETEs
against a malformed SQLite file while /healthz stayed 200. On
SQLITE_CORRUPT / malformed / SQLITE_IOERR, pause further rotate
writes and record the failure for /api/db/health.

Does not auto-REINDEX. Closes the fail-closed gap in #10736.
@diegosouzapw
diegosouzapw merged commit fefca17 into diegosouzapw:release/v3.8.50 Aug 21, 2026
7 of 16 checks passed
Sa3id23 pushed a commit to Sa3id23/OmniRoute that referenced this pull request Aug 21, 2026
⭐5 — Em SQLITE_CORRUPT/pager malformado durante rotação de call-log, pausa novas rotações em vez de retry de DELETE contra arquivo quebrado; /api/db/health reporta integrity_check_failed. Não faz REINDEX automático (inseguro em single-writer live). 4/4 testes novos + suíte irmã verde. Fecha o gap de diegosouzapw#10736.
AndrianBalanescu pushed a commit to AndrianBalanescu/OmniRoute that referenced this pull request Aug 21, 2026
⭐5 — Em SQLITE_CORRUPT/pager malformado durante rotação de call-log, pausa novas rotações em vez de retry de DELETE contra arquivo quebrado; /api/db/health reporta integrity_check_failed. Não faz REINDEX automático (inseguro em single-writer live). 4/4 testes novos + suíte irmã verde. Fecha o gap de diegosouzapw#10736.
AndrianBalanescu pushed a commit to AndrianBalanescu/OmniRoute that referenced this pull request Aug 28, 2026
⭐5 — Em SQLITE_CORRUPT/pager malformado durante rotação de call-log, pausa novas rotações em vez de retry de DELETE contra arquivo quebrado; /api/db/health reporta integrity_check_failed. Não faz REINDEX automático (inseguro em single-writer live). 4/4 testes novos + suíte irmã verde. Fecha o gap de diegosouzapw#10736.
@RaviTharuma
RaviTharuma deleted the fix/10736-corrupt-rotate-fence branch September 23, 2026 19:37
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
⭐5 — Em SQLITE_CORRUPT/pager malformado durante rotação de call-log, pausa novas rotações em vez de retry de DELETE contra arquivo quebrado; /api/db/health reporta integrity_check_failed. Não faz REINDEX automático (inseguro em single-writer live). 4/4 testes novos + suíte irmã verde. Fecha o gap de diegosouzapw#10736.
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.

2 participants