The process was alive, the panel was not
  • Tanga
  • Debugging
  • SQLite
  • Monitoring

The process was alive, the panel was not

68
One day the Tanga admin panel stopped opening. systemd said the service was active, the process was in memory, and yet every request hung until the browser gave up. There was no error to read, so I looked at the process itself. py-spy can dump the stack of every thread in a running Python program without stopping it. The dump showed the web server's queue full and all worker threads stuck in the same place: opening and closing the encrypted SQLite connection. The panel opens a short-lived connection for each request. With SQLCipher, opening and closing in parallel threads could end in a deadlock — each thread holding what the other one needed. Nothing crashed and nothing was logged; everything simply waited. The fix was a single lock: connections are now opened and closed one at a time. For an admin panel that wait is unnoticeable, and the race is gone. The second fix is for next time. A timer checks the panel's health endpoint every two minutes; after two failed checks in a row it restarts the service and writes a line to the journal. Takeaway: "the process is running" is not the same as "the service works". A health check has to make a real request.