Skip to content

Commit

Permalink
source-mysql: More connection error logging
Browse files Browse the repository at this point in the history
I hate this TLS vs non-TLS connection retrying thing and how it
results in two distinct errors, let's just make sure to log both
so I can at least figure out what went wrong in all cases.
  • Loading branch information
willdonnelly committed Oct 8, 2024
1 parent 02692b5 commit 1019b0e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions source-mysql-batch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func connectMySQL(ctx context.Context, cfg *Config) (*client.Conn, error) {
log.WithField("addr", cfg.Address).Info("connected without TLS")
conn = connWithoutTLS
} else {
log.WithFields(log.Fields{"withTLS": errWithTLS, "nonTLS": errWithoutTLS}).Error("unable to connect to database")
var mysqlErr *mysql.MyError
if errors.As(errWithTLS, &mysqlErr) && mysqlErr.Code == mysql.ER_ACCESS_DENIED_ERROR {
return nil, cerrors.NewUserError(mysqlErr, "incorrect username or password")
Expand Down
1 change: 1 addition & 0 deletions source-mysql/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (db *mysqlDatabase) connect(_ context.Context) error {
logrus.WithField("addr", address).Info("connected without TLS")
db.conn = connWithoutTLS
} else {
logrus.WithFields(logrus.Fields{"withTLS": errWithTLS, "nonTLS": errWithoutTLS}).Error("unable to connect to database")
var mysqlErr *mysql.MyError
if errors.As(errWithTLS, &mysqlErr) && mysqlErr.Code == mysql.ER_ACCESS_DENIED_ERROR {
return cerrors.NewUserError(mysqlErr, "incorrect username or password")
Expand Down

0 comments on commit 1019b0e

Please sign in to comment.