Repository navigation
Disable zero-length interval quotas - #110846
Conversation
|
Workflow [PR], commit [055ecab] Summary: ❌
AI ReviewSummaryThis PR rejects non-positive quota intervals to stop the divide-by-zero path in quota consumption, and it adds a stateless regression test for PR Metadata
### Changelog category (leave one):
- Bug Fix (changelog entry is required)The Findings❌ Blockers
Final VerdictStatus: ❌ Block |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 12/14 (85.71%) · Uncovered code |
|
No one sets 0 interval quotas, so this is not a concern for upgrades |
Pulls in the quota zero-length-interval SIGFPE fix (#110846) so the unrelated Stress amd_tsan flake clears on the next CI run. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pull in #110846 ("Disable zero-length interval quotas", merged into master as 6a09288), which fixes the SIGFPE in `EnabledQuota::Interval::getEndOfInterval` that failed the Stress test (amd_debug) job on this PR (tracked issue #110860, now closed). The crash was unrelated to framing formats; merging clears that red on the next CI run. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The test created a query quota with `TO default`. A quota is a server-global entity, and in stress and parallel runs all stateless tests execute concurrently against the same server as the `default` user, so the quota on `default` was consumed by every concurrent query, exhausted its limit, and made the server reject subsequent queries with `QUOTA_EXCEEDED` — eventually taking the whole server down (`Server is not responding`). The interval is validated at CREATE time in `InterpreterCreateQuotaQuery`, independent of the `TO` assignment, so the quota does not need to be assigned to anyone for the test to exercise the `BAD_ARGUMENTS` rejection. Drop the `TO default` clause so the test no longer touches the shared `default` user; the reference output (`BAD_ARGUMENTS` / `BAD_ARGUMENTS` / `ok`) is unchanged. Surfaced on the `Stress test (amd_msan)` job of ClickHouse#106215 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106215&sha=0b2a2b671abe9df2dae40253fb8fafacaf699575&name_0=PR&name_1=Stress%20test%20%28amd_msan%29 Caused by: ClickHouse#110846 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Disable zero-length interval quotas
The test created a query quota with `TO default`. A quota is a server-global entity, and in stress and parallel runs all stateless tests execute concurrently against the same server as the `default` user, so the quota on `default` was consumed by every concurrent query, exhausted its limit, and made the server reject subsequent queries with `QUOTA_EXCEEDED` — eventually taking the whole server down (`Server is not responding`). The interval is validated at CREATE time in `InterpreterCreateQuotaQuery`, independent of the `TO` assignment, so the quota does not need to be assigned to anyone for the test to exercise the `BAD_ARGUMENTS` rejection. Drop the `TO default` clause so the test no longer touches the shared `default` user; the reference output (`BAD_ARGUMENTS` / `BAD_ARGUMENTS` / `ok`) is unchanged. Surfaced on the `Stress test (amd_msan)` job of ClickHouse#106215 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106215&sha=0b2a2b671abe9df2dae40253fb8fafacaf699575&name_0=PR&name_1=Stress%20test%20%28amd_msan%29 Caused by: ClickHouse#110846 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a server crash (integer division by zero) when a quota with a zero-length interval (for example CREATE QUOTA q FOR INTERVAL 0 SECOND MAX queries = 1000) was consumed. A non-positive quota interval duration is now rejected at quota creation.
Description
Found by the fuzzer (STID 4141-5b13,
Stress test (arm_asan_ubsan, s3), PR #110228, sha d463af4): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110228&sha=d463af42c39ba64e89709493b3e9aa2f0393e22f&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29Root cause:
EnabledQuota::Interval::getEndOfIntervalcomputes(current_time - end + duration) / duration. With a zero-length intervalduration == 0, so consuming the quota divides by zero. In debug/UBSan builds this is reported as UB atlibcxx/include/__chrono/duration.h; in release builds it is a real SIGFPE (signal 8, integer divide by zero) that terminates the server.Repro:
Fix: reject a non-positive interval duration at quota creation in
updateQuotaFromQueryImpl, which is the single validation point used by both the SQL DDL path and the on-disk reload path (AccessEntityIO). The XML users-config path already skips non-positive durations. A fractional interval that rounds down to zero seconds (e.g.INTERVAL 0.4 SECOND) is rejected too, since it hits the same code path.Closes #110343
Closes #110860
Version info
26.7.1.1146(included in26.7and later)