MySQL server has gone away error on Adobe Commerce on cloud
This article talks about the solution for the issue where you receive an " SQL server has gone away " error message in the cron.log
file. A range of symptoms including image file importing issues or deployment failure may be experienced.
Affected products and versions
- Adobe Commerce on cloud infrastructure, all supported versions.
Issue
You receive an " SQL server has gone away " error message in the cron.log
file.
Steps to reproduce
Import files and trigger a deployment.
Expected result
Successful deployment.
Actual result
Error message in cron.log
:" SQLSTATE[HY000] [2006] MySQL server has gone away at/app/AAAAAAAAA/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:144"
Cause
The default_socket_timeout
value is set too low. This is caused by the setting default_socket_timeout
. If php doesn’t receive anything from the MySQL database within this period, it assumes it is disconnected and throws the error.
Solution
- Check the current timeout period for
default_socket_timeout
by running in the CLI:php -i |grep default_socket_timeout
- Depending on the timeout setting increase, the
default_socket_timeout
variable to the expected longest possible run time in the/etc/platform/<project_name>/php.ini
file. It is suggested that you set between 10-15 mins. - Commit it to GIT and redeploy.