Skip to content

feat(eap): downsample NORMAL/LOW_PRIORITY when cluster load exceeds reject thresholds - #8688

Open
pbhandari wants to merge 11 commits into
masterfrom
prajjwalbhandari/load-threshold-downsample
Open

pbhandari wants to merge 11 commits into
masterfrom
prajjwalbhandari/load-threshold-downsample

Conversation

@pbhandari

@pbhandari pbhandari commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

When cluster load exceeds any active allocation policy thresholds.reject, NORMAL and LOW_PRIORITY queries move one step coarser on the EAP ladder (1 → 8 → 64 → 512 via Tier.lower()). Already at 512 stays 512. A tier not on the ladder becomes TIER_1 then can step up on a later request. Highest-accuracy modes are unchanged. can_run is not flipped.

Runs after _update_routing_decision, so it coarsens whatever outcomes already picked. Emits sampling_in_storage_allocation_policy_downsample when that bump runs, so we can track how often we downsample due to load.

LoadInfo.exceeds({}) is false (no ceilings → nothing exceeded). An empty reject map therefore does not downsample, and a rejection is pardoned when load info is present. Missing load info still rejects.

can_run behaviour is unchanged for now. So this will only downsample on unenforced policies (to allow our enforced rate-limits to continue rate limiting).

@linear-code

linear-code Bot commented Nov 10, 2026

Copy link
Copy Markdown

EAP-732

@pbhandari
pbhandari marked this pull request as ready for review November 10, 2026 16:57
@pbhandari
pbhandari requested review from a team as code owners November 10, 2026 16:57
@@ -1,3 +1,5 @@
from __future__ import annotations

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we really need this?

It seems harmless, without it we can also just continue using "Tier" and return Tier.TIER_1 works without this import

also in 3.14 version its enabled automatically, so it might be better to keep it so we dont need to rewrite "Tier" to Tier once we upgrade(pretty sure nobody will do that)

Just making sure its intentional and not ai being enthusiastic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah; I hate the "Tier" style annotations. I almost always want from __future__ import Annotations.

Comment on lines +19 to +20
if self not in ladder:
return Tier.TIER_1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this ever happen? A query with no tier / unknown tier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Probably not. But technically yes.

This will ensure that in those instance we route to a tier; instead of 500-ing on the query.

Comment thread snuba/downsampled_storage_tiers.py Resolved
Comment on lines +860 to +871
@pytest.mark.parametrize(
"start, expected",
[
(Tier.TIER_1, Tier.TIER_8),
(Tier.TIER_8, Tier.TIER_64),
(Tier.TIER_64, Tier.TIER_512),
(Tier.TIER_512, Tier.TIER_512),
(Tier.TIER_NO_TIER, Tier.TIER_1),
],
)
def test_lower(start: Tier, expected: Tier) -> None:
assert start.lower() == expected

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

test for the edges of .lower() behaviour

@@ -1,3 +1,5 @@
from __future__ import annotations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah; I hate the "Tier" style annotations. I almost always want from __future__ import Annotations.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit eb1c500. Configure here.

This branch has not been deployed

No deployments
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.

2 participants