Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: change retry limit for ScanRegionAttemptTimes #41489

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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