Skip to content

Commit

Permalink
kv: improve IllegalReplicationChangeError
Browse files Browse the repository at this point in the history
Include information about the replica that is returning the error and
about the current range descriptor.

Related to cockroachdb#85879.

Release justification: low risk, improves debugging.
  • Loading branch information
nvanbenschoten committed Aug 17, 2022
1 parent f0c8bfd commit fa0e39a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/kv/kvserver/replica_raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func (r *Replica) propose(
// See also https://github.com/cockroachdb/cockroach/issues/67740.
lhRemovalAllowed := r.store.cfg.Settings.Version.IsActive(
ctx, clusterversion.EnableLeaseHolderRemoval)
lhDescriptor, err := r.GetReplicaDescriptor()
lhDesc, err := r.GetReplicaDescriptor()
if err != nil {
return roachpb.NewError(err)
}
Expand All @@ -400,11 +400,11 @@ func (r *Replica) propose(
// transferred away. The previous leaseholder is a LEARNER in the target config,
// and therefore shouldn't continue holding the lease.
if err := roachpb.CheckCanReceiveLease(
lhDescriptor, proposedDesc.Replicas(), lhRemovalAllowed,
lhDesc, proposedDesc.Replicas(), lhRemovalAllowed,
); err != nil {
e := errors.Mark(errors.Wrapf(err, "received invalid ChangeReplicasTrigger %s to "+
"remove self (leaseholder); lhRemovalAllowed: %v; proposed descriptor: %v", crt,
lhRemovalAllowed, proposedDesc), errMarkInvalidReplicationChange)
e := errors.Mark(errors.Wrapf(err, "%v received invalid ChangeReplicasTrigger %s to "+
"remove self (leaseholder); lhRemovalAllowed: %v; current desc: %v; proposed desc: %v",
lhDesc, crt, lhRemovalAllowed, r.Desc(), proposedDesc), errMarkInvalidReplicationChange)
log.Errorf(p.ctx, "%v", e)
return roachpb.NewError(e)
}
Expand Down

0 comments on commit fa0e39a

Please sign in to comment.