Skip to content

Conversation

@wenyihu6
Copy link
Contributor

@wenyihu6 wenyihu6 commented Aug 27, 2025

Stacked on top of #152596.


Previously, replicas could be enqueued at a high priority but end up processing
a lower-priority actions, causing priority inversion and unfairness to other
replicas behind them that needs a repair action. This commit adds metrics to
track such cases. In addition, this commit also adds metrics to track when
replicas are requeued in the replicate queue due to a priority inversion from a
repair action to a rebalance action.

Part of: #151847
Release note: none

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@wenyihu6 wenyihu6 force-pushed the newobs branch 5 times, most recently from 14f55e5 to d80f84e Compare August 27, 2025 21:11
@wenyihu6 wenyihu6 changed the title kvserver: new observability kvserver: track priority inversion Aug 27, 2025
@wenyihu6 wenyihu6 changed the title kvserver: track priority inversion kvserver: track priority inversion in replicate queue metrics Aug 27, 2025
@wenyihu6 wenyihu6 marked this pull request as ready for review August 27, 2025 21:14
@wenyihu6 wenyihu6 requested review from a team as code owners August 27, 2025 21:14
Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sumeerbhola reviewed 1 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani and @tbg)


pkg/kv/kvserver/replicate_queue.go line 322 at r3 (raw file):

		Unit:        metric.Unit_COUNT,
	}
	metaReplicateQueuePriorityInversionForAddVoterCount = metric.Metadata{

(drive-by comments)

This commit adds a new cluster setting PriorityInversionRequeue that controls
whether the replicate queue should requeue replicas when their priority at
enqueue time differs significantly from their priority at processing time
(e.g. dropping from top 3 to the lowest priority).
Previously, a replica could enter the queue with high priority but, by the time
it was processed, the action planned for this replica may have a low priority,
causing us to perform low priority work. Specifically, we are mostly worried
about cases where the priority changes from any of the repair actions to
consider rebalance. Rebalancing could take a long time and block other ranges
enqueued with actual repair action needed. This commit ensures that such
replicas are requeued instead, avoiding priority inversions.
Previously, replicas could be enqueued at a high priority but end up processing
a lower-priority actions, causing priority inversion and unfairness to other
replicas behind them that needs a repair action. This commit adds metrics to
track such cases. In addition, this commit also adds metrics to track when
replicas are requeued in the replicate queue due to a priority inversion from a
repair action to a rebalance action.
@wenyihu6
Copy link
Contributor Author

wenyihu6 commented Aug 29, 2025

Closing in favour of a new PR. Will address your comments in the new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants