diff --git a/br/pkg/task/restore.go b/br/pkg/task/restore.go index 01d945939fc15..7dcdc1274413a 100644 --- a/br/pkg/task/restore.go +++ b/br/pkg/task/restore.go @@ -580,7 +580,8 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf TTL: utils.DefaultBRGCSafePointTTL, ID: utils.MakeSafePointID(), } - g.Record("BackupTS", restoreTS) + g.Record("BackupTS", backupMeta.EndVersion) + g.Record("RestoreTS", restoreTS) // restore checksum will check safe point with its start ts, see details at // https://github.com/pingcap/tidb/blob/180c02127105bed73712050594da6ead4d70a85f/store/tikv/kv.go#L186-L190 diff --git a/executor/brie.go b/executor/brie.go index c21432b654301..f26ae56aa32e4 100644 --- a/executor/brie.go +++ b/executor/brie.go @@ -102,6 +102,7 @@ type brieTaskInfo struct { storage string connID uint64 backupTS uint64 + restoreTS uint64 archiveSize uint64 message string } @@ -411,9 +412,17 @@ func (e *BRIEExec) Next(ctx context.Context, req *chunk.Chunk) error { req.AppendString(0, e.info.storage) req.AppendUint64(1, e.info.archiveSize) - req.AppendUint64(2, e.info.backupTS) - req.AppendTime(3, e.info.queueTime) - req.AppendTime(4, e.info.execTime) + switch e.info.kind { + case ast.BRIEKindBackup: + req.AppendUint64(2, e.info.backupTS) + req.AppendTime(3, e.info.queueTime) + req.AppendTime(4, e.info.execTime) + case ast.BRIEKindRestore: + req.AppendUint64(2, e.info.backupTS) + req.AppendUint64(3, e.info.restoreTS) + req.AppendTime(4, e.info.queueTime) + req.AppendTime(5, e.info.execTime) + } e.info = nil return nil } @@ -569,6 +578,8 @@ func (gs *tidbGlueSession) Record(name string, value uint64) { switch name { case "BackupTS": gs.info.backupTS = value + case "RestoreTS": + gs.info.restoreTS = value case "Size": gs.info.archiveSize = value } diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go index dca14679a498d..f00d0625c9cf0 100644 --- a/planner/core/planbuilder.go +++ b/planner/core/planbuilder.go @@ -2925,7 +2925,7 @@ func buildCancelDDLJobsFields() (*expression.Schema, types.NameSlice) { return schema.col2Schema(), schema.names } -func buildBRIESchema() (*expression.Schema, types.NameSlice) { +func buildBRIESchema(kind ast.BRIEKind) (*expression.Schema, types.NameSlice) { longlongSize, _ := mysql.GetDefaultFieldLengthAndDecimal(mysql.TypeLonglong) datetimeSize, _ := mysql.GetDefaultFieldLengthAndDecimal(mysql.TypeDatetime) @@ -2933,6 +2933,9 @@ func buildBRIESchema() (*expression.Schema, types.NameSlice) { schema.Append(buildColumnWithName("", "Destination", mysql.TypeVarchar, 255)) schema.Append(buildColumnWithName("", "Size", mysql.TypeLonglong, longlongSize)) schema.Append(buildColumnWithName("", "BackupTS", mysql.TypeLonglong, longlongSize)) + if kind == ast.BRIEKindRestore { + schema.Append(buildColumnWithName("", "Cluster TS", mysql.TypeLonglong, longlongSize)) + } schema.Append(buildColumnWithName("", "Queue Time", mysql.TypeDatetime, datetimeSize)) schema.Append(buildColumnWithName("", "Execution Time", mysql.TypeDatetime, datetimeSize)) return schema.col2Schema(), schema.names @@ -3178,7 +3181,7 @@ func (b *PlanBuilder) buildSimple(ctx context.Context, node ast.StmtNode) (Plan, return nil, err } case *ast.BRIEStmt: - p.setSchemaAndNames(buildBRIESchema()) + p.setSchemaAndNames(buildBRIESchema(raw.Kind)) if raw.Kind == ast.BRIEKindRestore { err := ErrSpecificAccessDenied.GenWithStackByArgs("SUPER or RESTORE_ADMIN") b.visitInfo = appendDynamicVisitInfo(b.visitInfo, "RESTORE_ADMIN", false, err)