On 11/30/2012 12:04 AM, Simon Slavin wrote:
I have a folder with 17 independent databases in, each of them opened
for reading an writing occasionally.  Two of them have both -wal and
-shm files, even though they shouldn't have been opened for read or
write for days, and the last opening of each one closed connections
properly without crashing.

Should these journal files exist even when nothing is open or has
crashed ?  I thought that properly-closed connections deleted journal
files for databases in WAL mode.

Is there some official method to delete them ?  I tried VACUUM on one
and when the connection was closed the journal files were deleted,
but I don't want to do that if their existence definitely indicates
that my code is not closing those files correctly.

You should probably assume that.

Usually *-wal and *-shm files are deleted when the number of
connections to a database drops from one to zero.

I think there is a race condition there though - if the last two
connections disconnect more or less at the same time the files
might not be removed. Seems unlikely that you would strike that
twice, but who knows.

To delete them, just run any query on the database and then disconnect.
i.e.

  sqlite3 databasefile.db "SELECT * FROM sqlite_master;" > /dev/null




_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to