br: system view tidb_mdl_view is missing when br restore with --with-sys-table
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
- Backup cluster
```shell
tiup br backup full --pd "127.0.0.1:2379" --storage "s3://us-west-2-demo-bucket-backup/full?access-key=xxxx&secret-access-key=xxxx" --log-file backup.log
```
- Drop system view `mysq.tidb_mdl_view`
```sql
drop view mysql.tidb_mdl_view;
```
- Restore cluster with `--with-sys-table`
```shell
tiup br restore full --pd "127.0.0.1:2379" --storage "s3://us-west-2-demo-bucket-backup/full?access-key=xxxx&secret-access-key=xxxx" --with-sys-table --log-file restore.log
```
- View `mysql.tidb_mdl_view` existed when restored to `__TiDB_BR_Temporary_mysql` database, but was missing during rename ops.
```sql
mysql> select * from views\G
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: __TiDB_BR_Temporary_mysql
TABLE_NAME: tidb_mdl_view
VIEW_DEFINITION: (SELECT `job_id` AS `job_id`,`db_name` AS `db_name`,`table_name` AS `table_name`,`query` AS `query`,`session_id` AS `session_id`,`txnstart` AS `txnstart`,TIDB_DECODE_SQL_DIGESTS(`all_sql_digests`, 4096) AS `SQL_DIGESTS` FROM ((`information_schema`.`ddl_jobs`) JOIN `information_schema`.`cluster_tidb_trx`) JOIN `information_schema`.`cluster_processlist` WHERE (`ddl_jobs`.`state`!=_UTF8MB4'synced' AND `ddl_jobs`.`state`!=_UTF8MB4'cancelled') AND FIND_IN_SET(`ddl_jobs`.`table_id`, `cluster_tidb_trx`.`related_table_ids`) AND `cluster_tidb_trx`.`session_id`=`cluster_processlist`.`id`)
CHECK_OPTION: CASCADED
IS_UPDATABLE: NO
DEFINER: @
SECURITY_TYPE: DEFINER
CHARACTER_SET_CLIENT: utf8mb4
COLLATION_CONNECTION: utf8mb4_bin
1 row in set (0.00 sec)
mysql> select * from views\G
Empty set (0.00 sec)
```
### 2. What did you expect to see? (Required)
`mysql.tidb_mdl_view` was sucessfully restored from backup.
### 3. What did you see instead (Required)
`mysql.tidb_mdl_view` was missing.
### 4. What is your TiDB version? (Required)
```sql
mysql> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v7.3.0
Edition: Community
Git Commit Hash: 40b72e7a9a4fc9670d4c5d974dd503a3c6097471
Git Branch: heads/refs/tags/v7.3.0
UTC Build Time: 2023-08-08 09:27:28
GoVersion: go1.20.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)
```
Contributor guide
Assessment
This issue has not been assessed yet.