Database is locked

Hi. Every morning at 6 am I get a warning notification due to “no value”. The reason for the error appears as follows. It fixes in a few minutes, but it causes me to receive dozens of notifications. How can I solve this problem?

Version: Grafana v9.5.1 (bc353e4b2d)
Error: failed to build query ‘A’: [sqlstore.max-retries-reached] retry 1: database is locked

I’m also experiencing a lot of those after upgrade from 9.4.7 to 9.5.2

Hello @here,

Please see this GitHub link which provided a good workaround.

Also, I believe that you are using SQLIte as Grafana backend DB so best would be to switch to MySQL or PostgreSQL (same link also has the information).

I hope this helps.

Thanks for the hint, I enabled WAL for sqlite3 using GF_DATABASE_WAL=true env variable (running dockerized grafana).
See also enabling wal = true in grafana.ini as default for Grafana SQLite installation · Issue #65115 · grafana/grafana · GitHub (about enabling it by default).

1 Like

Update Status

It seems that the Engineering team has made some changes in the code to improve the Database stability and avoid such locks.

Still, the best and suggested method is to switch to either MySQL or PostgreSQL.

Therefore marking this post as resolved