diff --git a/ddl/ddl.go b/ddl/ddl.go index c9ba3a768a577..28d15245ab3d8 100644 --- a/ddl/ddl.go +++ b/ddl/ddl.go @@ -755,6 +755,8 @@ func (d *ddl) Start(ctxPool *pools.ResourcePool) error { d.sessPool = sess.NewSessionPool(ctxPool, d.store) d.ownerManager.SetBeOwnerHook(func() { var err error + d.ddlSeqNumMu.Lock() + defer d.ddlSeqNumMu.Unlock() d.ddlSeqNumMu.seqNum, err = d.GetNextDDLSeqNum() if err != nil { logutil.BgLogger().Error("error when getting the ddl history count", zap.Error(err))