Skip to content

Commit

Permalink
test: change retry limit for ScanRegionAttemptTimes
Browse files Browse the repository at this point in the history
Signed-off-by: lance6716 <lance6716@gmail.com>
  • Loading branch information
lance6716 committed Feb 16, 2023
1 parent f9e1845 commit a2ef082
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions br/pkg/lightning/backend/local/localhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}

Expand Down
10 changes: 1 addition & 9 deletions br/pkg/restore/split/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
}
}

Expand Down
9 changes: 5 additions & 4 deletions br/pkg/restore/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit a2ef082

Please sign in to comment.