From 68d54f5f42eb16afa98846d00f6a8cc4f091eb2f Mon Sep 17 00:00:00 2001 From: Chunzhu Li Date: Wed, 8 Feb 2023 22:54:53 +0800 Subject: [PATCH] address comments --- br/pkg/lightning/restore/table_restore.go | 7 ++++++- .../run.sh | 21 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/br/pkg/lightning/restore/table_restore.go b/br/pkg/lightning/restore/table_restore.go index bb607245d27e5..fc669a271b2a6 100644 --- a/br/pkg/lightning/restore/table_restore.go +++ b/br/pkg/lightning/restore/table_restore.go @@ -794,7 +794,12 @@ func (tr *TableRestore) postProcess( } hasDupe = hasLocalDupe } - failpoint.Inject("SlowDownCheckDupe", func() {}) + failpoint.Inject("SlowDownCheckDupe", func(v failpoint.Value) { + sec := v.(int) + tr.logger.Warn("start to sleep several seconds before checking other dupe", + zap.Int("seconds", sec)) + time.Sleep(time.Duration(sec) * time.Second) + }) 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 feef4da8f609b..b1bf1e3869d27 100644 --- a/br/tests/lightning_duplicate_resolution_incremental/run.sh +++ b/br/tests/lightning_duplicate_resolution_incremental/run.sh @@ -22,14 +22,33 @@ LOG_FILE1="$TEST_DIR/lightning-duplicate-resolution1.log" LOG_FILE2="$TEST_DIR/lightning-duplicate-resolution2.log" # 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)" +export GO_FAILPOINTS="github.com/pingcap/tidb/br/pkg/lightning/restore/SlowDownCheckDupe=return(10)" 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" & + +counter=0 +while [ $counter -lt 10 ]; do + if grep -Fq "start to sleep several seconds before checking other dupe" "$LOG_FILE1"; then + echo "lightning 1 already starts waiting for dupe" + break + fi + ((counter += 1)) + echo "waiting for lightning 1 starts" + sleep 1 +done + +if [ $counter -ge 10 ]; then + echo "fail to wait for lightning 1 starts" + exit 1 +fi + 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" & wait +export GO_FAILPOINTS="" + # Ensure table is consistent. run_sql 'admin check table dup_resolve_detect.ta'