Skip to content

Commit

Permalink
ddl: fix ingest checkpoint not resumed for empty partitions (#44271) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored May 30, 2023
1 parent 2fa7707 commit 635a436
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions ddl/job_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ func getDDLReorgHandle(se *sess.Session, job *model.Job) (element *meta.Element,
}

func getCheckpointReorgHandle(se *sess.Session, job *model.Job) (startKey, endKey kv.Key, physicalTableID int64, err error) {
startKey, endKey = kv.Key{}, kv.Key{}
sql := fmt.Sprintf("select reorg_meta from mysql.tidb_ddl_reorg where job_id = %d", job.ID)
ctx := kv.WithInternalSourceType(context.Background(), getDDLRequestSource(job.Type))
rows, err := se.Execute(ctx, sql, "get_handle")
Expand All @@ -629,8 +630,12 @@ func getCheckpointReorgHandle(se *sess.Session, job *model.Job) (startKey, endKe
zap.String("end", hex.EncodeToString(cp.EndKey)),
zap.Int64("checkpoint physical ID", cp.PhysicalID))
physicalTableID = cp.PhysicalID
startKey = cp.StartKey
endKey = cp.EndKey
if len(cp.StartKey) > 0 {
startKey = cp.StartKey
}
if len(cp.EndKey) > 0 {
endKey = cp.EndKey
}
}
}
return
Expand Down
2 changes: 1 addition & 1 deletion ddl/reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func overwriteReorgInfoFromGlobalCheckpoint(w *worker, sess *sess.Session, job *
if err != nil {
return errors.Trace(err)
}
if len(start) > 0 && len(end) > 0 && pid > 0 {
if pid > 0 {
reorgInfo.StartKey = start
reorgInfo.EndKey = end
reorgInfo.PhysicalTableID = pid
Expand Down

0 comments on commit 635a436

Please sign in to comment.