proper closing of sqlite connection
ci/woodpecker/push/e2e Pipeline was successful
ci/woodpecker/push/fmt Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This commit is contained in:
2026-08-07 23:27:49 -04:00
parent a13bc17629
commit ff9f679fcb
2 changed files with 12 additions and 0 deletions
+4
View File
@@ -170,6 +170,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_graceful_shutdown(shutdown_signal()) .with_graceful_shutdown(shutdown_signal())
.await?; .await?;
info!("shutdown complete; closing database"); info!("shutdown complete; closing database");
// Explicitly close the pool so SQLite can checkpoint and remove the
// WAL/SHM sidecar files. Without this, the pool's background close task
// races with process exit and the sidecars can be left behind.
db.close().await;
Ok(()) Ok(())
} }
+8
View File
@@ -74,6 +74,14 @@ impl SqliteDatabase {
} }
impl SqliteDatabase { impl SqliteDatabase {
/// Closes the connection pool, waiting for all connections to be released
/// and closed. This lets SQLite checkpoint and remove the WAL/SHM sidecar
/// files on a clean shutdown; without it, the pool's background close task
/// races with process exit and the sidecars may be left behind.
pub async fn close(&self) {
self.pool.close().await;
}
/// Runs `operation` inside a single transaction, committing on success and /// Runs `operation` inside a single transaction, committing on success and
/// rolling back on error. Multiple repositories can participate in the same /// rolling back on error. Multiple repositories can participate in the same
/// transaction so their writes commit together atomically. /// transaction so their writes commit together atomically.