Skip to content

Commit b80f751

Browse files
committed
kvserver: treat priority update as a success with onEnqueueResult
Previously, bq.addInternal invoked processCallback.onEnqueueResult with a newly constructed error whenever a replica was already present and re-enqueued with a higher priority, since the priority had to be passed dynamically. This commit instead treats the case as a success and passes the updated heap index to onEnqueueResult, as the caller mainly cares about whether the replica is already in the queue and its new position.
1 parent b54e16b commit b80f751

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/kv/kvserver/queue.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -894,10 +894,9 @@ func (bq *baseQueue) addInternal(
894894
if log.V(1) {
895895
log.Infof(ctx, "updating priority: %0.3f -> %0.3f", item.priority, priority)
896896
}
897-
// TODO(wenyihu6): will this introduce a lot of new memory allocation?
898-
processCallback.onEnqueueResult(-1, /*indexOnHeap*/
899-
errors.Wrapf(errReplicaAlreadyInQueue, "priority=%.3f->%.3f", item.priority, priority))
900897
bq.mu.priorityQ.update(item, priority)
898+
// item.index should be updated now based on heap property now.
899+
processCallback.onEnqueueResult(item.index /*indexOnHeap*/, nil)
901900
}
902901
return false, nil
903902
}

0 commit comments

Comments
 (0)