diff --git a/br/pkg/lightning/backend/local/localhelper_test.go b/br/pkg/lightning/backend/local/localhelper_test.go index 023fade304fae..9db20baa220fd 100644 --- a/br/pkg/lightning/backend/local/localhelper_test.go +++ b/br/pkg/lightning/backend/local/localhelper_test.go @@ -556,6 +556,11 @@ func (h *scanRegionEmptyHook) AfterScanRegions(res []*split.RegionInfo, err erro } func TestBatchSplitRegionByRangesScanFailed(t *testing.T) { + backup := split.ScanRegionAttemptTimes + split.ScanRegionAttemptTimes = 3 + defer func() { + split.ScanRegionAttemptTimes = backup + }() doTestBatchSplitRegionByRanges(context.Background(), t, &scanRegionEmptyHook{}, "scan region return empty result", defaultHook{}) } diff --git a/br/pkg/restore/split/split.go b/br/pkg/restore/split/split.go index e06c8ab1c93d5..8edf4e16ccf4d 100644 --- a/br/pkg/restore/split/split.go +++ b/br/pkg/restore/split/split.go @@ -9,7 +9,6 @@ import ( "time" "github.com/pingcap/errors" - "github.com/pingcap/failpoint" "github.com/pingcap/log" berrors "github.com/pingcap/tidb/br/pkg/errors" "github.com/pingcap/tidb/br/pkg/logutil" @@ -185,15 +184,8 @@ type scanRegionBackoffer struct { } func newScanRegionBackoffer() utils.Backoffer { - attempt := ScanRegionAttemptTimes - // only use for test. - failpoint.Inject("scanRegionBackoffer", func(val failpoint.Value) { - if val.(bool) { - attempt = 3 - } - }) return &scanRegionBackoffer{ - attempt: attempt, + attempt: ScanRegionAttemptTimes, } } diff --git a/br/pkg/restore/util_test.go b/br/pkg/restore/util_test.go index 4af6922efa30a..087df4cbdcc2c 100644 --- a/br/pkg/restore/util_test.go +++ b/br/pkg/restore/util_test.go @@ -7,7 +7,6 @@ import ( "encoding/binary" "testing" - "github.com/pingcap/failpoint" backuppb "github.com/pingcap/kvproto/pkg/brpb" "github.com/pingcap/kvproto/pkg/import_sstpb" "github.com/pingcap/kvproto/pkg/metapb" @@ -231,7 +230,11 @@ func TestPaginateScanRegion(t *testing.T) { regionMap := make(map[uint64]*split.RegionInfo) var regions []*split.RegionInfo var batch []*split.RegionInfo - require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/br/pkg/restore/split/scanRegionBackoffer", "return(true)")) + backup := split.ScanRegionAttemptTimes + split.ScanRegionAttemptTimes = 3 + defer func() { + split.ScanRegionAttemptTimes = backup + }() _, err := split.PaginateScanRegion(ctx, NewTestClient(stores, regionMap, 0), []byte{}, []byte{}, 3) require.Error(t, err) require.True(t, berrors.ErrPDBatchScanRegion.Equal(err)) @@ -294,8 +297,6 @@ func TestPaginateScanRegion(t *testing.T) { require.Error(t, err) require.True(t, berrors.ErrPDBatchScanRegion.Equal(err)) require.Regexp(t, ".*region endKey not equal to next region startKey.*", err.Error()) - - require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/br/pkg/restore/split/scanRegionBackoffer")) } func TestRewriteFileKeys(t *testing.T) {