Skip to content

fix: explicitly checkpoint WAL on shutdown to ensure consolidation#105

Merged
deepjoy merged 2 commits into
mainfrom
close-db-on-exit
Mar 28, 2026
Merged

fix: explicitly checkpoint WAL on shutdown to ensure consolidation#105
deepjoy merged 2 commits into
mainfrom
close-db-on-exit

Conversation

@deepjoy

@deepjoy deepjoy commented Mar 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an explicit PRAGMA wal_checkpoint(TRUNCATE) call before closing the SQLite connection pool during shutdown
  • pool.close() alone only triggers a passive checkpoint, which can leave WAL/SHM files behind after the process exits
  • Downgrade taskmill from 0.7.1 to 0.6.0 to match the API used in the codebase

Why

SQLite WAL mode relies on checkpointing to consolidate write-ahead log data back into the main database file. The default passive checkpoint performed by sqlx::Pool::close() is best-effort and may leave -wal and -shm files on disk after shutdown. Over time (or after unclean exits), this can lead to stale WAL files or unexpected state on restart. A TRUNCATE checkpoint forces full consolidation and removes the WAL file.

Test plan

  • Verify the server shuts down cleanly without leftover -wal/-shm files
  • Confirm existing integration tests pass (cargo test)
  • Verify taskmill 0.6.0 compiles and works correctly with the current task scheduling code

deepjoy added 2 commits March 28, 2026 10:47
pool.close() only triggers a passive checkpoint which can leave WAL
files unconsolidated. Use PRAGMA wal_checkpoint(TRUNCATE) to force
all WAL data back into the main database before closing.
@deepjoy deepjoy merged commit 1f65b91 into main Mar 28, 2026
1 check passed
@deepjoy deepjoy deleted the close-db-on-exit branch March 28, 2026 18:13
@github-actions github-actions Bot mentioned this pull request Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant