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

owner: ignore duplicated DDL job in ddl puller (#2423) #2459

Merged
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
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