I am using SQLite in a situation with two processes running locally using the same local database.
One process only ever reads the database. The other process reads from and writes to the database.
In order to take advantage of caching and prepared queries, both processes open a connection to the database on initialisation and maintain the same connection until the program is closed.
I have recently started running into concurrency problems. I use write ahead logging, which allows the writer process to modify the database without the reader process having to close its connection. However, it seems any changes written to the database are not visible to the reader process until that process is restarted. Basically it seems the reader sees a snapshot of how the database looked when it executed its first query to the database, and ignores any updates.
Has anyone tried to use SQLite in a similar situation? Is there a way I can release the shared lock the reader takes out on the DB without closing the connection? Is there a smart way SQLite can know that the reader's cache is invalid after the DB has been modified by the reader?
Any help would be appreciated. I would rather not have to re-write the applications to open and close connections all the time.
Aucun commentaire:
Enregistrer un commentaire