Skip to content

Commit

Permalink
br: fix race in test Test(Split|Restore)Failed (pingcap#33313)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuJuncen committed Mar 25, 2022
1 parent eacba78 commit 4cf121d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions br/pkg/restore/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,17 @@ func TestRegionConsistency(t *testing.T) {
}

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 @@ -587,6 +592,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

0 comments on commit 4cf121d

Please sign in to comment.