SQLSTATE[HY000] [2006] and QLSTATE[HY000] [2002] when using socket from containers to mariadb

I have around 6 containers accessing MariaDB using a socket.

at a point – some of the containers lost access to the MariaDB server with these errors (2006 and 2002)
The only way to reconnect to MariaDB is restarting the containers.

at the same time – regular access from non-containerized php (using regular tcp based connection) is working without any issues.

I’m not sure if it’s related to the use of file socket (this is Debian, running MariaDB), use of containers, or php drivers.

any ideas how to debug/solve this problem ?

Original Error Codes (from 2 containers)

[2020-11-19 17:25:43] request.CRITICAL: Uncaught PHP Exception DoctrineDBALExceptionDriverException: "An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away" at /docker/source/chat-api/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 106 {"exception":"[object] (DoctrineDBALExceptionDriverException(code: 0): An exception occurred in driver: SQLSTATE[HY000] [2006] MySQL server has gone away at /1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:106, DoctrineDBALDriverPDOException(code: 2006): SQLSTATE[HY000] [2006] MySQL server has gone away at /1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2006): SQLSTATE[HY000] [2006] MySQL server has gone away at /1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27, PDOException(code: 0): PDO::__construct(): MySQL server has gone away at /1/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)"} [] [2020-11-19 17:28:26] request.CRITICAL: Uncaught PHP Exception
DoctrineDBALExceptionConnectionException: "An exception occurred in
driver: SQLSTATE[HY000] [2002] Connection refused" at
/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php
line 93 {"exception":"[object] (DoctrineDBALExceptionConnectionException(code: 0): An exception
occurred in driver: SQLSTATE[HY000] [2002] Connection refused at
/2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:93,
DoctrineDBALDriverPDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at
/2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31,
PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at
/2/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)"}
[]

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *