Thanks for an additional explanation, I used sqlite3_get_autocommit() for
debugging and it helped me to find out that it really was my fault. There
was an incorrect processing after COMMIT returned SQLITE_BUSY. So sorry for
this.

However, right after fixing this, I found another problem. It certainly can
be my fault, but I don't see how could it be: If I don't use transactions,
multiple threads seem to proceed well, but then right after I add BEGIN and
COMMIT to some place, all threads lock eventually. I debugged it and found
that _all_ threads accessing SQLite are in a loop waiting for an action to
proceed and all of them keep getting SQLITE_BUSY result. I wonder, can it be
somehow my fault, or is it some kind of a dead-lock in SQLite?

In the simpliest form it takes only two threads to reproduce and the problem
looks like:

Thread 1:

BEGIN TRANSACTION            <-- proceeded
INSERT INTO ...                      <-- Processing stops here, waiting in a
loop, Sqlite3_step() infinitely returns SQLITE_BUSY
COMMIT


Thread 2:

  // no explicit transaction start here
DELETE FROM ...                   <-- Processing stops here, waiting in a
loop, Sqlite3_step() infinitely returns SQLITE_BUSY


Thread 2 can also look like this in order to reproduce the problem
(situation in Thread 1 remains the same):

BEGIN TRANSACTION            <-- proceeded
DELETE FROM ...                  <-- proceeded 
COMMIT                                 <-- Processing stops here, waiting in
a loop, Sqlite3_step() infinitely returns SQLITE_BUSY

No other thread calls any SQLite function.

Do you have any idea what could be wrong?

Thanks,
Jiri


Reply via email to