Skip to content

close sync with err: ERROR 4031 #963

Open
@imysm

Description

@imysm

go version 1.22.10
mysql version 8.0.32
go-mysql 1.9.1

When using the canal method to parse the binlog in real time, the following error occurs intermittently: "binlogstreamer.go:78 close sync with err: ERROR 4031 (HY000): The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior." I wonder if it is necessary to set some additional parameters when connecting to MySQL?

Activity

dveeden

dveeden commented on Jan 3, 2025

@dveeden
Collaborator

Any related entries in the MySQL logs? (with log_error_verbosity=3 if possible, see also https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_log_error_verbosity )

dveeden

dveeden commented on Jan 3, 2025

@dveeden
Collaborator

What settings have you set for wait_timeout and interactive_timeout? How often does this happen?

imysm

imysm commented on Jan 3, 2025

@imysm
Author

mysql param wait_timeout =3600 interactive_timeout=3000
Sometimes it occurs once every dozen days, and sometimes it occurs once every few days.
Does this require adjusting the MySQL settings? Or is it sufficient to add some parameters to the application client? Is it possible to enable auto - reconnection, or can we send heartbeats to prevent the connection from dropping?

lance6716

lance6716 commented on Jan 3, 2025

@lance6716
Collaborator

mysql param wait_timeout =3600 interactive_timeout=3000 Sometimes it occurs once every dozen days, and sometimes it occurs once every few days. Does this require adjusting the MySQL settings? Or is it sufficient to add some parameters to the application client? Is it possible to enable auto - reconnection, or can we send heartbeats to prevent the connection from dropping?

If your application can consume binlog within 3000 seconds, the connection will not be killed by MySQL server. Please check your logic if it's stuck.

dveeden

dveeden commented on Jan 3, 2025

@dveeden
Collaborator

Is the gap between binlog events always less than the timeout?

imysm

imysm commented on Jan 3, 2025

@imysm
Author

My current solution is to use Supervisor to manage the process. When the program encounters an error, it will exit with code 1, and then Supervisor will automatically restart the program to achieve the purpose of continuously consuming the binlog. However, I can't find the reason for the ERROR 4031 (HY000) error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close sync with err: ERROR 4031 · Issue #963 · go-mysql-org/go-mysql