Skip to content

Commit

Permalink
allocator: fix panic when accessing nil store descriptor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aliher1911 committed Feb 6, 2023
1 parent c4257c9 commit 750f930
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/kv/kvserver/allocator/storepool/store_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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--
}
}
Expand Down

0 comments on commit 750f930

Please sign in to comment.