Skip to content

Exception "HY000: no connection to the server" when using connection tracking in Warlock

Warlock is a long running process, meaning that services start up and once stuff is loaded into memory, it stays there until it is specifically deleted. When we use Hazaar\DBI\Adapter::getInstance() to get a DBI Adapter instance, that instance is tracked in memory (based on environment/config). Because this connection is now established once and then expected to always be there, if the database disappears for a bit and the connection dies, the Adaptor is in a broken.

This issue means I need to update getInstance() to check the connection state and if it's dead, kill off the existing instance and create a new one. I will need to do this as efficiently as possible so hopefully PHP-PDO has the tools to check connection states.