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

br: Compatibility problem between br and TiDB for DDLs about attribute in Incremental Backup #29360

Merged
merged 9 commits into from
Nov 4, 2021
15 changes: 15 additions & 0 deletions br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ func BuildBackupRangeAndSchema(
return ranges, backupSchemas, nil
}

func skipUnsupportedDDLJob(job *model.Job) bool {
switch job.Type {
// Because TiDB V5.3.0 supports TableAttributes and TablePartitionAttributes.
// Incremental Backup need skip these DDLs to be compatible with previous br versions.
case model.ActionAlterTableAttributes, model.ActionAlterTablePartitionAttributes:
return true
}

return false
}

// WriteBackupDDLJobs sends the ddl jobs are done in (lastBackupTS, backupTS] to metaWriter.
func WriteBackupDDLJobs(metaWriter *metautil.MetaWriter, store kv.Storage, lastBackupTS, backupTS uint64) error {
snapshot := store.GetSnapshot(kv.NewVersion(backupTS))
Expand Down Expand Up @@ -388,6 +399,10 @@ func WriteBackupDDLJobs(metaWriter *metautil.MetaWriter, store kv.Storage, lastB

count := 0
for _, job := range allJobs {
if skipUnsupportedDDLJob(job) {
continue
}

if (job.State == model.JobStateDone || job.State == model.JobStateSynced) &&
(job.BinlogInfo != nil && job.BinlogInfo.SchemaVersion > lastSchemaVersion) {
jobBytes, err := json.Marshal(job)
Expand Down