diff --git a/br/pkg/restore/snap_client/systable_restore.go b/br/pkg/restore/snap_client/systable_restore.go index 2e8dc71d1135e..524cfa17fdf72 100644 --- a/br/pkg/restore/snap_client/systable_restore.go +++ b/br/pkg/restore/snap_client/systable_restore.go @@ -28,6 +28,13 @@ const ( sysUserTableName = "user" ) +var planPeplayerTables = map[string]map[string]struct{}{ + "mysql": { + "plan_replayer_status": {}, + "plan_replayer_task": {}, + }, +} + var statsTables = map[string]map[string]struct{}{ "mysql": { "stats_buckets": {}, @@ -62,11 +69,55 @@ var unRecoverableTable = map[string]map[string]struct{}{ "tidb": {}, "global_variables": {}, "capture_plan_baselines_blacklist": {}, + // GET_LOCK() or IS_USED_LOCK() try to insert a lock into the table in a pessimistic transaction but finally rollback. + // Therefore actually the table is empty. + "advisory_locks": {}, + // Table ID is recorded in the column `job_info` so that the table cannot be recovered simply. + "analyze_jobs": {}, + // Table ID is recorded in the column `table_id` so that the table cannot be recovered simply. + "analyze_options": {}, + // Distributed eXecution Framework + // Records the tidb node information, no need to recovered. + "dist_framework_meta": {}, + "tidb_global_task": {}, + "tidb_global_task_history": {}, + "tidb_background_subtask": {}, + "tidb_background_subtask_history": {}, + // DDL internal system tables. + "tidb_ddl_history": {}, + "tidb_ddl_job": {}, + "tidb_ddl_reorg": {}, + // Table ID is recorded in the column `schema_change` so that the table cannot be recovered simply. + "tidb_ddl_notifier": {}, + // v7.2.0. Based on Distributed eXecution Framework, records running import jobs. + "tidb_import_jobs": {}, + + "help_topic": {}, + // records the RU for each resource group temporary, no need to recovered. + "request_unit_by_group": {}, + // load the table data into the memory. + "table_cache_meta": {}, + + // TiDB runaway internal information. + "tidb_runaway_queries": {}, + "tidb_runaway_watch": {}, + "tidb_runaway_watch_done": {}, + + // TiDB internal ttl information. + "tidb_ttl_job_history": {}, + "tidb_ttl_table_status": {}, + "tidb_ttl_task": {}, + + // TiDB internal timers. + "tidb_timers": {}, + // gc info don't need to recover. "gc_delete_range": {}, "gc_delete_range_done": {}, "index_advisor_results": {}, + // TiDB internal system table to synchronize metadata locks across nodes. + "tidb_mdl_info": {}, // replace into view is not supported now "tidb_mdl_view": {}, @@ -96,6 +147,15 @@ func isStatsTable(schemaName string, tableName string) bool { return ok } +func isPlanReplayerTables(schemaName string, tableName string) bool { + tableMap, ok := planPeplayerTables[schemaName] + if !ok { + return false + } + _, ok = tableMap[tableName] + return ok +} + // RestoreSystemSchemas restores the system schema(i.e. the `mysql` schema). // Detail see https://github.com/pingcap/br/issues/679#issuecomment-762592254. func (rc *SnapClient) RestoreSystemSchemas(ctx context.Context, f filter.Filter) (rerr error) { @@ -254,6 +314,10 @@ func (rc *SnapClient) replaceTemporaryTableToSystable(ctx context.Context, ti *m return nil } + if isPlanReplayerTables(dbName, tableName) { + return nil + } + if isUnrecoverableTable(dbName, tableName) { return nil }