Skip to content

The mysql's wait_timeout configuration will affect the binlog dump? #131

Open
@marunrun

Description

@marunrun

SHOW VARIABLES LIKE "version%"

"version","8.0.13",
"version_comment","Source distribution",
"version_compile_machine","aarch64",
"version_compile_os","Linux",
"version_compile_zlib","1.2.11",

"wait_timeout","86400"


After my service starts, I receive a "Disconnected by remote side" message every day (86400 seconds).

logs :

2025-01-14T15:56:55.634928+08:00 400564673 [Note] [MY-010914] [Server] Aborted connection 400564673 to db: 'unconnected' user: 'root' host: '' (failed on flush_net()).
2025-01-14T15:56:55.634628+08:00 400564673 [Note] [MY-011171] [Server] Stop asynchronous binlog_dump to slave (server_id: 100009).
2025-01-15T15:56:59.217796+08:00 669666506 [Note] [MY-010914] [Server] Aborted connection 669666506 to db: 'unconnected' user: 'root' host: '' (failed on flush_net()).
2025-01-15T15:56:59.216858+08:00 669666506 [Note] [MY-011171] [Server] Stop asynchronous binlog_dump to slave (server_id: 100009).

I tried various methods, and eventually, I resolved the issue by setting the following parameters in the code:

 private function getBinlogStream(): void
    {
        $this->checkSum = $this->repository->isCheckSum();
        if ($this->checkSum) {
            $this->execute('SET @master_binlog_checksum = @@global.binlog_checksum');
        }

        if (0 !== Config::getHeartbeatPeriod()) {
            // master_heartbeat_period is in nanoseconds
            $this->execute('SET @master_heartbeat_period = ' . Config::getHeartbeatPeriod() * 1000000000);
        }
+     $this->execute('set wait_timeout=9999999');
+     $this->execute('set net_write_timeout=7200');
+     $this->execute('set net_read_timeout=7200');
....
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions