Repository navigation
Trim test_max_bytes_ratio_before_external_distinct to fit the client timeout - #121096
Conversation
…timeout test_max_bytes_ratio_before_external_distinct[server] and [user] hit the integration harness's hard 600 second per-query cap on Integration tests (amd_asan_ubsan, db disk, 1/8). The cap is DEFAULT_QUERY_TIMEOUT in tests/integration/helpers/client.py and is applied unconditionally, so it cannot be raised from the test: the timeout= kwarg of node.query() only arms an additional, earlier timer. The test asserts a memory-limit behaviour by actually consuming memory up to the node's limit, so its runtime has a floor set by that limit. At 100M keys against 10Gi the floor exceeds the cap on the slowest sanitizer flavour: over 30 days that job ran the param 918 times with a p50 of 573s, 727 runs over 540s and 233 over 595s, while the sort and group_by params in the same file have 0 runs over 540s. It is not a release-build regression: on arm_binary the same test takes 36s versus 41s for its sort sibling, and the 15.6x sanitizer factor is a property of a single-threaded comparison-based spill path that is not shipped. Reducing the workload alone would break the oracle, because the unspilled peak must still exceed the node limit for the ratio=0 half to be rejected. So the limit and the workload come down together, on a dedicated instance pair so that the group_by and sort params keep their 10Gi configs untouched: 7M keys of exactly 800 bytes against a 4Gi limit. Which tracker refuses the ratio=0 half is now asserted rather than argued from the server logs: each parametrize row carries its own expected text, so [server] requires "(total) memory limit exceeded" and [user] requires "User memory limit exceeded", both with "maximum: 4.00 GiB", and swapping the two expectations reddens both params. Those two substrings are the only ones common to the tracked and the RSS arm of the limit check, so they hold on an address,undefined build and on a non-sanitizer one alike. The spilling half also gains an assertion that it really spilled, using the query_id plus ProfileEvents['ExternalDistinctWritePart'] idiom already used by test_external_distinct_disk_limits, so shrinking the scale makes that arm strictly stronger than before instead of weaker. Measured on the address,undefined build: the spilling query drops from 410.8s to 42.6s, the whole file from 6 passed in about 1850s to 6 passed in 1030.7s, and the two added idle instances cost 1.5s of cluster startup.
Internal second-model review (1 major fixed and re-verified, 2 refuted with evidence, 4 noted)Before opening this I ran an independent cold review plus a second-model gate over the diff and ❌ Fixed before this PR opened
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260919-222200 |
|
Workflow [PR], commit [ff2c752] Summary: ✅ AI ReviewSummaryThis PR trims Missing context / blind spots
Final Verdict✅ No blocking or major review findings. |
0f8787e
`test_max_bytes_ratio_before_external_distinct[server]` fails on `Integration tests (amd_asan_ubsan, db disk, 1/8)` in about half of the runs that carry ClickHouse#121096: 16 failures against 17 passes since it merged on 2026-09-21, 4 of them on `master`. The `[user]` parameter passed 33 out of 33 over the same window. It is the spilling half that fails, and it is rejected on RSS rather than on tracked memory: `(total) memory limit exceeded: would use 2.65 GiB (attempt to allocate chunk of 64.50 MiB), current RSS: 3.95 GiB, maximum: 4.00 GiB`. `max_server_memory_usage` is enforced against RSS, and an Address Sanitizer build's RSS carries redzones and quarantined chunks that the memory tracker never sees - 1.3 GiB of them here. The query itself behaves as designed. With `max_bytes_ratio_before_external_distinct = 0.3` against the node's 4 GiB it spills at 1.2 GiB, and the final merge then holds 54 suppression runs of 16 MiB, 4 ordinary runs read back in 64.50 MiB blocks and a 15 chunk in-memory tail open at once, so it needs roughly twice the spill threshold. That leaves about 1.3 GiB of the node spare, which is exactly what the sanitizer overhead consumes. Raising the limit does not buy margin, because the unspilled peak has to stay above it, and ClickHouse#121096 already sized the workload to the harness's 600 second per-query cap. The `[user]` parameter is unaffected by construction, because `max_memory_usage_for_user` counts tracked bytes rather than RSS, so only the `[server]` parameter is skipped and only on an Address Sanitizer build. Both parameters keep running on `arm_binary` and on `amd_llvm_coverage`, where neither has failed. Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=e033cea645358fa98672769636b5c979d8adcd26&name_0=MasterCI&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%201%2F8%29 Related: ClickHouse#121096
|
The revert and #121454 interleaved, and the tree that shipped is a combination neither change was measured against. #121454 was opened 2026-09-21 22:54Z against a master that still carried this PR. Its description says " Measured on Separately, the skip's comment cites You own this test and A. I re-land only the A is the only one of the three that keeps any ASan coverage of this oracle, which is why I would pick it, but the call is yours. |
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md. Changelog-revert: 119274 118919 Revert "Carry the mutation version onto a rewritten lightweight `DELETE`" Changelog-revert: 119306 119274 Revert "Revert "Carry the mutation version onto a rewritten lightweight `DELETE`"" Changelog-revert: 119334 117356 Revert "Unify the spill trigger for hash joins" Changelog-revert: 119335 119334 Revert "Revert "Unify the spill trigger for hash joins"" Changelog-revert: 121135 118279 Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer" Changelog-revert: 121136 121135 Revert "Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer"" Changelog-revert: 121258 118216 Revert "Do not invert an ordered comparison that can see a `NaN` in the CNF form" Changelog-revert: 121298 117578 Revert "Bound the docker buildx retry ladder by wall clock, not by the timeout divisor" Changelog-revert: 121443 114465 Revert "Fix an error reading an Iceberg table whose `current-snapshot-id` is JSON null" Changelog-revert: 121477 121096 Revert "Trim `test_max_bytes_ratio_before_external_distinct` to fit the client timeout" Changelog-revert: 121901 121869 Revert "docs(managed-postgres): updated Private Service Connect" Changelog-revert: 122110 118223 Revert "Correct nightly coverage selection and share PR test manifests" Changelog-revert: 122140 120312 Revert "Refuse a `Set` table on the right side of `IN` when a row policy applies to it" Changelog-deleted-entry: 114465 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed an error when reading an Iceberg table whose `current-snapshot-id` is JSON null, which some writers emit for a table with no current snapshot. [#114465](#114465) ([Shaohua Wang](https://github.com/tiandiwonder)). Changelog-deleted-entry: 118216 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed `convert_query_to_cnf = 1` silently dropping rows with a `NaN` in a floating point column: the conversion rewrote `NOT (x < c)` into `x >= c`, which is not an equivalent condition for `NaN`. [#118216](#118216) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Changelog-deleted-entry: 118223 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Correct nightly coverage selection and share PR test manifests. [#118223](#118223) ([Nikita Fomichev](https://github.com/fm4v)). Changelog-deleted-entry: 120312 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * A row policy on a `Set`-engine table was accepted but never applied: the right side of `IN` read the prebuilt set directly and returned the rows the policy hides. Such a query now fails with `ACCESS_DENIED`, because the `Set` engine has no read path that could filter the rows. Queries that used a `Set` table covered by a database-wide row policy ran unfiltered before and now throw. [#120312](#120312) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)). Changelog-deleted-entry: 121096 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Sized `test_max_bytes_ratio_before_external_distinct` to fit the integration harness's 600 second per-query timeout. [#121096](#121096) ([Groene AI](https://github.com/groeneai)).
test_max_bytes_ratio_before_external_distinct[user] fails on Integration tests (amd_asan_ubsan, db disk, 1/8) at the integration harness's 600 second per-query cap (DEFAULT_QUERY_TIMEOUT in helpers/client.py, applied unconditionally): since ClickHouse#121454 merged, 10 of 1972 runs on that job failed with "timed out after 600 seconds" at the ratio = 0.3 spilling call, one of them on master, and the passing runs have a median of 587 s. The test proves a memory-limit behaviour by consuming memory up to the limit, so the limit sets its runtime. At node_user's 10Gi profile limit the rejection half needs an unspilled footprint above 10 GiB, i.e. 100M ~85-byte keys, and on the ASan build the spilling half alone takes 412 s locally. ClickHouse#121096 had moved both parameters to 4Gi instances with 7M keys of 800 bytes; ClickHouse#121454 then skipped [server] under ASan, measured on that tree, and kept [user] because a user limit counts tracked bytes, not RSS; ClickHouse#121477 reverted ClickHouse#121096 in full on the strength of [server] failures (its query filters distinct[server]), which put [user] back on the workload that times out. This gives the [user] row its own query, the 7M x 800-byte workload with max_memory_usage_for_user = '4Gi' in its SETTINGS, on the existing node_user, so no instance is added. A user's memory tracker is reset when the user's last running query finishes (ProcessList), and the next query applies its own limit, so the 4 GiB holds after the group_by and sort tests' 10Gi queries on the same node. [server] keeps its query, node and ASan skip; only its query moved into the parametrize row. The trimmed [user] row passed all 152 runs of the failing job that carried ClickHouse#121096 (median 76 s). max_block_size is pinned to its default because the final merge holds one block of every spilled run at once, and a random draw above ~83.9K rows makes each 800-byte-key block a 128 MiB allocation. Measured on the ASan build (query_log.memory_usage of the spilling query, pin removed, draw forced): 84000 -> 3.45 GiB, 92237 -> 3.61 GiB, 96000 -> 3.33 GiB of the 4 GiB limit, and 88000 rejects the spilling query itself. The peak is not monotone in the draw (100000 -> 2.73 GiB, 50000 -> 2.04 GiB), because the size of the unspilled tail depends on how the input chunks align with the run size. Pinned, it is 2.57 GiB with 58 runs and 14 tail chunks at every draw. 04493_external_distinct and its siblings pin the same value. Measured locally, ASan+UBSan, db disk flavour, harness containers (cpus: 5, mem_limit: 12g): the spilling query drops from 411.6 s to 43.5 s; with the client cap scaled to 200 s the old test times out and the new one passes; the unspilled peak is 5.69 GiB, so the ratio = 0 half is still rejected, by "User memory limit exceeded ... maximum: 4.00 GiB"; 50 of 50 repetitions and the whole module twice passed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #116569
Related: #104965
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Sized
test_max_bytes_ratio_before_external_distinctto fit the integration harness's 600 second per-query timeout.Description
test_max_bytes_ratio_before_external_distinct[server]and[user]time out at the harness's hard 600 second per-query cap onIntegration tests (amd_asan_ubsan, db disk, 1/8): over 30 days it ran[server]1031 times at a median of 572s, 260 of them at or above 595s, whilesortandgroup_byin the same file have 0 runs over 540s. The cap isDEFAULT_QUERY_TIMEOUTinhelpers/client.py, applied unconditionally, so the test cannot raise it; thetimeout=kwarg only arms an additional, earlier timer.Not a release-build regression: on
arm_binarythis test takes 36s against 41s for itssortsibling; the 15.6x sanitizer factor comes from a single-threaded comparison-based spill path, on builds that are not shipped.long_run, the other remedy, would delete the coverage (pytest.inicarriesaddopts = -m 'not long_run and not e2e'and no job selects the marker). The merged siblingtest_external_distinct_disk_limitscovers this feature at 16k to 262k rows.The test asserts a memory-limit behaviour by consuming memory up to the node's limit, so its runtime has a floor set by that limit, and shrinking the workload alone would break the oracle: the unspilled peak must still exceed the limit for the
ratio=0half to be rejected. So limit and workload come down together, on a dedicated instance pair, leavinggroup_byandsorton their untouched 10Gi configs: 7M keys of exactly 800 bytes against 4Gi, sized for RSS headroom rather than minimality.Each param asserts which tracker rejected it,
(total)orUseratmaximum: 4.00 GiB; both pass onaddress,undefinedand non-sanitizer builds, and swapping the expected texts reddens both. The spilling half asserts that it spilled, so the trim strengthens that arm. The spilling query drops from 411s to 42s and the file from about 1850s to 1031s; the two added idle instances cost 1.5s of startup.Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=104965&sha=81348dcffea1f5d0c73f4894d63a28a718bcbdfa&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20db%20disk%2C%201%2F8)
30 days of per-param timings on the failing job, and the query
Workflow [PR]
Sync PR [sync-upstream/pr/121096]
Version info
26.10.1.372-master(included in26.10and later)