Marcus

thanks for your suggestions. I have of course checked the obvious things
before posting here.

Both the BEGIN EXCLUSIVE and the COMMIT return SQLITE_OK.

Each thread opens its own db handle with sqlite_open and operates on it.
These are completely isolated, they don't know about each other and they do
not share any data or sqlite constructs. Both threads work flawlessly as
long as they don't operate in parallel.

I have compiled SQLite with SQLITE_THREADSAFE=1 and the checks in the source
code of SQLite use the mutexes to protect the library. Looks good that far.


I cannot post the source code easily because I use my wrapper class, and I
would have to strip it down to the core 'C' SQLite calls to show you what
actually is done. This wrapper is in use for quite some time and has been
tested for a year now.

But what I do in these two threads which cause the trouble is really simple:


1: if BEGIN EXCLUSIVE TRANSACTION successful then {
2:  INSERT INTO...
3:  DELETE FROM...
4:  COMMIT
5: }

Thread A blocks in 1: because it waits for the transaction.
Thread B blocks in line 2: but has successfully opened an exclusive
transaction.

I now wonder why it can block in the INSERT after successfully opening an
exclusive transaction?
I could not find an explanation in the online docs for this behavior. My
impression was that if the BEGIN EXCLUSIVE succeeds, further operations on
the same db handle cannot block.

The threads may even work on different tables, and still the deadlock
occurs.


-- Mario



-----Original Message-----

I have no idea why it doesn't work in that way, it used to in my
application. however, just a few points:

maybe your BEGIN wasn't successful and you didn't realize ?
maybe you run the INSERT on a DB handle that was not the one that invoked
the BEGIN ?
maybe your COMMIT wasn't successful and you didn't realize ?
maybe your are not in threadsave mode ?

I suggest that you post at least a part of your code here, or even better a
short example that shows the problem.
This usually gives the people here a better chance to provide useful hints.

hope this helps

Marcus

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to