Skip to content

Commit

Permalink
sink(ticdc): add one errors to ddl unretryable black list. (#8088)
Browse files Browse the repository at this point in the history
close #8087
  • Loading branch information
asddongmen authored Feb 28, 2023
1 parent dca26ee commit a14273a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cdc/sink/ddlsink/mysql/mysql_ddl_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func NewDDLSink(
// WriteDDLEvent writes a DDL event to the mysql database.
func (m *DDLSink) WriteDDLEvent(ctx context.Context, ddl *model.DDLEvent) error {
err := m.execDDLWithMaxRetries(ctx, ddl)
// we should not retry changefeed if DDL failed by return an unretryable error.
if !errorutil.IsRetryableDDLError(err) {
return cerror.WrapChangefeedUnretryableErr(err)
}
return errors.Trace(err)
}

Expand Down Expand Up @@ -127,7 +131,7 @@ func (m *DDLSink) execDDLWithMaxRetries(ctx context.Context, ddl *model.DDLEvent
}, retry.WithBackoffBaseDelay(pmysql.BackoffBaseDelay.Milliseconds()),
retry.WithBackoffMaxDelay(pmysql.BackoffMaxDelay.Milliseconds()),
retry.WithMaxTries(defaultDDLMaxRetry),
retry.WithIsRetryableErr(cerror.IsRetryableError))
retry.WithIsRetryableErr(errorutil.IsRetryableDDLError))
}

func (m *DDLSink) execDDL(pctx context.Context, ddl *model.DDLEvent) error {
Expand Down
3 changes: 2 additions & 1 deletion pkg/errorutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func IsRetryableDDLError(err error) bool {
mysql.ErrNoSuchTable,
mysql.ErrNoSuchIndex,
mysql.ErrKeyColumnDoesNotExits,
mysql.ErrWrongColumnName:
mysql.ErrWrongColumnName,
mysql.ErrPartitionMgmtOnNonpartitioned:
return false
}
return true
Expand Down
2 changes: 1 addition & 1 deletion pkg/errorutil/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func TestIsRetryableDDLError(t *testing.T) {
err error
ret bool
}{
{nil, false},
{errors.New("raw error"), false},
{newMysqlErr(tmysql.ErrNoDB, "Error: Duplicate key name 'some_key'"), false},
{newMysqlErr(tmysql.ErrParse, "Can't create database"), false},
Expand All @@ -105,6 +104,7 @@ func TestIsRetryableDDLError(t *testing.T) {
{newMysqlErr(tmysql.ErrNoSuchIndex, "index not exist"), false},
{newMysqlErr(tmysql.ErrWrongColumnName, "wrong column name'"), false},
{newMysqlErr(tmysql.ErrDupKeyName, "Duplicate key name 'some_key'"), true},
{newMysqlErr(tmysql.ErrPartitionMgmtOnNonpartitioned, "xx"), false},
}

for _, c := range cases {
Expand Down

0 comments on commit a14273a

Please sign in to comment.