Skip to content

Commit

Permalink
kvserver: re-add spuriously removed nil check in relocateOne
Browse files Browse the repository at this point in the history
e924d91 introduced a bug by spuriously
removing a nil check over the result of a call to
`allocateTargetFromList`. This commit re-adds the check.

The bug could cause a panic when `AdminRelocateRange` was called by the
`StoreRebalancer` or the `mergeQueue` if one (or more) of the stores
that are supposed to receive a replica for a range become unfit for
receiving the replica (due to balancing reasons / or shifting
constraints) _between when rebalancing decision is made and when it's
executed_.

Resolves #60812

Release justification: fixes bug that causes a panic
Release note: None
  • Loading branch information
aayushshah15 committed Feb 24, 2021
1 parent 3bae09b commit 06401ce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kv/kvserver/replica_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,10 @@ func (s *Store) relocateOne(
existingNonVoters,
s.allocator.scorerOptions(),
args.targetType)
if targetStore == nil {
return nil, nil, fmt.Errorf("none of the remaining %ss %v are legal additions to %v",
args.targetType, args.targetsToAdd, desc.Replicas())
}

target := roachpb.ReplicationTarget{
NodeID: targetStore.Node.NodeID,
Expand Down

0 comments on commit 06401ce

Please sign in to comment.