Skip to content

Commit

Permalink
kvserver: determine if leaseholder is removed using proposed replica …
Browse files Browse the repository at this point in the history
…descriptor

Previosly, the determination of whether a leaseholder is being removed was made
by looking at the proposed changes. As a step towards #74077
we'd like to instead look at the replica descriptor that the reconfiguration change would result in.
This prepares the ground for making a distinction between incoming and outgoing replicas in the next PR.
This PR should not cause any change in behavior.

Release note: None
  • Loading branch information
shralex committed Jan 5, 2022
1 parent ecdf51b commit 2232fb2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,11 @@ func (r *Replica) propose(
// the replica remains in the descriptor, but as VOTER_{OUTGOING,DEMOTING}.
// We want to block it from getting into that state in the first place,
// since there's no stopping the actual removal/demotion once it's there.
// The Removed() field has contains these replicas when this first
// transition is initiated, so its use here is copacetic.
// IsVoterNewConfig checks that the leaseholder is a full replica in the
// proposed configuration.
replID := r.ReplicaID()
for _, rDesc := range crt.Removed() {
rDesc, ok := p.command.ReplicatedEvalResult.State.Desc.GetReplicaDescriptorByID(replID)
for !ok || !rDesc.IsVoterNewConfig() {
if rDesc.ReplicaID == replID {
err := errors.Mark(errors.Newf("received invalid ChangeReplicasTrigger %s to remove self (leaseholder)", crt),
errMarkInvalidReplicationChange)
Expand Down

0 comments on commit 2232fb2

Please sign in to comment.