How can I fix the error: Mysql Server has gone away?

Overview

This article provides steps to resolve the "MySQL server has gone away" error encountered by Amavis when connecting to a MariaDB database. The issue typically occurs when the database server terminates idle persistent connections before Amavis can reuse them.

Symptoms and Cause

The mail log displays the following Amavis notification:

Aug  3 01:00:20 el7p17 amavis[114160]: (114160-02) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 130) line 173.

This error indicates that Amavis attempted to use a persistent database connection that was dropped by the MariaDB server due to timeout settings. Consequently, Amavis must re-establish the connection.

Resolution

To prevent premature connection drops, adjust the wait_timeout parameter in your MariaDB configuration files. Follow these steps:

  1. Open the primary configuration file located at /etc/my.cnf.
  2. Verify that no conflicting values exist within the /etc/my.cnf.d/ directory, as files in this directory may override default settings.
  3. Add or modify the [mysqld] section to include the recommended timeout value:
[mysqld]
wait_timeout = 28800
  1. Save the configuration file.
  2. Restart the MariaDB service to apply the changes:
systemctl restart mariadb

Troubleshooting and Verification

After restarting the service, monitor the mail logs to confirm that Amavis successfully maintains persistent connections without triggering reconnection notices. If the error persists:

  • Confirm that the MariaDB service is running correctly.
  • Check for additional timeout parameters such as interactive_timeout or connection pool limits in your application configuration.
  • Review system resource utilization to ensure the database server is not terminating connections due to memory constraints.
  • mysql
  • 0 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

How can I fix the error: Host '127.0.0.1' is not allowed to connect to this MariaDB server?

Overview This article provides resolution steps for the MariaDB connection error Host...

How can I fix the error: Parse error at /etc/clamav/clamd.conf Unknown option ScanImage?

Overview The clamav-daemon.service may fail to start due to unrecognized configuration...

How can I fix the error: The domain limit of this license key has been reached?

Overview The Admin and Pro editions of Danami products enforce a maximum domain limit within the...

After upgrading from Centos 7 to AlmaLinux 8 Amavis is treating mail with low scores as spam. How can I fix this?

Overview Following an upgrade from CentOS 7 to AlmaLinux 8, Amavis may incorrectly classify...