diff --git a/br/pkg/restore/BUILD.bazel b/br/pkg/restore/BUILD.bazel index 5f7e7f79bc..416b4083db 100644 --- a/br/pkg/restore/BUILD.bazel +++ b/br/pkg/restore/BUILD.bazel @@ -153,6 +153,7 @@ go_test( "@org_golang_google_grpc//codes", "@org_golang_google_grpc//keepalive", "@org_golang_google_grpc//status", + "@org_golang_x_exp//slices", "@org_uber_go_goleak//:goleak", "@org_uber_go_multierr//:multierr", "@org_uber_go_zap//:zap", diff --git a/br/pkg/restore/client_test.go b/br/pkg/restore/client_test.go index 1b48bb6050..e0c75e28b5 100644 --- a/br/pkg/restore/client_test.go +++ b/br/pkg/restore/client_test.go @@ -30,6 +30,7 @@ import ( "github.com/pingcap/tidb/tablecodec" "github.com/stretchr/testify/require" pd "github.com/tikv/pd/client" + "golang.org/x/exp/slices" "google.golang.org/grpc/keepalive" ) @@ -424,9 +425,9 @@ func (r *RecordStores) put(id uint64) { } func (r *RecordStores) sort() { - sort.Slice(r.stores, func(i, j int) bool { - return r.stores[i] < r.stores[j] - }) + r.mu.Lock() + defer r.mu.Unlock() + slices.Sort(r.stores) } var recordStores RecordStores