fix(core): include dbPath in corruption log messages

Ensures operators can identify which database has integrity issues
when multiple DB instances are running.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Timothy Laurent
2026-05-03 09:06:39 -07:00
parent 2fce9b13c9
commit 2f96fd34a9

View File

@@ -925,14 +925,14 @@ export class Database {
const integrity = this.integrityCheck(); const integrity = this.integrityCheck();
if (!integrity.ok) { if (!integrity.ok) {
this.corruptionDetected = true; this.corruptionDetected = true;
console.warn("[fusion:db] Database integrity check FAILED — corruption detected"); console.warn(`[fusion:db] Database integrity check FAILED for ${this.dbPath} — corruption detected`);
// Attempt WAL checkpoint recovery // Attempt WAL checkpoint recovery
try { try {
this.db.exec("PRAGMA wal_checkpoint(TRUNCATE)"); this.db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
const recheck = this.integrityCheck(); const recheck = this.integrityCheck();
if (recheck.ok) { if (recheck.ok) {
this.corruptionDetected = false; this.corruptionDetected = false;
console.warn("[fusion:db] Database recovered via WAL checkpoint."); console.warn(`[fusion:db] Database recovered via WAL checkpoint: ${this.dbPath}`);
} else { } else {
console.error( console.error(
`[fusion:db] Database is corrupted and could not be auto-recovered. ` + `[fusion:db] Database is corrupted and could not be auto-recovered. ` +
@@ -941,7 +941,7 @@ export class Database {
} }
} catch { } catch {
console.error( console.error(
"[fusion:db] Database corruption detected and checkpoint recovery failed. " + `[fusion:db] Database corruption detected for ${this.dbPath} and checkpoint recovery failed. ` +
"Manual recovery required.", "Manual recovery required.",
); );
} }