Patch to support the Unlock Notify feature for shared-cache mode: blocking prepare and step
Issue #36
new
Originally reported on Google Code with ID 36
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.
Reported by bkoehm
on 2011-09-22 21:39:20
<hr> * Attachment: 20110922-unlockNotifyPatch.diff
Comments (4)
-
-
2 votes
-
- attached 20110922-unlockNotifyPatch.diff
-
-
assigned issue to
- edited description
-
assigned issue to
- Log in to comment
``` Thanks for the patch! We'll review it and possibly merge it next time we have an iteration on sqlite4java.
Cheers Igor ```
Reported by `sereda` on 2011-09-22 22:12:56 - Status changed: `Accepted` - Labels added: Type-Enhancement - Labels removed: Type-Defect