br: fix data race in the RecordStores (#37472)
close pingcap/tidb#37470
This commit is contained in:
@ -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",
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user