lundi 5 janvier 2015

Sqlite deadlock across multiple threads with different files

I've got an OS X app (Yosemite, 10.10) that performs long-running jobs involving heavy use of sqlite across multiple threads. And I've hit a deadlock across 8 threads, all of which are stuck in sqlite code connecting to different database files. There is no apparent resource-related connection between them.


Four of them are at this stack. Of those, three are operating on the same table (again, different database files); three are updating and one is querying.



__psynch_mutexwait
_pthread_mutex_lock
unixLock
sqlite3PagerSharedLock
sqlite3BtreeBeginTrans
sqlite3VdbeExec
sqlite3_step


One is at this stack, updating the same table as three of the ones at the stack above.



guarded_close_np
nolockClose
pager_end_transaction
sqlite3BtreeCommitPhaseTwo
sqlite3VdbeHalt
sqlite3VdbeExec
sqlite3_step


Two are at this stack, opening database files with the same name in different locations. The open mode is SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX.



__psynch_mutexwait
_pthread_mutex_lock
sqlite3ParseUri
openDatabase


One is at this stack, ending a transaction.



__psynch_mutexwait
_pthread_mutex_lock
unixLock
sqlite3VdbeHalt
sqlite3VdbeExec
sqlite3_step


So, the question: what could cause sqlite to deadlock without involving any shared resources?


Aucun commentaire:

Enregistrer un commentaire