On 2015-08-10 11:49 PM, ??????? ??????????? wrote: > When I set timeout to 120000 ms (2 minutes). It starts work. But as I > understand from reading SQLite C interface, when DB in WAL journal mode it > should work without busytimeout. > > Can it work without busy timeout?
It can work without Timeouts - the timeout setting is only to make SQLite wait a bit for the DB to become available if it is busy. If you want to work without timeouts, you have to check for "SQLITE_BUSY" messages and make your program wait and retry the operation. By setting a timeout, SQLite simply does this for you. Also, your assumption about WAL mode is wrong: It allows reading from a second connection while writing on one connection, but not writing from a second connection. This includes starting immediate transactions (requiring a write-lock) from a second connection and such operations as DELETE and UPDATE which you say you do use. There is no way you can do writing from 2 connections without checking for SQLITE_BUSY and waiting when it is busy. Starting these write-operations from the second connection needs to wait until the DB is accessible, and once it started writing, then the first connection has to wait until the DB is accessible before it can write again - so you have to wait for the DB to be accessible. Setting a Timeout does this automatically for you. More info here: https://www.sqlite.org/wal.html#concurrency As to the minimum period: There is no minimum period, you have to understand what your database will do and how long it will write, how slow is your disk/media and make a timeout that is suitable. You can make the timeout very large, but if something goes wrong, your program will "hang" until the time runs out before it gives an error - so don't make it too large - and - test it really well. > > 2015-08-10 17:11 GMT+03:00 Simon Slavin <slavins at bigfraud.org>: > >> On 9 Aug 2015, at 10:37pm, ??????? ??????????? <dm3chip at gmail.com> wrote: >> >>> I've got a problem. I'm using sqlite3 in my C++ project. In the log I've >>> got error's *DB is locked error code 5*. As I know error code 5 means, >> that >>> DB is busy. >> For testings, please use >> >> <https://www.sqlite.org/c3ref/busy_timeout.html> >> >> int sqlite3_busy_timeout(sqlite3*, int ms); >> >> with a timeout of a couple of minutes. (Really. Minutes.) You will need >> to set it on all connections, not just the one which is currently reporting >> errors. >> >> Simon. >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users at mailinglists.sqlite.org >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

