Repository navigation
Give 00084_external_aggregation real memory headroom - #112054
Merged
Merged
Conversation
The second query of the test spills to disk at 200 MB
(`max_bytes_before_external_group_by`) and was capped at 300000000
(286.10 MiB) by `max_memory_usage`. Measured on an idle machine it peaks at
258-290 MiB, i.e. it ran at 90-97% of its own limit, so any allocation the
query makes on top of the aggregation state pushed it over and the test
failed with `MEMORY_LIMIT_EXCEEDED`.
One reproducible way to add that extra memory is the aggregation hash-table
size statistics: once the cache holds an entry for this aggregation,
`collect_hash_table_stats_during_aggregation` preallocates ~2.7 million
elements and the peak jumps from ~258 MiB to ~374 MiB. With the old limit
the test then fails on every run, with the same message as in CI:
Query memory limit exceeded: would use 288.69 MiB
(attempt to allocate chunk of 4.06 MiB), maximum: 286.10 MiB
Raise the limit to 600000000 (572.20 MiB). Without spilling the same query
needs ~855 MiB and still fails with `MEMORY_LIMIT_EXCEEDED` under the new
limit, so the test keeps checking that the aggregation goes to disk.
https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=a8c156e623333d40936998a3b0d273966835912c&name_0=MasterCI&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [3a9ca63] Summary: ✅ AI ReviewSummaryThis PR raises Missing context / blind spots
Final VerdictStatus: ✅ Approve |
This was referenced Jul 27, 2026
This was referenced Jul 27, 2026
1 task done
This was referenced Jul 27, 2026
1 task
Merged
This was referenced Jul 28, 2026
Merged
Merged
This was referenced Jul 28, 2026
1 task
This was referenced Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the recurring
MEMORY_LIMIT_EXCEEDEDflakiness of00084_external_aggregation, e.g. this MasterCI run:29 failures over 2026-07-26 and 2026-07-27 across
amd_tsan,arm_binary,amd_debug,amd_msanandamd_asan_ubsan, always on the second query and always with code 241. The settings randomizer is not the trigger: CI's own diagnosis reruns the same randomized settings 16-22 times and they all pass.What is going on
The second query spills at 200 MB (
max_bytes_before_external_group_by) and was capped at300000000(286.10 MiB) bymax_memory_usage. Measured againsttest.hitson an idle machine, over 10 runs of the query pair on a freshly started server, the second query peaks at 258-290 MiB - 90-97% of its own limit. There is essentially no headroom, so anything the query allocates on top of the aggregation state crosses the limit.One reproducible source of that extra memory is the aggregation hash-table size statistics. Once the statistics cache holds an entry for this aggregation,
collect_hash_table_stats_during_aggregationpreallocates the hash tables and the peak jumps by more than 100 MiB:AggregationPreallocatedElementsInHashTablesIn the second state the current test fails on every single run with exactly the CI message:
This is the same interaction between external aggregation and the hash-table statistics that #111984 describes for
04625_hash_table_sizes_stats_table_expression_modifiers.The fix
Raise
max_memory_usagefor the second query to600000000(572.20 MiB) and record why in a comment. The number is picked so the test keeps its meaning:max_bytes_before_external_group_by = 0) the same query needs ~855 MiB and still fails under the new limit (would use 687.22 MiB ... maximum: 572.20 MiB), so the test still verifies that the aggregation goes to disk;Verified locally on an ARM release build of master (
26.8.1.144) withtest.hitsloaded from the stateful web disk: the patched test passes and matches the reference both on a fresh server and on a server whose statistics cache makes the current version fail 3/3.Related: #102618
Related: #111984
Changelog category (leave one):
Documentation entry for user-facing changes