[sqlite version 3.28.0 (2019-04-16)]
I am using sqlite in a multi-threaded application.
Sqlite threading-mode is configured for multi-threading (compilation flag: SQLITE_THREADSAFE=2).
In accordance to that each thread is using its own database connection.
In addition, since the multiple connections can access the database simultaneously and in order to avoid the ‘database is locked’ (error 5) I implement a busy-handler callback and assign it to the connection using sqlite3_busy_handler() right after connection creation.
Generally speaking, all is working well, however I did find that in the following scenario my busy-handler is not being called:
- Code begins transaction (
BEGIN TRANSACTION), - Code working with sqlite-statement (
sqlite3_prepare_v2(),sqlite3_bind_xxx()), - Eventually when calling
sqlite3_step()I receive the ‘database is locked’ (error 5) without my busy-handler ever being called.
I know that in sqlite documentation it says:
The presence of a busy handler does not guarantee that it will be invoked when there is lock contention. If SQLite determines that invoking the busy handler could result in a deadlock, it will go ahead and return
SQLITE_BUSY
However, my condition is a simple stand-alone application that does not share the database with any other applications. For this reason, I cannot see why would my busy-handler callback not get called.
My question:
Is there a way to configure sqlite to always call my busy-handler callback?