Skip to content

fix(allocation-policies): Stop BytesScannedRejectingPolicy throttling every query - #8624

Merged
dezzeddi merged 3 commits into
masterfrom
dani/bsr-request-scan-limit
Nov 2, 2026
Merged

dezzeddi merged 3 commits into
masterfrom
dani/bsr-request-scan-limit

Conversation

@dezzeddi

@dezzeddi dezzeddi commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

BytesScannedRejectingPolicy asked the rate limiter for a fixed 1e12 bytes (1 TB; the old constant name PETABYTE was wrong). The limiter grants min(requested, remaining), so granted never exceeded 1 TB.

The policy computes used = limit - granted, so usage looked far higher than it was. With a 20 TB limit and zero usage, used = 19 TB, which is over the throttle point (20 / 1.5 ≈ 13.3 TB), so every query is throttled. This happens for any limit above about 3 TB.

Fix: request scan_limit. check_within_quotas doesn't consume quota, so only the reported remaining amount changes.

…an limit is above ~3 TB

BytesScannedRejectingPolicy asked the rate limiter for a fixed 1e12 bytes to
find out how much quota was left. The rate limiter grants
min(requested, remaining), so granted could never exceed 1 TB and
used_quota = scan_limit - granted was overstated by scan_limit - 1 TB. For any
scan_limit above ~3 TB the throttle check (granted < scan_limit -
scan_limit // 1.5) was always true, so those tenants ran at half threads even
with zero usage. quota_used was also wrong for every limit above 1 TB.

Request scan_limit instead. check_within_quotas does not consume quota, so
asking for the full limit only changes the reported remaining amount.
@dezzeddi
dezzeddi requested a review from a team as a code owner October 29, 2026 06:07
@dezzeddi
dezzeddi marked this pull request as draft October 29, 2026 06:11
@dezzeddi dezzeddi changed the title fix(allocation-policies): Stop BSR throttling every query when the scan limit is above ~3 TB fix(allocation-policies): BytesScannedRejectingPolicy incorrectly throttling queries when it shouldnt Oct 29, 2026
@dezzeddi
dezzeddi marked this pull request as ready for review October 29, 2026 06:21
@dezzeddi dezzeddi changed the title fix(allocation-policies): BytesScannedRejectingPolicy incorrectly throttling queries when it shouldnt fix(allocation-policies): Stop BytesScannedRejectingPolicy throttling every query Oct 29, 2026
@dezzeddi
dezzeddi enabled auto-merge (squash) November 2, 2026 19:29
@dezzeddi
dezzeddi merged commit f8cfde0 into master Nov 2, 2026
71 checks passed
@dezzeddi
dezzeddi deleted the dani/bsr-request-scan-limit branch November 2, 2026 19:37
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