• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

TFS 1.X+ SQL error ?

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,398
Reaction score
165
Hello, i got this error pops up, very randm, and basicaly while 0 players is online

Error:
LUA:
[Error - mysql_store_result] Query: SELECT `reason`, `expires_at`, (SELECT `name` FROM `players` WHERE `id` = `banned_by`) AS `name` FROM `ip_bans` WHERE `ip` = 3586606524
Message: The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.

How i can fix it ? Can anyome help me out please
Im using 8.6 tfs 1.3-1.4
 
Google is your friend!
You have to increase interactive_timeout in the mysql config
interactive_time is for interactive sessions, whereas wait_timeout is for non-interactive sessions.

What's an interactive session? It's one with a human at the keyboard.

When your code connects to MySQL, runs a query and then spends 3 seconds processing that query before disconnecting, that's 3 seconds of the wait_timeout.

When you use the mysql command line client to connect, run a command and spend 10 seconds reading the output, that's 10 seconds of interactive_timeout. If you walk away and have lunch, that's 3600 seconds of interactive_timeout.

In both cases, when you or your code runs another query, the waiting time is reset back to 0.

You can see the values for all the current sessions by typing show processlist. The values in the sleep(5) function is the number of seconds since that connection last did anything.

  1. Edit my.cnf (the MySQL configuration file).
    Code:
    sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf

  2. Locate the timeout configuration and adjust it to fit your server.
  3. Code:
    [mysqld]
    wait_timeout = 31536000
    interactive_timeout = 31536000


  4. Save the changes and exit the editor.
  5. Restart MySQL to apply the changes as follows:
    Code:
    sudo /etc/init.d/mysql restart

Taken form:


 
Increasing wait_timeout / interactive_timeout is a common workaround and may reduce how often this happens, but it doesn’t actually fix the root cause.

The real issue is that TFS keeps a long-lived MySQL connection and assumes it will never die. When MySQL drops an idle connection (timeout, socket reset, reload, etc.), TFS keeps reusing a dead MYSQL handle, which leads to errors like:

"The client was disconnected by the server because of inactivity", even with high timeout values.

The proper fix is to add reconnect logic in database.cpp:
  • Detect reconnectable MySQL errors (CR_SERVER_GONE_ERROR, CR_SERVER_LOST, etc.)
  • Close the dead connection
  • Reconnect using the stored DB config
  • Retry the query once
This makes the server resilient to idle disconnects, MySQL restarts, and network hiccups, instead of relying on very large timeout values.

Many TFS versions (1.3–1.4 included) retry queries but never reconnect, which causes infinite retry loops or random errors while 0 players are online.

If people are interested, I can:
  • post a generic reconnect pattern (no server-specific code), or
  • prepare a clean PR that adds safe reconnect handling to the DB layer.
TL;DR:
MySQL timeouts are a band-aid.
Proper reconnect logic is the real fix.
 
Back
Top