Skip to content

Commit

Permalink
test: fix the data race in restore test (pingcap#57762)
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer authored and YuJuncen committed Jan 16, 2025
1 parent e503604 commit aa0d27c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion br/pkg/restore/restorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package restore_test

import (
"context"
"sync"
"testing"

"github.com/pingcap/errors"
Expand Down Expand Up @@ -65,8 +66,11 @@ func TestSimpleRestorerImportAndProgress(t *testing.T) {
{SSTFiles: files},
}
progressCount = int64(0)
var mu sync.Mutex
err = restorer.GoRestore(func(progress int64) {
mu.Lock()
progressCount += progress
mu.Unlock()
}, batchFileSet)
require.NoError(t, err)
err = restorer.WaitUntilFinish()
Expand Down Expand Up @@ -145,7 +149,12 @@ func TestMultiTablesRestorerRestoreSuccess(t *testing.T) {
var progress int64
fileSets := createSampleBatchFileSets()

restorer.GoRestore(func(p int64) { progress += p }, fileSets)
var mu sync.Mutex
restorer.GoRestore(func(p int64) {
mu.Lock()
progress += p
mu.Unlock()
}, fileSets)
err := restorer.WaitUntilFinish()
require.NoError(t, err)

Expand Down

0 comments on commit aa0d27c

Please sign in to comment.