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

[sql connector] Please recreate sql connection on connection failure #3071

Closed
hankduan opened this issue Feb 22, 2020 · 2 comments
Closed

[sql connector] Please recreate sql connection on connection failure #3071

hankduan opened this issue Feb 22, 2020 · 2 comments
Labels
sql Support for SQL databases (ie. MySQL)

Comments

@hankduan
Copy link

Summary:
We had an incident where we failed over the mysql instance so the cname resolves to another ip at that time, but cadence did not recover. Cadence recovered after manually restarting it.
Later we found this is because Cadence uses go-sql-driver, which does not re-establish the connection to sql on failure.
Given this is a common failure mode, can Cadence recreate the sql connection on connection failure?

Here's the slack chat thread

Regarding the MySQL connector for cadence. We had an incident where we failed over the mysql instance so the cname resolves to another ip at that time, but cadence did not recover. Does Cadence's mysql connector re-resolve the cname

Maxim 23 hours ago
Filed go-sql-driver/mysql#1064

Hank Duan 23 hours ago
Thanks!

Maxim 21 hours ago
Did Cadence recover after restart?

Hank Duan 17 hours ago
yea

Hank Duan 17 hours ago
but it required a manual restart

Maxim 7 hours ago
Then I believe it is db driver issue

Hank Duan 2 hours ago
looks like they will not address it at the driver side. Are there any plans for cadence to reestablish connection on failures?

Hank Duan 2 hours ago
this is a very common failure mode

Hank Duan 2 hours ago
i.e. db failure over causes cname to switch. The original ip might no longer be connectable and will fail indefinitely until cadence re-resolve cname

Maxim 1 hour ago
Please file an issue

@jontro
Copy link
Contributor

jontro commented Feb 26, 2020

Just to chime in here, the issue could potentially be caused by a too long idle timeout.

See http://go-database-sql.org/connection-pool.html and this linked issue go-sql-driver/mysql#257

Changing maxConnLifetime should be a first step to try.
Afaik the connection manager should take care of retries. Dns records must of course be properly configured with a low ttl

@sheerun
Copy link
Contributor

sheerun commented Feb 26, 2020

Could this be handled at cadence level by specifying multiple DNS addresses to connect? e.g. addresses to primary master and secondary master

@meiliang86 meiliang86 added the sql Support for SQL databases (ie. MySQL) label Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql Support for SQL databases (ie. MySQL)
Projects
None yet
Development

No branches or pull requests

5 participants