Repository navigation
Skip the RSS-based half of the external DISTINCT memory test under ASan - #121454
Conversation
`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 #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 #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: #121096
|
Workflow [PR], commit [d2b0cb0] Summary: ✅ AI ReviewSummaryThis PR skips Findings
Final Verdict
|
| pytest.skip("TSan build is skipped due to memory overhead") | ||
| if sanitizer_build["memory"]: | ||
| pytest.skip("Memory Sanitizer uses more memory, making precise memory limit testing unreliable") | ||
| if limit_follows_rss and sanitizer_build["address"]: |
There was a problem hiding this comment.
This skips the entire [server] parameter, but the flakiness described in the PR only affects the first half of the test: the max_bytes_ratio_before_external_distinct = 0.3 query that is supposed to spill and finish. The second half is still the deterministic regression check that the same DISTINCT query fails under max_server_memory_usage when spilling is disabled. With this guard, ASan stops testing any server-limit behavior for external DISTINCT. Can we split the success and failure assertions, or move the skip so only the spill-success branch is bypassed?
…l-distinct-memory-limit-asan # Conflicts: # tests/integration/test_max_bytes_ratio_before_external_order_group_by_for_server/test.py
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]>
Resolve the conflict in test_max_bytes_ratio_before_external_order_group_by_for_server/test.py. 26.9 has neither ClickHouse#120751 (the `sanitizer_build` dict) nor ClickHouse#121454 (the `limit_follows_rss` parameter and the ASan skip of the `[server]` case), so only the change of ClickHouse#122494 itself is ported: each case's query moves into its parametrize row, and the `[user]` row runs the 7M x 800-byte query with `max_memory_usage_for_user = '4Gi'`. The 26.9 sanitizer checks and the `[server]` query are kept as they are. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #121454 to 26.9: Skip the RSS-based half of the external DISTINCT memory test under ASan
…TINCT memory test under ASan
Backport #121454 to 26.9: Skip the RSS-based half of the external DISTINCT memory test under ASan
…TINCT memory test under ASan
Related: #121096
Related: #104965
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Skipped the RSS-based parameter of
test_max_bytes_ratio_before_external_distincton Address Sanitizer builds, where it fails about half of the time.Description
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
test_max_bytes_ratio_before_external_distinct[server]fails onIntegration tests (amd_asan_ubsan, db disk, 1/8)in about half of the runs that carry #121096, which resized the test on 2026-09-21 to fit the harness's per-query timeout. Since it merged, the parameter has 16 failures against 17 passes on that job, 4 of the failures onmaster;[user]has 33 passes and no failures, and neither parameter has failed onarm_binaryoramd_llvm_coverage. Before #121096 the same test failed the other way, by exceeding the 600 second client timeout, so this is the second failure mode of the same oracle rather than a new one.Post-#121096 runs on the failing job, per parameter
What fails
It is the spilling half of the test, the one that is supposed to succeed, and it is rejected on RSS rather than on tracked memory:
max_server_memory_usageis enforced against RSS, and an Address Sanitizer build's RSS carries redzones and quarantined chunks that the memory tracker never sees. Here that gap is 1.3 GiB: the server log has(total) current memory usage: 2.01 GiBagainst a tracked baseline of 10 MiB, so the whole gap is allocator overhead.Why the node has no room for it
The query behaves as designed. With
max_bytes_ratio_before_external_distinct = 0.3against the node's 4 GiB it spills at 1.2 GiB, and the server log shows what the final merge then holds open at once:54 suppression runs of 15.98 MiB, 4 ordinary runs of 958.83 MiB read back in 64.50 MiB blocks, and a 15 chunk in-memory tail, all live simultaneously — roughly twice the spill threshold, which is what the 2.65 GiB in the exception is. That leaves about 1.3 GiB of the node spare, exactly what the sanitizer overhead consumes, so the test sits on the break-even point and flips on run-to-run variation.
Raising the limit does not buy margin, because the unspilled peak has to stay above it and #121096 already sized the workload to the 600 second per-query cap; lowering it is worse, because the sanitizer surcharge is a fixed cost that a smaller budget absorbs less well.
The fix
[user]is unaffected by construction —max_memory_usage_for_usercounts tracked bytes rather than RSS — so only[server], and only on an Address Sanitizer build, is skipped. The file already skips this test on Thread and Memory Sanitizer builds for the same class of reason. Both parameters keep running onarm_binary(36 s) and onamd_llvm_coverage.Not fixed here
Reading all 58 runs back concurrently puts the entire spilled hash set back into memory, so the merge phase of external
DISTINCTneeds about twice the spill threshold rather than staying under it. ExternalORDER BYhas had the same shape of problem (ff8e0db56d79). That is a property of the new operator's design rather than of this test, and bounding the merge fan-in belongs with the feature rather than with a CI fix.Workflow [PR]
Sync PR [sync-upstream/pr/121454]
Version info
26.10.1.426-master(included in26.10and later)