Skip to content

Commit

Permalink
sink(ticdc): add one errors to ddl unretryable black list. (pingcap#8088
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Feb 28, 2023
1 parent 0c7720b commit db2e700
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cdc/sinkv2/ddlsink/mysql/mysql_ddl_sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func NewMySQLDDLSink(

func (m *mysqlDDLSink) 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 @@ -125,7 +129,7 @@ func (m *mysqlDDLSink) execDDLWithMaxRetries(ctx context.Context, ddl *model.DDL
}, retry.WithBackoffBaseDelay(pmysql.BackoffBaseDelay.Milliseconds()),
retry.WithBackoffMaxDelay(pmysql.BackoffMaxDelay.Milliseconds()),
retry.WithMaxTries(defaultDDLMaxRetry),
retry.WithIsRetryableErr(cerror.IsRetryableError))
retry.WithIsRetryableErr(errorutil.IsRetryableDDLError))
}

func (m *mysqlDDLSink) 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 db2e700

Please sign in to comment.