On Aug 17, 2010, at 1:48 AM, Nikolaus Rath wrote: > Hello, > > The script below fails with > > Deadlock detected when executing 'DELETE FROM foo WHERE id=2' > > What I think should be happening instead is this: > > - When executing statement 1, the main thread obtains a SHARED lock.
> - When executing statement 2, the main thread briefly obtains an > EXCLUSIVE lock. After statement 2 is executed, the EXCLUSIVE lock is > released and the main thread continues to hold the SHARED lock > (since > statement 1 is still active) Quite correct. > - Thread 2 wants to get an EXCLUSIVE lock but it can't. So the busy > handlers waits for the main thread to release it's lock. While waiting, thread 2 is holding a PENDING lock. > - The main thread once again briefly obtains an EXCLUSIVE lock to > execute statement 4. After that it releases all locks. Cannot obtain the required EXCLUSIVE lock, due to the PENDING lock held by thread 2. http://www.sqlite.org/lockingv3.html#pending_lock > - Now thread 2 can execute statement 3. This would be true, but we don't get this far because the program bails after the SQLITE_BUSY in the previous step. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users