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

ddl: prevent returning zero schema version for alter sequence (#36277) #36414

Merged
merged 3 commits into from
Aug 9, 2022
Merged
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
10 changes: 8 additions & 2 deletions ddl/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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 @@ -272,7 +276,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