Pihole In Kubernetes SQL Error DB locked

Im running Pihole in a Kubernetes deployment to find out that if running more than 2 replicas locks up the SQL DB as you can only write by one process so if the 2nd replica gets deployed then fails to write into the DB causing DNS issues.

  1. Configurations to the DB be updated to allow multiple sessions writes?
  2. Roadmap to allow write to an external DB?

IIRC a SQLite Database is used and AFAIK it’s not really the best choice for such scenarios…?!

Thanks @nero355 on the quip reply and insight!

1 Like

Right now, I think the only way you can fix this is by using 2 DNS, so 2 deployments (in k8s maybe a statefulset). A primary and a secondary with both having it’s own sqlite database.

Are you sharing the same database between 2 instances?

This won't work if both instances are running at the same time.
A SQLite3 database supports multiple simultaneous readers, but usually only one writer at a time.

Also, each Pi-hole uses an "in-memory" database where the queries are initially stored and the records are saved to disk from time to time. Two different Pi-holes (with 2 different in-memory databases) will try to save to the same disk database. The primary keys from different databases won't match, causing issues.

1 Like

Yes, I am. Well two pods but yes… the same thing.

Thank you! Great solution as it has all the things you would get from other open source right out of a UI.