Skip to content

Commit

Permalink
owner: ignore duplicated DDL job in ddl puller (#2423)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei authored Aug 3, 2021
1 parent 9006bca commit 15e53d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions cdc/owner/ddl_puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type ddlPullerImpl struct {
mu sync.Mutex
resolvedTS uint64
pendingDDLJobs []*timodel.Job
lastDDLJobID int64
cancel context.CancelFunc
}

Expand Down Expand Up @@ -117,9 +118,14 @@ func (h *ddlPullerImpl) Run(ctx cdcContext.Context) error {
log.Info("discard the ddl job", zap.Int64("jobID", job.ID), zap.String("query", job.Query))
return nil
}
if job.ID == h.lastDDLJobID {
log.Warn("ignore duplicated DDL job", zap.Any("job", job))
return nil
}
h.mu.Lock()
defer h.mu.Unlock()
h.pendingDDLJobs = append(h.pendingDDLJobs, job)
h.lastDDLJobID = job.ID
return nil
}

Expand Down
5 changes: 2 additions & 3 deletions cdc/owner/ddl_puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ func (s *ddlPullerSuite) TestPuller(c *check.C) {
resolvedTs, ddl = p.PopFrontDDL()
c.Assert(resolvedTs, check.Equals, uint64(25))
c.Assert(ddl.ID, check.Equals, int64(3))
resolvedTs, ddl = p.PopFrontDDL()
c.Assert(resolvedTs, check.Equals, uint64(25))
c.Assert(ddl.ID, check.Equals, int64(3))
_, ddl = p.PopFrontDDL()
c.Assert(ddl, check.IsNil)

waitResolvedTsGrowing(c, p, 30)
resolvedTs, ddl = p.PopFrontDDL()
Expand Down

0 comments on commit 15e53d9

Please sign in to comment.