@@ -809,7 +809,7 @@ func (rq *replicateQueue) applyChange(
809
809
case plan.AllocationFinalizeAtomicReplicationOp :
810
810
err = rq .finalizeAtomicReplication (ctx , replica )
811
811
case plan.AllocationTransferLeaseOp :
812
- err = rq .TransferLease (ctx , replica , op .Source . StoreID , op .Target . StoreID , op .Usage )
812
+ err = rq .TransferLease (ctx , replica , op .Source , op .Target , op .Usage )
813
813
case plan.AllocationChangeReplicasOp :
814
814
err = rq .changeReplicas (
815
815
ctx ,
@@ -949,7 +949,7 @@ func (rq *replicateQueue) shedLease(
949
949
rangeUsageInfo := repl .RangeUsageInfo ()
950
950
// Learner replicas aren't allowed to become the leaseholder or raft leader,
951
951
// so only consider the `VoterDescriptors` replicas.
952
- target := rq .allocator .TransferLeaseTarget (
952
+ targetDesc := rq .allocator .TransferLeaseTarget (
953
953
ctx ,
954
954
rq .storePool ,
955
955
desc ,
@@ -960,11 +960,18 @@ func (rq *replicateQueue) shedLease(
960
960
false , /* forceDecisionWithoutStats */
961
961
opts ,
962
962
)
963
- if target == (roachpb.ReplicaDescriptor {}) {
963
+ if targetDesc == (roachpb.ReplicaDescriptor {}) {
964
964
return allocator .NoSuitableTarget , nil
965
965
}
966
-
967
- if err := rq .TransferLease (ctx , repl , repl .store .StoreID (), target .StoreID , rangeUsageInfo ); err != nil {
966
+ source := roachpb.ReplicationTarget {
967
+ NodeID : repl .NodeID (),
968
+ StoreID : repl .StoreID (),
969
+ }
970
+ target := roachpb.ReplicationTarget {
971
+ NodeID : targetDesc .NodeID ,
972
+ StoreID : targetDesc .StoreID ,
973
+ }
974
+ if err := rq .TransferLease (ctx , repl , source , target , rangeUsageInfo ); err != nil {
968
975
return allocator .TransferErr , err
969
976
}
970
977
return allocator .TransferOK , nil
@@ -990,7 +997,7 @@ type RangeRebalancer interface {
990
997
TransferLease (
991
998
ctx context.Context ,
992
999
rlm ReplicaLeaseMover ,
993
- source , target roachpb.StoreID ,
1000
+ source , target roachpb.ReplicationTarget ,
994
1001
rangeUsageInfo allocator.RangeUsageInfo ,
995
1002
) error
996
1003
@@ -1019,16 +1026,16 @@ func (rq *replicateQueue) finalizeAtomicReplication(ctx context.Context, repl *R
1019
1026
func (rq * replicateQueue ) TransferLease (
1020
1027
ctx context.Context ,
1021
1028
rlm ReplicaLeaseMover ,
1022
- source , target roachpb.StoreID ,
1029
+ source , target roachpb.ReplicationTarget ,
1023
1030
rangeUsageInfo allocator.RangeUsageInfo ,
1024
1031
) error {
1025
1032
rq .metrics .TransferLeaseCount .Inc (1 )
1026
1033
log .KvDistribution .Infof (ctx , "transferring lease to s%d" , target )
1027
- if err := rlm .AdminTransferLease (ctx , target , false /* bypassSafetyChecks */ ); err != nil {
1034
+ if err := rlm .AdminTransferLease (ctx , target . StoreID , false /* bypassSafetyChecks */ ); err != nil {
1028
1035
return errors .Wrapf (err , "%s: unable to transfer lease to s%d" , rlm , target )
1029
1036
}
1030
1037
1031
- rq .storePool .UpdateLocalStoresAfterLeaseTransfer (source , target , rangeUsageInfo )
1038
+ rq .storePool .UpdateLocalStoresAfterLeaseTransfer (source . StoreID , target . StoreID , rangeUsageInfo )
1032
1039
return nil
1033
1040
}
1034
1041
0 commit comments