There is one database file in which several tables (4-5). It is rarely accessed (approximately 1 per minute and an endless loop that calls to it every 5 seconds).

So, everything works fine, but sometimes the error sqlite3.OperationalError: database is locked comes sqlite3.OperationalError: database is locked (and with data scaling I’m afraid I’ll crawl out more often)

How can I solve this problem? (something like waiting until the DB is free)

As an option for now: create several database files for a small load distribution (but this does not help much since all the tables are interconnected).

The script is located on a vps server with 512 MB of RAM, 10 GB of SD (100 MB / s) and 1 2.4 GHz core (can it switch to some other type of postgresql subd?)

  • Appeal from one process or from several? If from one, you can just hang the python lock. If from several, why from several? - andreymal
  • So this is a cgi script that is accessed every minute. Well, an endless loop in the code that accesses the database every 5 seconds. The speed of the response of this script is not very important (they can wait 1-2 seconds) - Vladimir Saleev
  • And why cgi, and not wsgi? - andreymal
  • Yes, it does not matter. It is necessary to solve the problem with queries to the database :) Creating your own file for each table should partially solve the problem, but I would like to somehow adjust the waiting for other queries - Vladimir Saleev
  • It is important that sqlite is not intended to be used from several processes, and if you do not want to use wsgi, then sqlite is better to change to something else - andreymal

0