Commit 7f88e73 1 parent 6e0c38a commit 7f88e73 Copy full SHA for 7f88e73
File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -529,7 +529,7 @@ func BuildBackupRangeAndSchema(
529
529
530
530
for _ , dbInfo := range dbs {
531
531
// skip system databases
532
- if ! tableFilter .MatchSchema (dbInfo .Name .O ) || util .IsMemDB (dbInfo .Name .L ) {
532
+ if ! tableFilter .MatchSchema (dbInfo .Name .O ) || util .IsMemDB (dbInfo .Name .L ) || utils . IsTemplateSysDB ( dbInfo . Name ) {
533
533
continue
534
534
}
535
535
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import (
16
16
17
17
// temporaryDBNamePrefix is the prefix name of system db, e.g. mysql system db will be rename to __TiDB_BR_Temporary_mysql
18
18
const temporaryDBNamePrefix = "__TiDB_BR_Temporary_"
19
+ const temporarySysDB = temporaryDBNamePrefix + "mysql"
19
20
20
21
// NeedAutoID checks whether the table needs backing up with an autoid.
21
22
func NeedAutoID (tblInfo * model.TableInfo ) bool {
@@ -96,6 +97,11 @@ func EncloseDBAndTable(database, table string) string {
96
97
return fmt .Sprintf ("%s.%s" , EncloseName (database ), EncloseName (table ))
97
98
}
98
99
100
+ // IsTemplateSysDB checks wheterh the dbname is temporary system database(__TiDB_BR_Temporary_mysql).
101
+ func IsTemplateSysDB (dbname model.CIStr ) bool {
102
+ return dbname .O == temporarySysDB
103
+ }
104
+
99
105
// IsSysDB tests whether the database is system DB.
100
106
// Currently, the only system DB is mysql.
101
107
func IsSysDB (dbLowerName string ) bool {
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ run_sql "CREATE TABLE ${DB}1.usertable1 ( \
67
67
PRIMARY KEY (YCSB_KEY) \
68
68
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
69
69
70
+ # backup empty table
70
71
echo " backup empty table start..."
71
72
run_br --pd $PD_ADDR backup full -s " local://$TEST_DIR /empty_table"
72
73
@@ -75,6 +76,7 @@ while [ $i -le $DB_COUNT ]; do
75
76
i=$(( $i + 1 ))
76
77
done
77
78
79
+ # restore empty table.
78
80
echo " restore empty table start..."
79
81
run_br --pd $PD_ADDR restore full -s " local://$TEST_DIR /empty_table"
80
82
@@ -85,3 +87,15 @@ while [ $i -le $DB_COUNT ]; do
85
87
run_sql " DROP DATABASE $DB$i ;"
86
88
i=$(( $i + 1 ))
87
89
done
90
+
91
+
92
+ # backup, skip temporary system database(__TiDB_BR_Temporary_mysql) when backup
93
+ run_sql " CREATE DATABASE __TiDB_BR_Temporary_mysql" ;
94
+ run_sql " CREATE TABLE __TiDB_BR_Temporary_mysql.tables_priv(id int);" ;
95
+ echo " backup and skip __TiDB_BR_Temporary_mysql start..."
96
+ run_br --pd $PD_ADDR backup full -s " local://$TEST_DIR /skip_temporary_mysql"
97
+
98
+ # restore successfully without panic.
99
+ run_sql " DROP DATABASE __TiDB_BR_Temporary_mysql" ;
100
+ echo " restore the data start..."
101
+ run_br restore full -s " local://$TEST_DIR /skip_temporary_mysql" --pd $PD_ADDR --ratelimit 1024
You can’t perform that action at this time.
0 commit comments