From de3ea3491578feb2798650d85299362775885db0 Mon Sep 17 00:00:00 2001 From: Jianjun Liao Date: Fri, 12 Apr 2024 11:45:34 +0800 Subject: [PATCH 1/2] complete the list of unrecoverable tables Signed-off-by: Jianjun Liao --- br/pkg/restore/systable_restore.go | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/br/pkg/restore/systable_restore.go b/br/pkg/restore/systable_restore.go index 93b503f51b5b0..71d6a10a42704 100644 --- a/br/pkg/restore/systable_restore.go +++ b/br/pkg/restore/systable_restore.go @@ -39,11 +39,53 @@ var statsTables = map[string]map[string]struct{}{ }, } +var plan_replayer = map[string]map[string]struct{}{ + "mysql": { + "plan_replayer_status": {}, + "plan_replayer_task": {}, + }, +} + var unRecoverableTable = map[string]map[string]struct{}{ "mysql": { // some variables in tidb (e.g. gc_safe_point) cannot be recovered. "tidb": {}, "global_variables": {}, + // 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": {}, + // 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": {}, + // 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": {}, "column_stats_usage": {}, "capture_plan_baselines_blacklist": {}, @@ -51,6 +93,8 @@ var unRecoverableTable = map[string]map[string]struct{}{ "gc_delete_range": {}, "gc_delete_range_done": {}, + // TiDB internal system table to synchronize metadata locks across nodes. + "tidb_mdl_info": {}, // replace into view is not supported now "tidb_mdl_view": {}, }, From d427956194ace48069ff252f27fc4e1a612be91f Mon Sep 17 00:00:00 2001 From: Jianjun Liao Date: Mon, 20 Jan 2025 18:48:39 +0800 Subject: [PATCH 2/2] add more unrecoverable system tables Signed-off-by: Jianjun Liao --- .../restore/snap_client/systable_restore.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/br/pkg/restore/snap_client/systable_restore.go b/br/pkg/restore/snap_client/systable_restore.go index 4e6b598395c51..524cfa17fdf72 100644 --- a/br/pkg/restore/snap_client/systable_restore.go +++ b/br/pkg/restore/snap_client/systable_restore.go @@ -72,6 +72,10 @@ var unRecoverableTable = map[string]map[string]struct{}{ // 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": {}, @@ -83,6 +87,8 @@ var unRecoverableTable = map[string]map[string]struct{}{ "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": {}, @@ -141,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) { @@ -299,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 }