Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/metadata/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,14 @@ impl MetadataStore {

/// Gracefully close the metadata store, flushing WAL to the main database.
pub async fn close(&self) {
// Explicitly checkpoint and truncate the WAL before closing.
// pool.close() alone only passively checkpoints which may leave WAL files behind.
if let Err(e) = sqlx::query("PRAGMA wal_checkpoint(TRUNCATE)")
.execute(&self.pool)
.await
{
tracing::warn!("WAL checkpoint failed during shutdown: {e}");
}
self.pool.close().await;
}

Expand Down
Loading