log-backup: fix checkpoint display (#36166)

fixed pingcap/tidb#36092
This commit is contained in:
山岚
2022-07-13 19:25:05 +08:00
committed by GitHub
parent 8997604531
commit 2ff12e8b64

View File

@ -136,6 +136,8 @@ func (p *printByTable) AddTask(task TaskStatus) {
info := fmt.Sprintf("%s; gap=%s", pTime, gapColor.Sprint(gap))
return info
}
cp := task.GetMinStoreCheckpoint()
table.Add("checkpoint[global]", formatTS(cp.TS))
p.addCheckpoints(&task, table, formatTS)
for store, e := range task.LastErrors {
table.Add(fmt.Sprintf("error[store=%d]", store), e.ErrorCode)
@ -147,21 +149,15 @@ func (p *printByTable) AddTask(task TaskStatus) {
func (p *printByTable) addCheckpoints(task *TaskStatus, table *glue.Table, formatTS func(uint64) string) {
cp := task.GetMinStoreCheckpoint()
items := make([][2]string, 0, len(task.Checkpoints))
if cp.Type() != CheckpointTypeGlobal {
for _, cp := range task.Checkpoints {
switch cp.Type() {
case CheckpointTypeStore:
items = append(items, [2]string{fmt.Sprintf("checkpoint[store=%d]", cp.ID), formatTS(cp.TS)})
table.Add(fmt.Sprintf("checkpoint[store=%d]", cp.ID), formatTS(cp.TS))
}
}
} else {
items = append(items, [2]string{"checkpoint[central-global]", formatTS(cp.TS)})
}
for _, item := range items {
table.Add(item[0], item[1])
}
}
func (p *printByTable) PrintTasks() {