From 61528223d22763358d5c5fecda8819dd4da6511d Mon Sep 17 00:00:00 2001 From: Arenatlx <314806019@qq.com> Date: Thu, 21 Jul 2022 15:15:09 +0800 Subject: [PATCH] cherry pick #36277 to release-6.1 Signed-off-by: ti-srebot --- ddl/sequence.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ddl/sequence.go b/ddl/sequence.go index ceea68d90810b..ad8390bdf2cc2 100644 --- a/ddl/sequence.go +++ b/ddl/sequence.go @@ -259,7 +259,11 @@ func onAlterSequence(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ erro job.State = model.JobStateCancelled return ver, errors.Trace(err) } - shouldUpdateVer := !reflect.DeepEqual(*tblInfo.Sequence, copySequenceInfo) || restart + same := reflect.DeepEqual(*tblInfo.Sequence, copySequenceInfo) + if same && !restart { + job.State = model.JobStateDone + return ver, errors.Trace(err) + } tblInfo.Sequence = ©SequenceInfo // Restart the sequence value. @@ -276,7 +280,9 @@ func onAlterSequence(d *ddlCtx, t *meta.Meta, job *model.Job) (ver int64, _ erro } // Store the sequence info into kv. - ver, err = updateVersionAndTableInfo(d, t, job, tblInfo, shouldUpdateVer) + // Set shouldUpdateVer always to be true even altering doesn't take effect, since some tools like drainer won't take + // care of SchemaVersion=0. + ver, err = updateVersionAndTableInfo(d, t, job, tblInfo, true) if err != nil { return ver, errors.Trace(err) }