How to use the same SQLite3 database from multiple Perl processes?

I have a bad situation where several Perl processes are writing and reading the same SQLite3 database at the same time.

This often causes Perl processes to crash, because two processes will write at the same time, or one process will read from the database and the other will try to update the same record.

Does anyone know how I could coordinate several processes to work with the same sqlite database?

I will work on the transition of this system to another database engine, but before I do this, I somehow need to fix it so that it works as it is.

+6
source share
1 answer

SQLite is intended for use in multiple processes. There are some exceptions if you place the sqlite file on a network drive, and there may be a way to compile it so that it will be used from one process, but I use it from several processes regularly. If you are having problems, try increasing the timeout value. SQLite uses file system locks to protect data from simultaneous access. If one process is written to a file, a second process may be required. I set my timeouts to 3 seconds and I have very few problems with this.

Here is the link to set the timeout value

+7
source

Source: https://habr.com/ru/post/918591/


All Articles