mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 08:49:13 +00:00
feat(sqlite): commit WAL on startup (#684)
* fix(sqlite): increase page_size to 65536 * fix(db): implement WAL commit on startup * revert page_size
This commit is contained in:
parent
ef61331a22
commit
603828be9d
1 changed files with 10 additions and 0 deletions
|
@ -34,6 +34,16 @@ func (db *DB) openSQLite() error {
|
||||||
return errors.Wrap(err, "enable wal")
|
return errors.Wrap(err, "enable wal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When Autobrr does not cleanly shutdown, the WAL will still be present and not committed.
|
||||||
|
// This is a no-op if the WAL is empty, and a commit when the WAL is not to start fresh.
|
||||||
|
// When commits hit 1000, PRAGMA wal_checkpoint(PASSIVE); is invoked which tries its best
|
||||||
|
// to commit from the WAL (and can fail to commit all pending operations).
|
||||||
|
// Forcing a PRAGMA wal_checkpoint(RESTART); in the future on a "quiet period" could be
|
||||||
|
// considered.
|
||||||
|
if _, err = db.handler.Exec(`PRAGMA wal_checkpoint(TRUNCATE);`); err != nil {
|
||||||
|
return errors.Wrap(err, "commit wal")
|
||||||
|
}
|
||||||
|
|
||||||
// Enable foreign key checks. For historical reasons, SQLite does not check
|
// Enable foreign key checks. For historical reasons, SQLite does not check
|
||||||
// foreign key constraints by default. There's some overhead on inserts to
|
// foreign key constraints by default. There's some overhead on inserts to
|
||||||
// verify foreign key integrity, but it's definitely worth it.
|
// verify foreign key integrity, but it's definitely worth it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue