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

*(cdc): accept access denied error when query tidb_version (#11129) #11142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cdc/sink/dmlsink/txn/mysql/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ func newTestMockDB(t *testing.T) (db *sql.DB, mock sqlmock.Sqlmock) {
Number: 1305,
Message: "FUNCTION test.tidb_version does not exist",
})
// mock a different possible error for the second query
mock.ExpectQuery("select tidb_version()").WillReturnError(&dmysql.MySQLError{
Number: 1305,
Message: "FUNCTION test.tidb_version does not exist",
Number: 1044,
Message: "Access denied for user 'cdc'@'%' to database 'information_schema'",
})
require.Nil(t, err)
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/sink/mysql/db_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func CheckIsTiDB(ctx context.Context, db *sql.DB) (bool, error) {
log.Error("check tidb version error", zap.Error(err))
// downstream is not TiDB, do nothing
if mysqlErr, ok := errors.Cause(err).(*dmysql.MySQLError); ok && (mysqlErr.Number == tmysql.ErrNoDB ||
mysqlErr.Number == tmysql.ErrSpDoesNotExist) {
mysqlErr.Number == tmysql.ErrSpDoesNotExist || mysqlErr.Number == tmysql.ErrDBaccessDenied) {
return false, nil
}
return false, errors.Trace(err)
Expand Down
Loading