Doug Nebeker <[EMAIL PROTECTED]> wrote: > Thanks for the input Ned--I thought there had to be more going on. > > After reading about BEGIN TRANSACTION some more, it seems like some > times my retry strategy works (a reader gets SQLITE_BUSY because a > writer is holding an exclusive lock, in which case retrying the same > sqlite3_ call later in the reader would work--and does from what I've > seen). But once the deadlock case is hit, one must abort/rollback as > you point out. > > Is there a way to detect the deadlock situation (will SQLite return > SQLITE_LOCKED), or would it be better to retry a couple of times and > then rollback? > > Is it best to bail out by closing the database handle, or calling > sqlite3_prepare16 on a "rollback" statement and trying to execute it? >
If you always do "BEGIN EXCLUSIVE" instead of just "BEGIN" to start your transaction, you will never get into the deadlock in the first place. -- D. Richard Hipp <[EMAIL PROTECTED]>