Skip to content

Commit 499aefd

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 2e20ab6 commit 499aefd

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
@@ -870,10 +870,9 @@ func (bq *baseQueue) addInternal(
870870
if log.V(1) {
871871
log.Dev.Infof(ctx, "updating priority: %0.3f -> %0.3f", item.priority, priority)
872872
}
873-
// TODO(wenyihu6): will this introduce a lot of new memory allocation?
874-
processCallback.onEnqueueResult(-1, /*indexOnHeap*/
875-
errors.Wrapf(errReplicaAlreadyInQueue, "priority=%.3f->%.3f", item.priority, priority))
876873
bq.mu.priorityQ.update(item, priority)
874+
// item.index should be updated now based on heap property now.
875+
processCallback.onEnqueueResult(item.index /*indexOnHeap*/, nil)
877876
}
878877
return false, nil
879878
}

0 commit comments

Comments
 (0)