From c21367737d8c29f3476dbd86446349bb9e27849b Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Tue, 7 Feb 2023 18:04:08 +0800 Subject: [PATCH] fix --- br/pkg/lightning/restore/meta_manager.go | 4 ++-- br/pkg/lightning/restore/table_restore.go | 1 + .../lightning_duplicate_resolution_incremental/run.sh | 9 ++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/br/pkg/lightning/restore/meta_manager.go b/br/pkg/lightning/restore/meta_manager.go index 155c464a77cca..ee5fb93ace19e 100644 --- a/br/pkg/lightning/restore/meta_manager.go +++ b/br/pkg/lightning/restore/meta_manager.go @@ -87,7 +87,7 @@ type tableMetaMgr interface { UpdateTableStatus(ctx context.Context, status metaStatus) error UpdateTableBaseChecksum(ctx context.Context, checksum *verify.KVChecksum) error CheckAndUpdateLocalChecksum(ctx context.Context, checksum *verify.KVChecksum, hasLocalDupes bool) ( - needChecksum bool, needRemoteDupe bool, baseTotalChecksum *verify.KVChecksum, err error) + otherHasDupe bool, needRemoteDupe bool, baseTotalChecksum *verify.KVChecksum, err error) FinishTable(ctx context.Context) error } @@ -1069,7 +1069,7 @@ func (m noopTableMetaMgr) UpdateTableBaseChecksum(ctx context.Context, checksum } func (m noopTableMetaMgr) CheckAndUpdateLocalChecksum(ctx context.Context, checksum *verify.KVChecksum, hasLocalDupes bool) (bool, bool, *verify.KVChecksum, error) { - return true, true, &verify.KVChecksum{}, nil + return false, true, &verify.KVChecksum{}, nil } func (m noopTableMetaMgr) FinishTable(ctx context.Context) error { diff --git a/br/pkg/lightning/restore/table_restore.go b/br/pkg/lightning/restore/table_restore.go index e28144f042a8c..8339e7694dc03 100644 --- a/br/pkg/lightning/restore/table_restore.go +++ b/br/pkg/lightning/restore/table_restore.go @@ -794,6 +794,7 @@ func (tr *TableRestore) postProcess( } hasDupe = hasLocalDupe } + failpoint.Inject("SlowDownCheckDupe", func() {}) otherHasDupe, needRemoteDupe, baseTotalChecksum, err := metaMgr.CheckAndUpdateLocalChecksum(ctx, &localChecksum, hasDupe) if err != nil { diff --git a/br/tests/lightning_duplicate_resolution_incremental/run.sh b/br/tests/lightning_duplicate_resolution_incremental/run.sh index 6b13f5b368871..8f0e27108b9c6 100644 --- a/br/tests/lightning_duplicate_resolution_incremental/run.sh +++ b/br/tests/lightning_duplicate_resolution_incremental/run.sh @@ -21,11 +21,14 @@ check_cluster_version 5 2 0 'duplicate detection' || exit 0 LOG_FILE1="$TEST_DIR/lightning-duplicate-resolution1.log" LOG_FILE2="$TEST_DIR/lightning-duplicate-resolution2.log" -# make sure after first lightning finishes importing, the second lightning then starts +# let lightning run a bit slow to avoid some table in the first lightning finish too fast. +export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/lightning/restore/SlowDownCheckDupe=sleep(5000)" run_lightning --backend local --sorted-kv-dir "$TEST_DIR/lightning_duplicate_resolution_incremental.sorted1" \ - --enable-checkpoint=1 --log-file "$LOG_FILE1" --config "tests/$TEST_NAME/config1.toml" + --enable-checkpoint=1 --log-file "$LOG_FILE1" --config "tests/$TEST_NAME/config1.toml" & run_lightning --backend local --sorted-kv-dir "$TEST_DIR/lightning_duplicate_resolution_incremental.sorted2" \ - --enable-checkpoint=1 --log-file "$LOG_FILE2" --config "tests/$TEST_NAME/config2.toml" + --enable-checkpoint=1 --log-file "$LOG_FILE2" --config "tests/$TEST_NAME/config2.toml" & + +wait # Ensure table is consistent. run_sql 'admin check table dup_resolve_detect.ta'