-
Notifications
You must be signed in to change notification settings - Fork 1k
allow disabling the default golang database/sql retry behavior #899
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
Conversation
|
||
// here we issue assert that even though we only issued 1 query, that the retries | ||
// remained on and there were 3 calls to the DB. | ||
require.Equal(t, 3, srv.handler.queryCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we had 3 calls to the server mockHandler because the database/sql package retried 3 times and retries were NOT turned off.
|
||
// here we issue assert that even though we only issued 1 query, that the retries | ||
// remained on and there were 3 calls to the DB. | ||
require.Equal(t, 1, srv.handler.queryCount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same test as before but the retries were off and now there is only 1 call to the server mockHandler
…mysql-org#894) After upgrading to MariaDB 11.4, the canal module stopped detecting row updates within transactions due to incorrect handling of fake rotate events. MariaDB 11.4 does not set LogPos for certain events, causing these events to be ignored. This fix modifies the handling to consider fake rotate events only for ROTATE_EVENTs with timestamp = 0, aligning with MariaDB and MySQL documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest lgtm
…ditional-ddls * origin/add-additional-ddls: allow disabling the default golang database/sql retry behavior (go-mysql-org#899)
We've run into a problem caused by the Golangs
database/sql
package default retry behavior (which can't be disabled by the way) when an ErrBadConn from thedatabase/sql/driver
is returned by the driver. We're looking to have our application fail fast when an issue occurs reaching the DB, but as of now we're seeing 3 retries, causing our application to hang up longer than we'd like.Seems like others in the community have been asking for a way to disable retries, see golang/go#52886 but the go developers have decided to not allow developers to configure that behavior.
This PR makes use of the Validator interface, along with introducing a new Driver argument called
retries
to determine if ErrBadConn or the go-mysql-org native ErrBadConn should be returned.This takes advantage of the fact that retry won't occur unless the database/sql ErrBadConn is returned. Per go docs:
And to maintain the behavior of discarding bad connection, the Validator interface will return false for isValid(), preventing the bad connection from being cached for reuse in sql.DB.
Thoughts on this are appreciated.