From 40981b4dd9db5f9d9968dca54c99f7d993c3075d Mon Sep 17 00:00:00 2001 From: lhy1024 Date: Tue, 14 Jan 2025 16:31:53 +0800 Subject: [PATCH] test-2 Signed-off-by: lhy1024 --- pkg/core/store.go | 3 +++ tests/testutil.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) 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),