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

skip the "cancled" ddl in ddl history #1229

Merged
merged 2 commits into from
May 11, 2023
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
9 changes: 7 additions & 2 deletions drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ ForLoop:
schema, table string
)
sql := b.job.Query

if b.job.BinlogInfo.SchemaVersion == 0 {
log.Info("skip ddl due to the failed ddl", zap.String("sql", sql), zap.Int64("commit ts", commitTS))
appendFakeBinlogIfNeeded(nil, commitTS)
continue
}
schema, table, err = s.schema.getSchemaTableAndDelete(b.job.BinlogInfo.SchemaVersion)
if err != nil {
err = errors.Trace(err)
Expand Down Expand Up @@ -505,8 +511,7 @@ ForLoop:
}
}
} else {
log.Info("skip ddl by SyncDDL setting to false", zap.String("schema", schema), zap.String("table", table),
zap.String("sql", sql), zap.Int64("commit ts", commitTS))
log.Info("skip ddl by SyncDDL setting to false", zap.String("sql", sql), zap.Int64("commit ts", commitTS))
// A empty sql force it to evict the downstream table info.
if s.cfg.DestDBType == "tidb" || s.cfg.DestDBType == "mysql" || s.cfg.DestDBType == "oracle" {
shouldSkip = true
Expand Down
28 changes: 28 additions & 0 deletions drainer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,34 @@ func (s *syncerSuite) TestNewSyncer(c *check.C) {
job: job,
})

// Add failed ddl
commitTS++
jobID++
binlog = &pb.Binlog{
Tp: pb.BinlogType_Commit,
CommitTs: commitTS,
DdlQuery: []byte("alter table test.test add column a int"),
DdlJobId: jobID,
}
job = &model.Job{
ID: jobID,
SchemaID: 1, // must be the previous create schema id of `test`
Type: model.ActionAddColumn,
State: model.JobStateSynced,
Query: "create table test.test(id int)",
BinlogInfo: &model.HistoryInfo{
SchemaVersion: 0,
TableInfo: &model.TableInfo{
ID: testTableID,
Name: model.CIStr{O: "test", L: "test"},
},
},
}
syncer.Add(&binlogItem{
binlog: binlog,
job: job,
})

// Add dml
commitTS++
binlog = &pb.Binlog{
Expand Down