I have an SQLite database that I am keeping open and writing to in process A. I would like to be able to use it from process B on a read-only basis.
According to the document,
The process A will be making lots of little writes so I don't think making a copy on each transaction commit will be efficient.
The only way I can see it is for the reader to wait until the database enters UNLOCKED state, get a SHARED lock for the duration of the read and then release it. Meanwhile process A will want to write and will be blocked until the lock becomes available - if it ever does (what if process B crashes?). This means that process A and process B will be in contention for locks - B wants SHARED and A wants EXCLUSIVE and this will slow things down or even lead to concurrency problems.
Is there any way to achieve my aim of concurrent writing and reading?
Use WAL mode. It supports concurrent readers and one writer.
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