"database is locked" - unable to use grafana anymore :(

Hi there,

I had a power outage and my docker containers got killed. After restarting them, Grafana is very
slow and I get a lot of these messages in the logs:

t=2019-04-21T16:28:24+0000 lvl=eror msg="Failed to update last_seen_at" logger=context userId=1 orgId=1 uname=admin error="database is locked"

I also cannot save the dashboard. I suspect there are some stale locks in place?

Can anyone tell me how I can fix this?
Thank you very much!

1 Like

The “database is locked” error indicates a problem with your sqlite database. This can happen if the database is left in an inconsistent state after a crash, or if there are problems with the disk.

One thing you can try is to dump the data from your existing db file into a new one, then swap it out. From inside your Grafana data directory (after shutting down Grafana):

sqlite3 grafana.db '.clone grafana-new.db'
mv grafana.db grafana-old.db
mv grafana-new.db grafana.db
1 Like

Thanks a lot! This worked!

1 Like