SQLite Forum

sqlite3_busy_handler missing
Login
I needed this for a workaround. Maybe this is not needed anymore, but as until now it was working alright I didnĀ“t look into it anymore.
My app opens and closes connections frequently. It does not reuse a single connection to SQLite (and this behavior cannot be easily changed). 
SQLite cannot handle multiple open connections so I have to be careful not to open a new connection when one was already open, but that was not a problem because the system is not multitasking and connections are short-lived.
The thing is that starting from System.Data.SQLite version 1.0.82 connections started being freed through sqlite3_close_v2, which left "zombie" native connections (blocking the db) if there were pending statements that could be processed.
Sometimes it was the case the some statements generated by IDataReaders would not be garbage collected in time or they would be in the finalization queue at commit time, 
so the commit would be blocked waiting for the GC to eliminate the statement and it would eventually timeout.
I hooked sqlite3_busy_handler to get notified of the impending timeout and so force a GC. It was hacky but that did the trick, and I could not find any proper workaround for this problematic behavior.
Maybe it was an internal problem from the data reader when handling the statements (I did close them properly but the native statement still remained alive).
Do you happen to know if this behavior has been modified or any other way to handle it without the need of sqlite3_busy_handler?