From be707a388b9a12c7b0d00cd2efc929f3652f234c Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 5 Mar 2020 09:34:54 +0800 Subject: [PATCH] ignore some dirty schema in tidb (#35) Co-authored-by: 3pointer --- v4/export/dump.go | 3 +++ v4/export/prepare.go | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/v4/export/dump.go b/v4/export/dump.go index a20d0d6fc2466..fa91d53782c69 100644 --- a/v4/export/dump.go +++ b/v4/export/dump.go @@ -29,6 +29,7 @@ func Dump(conf *Config) (err error) { if err != nil { return err } + if !conf.NoViews { views, err := listAllViews(pool, databases) if err != nil { @@ -37,6 +38,8 @@ func Dump(conf *Config) (err error) { conf.Tables.Merge(views) } + filterDirtySchemaTables(conf) + conCtrl, err := NewConsistencyController(conf, pool) if err != nil { return err diff --git a/v4/export/prepare.go b/v4/export/prepare.go index 7e353b28e77e2..8e27447cf9493 100644 --- a/v4/export/prepare.go +++ b/v4/export/prepare.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/pingcap/dumpling/v4/log" + "go.uber.org/zap" ) func detectServerInfo(db *sql.DB) (ServerInfo, error) { @@ -92,3 +93,16 @@ func (d DatabaseTables) Merge(other DatabaseTables) { d[name] = append(d[name], infos...) } } + +func filterDirtySchemaTables(conf *Config) { + switch conf.ServerInfo.ServerType { + case ServerTypeTiDB: + for dbName := range conf.Tables { + switch strings.ToUpper(dbName) { + case "INSPECTION_SCHEMA", "METRICS_SCHEMA", "PERFORMANCE_SCHEMA", "INFORMATION_SCHEMA": + log.Zap().Warn("unsupported dump schema in TiDB now", zap.String("schema", dbName)) + delete(conf.Tables, dbName) + } + } + } +}