Known issue: MySQL error 2006 (Server has gone away)

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search


Known issue: MySQL error 2006 (Server has gone away)

Status: Workaround available
Applies to: G1R:MP 0.1 alpha dedicated servers using MySQL or MariaDB

The dedicated server keeps database connections open between queries. If the database server closes an idle connection, a later query can fail with MySQL error 2006:

[lua][gothic_rp][error] [GothicRP][DB] registration conflict check failed (2006): Server has gone away

Startup migrations and database self-tests may complete successfully before this error appears. The problem can therefore occur even when the database address, credentials, schema, and permissions are correct.

Cause

G1R:MP uses persistent, non-interactive database connections. MariaDB applies wait_timeout to these connections and closes them after the configured number of idle seconds.

Some Hestia Control Panel installations use the following values:

wait_timeout=10
interactive_timeout=50

A wait_timeout of 10 seconds is too short for a persistent game-server connection. It explains why startup checks pass, but account registration, login, or another database operation fails shortly afterwards.

A successful test in the mariadb command-line client does not rule this out. The command-line client creates a new connection and can use interactive_timeout, while G1R:MP uses wait_timeout.

Confirm the active values

Run the following command on the database host:

sudo mariadb -NBe "SELECT @@GLOBAL.wait_timeout, @@GLOBAL.interactive_timeout;"

If the first value is 10, the server is affected by this configuration.

Workaround for HestiaCP and MariaDB

If the MariaDB settings are exposed in HestiaCP, open the server configuration for MariaDB and set:

wait_timeout=28800
interactive_timeout=28800

Alternatively, create a separate override file so the change is not mixed with HestiaCP's main template:

sudo nano /etc/mysql/mariadb.conf.d/99-g1rmp-timeouts.cnf

Add:

[mariadbd]
wait_timeout=28800
interactive_timeout=28800

Restart MariaDB:

sudo systemctl restart mariadb

Verify the active values again:

sudo mariadb -NBe "SELECT @@GLOBAL.wait_timeout, @@GLOBAL.interactive_timeout;"

The expected result is:

28800	28800

Finally, fully restart the G1R:MP dedicated server. Changes to the global timeout apply to new database sessions; an already disconnected G1R:MP connection is not repaired by changing the variable alone.

Important notes

  • Do not expose MariaDB port 3306 to the public Internet when G1R:MP and MariaDB run on the same machine. Use 127.0.0.1 in the resource configuration.
  • Restart G1R:MP after restarting MariaDB. A database restart invalidates connections that were already open.
  • If error 2006 appears immediately after a clean restart, verify the database host, port, database name, user permissions, and MariaDB error log.
  • On Debian and Ubuntu, useful diagnostics normally include /var/log/mysql/error.log and journalctl -u mariadb.

Further reading