Skip to content

Commit

Permalink
mounter: skip tiflash ddl (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
leoppro authored Mar 20, 2020
1 parent abccd4c commit bc45061
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cdc/entry/schema_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func (s *Storage) HandlePreviousDDLJobIfNeed(commitTs uint64) error {
}
currentJob, jobs := s.jobList.FetchNextJobs(s.currentJob, commitTs)
for _, job := range jobs {
if skipJob(job) {
if SkipJob(job) {
log.Info("skip DDL job because the job isn't synced and done", zap.Stringer("job", job))
continue
}
Expand All @@ -463,7 +463,7 @@ func (s *Storage) HandlePreviousDDLJobIfNeed(commitTs uint64) error {
func (s *Storage) HandleDDL(job *timodel.Job) (schemaName string, tableName string, sql string, err error) {
log.Debug("handle job: ", zap.String("sql query", job.Query), zap.Stringer("job", job))

if skipJob(job) {
if SkipJob(job) {
return "", "", "", nil
}

Expand Down Expand Up @@ -688,10 +688,15 @@ func (s *Storage) IsTruncateTableID(id int64) bool {
return ok
}

// SkipJob skip the job should not be executed
// TiDB write DDL Binlog for every DDL Job, we must ignore jobs that are cancelled or rollback
// For older version TiDB, it write DDL Binlog in the txn that the state of job is changed to *synced*
// 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 *timodel.Job) bool {
func SkipJob(job *timodel.Job) bool {
switch job.Type {
case timodel.ActionSetTiFlashReplica, timodel.ActionUpdateTiFlashReplicaStatus:
return true
}
return !job.IsSynced() && !job.IsDone()
}
2 changes: 1 addition & 1 deletion cdc/owner_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (h *ddlHandler) receiveDDL(rawDDL *model.RawKVEntry) error {
if err != nil {
return errors.Trace(err)
}
if job == nil {
if job == nil || entry.SkipJob(job) {
return nil
}

Expand Down

0 comments on commit bc45061

Please sign in to comment.