I have found that when my process has a lot of threads each of which opens a DIFFERENT database, they each block on eachother while opening each database.
Here is a little rust program to demonstrate the problem: <https:// pastebin.com/QGXFp6w6> If you simply remove the line "PRAGMA journal_mode = WAL;", then the program runs more than 5x faster. This is at least on conflict with the documentation, as the documentation suggests that a thread is a process for the purposes of sqlite's concurrency, at least when OPEN_NO_MUTEX is specified. I also feel like it's a bug in general, as opening two unrelated databases should not block eachother. Each thread blocks at this point: #0 __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135 #1 0x00007ffff74e4b95 in __GI___pthread_mutex_lock (mutex=0x7ffff7dd8148 <staticMutexes.10049+360>) at ../nptl/pthread_mutex_lock.c:80 #2 0x00007ffff7b26419 in unixEnterMutex () at sqlite3.c:31952 #3 unixLock (id=0x7ffff4a25180, eFileLock=1) at sqlite3.c:32894 #4 0x00007ffff7b1f2fa in sqlite3OsLock (lockType=1, id=<optimized out>) at sqlite3.c:21299 #5 pagerLockDb (pPager=pPager@entry=0x7ffff4a25008, eLock=eLock@entry=1) at sqlite3.c:50293 #6 0x00007ffff7b1f34b in pagerLockDb (eLock=1, pPager=0x7ffff4a25008) at sqlite3.c:53054 #7 pager_wait_on_lock (pPager=pPager@entry=0x7ffff4a25008, locktype=locktype@entry=1) at sqlite3.c:53051 #8 0x00007ffff7b55d6c in sqlite3PagerSharedLock (pPager=0x7ffff4a25008) at sqlite3.c:54293 #9 0x00007ffff7b56835 in lockBtree (pBt=0x7ffff4a151e8) at sqlite3.c:64591 #10 sqlite3BtreeBeginTrans (p=0x7ffff4a1b508, wrflag=wrflag@entry=0) at sqlite3.c:64956 #11 0x00007ffff7b82997 in sqlite3InitOne (db=0x7ffff4a12008, iDb=iDb@entry=0, pzErrMsg=pzErrMsg@entry=0x7ffff51fe778) at sqlite3.c:119558 #12 0x00007ffff7b82aca in sqlite3Init (db=0x7ffff4a12008, pzErrMsg=pzErrMsg@entry=0x7ffff51fe778) at sqlite3.c:119740 #13 0x00007ffff7b82b00 in sqlite3ReadSchema (pParse=pParse@entry=0x7ffff51fe770) at sqlite3.c:119765 #14 0x00007ffff7b8d8e4 in sqlite3Pragma (pParse=0x7ffff51fe770, pId1=pId1@entry=0x7ffff51fddd0, pId2=pId2@entry=0x7ffff51fdde8, pValue=pValue@entry=0x7ffff51fde18, minusFlag=minusFlag@entry=0) at sqlite3.c:117300 _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users