From c301f92d5525e65e7bea25d5a3c08ee393a66333 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:06:37 +0800 Subject: [PATCH 1/8] random pick file to check schema --- br/pkg/lightning/restore/check_info.go | 29 ++++++--- br/pkg/lightning/restore/restore.go | 2 +- br/pkg/lightning/restore/restore_test.go | 75 ++++++++++++++++++++++-- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index 023231691ec36..1ac0af5a3feb0 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -19,11 +19,13 @@ import ( "context" "fmt" "io" + "math/rand" "path/filepath" "reflect" "sort" "strconv" "strings" + "time" "github.com/docker/go-units" "github.com/pingcap/errors" @@ -559,19 +561,19 @@ func (rc *Controller) readColumnsAndCount(ctx context.Context, dataFileMeta mydu } // SchemaIsValid checks the import file and cluster schema is match. -func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTableMeta) ([]string, error) { +func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTableMeta) ([]string, int, error) { msgs := make([]string, 0) info, ok := rc.dbInfos[tableInfo.DB].Tables[tableInfo.Name] if !ok { msgs = append(msgs, fmt.Sprintf("TiDB schema `%s`.`%s` doesn't exists,"+ "please give a schema file in source dir or create table manually", tableInfo.DB, tableInfo.Name)) - return msgs, nil + return msgs, 0, nil } igCols := make(map[string]struct{}) igCol, err := rc.cfg.Mydumper.IgnoreColumns.GetIgnoreColumns(tableInfo.DB, tableInfo.Name, rc.cfg.Mydumper.CaseSensitive) if err != nil { - return nil, errors.Trace(err) + return nil, 0, errors.Trace(err) } for _, col := range igCol.Columns { igCols[col] = struct{}{} @@ -579,7 +581,7 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab if len(tableInfo.DataFiles) == 0 { log.L().Info("no data files detected", zap.String("db", tableInfo.DB), zap.String("table", tableInfo.Name)) - return nil, nil + return nil, 0, nil } colCountFromTiDB := len(info.Core.Columns) @@ -594,17 +596,26 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab // tidb_rowid have a default value. defaultCols[model.ExtraHandleName.String()] = struct{}{} - for _, dataFile := range tableInfo.DataFiles { + // only check the one random file of this table. + dataFiles := make([]mydump.FileInfo, 0, 1) + if len(tableInfo.DataFiles) > 0 { + rand.Seed(time.Now().Unix()) + index := rand.Intn(len(tableInfo.DataFiles)) + dataFiles = append(dataFiles, tableInfo.DataFiles[index]) + log.L().Info("pick random files to check", zap.String("db", tableInfo.DB), + zap.String("table", tableInfo.Name), zap.String("path", tableInfo.DataFiles[index].FileMeta.Path)) + } + for _, dataFile := range dataFiles { // get columns name from data file. dataFileMeta := dataFile.FileMeta if tp := dataFileMeta.Type; tp != mydump.SourceTypeCSV && tp != mydump.SourceTypeSQL && tp != mydump.SourceTypeParquet { msgs = append(msgs, fmt.Sprintf("file '%s' with unknown source type '%s'", dataFileMeta.Path, dataFileMeta.Type.String())) - return msgs, nil + return msgs, len(dataFiles), nil } colsFromDataFile, colCountFromDataFile, err := rc.readColumnsAndCount(ctx, dataFileMeta) if err != nil { - return nil, errors.Trace(err) + return nil, len(dataFiles), errors.Trace(err) } if colsFromDataFile == nil && colCountFromDataFile == 0 { log.L().Info("file contains no data, skip checking against schema validity", zap.String("path", dataFileMeta.Path)) @@ -670,10 +681,10 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab } } if len(msgs) > 0 { - return msgs, nil + return msgs, len(dataFiles), nil } } - return msgs, nil + return msgs, len(dataFiles), nil } func (rc *Controller) SampleDataFromTable(ctx context.Context, dbName string, tableMeta *mydump.MDTableMeta, tableInfo *model.TableInfo) error { diff --git a/br/pkg/lightning/restore/restore.go b/br/pkg/lightning/restore/restore.go index 85757927134aa..f0a365c689d86 100644 --- a/br/pkg/lightning/restore/restore.go +++ b/br/pkg/lightning/restore/restore.go @@ -1766,7 +1766,7 @@ func (rc *Controller) DataCheck(ctx context.Context) error { } if rc.cfg.App.CheckRequirements && noCheckpoint && rc.cfg.TikvImporter.Backend != config.BackendTiDB { - if msgs, err = rc.SchemaIsValid(ctx, tableInfo); err != nil { + if msgs, _, err = rc.SchemaIsValid(ctx, tableInfo); err != nil { return errors.Trace(err) } if len(msgs) != 0 { diff --git a/br/pkg/lightning/restore/restore_test.go b/br/pkg/lightning/restore/restore_test.go index 7758d7d81aa11..80bfdbc3bb71f 100644 --- a/br/pkg/lightning/restore/restore_test.go +++ b/br/pkg/lightning/restore/restore_test.go @@ -1900,10 +1900,11 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { ignoreColumns []*config.IgnoreColumns expectMsg string // MsgNum == 0 means the check passed. - MsgNum int - hasHeader bool - dbInfos map[string]*checkpoints.TidbDBInfo - tableMeta *mydump.MDTableMeta + MsgNum int + hasHeader bool + dbInfos map[string]*checkpoints.TidbDBInfo + tableMeta *mydump.MDTableMeta + checkFilesCount int }{ // Case 1: // csv has one column without header. @@ -1956,6 +1957,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 1, }, // Case 2.1: // csv has two columns(colA, colB) with the header. @@ -2000,6 +2002,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 1, }, // Case 2.2: // csv has two columns(colA, colB) with the header. @@ -2051,6 +2054,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 1, }, // Case 2.3: // csv has two columns(colA, colB) with the header. @@ -2110,6 +2114,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 1, }, // Case 2.4: // csv has two columns(colA, colB) with the header. @@ -2168,6 +2173,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 1, }, // Case 3: // table3's schema file not found. @@ -2204,6 +2210,64 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, + 0, + }, + // Case 4: + // table4 has two datafiles for table. we only check one random file. + // we expect the check success. + { + []*config.IgnoreColumns{ + { + DB: "db1", + Table: "table2", + Columns: []string{"cola"}, + }, + }, + "", + 0, + true, + map[string]*checkpoints.TidbDBInfo{ + "db1": { + Name: "db1", + Tables: map[string]*checkpoints.TidbTableInfo{ + "table2": { + ID: 1, + DB: "db1", + Name: "table2", + Core: &model.TableInfo{ + Columns: []*model.ColumnInfo{ + { + // colB has the default value + Name: model.NewCIStr("colB"), + DefaultIsExpr: true, + }, + }, + }, + }, + }, + }, + }, + &mydump.MDTableMeta{ + DB: "db1", + Name: "table2", + DataFiles: []mydump.FileInfo{ + { + FileMeta: mydump.SourceFileMeta{ + FileSize: 1 * units.TiB, + Path: case2File, + Type: mydump.SourceTypeCSV, + }, + }, + { + FileMeta: mydump.SourceFileMeta{ + FileSize: 1 * units.TiB, + Path: case2File, + Type: mydump.SourceTypeCSV, + }, + }, + }, + }, + 1, }, } @@ -2231,7 +2295,8 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { dbInfos: ca.dbInfos, ioWorkers: worker.NewPool(context.Background(), 1, "io"), } - msgs, err := rc.SchemaIsValid(ctx, ca.tableMeta) + msgs, checkedFilesCount, err := rc.SchemaIsValid(ctx, ca.tableMeta) + c.Assert(checkedFilesCount, Equals, ca.checkFilesCount) c.Assert(err, IsNil) c.Assert(msgs, HasLen, ca.MsgNum) if len(msgs) > 0 { From a1587c8a53755f5f306dffb15bcab80e81bfcdd8 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:26:28 +0800 Subject: [PATCH 2/8] address comment --- br/pkg/lightning/restore/check_info.go | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index 1ac0af5a3feb0..3d35e4e8d975b 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -18,15 +18,6 @@ import ( "bytes" "context" "fmt" - "io" - "math/rand" - "path/filepath" - "reflect" - "sort" - "strconv" - "strings" - "time" - "github.com/docker/go-units" "github.com/pingcap/errors" "github.com/pingcap/failpoint" @@ -45,6 +36,12 @@ import ( "github.com/tikv/pd/server/api" pdconfig "github.com/tikv/pd/server/config" "go.uber.org/zap" + "io" + "path/filepath" + "reflect" + "sort" + "strconv" + "strings" ) const ( @@ -596,16 +593,14 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab // tidb_rowid have a default value. defaultCols[model.ExtraHandleName.String()] = struct{}{} - // only check the one random file of this table. + // only check the first file of this table. dataFiles := make([]mydump.FileInfo, 0, 1) if len(tableInfo.DataFiles) > 0 { - rand.Seed(time.Now().Unix()) - index := rand.Intn(len(tableInfo.DataFiles)) - dataFiles = append(dataFiles, tableInfo.DataFiles[index]) - log.L().Info("pick random files to check", zap.String("db", tableInfo.DB), - zap.String("table", tableInfo.Name), zap.String("path", tableInfo.DataFiles[index].FileMeta.Path)) + dataFiles = append(dataFiles, tableInfo.DataFiles[0]) } for _, dataFile := range dataFiles { + log.L().Info("datafile to check", zap.String("db", tableInfo.DB), + zap.String("table", tableInfo.Name), zap.String("path", dataFile.FileMeta.Path)) // get columns name from data file. dataFileMeta := dataFile.FileMeta From 70a20dc0010a7c72f2b2a1487e72b4d72d126d2a Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:43:24 +0800 Subject: [PATCH 3/8] address comment --- br/pkg/lightning/restore/check_info.go | 16 ++++++++-------- br/pkg/lightning/restore/restore.go | 2 +- br/pkg/lightning/restore/restore_test.go | 10 ++++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index 3d35e4e8d975b..a244dc04d1bb4 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -558,19 +558,19 @@ func (rc *Controller) readColumnsAndCount(ctx context.Context, dataFileMeta mydu } // SchemaIsValid checks the import file and cluster schema is match. -func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTableMeta) ([]string, int, error) { +func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTableMeta) ([]string, error) { msgs := make([]string, 0) info, ok := rc.dbInfos[tableInfo.DB].Tables[tableInfo.Name] if !ok { msgs = append(msgs, fmt.Sprintf("TiDB schema `%s`.`%s` doesn't exists,"+ "please give a schema file in source dir or create table manually", tableInfo.DB, tableInfo.Name)) - return msgs, 0, nil + return msgs, nil } igCols := make(map[string]struct{}) igCol, err := rc.cfg.Mydumper.IgnoreColumns.GetIgnoreColumns(tableInfo.DB, tableInfo.Name, rc.cfg.Mydumper.CaseSensitive) if err != nil { - return nil, 0, errors.Trace(err) + return nil, errors.Trace(err) } for _, col := range igCol.Columns { igCols[col] = struct{}{} @@ -578,7 +578,7 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab if len(tableInfo.DataFiles) == 0 { log.L().Info("no data files detected", zap.String("db", tableInfo.DB), zap.String("table", tableInfo.Name)) - return nil, 0, nil + return nil, nil } colCountFromTiDB := len(info.Core.Columns) @@ -606,11 +606,11 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab if tp := dataFileMeta.Type; tp != mydump.SourceTypeCSV && tp != mydump.SourceTypeSQL && tp != mydump.SourceTypeParquet { msgs = append(msgs, fmt.Sprintf("file '%s' with unknown source type '%s'", dataFileMeta.Path, dataFileMeta.Type.String())) - return msgs, len(dataFiles), nil + return msgs, nil } colsFromDataFile, colCountFromDataFile, err := rc.readColumnsAndCount(ctx, dataFileMeta) if err != nil { - return nil, len(dataFiles), errors.Trace(err) + return nil, errors.Trace(err) } if colsFromDataFile == nil && colCountFromDataFile == 0 { log.L().Info("file contains no data, skip checking against schema validity", zap.String("path", dataFileMeta.Path)) @@ -676,10 +676,10 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab } } if len(msgs) > 0 { - return msgs, len(dataFiles), nil + return msgs, nil } } - return msgs, len(dataFiles), nil + return msgs, nil } func (rc *Controller) SampleDataFromTable(ctx context.Context, dbName string, tableMeta *mydump.MDTableMeta, tableInfo *model.TableInfo) error { diff --git a/br/pkg/lightning/restore/restore.go b/br/pkg/lightning/restore/restore.go index f0a365c689d86..85757927134aa 100644 --- a/br/pkg/lightning/restore/restore.go +++ b/br/pkg/lightning/restore/restore.go @@ -1766,7 +1766,7 @@ func (rc *Controller) DataCheck(ctx context.Context) error { } if rc.cfg.App.CheckRequirements && noCheckpoint && rc.cfg.TikvImporter.Backend != config.BackendTiDB { - if msgs, _, err = rc.SchemaIsValid(ctx, tableInfo); err != nil { + if msgs, err = rc.SchemaIsValid(ctx, tableInfo); err != nil { return errors.Trace(err) } if len(msgs) != 0 { diff --git a/br/pkg/lightning/restore/restore_test.go b/br/pkg/lightning/restore/restore_test.go index 80bfdbc3bb71f..b9d343b864323 100644 --- a/br/pkg/lightning/restore/restore_test.go +++ b/br/pkg/lightning/restore/restore_test.go @@ -2213,7 +2213,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { 0, }, // Case 4: - // table4 has two datafiles for table. we only check one random file. + // table4 has two datafiles for table. we only check the first file. // we expect the check success. { []*config.IgnoreColumns{ @@ -2262,7 +2262,10 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { FileMeta: mydump.SourceFileMeta{ FileSize: 1 * units.TiB, Path: case2File, - Type: mydump.SourceTypeCSV, + // This type will make the check failed. + // but it's the second file for table. + // so it's unreachable so this case will success. + Type: mydump.SourceTypeIgnore, }, }, }, @@ -2295,8 +2298,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { dbInfos: ca.dbInfos, ioWorkers: worker.NewPool(context.Background(), 1, "io"), } - msgs, checkedFilesCount, err := rc.SchemaIsValid(ctx, ca.tableMeta) - c.Assert(checkedFilesCount, Equals, ca.checkFilesCount) + msgs, err := rc.SchemaIsValid(ctx, ca.tableMeta) c.Assert(err, IsNil) c.Assert(msgs, HasLen, ca.MsgNum) if len(msgs) > 0 { From a5b5515f5873b55d18e0dd4b14606b53eca01e9a Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:45:51 +0800 Subject: [PATCH 4/8] address comment --- br/pkg/lightning/restore/check_info.go | 13 +++++++------ br/pkg/lightning/restore/restore_test.go | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index a244dc04d1bb4..17b22cf25d586 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -18,6 +18,13 @@ import ( "bytes" "context" "fmt" + "io" + "path/filepath" + "reflect" + "sort" + "strconv" + "strings" + "github.com/docker/go-units" "github.com/pingcap/errors" "github.com/pingcap/failpoint" @@ -36,12 +43,6 @@ import ( "github.com/tikv/pd/server/api" pdconfig "github.com/tikv/pd/server/config" "go.uber.org/zap" - "io" - "path/filepath" - "reflect" - "sort" - "strconv" - "strings" ) const ( diff --git a/br/pkg/lightning/restore/restore_test.go b/br/pkg/lightning/restore/restore_test.go index b9d343b864323..eb82526bcc56e 100644 --- a/br/pkg/lightning/restore/restore_test.go +++ b/br/pkg/lightning/restore/restore_test.go @@ -2265,7 +2265,7 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { // This type will make the check failed. // but it's the second file for table. // so it's unreachable so this case will success. - Type: mydump.SourceTypeIgnore, + Type: mydump.SourceTypeIgnore, }, }, }, From 45ee62c17096cd07d07d42a303e13767cc36d4df Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:47:02 +0800 Subject: [PATCH 5/8] address comment --- br/pkg/lightning/restore/restore_test.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/br/pkg/lightning/restore/restore_test.go b/br/pkg/lightning/restore/restore_test.go index eb82526bcc56e..76739a2aac206 100644 --- a/br/pkg/lightning/restore/restore_test.go +++ b/br/pkg/lightning/restore/restore_test.go @@ -1904,7 +1904,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { hasHeader bool dbInfos map[string]*checkpoints.TidbDBInfo tableMeta *mydump.MDTableMeta - checkFilesCount int }{ // Case 1: // csv has one column without header. @@ -1957,7 +1956,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, // Case 2.1: // csv has two columns(colA, colB) with the header. @@ -2002,7 +2000,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, // Case 2.2: // csv has two columns(colA, colB) with the header. @@ -2054,7 +2051,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, // Case 2.3: // csv has two columns(colA, colB) with the header. @@ -2114,7 +2110,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, // Case 2.4: // csv has two columns(colA, colB) with the header. @@ -2173,7 +2168,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, // Case 3: // table3's schema file not found. @@ -2210,7 +2204,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 0, }, // Case 4: // table4 has two datafiles for table. we only check the first file. @@ -2270,7 +2263,6 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { }, }, }, - 1, }, } From 90848fd07832ec32680a1bcd2c0f4134a50b1d11 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:47:35 +0800 Subject: [PATCH 6/8] fmt --- br/pkg/lightning/restore/restore_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/br/pkg/lightning/restore/restore_test.go b/br/pkg/lightning/restore/restore_test.go index 76739a2aac206..cc317a7d1d16b 100644 --- a/br/pkg/lightning/restore/restore_test.go +++ b/br/pkg/lightning/restore/restore_test.go @@ -1900,10 +1900,10 @@ func (s *tableRestoreSuite) TestSchemaIsValid(c *C) { ignoreColumns []*config.IgnoreColumns expectMsg string // MsgNum == 0 means the check passed. - MsgNum int - hasHeader bool - dbInfos map[string]*checkpoints.TidbDBInfo - tableMeta *mydump.MDTableMeta + MsgNum int + hasHeader bool + dbInfos map[string]*checkpoints.TidbDBInfo + tableMeta *mydump.MDTableMeta }{ // Case 1: // csv has one column without header. From cd6e7932ff9de28b44f43aa88343cc549d847a5d Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:53:40 +0800 Subject: [PATCH 7/8] Update br/pkg/lightning/restore/check_info.go Co-authored-by: glorv --- br/pkg/lightning/restore/check_info.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index 17b22cf25d586..ce02fb6f2e7a5 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -595,11 +595,8 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab defaultCols[model.ExtraHandleName.String()] = struct{}{} // only check the first file of this table. - dataFiles := make([]mydump.FileInfo, 0, 1) if len(tableInfo.DataFiles) > 0 { - dataFiles = append(dataFiles, tableInfo.DataFiles[0]) - } - for _, dataFile := range dataFiles { + dataFile := tableInfo.DataFiles[0] log.L().Info("datafile to check", zap.String("db", tableInfo.DB), zap.String("table", tableInfo.Name), zap.String("path", dataFile.FileMeta.Path)) // get columns name from data file. From 2cb3f1c10947eb34ac21cca90aaedfc316c37174 Mon Sep 17 00:00:00 2001 From: 3pointer Date: Thu, 26 Aug 2021 16:56:39 +0800 Subject: [PATCH 8/8] fmt --- br/pkg/lightning/restore/check_info.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/br/pkg/lightning/restore/check_info.go b/br/pkg/lightning/restore/check_info.go index ce02fb6f2e7a5..7ad0f11642a65 100644 --- a/br/pkg/lightning/restore/check_info.go +++ b/br/pkg/lightning/restore/check_info.go @@ -612,7 +612,7 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab } if colsFromDataFile == nil && colCountFromDataFile == 0 { log.L().Info("file contains no data, skip checking against schema validity", zap.String("path", dataFileMeta.Path)) - continue + return msgs, nil } if colsFromDataFile == nil { @@ -673,9 +673,6 @@ func (rc *Controller) SchemaIsValid(ctx context.Context, tableInfo *mydump.MDTab tableInfo.DB, tableInfo.Name, col, col)) } } - if len(msgs) > 0 { - return msgs, nil - } } return msgs, nil }