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
#36418)

close #36276
  • Loading branch information
ti-srebot authored Aug 9, 2022
1 parent 475c6a8 commit c9d8794
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(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 = &copySequenceInfo

// Restart the sequence value.
Expand All @@ -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)
}
Expand Down

0 comments on commit c9d8794

Please sign in to comment.