Repository navigation
Fix float-to-integer overflow in quota max value parsing - #111032
alexey-milovidov wants to merge 1 commit into
Conversation
The flaky check runs the test several times in parallel, and the fixed global quota name `q_04617` collided across runs (`ACCESS_ENTITY_ALREADY_EXISTS`, `UNKNOWN_QUOTA`): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111032&sha=db0ae75f32dffc349beee2261475a75bbf892780&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 #111032 Convert the test to `.sh` so the quota name can include `$CLICKHOUSE_DATABASE` (unique per run), and extend it with cases for quota types without an output denominator (`MAX queries = -1` and friends), per review. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The two CI failures are unrelated to this PR:
|
|
The remaining CI failure, Stress test (arm_debug) — logical error |
…uotaTypeInfo::stringToValue` The integration test only exercised the `output_denominator == 1` branch. Add a `users.xml` reload regression for `execution_time` with an out-of-range value (`1e19`, which exceeds the UInt64 range after scaling by the nanosecond denominator) and a negative-underflow value (`-1e-400`, which parses to -0.0 and is rejected by the sign bit), so the config half of the fix is covered independently of the SQL parser. #111032
|
The three CI failures are unrelated to this PR (quota limit parsing):
Pushed the requested |
|
The two CI failures on 9c1cfec are unrelated to this PR (quota limit parsing):
The AI review has approved and there are no unresolved review threads. |
|
The only CI failure on 5df2e86 — Stress test (amd_tsan), The new AI review finding (checked size-suffix multiply narrowing the multiplier to |
|
All four CI failures on c7abea5 are unrelated to this PR (quota limit parsing), except the last one, which is inconclusive by design:
Merged |
|
CI status on
Merged |
|
CI status on 4d24a0b — all reds are unrelated to this PR:
Also addressed the review finding: fractional literals for integer quota types (e.g. |
|
The CI failures on a39f192 are unrelated to this PR:
Merged |
|
Addressed the AI review finding in 78a28ca (see the thread reply): CI reds on c5bbe26, both unrelated to this change:
|
|
CI status on `78a28caea85`: the only red is Bugfix validation (unit tests), and it fails by construction — the "Compile before-binary" step builds `unit_tests_dbms` from the pre-fix sources with only the test files overlaid, and the new `gtest_parse_with_size_suffix.cpp` uses the `CHECK_OVERFLOW` template parameter of `parseWithSizeSuffix` that this PR introduces, so the "before" compile can only fail. The functional bugfix validation with `04617_quota_max_value_overflow` passed and is the real reproduction. This advisory check needs a waiver, not a code change. The AI review verdict is ✅ Approve with no remaining findings, and there are no unresolved review threads. Merged `master` (clean, no conflicts) to refresh CI; the affected translation units (`ParserCreateQuotaQuery.cpp`, `QuotaDefs.cpp`) rebuild cleanly on the merged tree. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
🕵 Addressed the AI review (round 15) in c7bebfc: the The two reds on 736ea04 are unrelated to this PR:
|
|
@alexey-milovidov A fix is already in progress: #113597, opened 2026-08-06 00:46 UTC -- about 13 hours before this run started, so You are right that this is unrelated to your PR, and
What actually consumed the budget is Root cause of that 34.4 min, and what #113597 changes: the gtest leaves The headroom is the reason a slow test turns into a red job at all: Two corrections to the corroboration, since it changes what is and is not the same bug:
So there is nothing for you to do on #111032 for this red, and no separate PR is owed from me beyond #113597, which is open and waiting on review. I am not proposing to raise the 45 min cap: 6 min of margin on a 39 min job is thin, but the tail is what regressed, and #113597 removes 34 of the 44 min. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes15 object files changed (+141.46 KiB total), 1 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units1894 translation units recompiled, 14376 s compile time in total, 1893 of them have a recent master baseline. |
|
🕵 The AI review verdict on
Merged |
|
🕵 The AI review verdict on
Rebuilt the affected translation units after the merge — |
The unit tests run sequentially in one binary under `timeout -s INT -v 45m gdb`. The summed test duration under TSan has grown from ~30 minutes in early July to 38-40 minutes now, leaving almost no headroom: a run on a slower machine exceeds the budget and the report blames whichever test happened to be running when `SIGINT` arrived - most recently `Storage/CoordinationTestWithCompression.TestStateMachineAndLogStore/MemCompressed`, which legitimately takes ~62 seconds and sits near the end of the run. Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112878&sha=3eea89cbb616eee24f1777cefb80ac39140aee60&name_0=PR&name_1=Unit%20tests%20(tsan) (ClickHouse#112878) and in the same job on ClickHouse#111032 the day before. Co-Authored-By: Claude Fable 5 <[email protected]>
|
🕵 The AI review verdict on The branch was 273 commits behind The only red on |
|
🕵 The AI review verdict on The branch was 732 commits behind Both reds on
|
|
🕵 The AI review verdict on
|
|
🕵 Merged |
|
🕵 Merged current |
f31a1f3 to
2bbc9eb
Compare
|
🕵 Closing as superseded by #113178, which merged the quota overflow fix into |
Related: #111007
The AST fuzzer with UBSan found that
CREATE QUOTA ... MAX execution_time = <huge number>casts an out-of-range double toQuotaValue(UInt64) inparseMaxValue: the value is multiplied by the quota type's output denominator (execution_timeis stored in nanoseconds) without a range check, which is undefined behavior:Bound the scaled value to the UInt64 range before the cast and throw a
BAD_ARGUMENTSexception for out-of-range, negative, or non-finite values, mirroring the existing guard for the quota interval duration. Apply the same guard toQuotaTypeInfo::stringToValue, which had the identical unchecked cast (reachable from quotas defined in the users configuration). Added a stateless regression test.Quota limit values are now taken from the literal text exactly (instead of a rounded
Float64), quoted and configuration values are parsed with overflow checks, and the value is shown back exactly:SHOW CREATE QUOTAoutput is replayable even for a limit at the top of the range. The system tablessystem.quota_limits,system.quota_usageandsystem.quotas_usageexpose scaled quota values (execution_time) exactly as well: the column type changed fromNullable(Float64)toNullable(Decimal(20, 9))(renderings of typical values are unchanged, since Decimal output trims trailing zeros).CI report where the fuzzer found it (in an unrelated PR): https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111007&sha=edff5021176b8081847ac3b4c6672f4089ad1ead&name_0=PR&name_1=AST%20fuzzer%20%28arm_asan_ubsan%29
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reject out-of-range values of quota limits with an output denominator (such as
MAX execution_time = 1e19inCREATE QUOTA) instead of casting them to an unspecified value (undefined behavior). Quota limits are stored, shown and replayed exactly; the scaled quota value columns ofsystem.quota_limits,system.quota_usageandsystem.quotas_usagechanged fromNullable(Float64)toNullable(Decimal(20, 9))to represent every value exactly.