On 2/26/16, Vince Scafaria <vince at dotalign.com> wrote: > I am using System.Data.SQLite in .NET and encountering "database is locked" > with wal using multiple threads from the same process running simple select > statements with (separate) read-only connections.
The first database connection (in any process) that opens a WAL-mode database file must create the *-wal and *-shm files used for transaction control. (Likewise, the last connection to close a WAL-mode database will delete those files.) But because new files must be created when opening, that means that a read-only database connection cannot be the first connection to open a WAL-mode database. A read-only database connection can open and read a WAL-mode database as long as some other (read/write) thread or process has already opened it, but the read-only connection cannot be the first to open it. Try this experiment: Before running your test program, connection to the database file using the sqlite3.exe command-line client and type ".schema". Leave sqlite3.exe connected to the database - just setting there doing nothing. Then while sqlite3.exe is running, rerun your test program. Let us know if that clears your problem. -- D. Richard Hipp drh at sqlite.org