Rune Torgersen
2018-07-25 21:56:10 UTC
We have an application that has multiple sqlite3 databases (30-40) open with exclusive locking.
Every night we do a database backup and a database integrity check.
The backup is done using sqlite3_backup_*. The check is done using a "PRAGMA integrity_check;"
Currently we allow reads/writes while doing both.
Management wants to know if we're doing it correctly, or if there are faster/easier ways to do backup (and check).
Also wants to know if a backup done using the live backup API gives us an exact copy (with any possible corruption) or if the backup is regenerated.
The checks are done to detect some issues we have had with corrupted databases (we think we fixed the issue, but are running the checks to make sure).
The databases have been opened with two connections (one for reads, one for writes), and use the following options:
sqlite3_busy_timeout(mDbConn, 500);
sqlite3_exec(mDbConn, "PRAGMA locking_mode = EXCLUSIVE;", 0, 0, 0);
sqlite3_exec(mDbConn, "PRAGMA synchronous = NORMAL;", 0, 0, 0);
sqlite3_exec(mDbConn, "PRAGMA journal_mode = TRUNCATE;", 0, 0, 0);
sqlite3_busy_timeout(mReadDbConn, 500);
sqlite3_exec(mReadDbConn, "PRAGMA read_uncommitted = 1;", 0, 0, 0);
Thanks,
Rune Torgersen
Innovative Systems LLC.
Every night we do a database backup and a database integrity check.
The backup is done using sqlite3_backup_*. The check is done using a "PRAGMA integrity_check;"
Currently we allow reads/writes while doing both.
Management wants to know if we're doing it correctly, or if there are faster/easier ways to do backup (and check).
Also wants to know if a backup done using the live backup API gives us an exact copy (with any possible corruption) or if the backup is regenerated.
The checks are done to detect some issues we have had with corrupted databases (we think we fixed the issue, but are running the checks to make sure).
The databases have been opened with two connections (one for reads, one for writes), and use the following options:
sqlite3_busy_timeout(mDbConn, 500);
sqlite3_exec(mDbConn, "PRAGMA locking_mode = EXCLUSIVE;", 0, 0, 0);
sqlite3_exec(mDbConn, "PRAGMA synchronous = NORMAL;", 0, 0, 0);
sqlite3_exec(mDbConn, "PRAGMA journal_mode = TRUNCATE;", 0, 0, 0);
sqlite3_busy_timeout(mReadDbConn, 500);
sqlite3_exec(mReadDbConn, "PRAGMA read_uncommitted = 1;", 0, 0, 0);
Thanks,
Rune Torgersen
Innovative Systems LLC.