Is there a way to wait until the database is available?
(1) By 6kEs4Majrd on 2020-06-03 22:09:12 [link] [source]
There is busy_timeout. But it must be a finite number. Is there a way to let sqlite3 wait until the database is available? Thanks.
The "busy_timeout" is implemented as an sqlite3_busy_handler() callback. You can substitute a different callback to do whatever you want.
(5) By 6kEs4Majrd on 2020-06-03 23:33:04 in reply to 2 [link] [source]
Could you show the code that should be used at the SQL command level instead of the C level? Thanks.
Could you show the code that should be used at the SQL command level instead of the C level?
The pragma is the only way to do it without from the console app. Setting it to the highest signed 32-bit value, like in your response to my deleted (and inaccurate) response, is the closest you can get with that app without writing and loading a custom C extension.
Not according to the API docs. Setting it to an absurdly high value (noting that it's a signed int, so 2GB is the max) would seem to be the only way. See <https://www.sqlite.org/c3ref/busy_handler.html>
(4) By 6kEs4Majrd on 2020-06-03 23:31:53 in reply to 3.1 [link] [source]
The max signed 32 bit integer is 2147483647. So I should set it as the following?
(7) By Gunter Hick (gunter_hick) on 2020-06-04 06:17:31 in reply to 1 [link] [source]
Wrong question. As you explained in your other post, you are expecting a deadlock to occur. By definition, no amount of waiting will resolve a deadlock. (At least) one of the processes involved in the deadlock has to release the resources it has acquired and start over. The proper response to SQLITE_BUSY as an indication of deadlock is to ROLLBACK and then repeat the transaction.