Originally created by: bko...@gmail.com
I've just begun to investigate using sqlite4java as a database backend for a web application.
I noticed in shared cache mode that I was getting a lot SQLITE_LOCKED errors.
I realized I needed sqlite3_unlock_notify() to implement blocking prepare() and step() and that sqlite4java hadn't implemented it yet.
So here's a patch for it!
I implemented it based on the documentation/code presented at http://www.sqlite.org/unlock_notify.html.
Here's how to enable blocking prepare() and step() (I added Javadoc documention too):
SQLiteConnection db = new SQLiteConnection(new File("test.db"));
// must be in shared cache mode to use unlock notify blocking
db.openV2(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_SHAREDCACHE);
// call setBlocking(true) to turn on blocking of prepare() and step()
db.setBlocking(true);
// prepare() and step() will now attempt to block when locked in accordance with sqlite3_unlock_notify() documentation
I have tested on my web application in a test environment and I no longer get the SQLITE_LOCKED (or SQLITE_LOCKED_SHARECACHE) errors so it's looking good, but granted it hasn't been battle-tested yet in any kind of high-traffic production environment.
It's my hope you can merge this into the mainline after reviewing it.
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: ser...@gmail.com
Thanks for the patch! We'll review it and possibly merge it next time we have an iteration on sqlite4java.
Cheers
Igor
Labels: -Type-Defect Type-Enhancement
Status: Accepted