Skip to content

Commit 5f3d1e7

Browse files
committed
content-sqlite: set quick_check pragma
Problem: if database is corrupt, content-sqlite may load successfully then fail a load/store request, resulting in secondary failures such as a KVS module load failure, and content-flush hang in rc3. Add the sqlite "quick_check" pragma which detects a corrupt database during module initialization. Fixes #4338
1 parent 23aa624 commit 5f3d1e7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/modules/content-sqlite/content-sqlite.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,14 @@ static int content_sqlite_opendb (struct content_sqlite *ctx, bool truncate)
640640
log_sqlite_error (ctx, "setting sqlite 'locking_mode' pragma");
641641
goto error;
642642
}
643+
if (sqlite3_exec (ctx->db,
644+
"PRAGMA quick_check",
645+
NULL,
646+
NULL,
647+
NULL) != SQLITE_OK) {
648+
log_sqlite_error (ctx, "setting sqlite 'quick_check' pragma");
649+
goto error;
650+
}
643651
if (sqlite3_exec (ctx->db,
644652
sql_create_table,
645653
NULL,

0 commit comments

Comments
 (0)