Skip to content

Commit

Permalink
Force more timely commits from the WAL journal to the SQLite file.
Browse files Browse the repository at this point in the history
We close idle connections in the thread pool after a minute, so that SQLite
actually commits the changes in the WAL journal into the core *.sqlite3 file.
  • Loading branch information
LTLA committed Sep 14, 2024
1 parent 70e1215 commit 091a043
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func initializeDatabase(path string) (*sql.DB, error) {
return nil, fmt.Errorf("failed to create SQLite file at %q; %w", path, err)
}

// Make sure to eventually close all idle connections in the pool so that
// SQLite actually commits its WAL journal.
db.SetConnMaxIdleTime(1 * time.Minute)

if (!accessible) {
err := func () error {
atx, err := createTransaction(db)
Expand Down

0 comments on commit 091a043

Please sign in to comment.