In an sqlite3-console:
sqlite>
CREATE TABLE items (id PRIMARY KEY);
BEGIN;
SELECT * FROM items;
INSERT INTO items VALUES(78);
sqlite> _
And then in a second console:
sqlite>
.timeout 10000;
BEGIN;
SELECT * FROM items;
INSERT INTO items VALUES(78);
Error: database is locked
sqlite> _
The “database is locked”-error happends instantly, which can’t be right, right?
If I omit the SELECT in the second console the busy handler waits for 10 seconds at the INSERT. I’ve found that using BEGIN EXCLUSIVE also makes the second transaction wait for 10 seconds, but then at the BEGIN-statement. (Which I’ve resolved to as a workaround.)
My question: Is this a bug, or as it should be? If this the expected behaviour, then why?
Thanks!
(SQLite v3.7.6)
Yes this is normal. Please read: http://www.sqlite.org/lockingv3.html