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

br: fix race in test Test(Split|Restore)Failed (#33313) #33339

Merged
merged 7 commits into from
Jun 17, 2022
8 changes: 8 additions & 0 deletions br/pkg/restore/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,17 @@ func (s *testRangeSuite) testNeedSplit(c *C, isRawKv bool) {
}

type fakeRestorer struct {
mu sync.Mutex

errorInSplit bool
splitRanges []rtree.Range
restoredFiles []*backuppb.File
}

func (f *fakeRestorer) SplitRanges(ctx context.Context, ranges []rtree.Range, rewriteRules *restore.RewriteRules, updateCh glue.Progress, isRawKv bool) error {
f.mu.Lock()
defer f.mu.Unlock()

if ctx.Err() != nil {
return ctx.Err()
}
Expand All @@ -491,6 +496,9 @@ func (f *fakeRestorer) SplitRanges(ctx context.Context, ranges []rtree.Range, re
}

func (f *fakeRestorer) RestoreFiles(ctx context.Context, files []*backuppb.File, rewriteRules *restore.RewriteRules, updateCh glue.Progress) error {
f.mu.Lock()
defer f.mu.Unlock()

if ctx.Err() != nil {
return ctx.Err()
}
Expand Down