diff --git a/pkg/core/store.go b/pkg/core/store.go index 9ec9a44bfc8..b8b892a20ea 100644 --- a/pkg/core/store.go +++ b/pkg/core/store.go @@ -666,6 +666,9 @@ func NewStoresInfo() *StoresInfo { func (s *StoresInfo) GetStore(storeID uint64) *StoreInfo { s.RLock() defer s.RUnlock() + if s.stores == nil { + return nil + } store, ok := s.stores[storeID] if !ok { return nil diff --git a/tests/testutil.go b/tests/testutil.go index fd8c90d1a0f..9ce3d796e6c 100644 --- a/tests/testutil.go +++ b/tests/testutil.go @@ -212,7 +212,8 @@ func MustPutStore(re *require.Assertions, cluster *TestCluster, store *metapb.St ts = time.Now().UnixNano() } raftCluster := grpcServer.GetRaftCluster() - storeInfo := raftCluster.GetStore(store.GetId()) + id := store.GetId() + storeInfo := raftCluster.GetStore(id) newStore := storeInfo.Clone( core.SetStoreStats(&pdpb.StoreStats{ Capacity: uint64(10 * units.GiB),