Skip to content

Commit

Permalink
skip temporary system database(__TiDB_BR_Temporary_mysql) when backup
Browse files Browse the repository at this point in the history
Signed-off-by: joccau <zak.zhao@pingcap.com>
  • Loading branch information
joccau authored and ti-chi-bot committed Feb 9, 2023
1 parent 516dc21 commit dfbc0d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func BuildBackupRangeAndSchema(

for _, dbInfo := range dbs {
// skip system databases
if !tableFilter.MatchSchema(dbInfo.Name.O) || util.IsMemDB(dbInfo.Name.L) {
if !tableFilter.MatchSchema(dbInfo.Name.O) || util.IsMemDB(dbInfo.Name.L) || utils.IsTemplateSysDB(dbInfo.Name) {
continue
}

Expand Down
6 changes: 6 additions & 0 deletions br/pkg/utils/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

// temporaryDBNamePrefix is the prefix name of system db, e.g. mysql system db will be rename to __TiDB_BR_Temporary_mysql
const temporaryDBNamePrefix = "__TiDB_BR_Temporary_"
const temporarySysDB = temporaryDBNamePrefix + "mysql"

// NeedAutoID checks whether the table needs backing up with an autoid.
func NeedAutoID(tblInfo *model.TableInfo) bool {
Expand Down Expand Up @@ -96,6 +97,11 @@ func EncloseDBAndTable(database, table string) string {
return fmt.Sprintf("%s.%s", EncloseName(database), EncloseName(table))
}

// IsTemplateSysDB checks wheterh the dbname is temporary system database(__TiDB_BR_Temporary_mysql).
func IsTemplateSysDB(dbname model.CIStr) bool {
return dbname.O == temporarySysDB
}

// IsSysDB tests whether the database is system DB.
// Currently, the only system DB is mysql.
func IsSysDB(dbLowerName string) bool {
Expand Down

0 comments on commit dfbc0d5

Please sign in to comment.