3 ms·
The particulars of using SQLite are clearly documented: https://www.sqlite.org/threadsafe.html https://www.sqlite.org/threadsafe.html You must use serialized
by epcoa 2y ago
The particulars of using SQLite are clearly documented:
https://www.sqlite.org/threadsafe.html https://www.sqlite.org/threadsafe.html
You must use serialized mode or provide your own concurrency control.
- fnordlord 2y agoIn my case, it's using default serialized mode. I would assume I was safe judging by "In serialized mode, API calls to affect or use any SQLite database connection or any object derived from such a database connection can be made safely from multiple threads" But in the unit tests I have setup, it hasn't been the case, at least with prepared statements being shared between threads.
- epcoa 2y agoYes that's exactly how it works in serialized build/mode. Are you sure not ultimately compiling with -DSQLITE_THREADSAFE=0 or 2? Also the serialized setting is distinct from the isolation level. sqlite has a famously extensive test suite and is effectively one of the most heavily tested libraries ever, and there are multithread tests in the suite. If your tests are triggering some other kind of race/undefined behavior there is also that to consider.