unexpected sqlite_busy behaviour within transactions

[email protected] Sat, 22 Feb 2020 13:50:13 +0100
Newsgroups gmane.comp.db.sqlite.general
Message-ID <trinity-5d110a27-e12b-4445-aa60-83466459d180-1582375813757@3c-app-gmx-bap68>
Hi

A busy_timout is honored by write commands outside of transactions and by single write commands inside transactions, but not if preceded by a read command. I did not find this behaviour in the documentation, thus it might be a bug.

To reproduce (in a linux terminal):
   sqlite3 ~/test.db "CREATE TABLE t(a);"
   echo '.timeout 5000' > ~/sqlitetest.init
   sqlite3 ~/test.db --init ~/sqlitetest.init "BEGIN IMMEDIATE TRANSACTION; SELECT * FROM t; INSERT INTO t VALUES(1); COMMIT;"
   sqlite3 ~/test.db --init ~/sqlitetest.init "BEGIN TRANSACTION; INSERT INTO t VALUES(1); COMMIT;"
   sqlite3 ~/test.db --init ~/sqlitetest.init "BEGIN TRANSACTION; SELECT * FROM t; INSERT INTO t VALUES(1); COMMIT;"
The three sqlite3 commands return immediately without error as the database is not locked.

Now lock the database in a second linux terminal
   sqlite3 ~/test.db
   sqlite> BEGIN IMMEDIATE TRANSACTION;

Then repeat the three sqlite3 commands in the first terminal. The first two commands take 5 seconds to return, as expected (due to busy_timeout). However, the last sqlite3 command returns immediately. Acquiring an exclusive lock prior to 'INSERT ...' apparently ignores the busy_timeout.

Best regards

Andreas

PS: I use SQLite version 3.27.2 2019-02-25 16:06:06 on raspbian / buster

_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users