Hi all,
This is an important (and systematic) bug, I have already reported it, but I most clearly rewritten (hopefully) here.
The problem is (in sqlite WAL mode: db.multiuser):
When the database is already busy/locked (a write transaction is already in progress), a new write request will freeze all the app during the timeout.
Of course, the second write request must be refused if the database is always busy/locked at the end of the timeout, but the app should not freeze during the timeout.
At first, this bug is invisible because the databases are small, so the transactions are very fast, and therefore are not in concurrence. But after some time, when the database becomes larger, tensions arise, especially in business applications with long transactions (While SQLITE still has resources).
Also, users tend to think that this is another problem. For example, a customer thought he had a network problem when the session was freezing from time to time (Web App). But it was this sqlite timeout problem. If the timeout is 2 seconds, the entire web app, all sessions, will be freezed for 2 seconds if the database is already busy.
it greatly reduces the interest of SQLITE WAL mode (db.multiuser) in Xojo.
I was afraid this is a limit of cooperative threads in Xojo, but no:
I spoke to Mr Hipp, creator of SQLITE. He’s very accessible. He told me:
“The interface that governs the timeout is “sqlite3_busy_handler()”.
Perhaps you can modify its callback to yield to another thread.”
Xojo does it? Maybe the problem is here.
Xojo already handles the “progress_handler” (in Xojo: sqlitedatabase.threadYieldInterval),
but according to Mr. Hipp, it’s the “busy_handler” is called when the database is busy/locked.
Below, I will put a test project and two videos showing the problem. I’ll write a new Feedback.