Skip to content

Commit

Permalink
ddl: prevent returning zero schema version for alter sequence (#36277) (
Browse files Browse the repository at this point in the history
#36416)

close #36276
  • Loading branch information
ti-srebot authored Aug 9, 2022
1 parent 965bb79 commit 3dc3508
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ddl/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ func onAlterSequence(t *meta.Meta, job *model.Job) (ver int64, _ error) {
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 = &copySequenceInfo

// Restart the sequence value.
Expand All @@ -276,7 +280,9 @@ func onAlterSequence(t *meta.Meta, job *model.Job) (ver int64, _ error) {
}

// Store the sequence info into kv.
ver, err = updateVersionAndTableInfo(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(t, job, tblInfo, true)
if err != nil {
return ver, errors.Trace(err)
}
Expand Down

0 comments on commit 3dc3508

Please sign in to comment.