-
Notifications
You must be signed in to change notification settings - Fork 293
puller: Support discarding unsupported DDL by setting ignore-txn-start-ts
in filter. (#12287)
#12291
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
base: release-8.1
Are you sure you want to change the base?
puller: Support discarding unsupported DDL by setting ignore-txn-start-ts
in filter. (#12287)
#12291
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,7 +355,7 @@ | |
zap.Uint64("startTs", job.StartTS), | ||
zap.Uint64("finishTs", job.BinlogInfo.FinishedTS), | ||
zap.Error(err)) | ||
if p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.TableName) { | ||
if p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.TableName, job.StartTS) { | ||
return true, nil | ||
} | ||
return false, cerror.WrapError(cerror.ErrHandleDDLFailed, | ||
|
@@ -378,11 +378,50 @@ | |
return false, cerror.WrapError(cerror.ErrHandleDDLFailed, | ||
errors.Trace(err), job.Query, job.StartTS, job.StartTS) | ||
} | ||
<<<<<<< HEAD | ||
======= | ||
case timodel.ActionCreateTables: | ||
querys, err := ddl.SplitQueries(job.Query) | ||
if err != nil { | ||
return false, errors.Trace(err) | ||
} | ||
// we only use multiTableInfos and Querys when we generate job event | ||
// So if some table should be discard, we just need to delete the info from multiTableInfos and Querys | ||
if len(querys) != len(job.BinlogInfo.MultipleTableInfos) { | ||
log.Error("the number of queries in `Job.Query` is not equal to "+ | ||
"the number of `TableInfo` in `Job.BinlogInfo.MultipleTableInfos`", | ||
zap.Int("numQueries", len(querys)), | ||
zap.Int("numTableInfos", len(job.BinlogInfo.MultipleTableInfos)), | ||
zap.String("Job.Query", job.Query), | ||
zap.Any("Job.BinlogInfo.MultipleTableInfos", job.BinlogInfo.MultipleTableInfos), | ||
zap.Error(cerror.ErrTiDBUnexpectedJobMeta.GenWithStackByArgs())) | ||
return false, cerror.ErrTiDBUnexpectedJobMeta.GenWithStackByArgs() | ||
} | ||
|
||
var newMultiTableInfos []*timodel.TableInfo | ||
var newQuerys []string | ||
|
||
multiTableInfos := job.BinlogInfo.MultipleTableInfos | ||
|
||
for index, tableInfo := range multiTableInfos { | ||
// judge each table whether need to be skip | ||
if p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, tableInfo.Name.O, job.StartTS) { | ||
continue | ||
} | ||
newMultiTableInfos = append(newMultiTableInfos, multiTableInfos[index]) | ||
newQuerys = append(newQuerys, querys[index]) | ||
} | ||
|
||
skip = len(newMultiTableInfos) == 0 | ||
|
||
job.BinlogInfo.MultipleTableInfos = newMultiTableInfos | ||
job.Query = strings.Join(newQuerys, "") | ||
>>>>>>> db43be26bf (puller: Support discarding unsupported DDL by setting `ignore-txn-start-ts` in filter. (#12287)) | ||
Check failure on line 419 in cdc/puller/ddl_puller.go
|
||
Comment on lines
+381
to
+419
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
case timodel.ActionRenameTable: | ||
oldTable, ok := snap.PhysicalTableByID(job.TableID) | ||
if !ok { | ||
// 1. If we can not find the old table, and the new table name is in filter rule, return error. | ||
discard := p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.BinlogInfo.TableInfo.Name.O) | ||
discard := p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.BinlogInfo.TableInfo.Name.O, job.StartTS) | ||
if !discard { | ||
return false, cerror.ErrSyncRenameTableFailed.GenWithStackByArgs(job.TableID, job.Query) | ||
} | ||
|
@@ -398,8 +437,8 @@ | |
} | ||
// since we can find the old table, it must be able to find the old schema. | ||
// 2. If we can find the preTableInfo, we filter it by the old table name. | ||
skipByOldTableName := p.filter.ShouldDiscardDDL(job.Type, oldTable.TableName.Schema, oldTable.TableName.Table) | ||
skipByNewTableName := p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.BinlogInfo.TableInfo.Name.O) | ||
skipByOldTableName := p.filter.ShouldDiscardDDL(job.Type, oldTable.TableName.Schema, oldTable.TableName.Table, job.StartTS) | ||
skipByNewTableName := p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.BinlogInfo.TableInfo.Name.O, job.StartTS) | ||
if err != nil { | ||
return false, cerror.WrapError(cerror.ErrHandleDDLFailed, | ||
errors.Trace(err), job.Query, job.StartTS, job.StartTS) | ||
|
@@ -424,7 +463,7 @@ | |
if job.BinlogInfo.TableInfo != nil { | ||
job.TableName = job.BinlogInfo.TableInfo.Name.O | ||
} | ||
skip = p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.TableName) | ||
skip = p.filter.ShouldDiscardDDL(job.Type, job.SchemaName, job.TableName, job.StartTS) | ||
} | ||
|
||
if skip { | ||
|
@@ -544,15 +583,23 @@ | |
if !ok { | ||
shouldDiscardOldTable = true | ||
} else { | ||
<<<<<<< HEAD | ||
shouldDiscardOldTable = p.filter.ShouldDiscardDDL(job.Type, oldSchemaNames[i].O, oldTable.Name.O) | ||
======= | ||
shouldDiscardOldTable = p.filter.ShouldDiscardDDL(job.Type, info.OldSchemaName.O, oldTable.Name.O, job.StartTS) | ||
>>>>>>> db43be26bf (puller: Support discarding unsupported DDL by setting `ignore-txn-start-ts` in filter. (#12287)) | ||
Check failure on line 590 in cdc/puller/ddl_puller.go
|
||
Comment on lines
+586
to
+590
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
newSchemaName, ok := snap.SchemaByID(newSchemaIDs[i]) | ||
if !ok { | ||
// the new table name does not hit the filter rule, so we should discard the table. | ||
shouldDiscardNewTable = true | ||
} else { | ||
<<<<<<< HEAD | ||
shouldDiscardNewTable = p.filter.ShouldDiscardDDL(job.Type, newSchemaName.Name.O, newTableNames[i].O) | ||
======= | ||
shouldDiscardNewTable = p.filter.ShouldDiscardDDL(job.Type, newSchemaName.Name.O, info.NewTableName.O, job.StartTS) | ||
>>>>>>> db43be26bf (puller: Support discarding unsupported DDL by setting `ignore-txn-start-ts` in filter. (#12287)) | ||
Comment on lines
+598
to
+602
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
|
||
if shouldDiscardOldTable && shouldDiscardNewTable { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Joining queries without a separator might make the reconstructed query string hard to read in logs and error messages. Consider joining with a semicolon to improve readability.