From 750f9307c669defa0b7023f66490e6dc827f53d4 Mon Sep 17 00:00:00 2001 From: Oleg Afanasyev Date: Mon, 6 Feb 2023 18:33:18 +0000 Subject: [PATCH] allocator: fix panic when accessing nil store descriptor Previously allocator was trying to update store descriptor counters on unitialized stores. Instead of checking if detail is nil which should never happen, it should check if descriptor in detail is not nil as it is only eventually populated by gossip. Release note: None --- pkg/kv/kvserver/allocator/storepool/store_pool.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kv/kvserver/allocator/storepool/store_pool.go b/pkg/kv/kvserver/allocator/storepool/store_pool.go index 55beabc549ff..3158746adae5 100644 --- a/pkg/kv/kvserver/allocator/storepool/store_pool.go +++ b/pkg/kv/kvserver/allocator/storepool/store_pool.go @@ -620,14 +620,14 @@ func (sp *StorePool) UpdateLocalStoreAfterRelocate( updateTargets := func(targets []roachpb.ReplicationTarget) { for _, target := range targets { - if toDetail := sp.GetStoreDetailLocked(target.StoreID); toDetail != nil { + if toDetail := sp.GetStoreDetailLocked(target.StoreID); toDetail.Desc != nil { toDetail.Desc.Capacity.RangeCount++ } } } updatePrevious := func(previous []roachpb.ReplicaDescriptor) { for _, old := range previous { - if toDetail := sp.GetStoreDetailLocked(old.StoreID); toDetail != nil { + if toDetail := sp.GetStoreDetailLocked(old.StoreID); toDetail.Desc != nil { toDetail.Desc.Capacity.RangeCount-- } }