> 5. Enter the following in session 2 (demonstrates unexpected behavior): > > .timeout 10000 > begin; > select * from my_table; > update my_table set userid=1; > > -> A 'database locked' error message is returned immediately. > > rollback; > > Is this the expected behavior in SQLite, and if so, how can I have > SQLite honor the timeout value within transactions that begin with the > select statement?
Yes, this is expected behavior. In this case transaction won't be able to ever proceed because it can proceed only when writing transaction in session 1 is committed but it cannot be committed until all reading transactions are finished, including transaction in session 2. So it's a deadlock and SQLite knows about that, thus it returns "database locked" immediately. Pavel On Mon, Dec 19, 2011 at 2:11 PM, Sigurdur Ragnarsson <siggi.ragnars...@gmail.com> wrote: > I have observed a peculiar behavior for timeouts in transactions when > a transaction begins with a 'select' statement. Basically, it seems > like the timeout setting is not honored in this instance and if an > 'update' statement follows the 'select' statement, a 'database locked' > error message is immediately returned. The following scenario can be > used to reproduce this behavior: > > 1. Create a database with a single table (I used the table name my_table) > 2. Open two sessions using the SQLite CLI > 3. Enter the following in session 1: > > begin immediate; > > 4. Enter the following in session 2 (demonstrates expected behavior): > > .timeout 10000 > begin; > update my_table set userid=1; > > -> A 'database locked' error message is returned in 10 seconds. > > rollback; > > 5. Enter the following in session 2 (demonstrates unexpected behavior): > > .timeout 10000 > begin; > select * from my_table; > update my_table set userid=1; > > -> A 'database locked' error message is returned immediately. > > rollback; > > Is this the expected behavior in SQLite, and if so, how can I have > SQLite honor the timeout value within transactions that begin with the > select statement? > > Thanks, > Sigurdur > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users