Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close sync with err: ERROR 4031 #963

Open
imysm opened this issue Jan 3, 2025 · 6 comments
Open

close sync with err: ERROR 4031 #963

imysm opened this issue Jan 3, 2025 · 6 comments

Comments

@imysm
Copy link

imysm commented Jan 3, 2025

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?

@dveeden
Copy link
Collaborator

dveeden commented Jan 3, 2025

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
Copy link
Collaborator

dveeden commented Jan 3, 2025

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

@imysm
Copy link
Author

imysm commented Jan 3, 2025

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
Copy link
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
Copy link
Collaborator

dveeden commented Jan 3, 2025

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

@imysm
Copy link
Author

imysm commented Jan 3, 2025

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants