I'm getting exc_bad_access when using multiple readers for sqlite on iOS. WAL is enabled on the database and sqlite3_threadsafety returns 2 so this shouldn't be a problem.
The code I'm using works fine for 100k+ users most of the time, but there are certain multithreading race conditions that cause sqlite3_prepare_v2 to have exc_bad_access. Basically when I spawn two threads to do a bunch of reads it crashes.
With WAL and threadsafe sqlite, multiple threads shouldn't be a problem but can't figure out what's causing this exc_bad_access.
Thanks in advance.
In that sense SQLite3 is not thread safe refer SQLite document
By "threadsafe" we mean that you can use different SQLite database connections in different threads at the same time. It has never been safe to use the same database connection simultaneously in multiple threads. If you use the sqlite3_prepare() API to create prepared statements, each prepared statement is considered to be a part of the database connection from which it was derived. So you cannot run two prepared statements originating from the same database connection in different threads at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With