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

mysql does not reconnect if connection was closed #670

Closed
bgaifullin opened this issue Sep 21, 2017 · 5 comments
Closed

mysql does not reconnect if connection was closed #670

bgaifullin opened this issue Sep 21, 2017 · 5 comments

Comments

@bgaifullin
Copy link
Contributor

Issue description

if connection has been closed by idle timeout, further requests fails with error 'invalid connection'
seems like this behaviour was introduced by commit 26471af.

because the same code works on version 3955978

Configuration

Driver version (or git SHA):
7785c74

Go version: run go version in your console
go version go1.9 darwin/amd64

Server version: E.g. MySQL 5.6, MariaDB 10.0.20
Ver 5.7.16-10 for osx10.12 on x86_64 (Homebrew)

Server OS: E.g. Debian 8.1 (Jessie), Windows 10
OSX 10.12

@methane
Copy link
Member

methane commented Sep 21, 2017

Duplicate of #657

@methane methane marked this as a duplicate of #657 Sep 21, 2017
@methane methane closed this as completed Sep 21, 2017
@methane
Copy link
Member

methane commented Sep 21, 2017

Summary: If your program start showing "invalid connection" after #302 (26471af),
your program might execute same query multiple times. If the query was not idempotent, you might broke your data.

You must not rely on old behavior. You must close connection from client side, before idle timeout.
Use DB.SetConnMaxLifetime(time.Second*10).

@bgaifullin
Copy link
Contributor Author

bgaifullin commented Sep 21, 2017

I use "auto-commit" and there is only "read-only" queries :(

I think DB.SetConnMaxLifetime(%time less than mysql server idle timeout%), right ?

@methane
Copy link
Member

methane commented Sep 21, 2017 via email

@bgaifullin
Copy link
Contributor Author

Ok.

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

2 participants