Hi, Am using the API and having trouble (deadlock or crash) with multithreaded access to a read-only sqlite3 file. Any help would be much appreciated.
- Running OSX with sqlite3 3.28.0 amalgamation compiled from code. Same issue is occurring when the code is compiled for Windows using mingw64 - I have one sqlite3 db file holding one table of data of about 100k rows and half a dozen columns with short-text or numeric data - I have one process with two threads concurrently accessing the table: - each thread has its own db connection - each thread is running an identical "select x" query, many thousands of time in rapid succession, with an indexed lookup, and only retrieving 1 row (at most) of data - I'm encountering a race condition and/or crash and have tried multiple different ways to address - Here are two approaches that are both failing: - deadlock: both processes open db (once each before quering begins) using SQLITE_OPEN_READONLY | SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_SHAREDCACHE. The deadlock occurs in the btreeCursor function, which both threads get stuck in (which in my version 3.28.0 amalgamation is on lines 67576-67581) for(pX=pBt->pCursor; pX; pX=pX->pNext){ if( pX->pgnoRoot==(Pgno)iTable ){ pX->curFlags |= BTCF_Multiple; pCur->curFlags |= BTCF_Multiple; } } - crash: both processes open db (once each before quering begins) using SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, with uri parameter immutable=1. The crash occurs in sqlite3DbMallocRawNN, with a bad memory access exception using lldb I've tried other permutations of various flags that go along for sqlite3_open_v2 , as well as setting pragma read_uncommitted, but can't seem to get multi-threaded concurrent rapid-fire querying to work at all. Am open to any changes to how the db is opened or sqlite3_step is called etc. Thoughts or suggestions? Seems like this should be a common use case so my guess is the solution is easy and I've just got something wrong... Thank you _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users