Weighted laning: configurable per-threshold weights#19665
Open
mshahid6 wants to merge 1 commit into
Open
Conversation
FrankChen021
reviewed
Jul 8, 2026
FrankChen021
left a comment
Member
There was a problem hiding this comment.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
Reviewed 4 of 4 changed files.
Found 1 weighted-laning cost calculation issue.
This is an automated review by Codex GPT-5.5
|
|
||
| if (durationThreshold != null && query.getDuration().isLongerThan(durationThreshold)) { | ||
| cost++; | ||
| cost += weightOrDefault(durationWeight); |
Member
There was a problem hiding this comment.
[P2] Prevent weighted cost overflow from bypassing lanes
The new weight fields are only validated as >= 1, but computeCost accumulates them in an int. A valid config such as durationWeight=1 and segmentCountWeight=Integer.MAX_VALUE overflows when both thresholds are breached; the wrapped negative cost does not satisfy any positive lane minCost, so the query falls back to the default pool instead of being throttled. Please accumulate in long or checked arithmetic, or reject configs whose maximum possible cost exceeds Integer.MAX_VALUE.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow-up to the weighted query laning strategy (#19225).
Configurable per-threshold weights (
WeightedQueryLaningStrategy)Previously every breached threshold added exactly 1 to a query's cost. This adds optional per-threshold weights so a breach on one dimension can count for more than another (e.g. a huge segment scan should outweigh a slightly-old interval). Each weight defaults to 1, so existing configs are unchanged.
New optional properties (each an integer >= 1, default 1):
periodWeight,durationWeight,segmentCountWeight,segmentRangeWeight.a weight must be >= 1 and its corresponding threshold must be configured
Example. A segment-count breach counts double, so a query breaching only segmentCount still reaches a cost-2 lane:
iddimension on thequery/prioritymetric (QueryScheduler)Also adds the query
iddimension for easily finding a query's priority.Key changed classes
WeightedQueryLaningStrategy— optional per-threshold weight fields + validationQueryScheduler—iddimension on thequery/prioritymetricRelease note
The
weightedquery laning strategy now supports optional per-threshold cost weights (periodWeight,durationWeight,segmentCountWeight,segmentRangeWeight; default 1), and thequery/prioritymetric now includes aiddimension.This PR has: