Skip to content

Commit

Permalink
drainer: fix ddl system table (#1251) (#1252)
Browse files Browse the repository at this point in the history
close #1250
  • Loading branch information
ti-chi-bot authored Jun 26, 2023
1 parent 3621449 commit a3f843b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions drainer/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/log"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/parser/mysql"
"go.uber.org/zap"
Expand Down Expand Up @@ -505,6 +506,9 @@ func (s *Schema) handleDDL(job *model.Job) (schemaName string, tableName string,
if table == nil {
return "", "", "", errors.NotValidf("job %d", job.ID)
}
if isDDLSystemTable(table.ID) {
continue
}

schema, ok := s.SchemaByID(job.SchemaID)
if !ok {
Expand Down Expand Up @@ -612,5 +616,13 @@ func addImplicitColumn(table *model.TableInfo) {
// Now, it write DDL Binlog in the txn that the state of job is changed to *done* (before change to *synced*)
// At state *done*, it will be always and only changed to *synced*.
func skipJob(job *model.Job) bool {
if isDDLSystemTable(job.TableID) {
return true
}
return !job.IsSynced() && !job.IsDone()
}

// isDDLSystemTable checks if the tableID is a ddl system table ID.
func isDDLSystemTable(tableID int64) bool {
return tableID > meta.MaxGlobalID
}
4 changes: 2 additions & 2 deletions drainer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ ForLoop:
} else if jobID > 0 {
log.Debug("get ddl binlog job", zap.Stringer("job", b.job))

if skipUnsupportedDDLJob(b.job) {
if skipUnsupportedDDLJob(b.job) || isDDLSystemTable(b.job.TableID) {
log.Info("skip unsupported DDL job", zap.Stringer("job", b.job))
appendFakeBinlogIfNeeded(nil, commitTS)
continue
Expand Down Expand Up @@ -601,7 +601,7 @@ func skipDMLEvent(pv *pb.PrewriteValue, schema *Schema, filter *filter.Filter, b
return false, errors.Errorf("not found table id: %d", mutation.GetTableId())
}

if filter.SkipSchemaAndTable(schemaName, tableName) {
if filter.SkipSchemaAndTable(schemaName, tableName) || isDDLSystemTable(mutation.GetTableId()) {
log.Debug("skip dml", zap.String("schema", schemaName), zap.String("table", tableName))
continue
}
Expand Down

0 comments on commit a3f843b

Please sign in to comment.