Skip to content

Commit

Permalink
Enhance mysql error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenepaniot committed Jan 18, 2023
1 parent 2a51a2f commit 1337b85
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mysql/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
const (
cleartextPasswords = "cleartext"
nativePasswords = "native"
unknownVarErrCode = 1193
unknownUserErrCode = 1396
)

Expand Down Expand Up @@ -314,15 +313,15 @@ func connectToMySQLInternal(ctx context.Context, conf *MySQLConfiguration) (*One
retryError := resource.RetryContext(ctx, conf.ConnectRetryTimeoutSec, func() *resource.RetryError {
db, err = sql.Open(driverName, dsn)
if err != nil {
if mysqlErrorNumber(err) == unknownVarErrCode || cloudsqlErrorNumber(err) != 0 || ctx.Err() != nil {
if mysqlErrorNumber(err) != 0 || cloudsqlErrorNumber(err) != 0 || ctx.Err() != nil {
return resource.NonRetryableError(err)
}
return resource.RetryableError(err)
}

err = db.PingContext(ctx)
if err != nil {
if mysqlErrorNumber(err) == unknownVarErrCode || cloudsqlErrorNumber(err) != 0 || ctx.Err() != nil {
if mysqlErrorNumber(err) != 0 || cloudsqlErrorNumber(err) != 0 || ctx.Err() != nil {
return resource.NonRetryableError(err)
}

Expand Down

0 comments on commit 1337b85

Please sign in to comment.