Repository navigation
Fix flaky 04625_hash_table_sizes_stats_table_expression_modifiers - #111984
alexey-milovidov wants to merge 2 commits into
Conversation
The test asserts the exact number of elements preallocated in the shard-side aggregation hash tables, and the settings randomizer turns external aggregation on (`max_bytes_before_external_group_by`, or its ratio-based variant) for ~half of the runs. When the first run of a pair spills, `Aggregator::writeToTemporaryFile` re-inits the hash table after each flush, so the sizes `updateStatistics` reads at the end of the query are the post-spill remainder instead of the real group count. The stats cache entry then sits below the 500e3 lower bound in `getSizeHint`, the second (`-prealloc`) run preallocates nothing, and `AggregationPreallocatedElementsInHashTables` is 0 rather than 650000. Pin both thresholds to 0 in the test's settings; the test is about the stats cache key including table expression modifiers, not about spilling. Everything else stays randomized. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| --max_size_to_preallocate_for_aggregation=1000000000000 | ||
| --serialize_query_plan=1 | ||
| --prefer_localhost_replica=0 | ||
| --max_bytes_before_external_group_by=0 |
There was a problem hiding this comment.
This disables randomized external aggregation for 04625, but the sibling tests/queries/0_stateless/04509_hash_table_sizes_stats_table_functions.sh is still exposed to the same failure mode. That test has no no-random-settings tag and both of its settings arrays still leave max_bytes_before_external_group_by and max_bytes_ratio_before_external_group_by randomized while asserting the same cold/hot AggregationPreallocatedElementsInHashTables invariant on 650e3 / 520e3 groups. A low positive spill threshold can therefore still make the first run spill, record only the post-spill remainder, and turn the -prealloc run into 0, so this PR only partially fixes the flake family. Please pin the same two settings to 0 there as well, or otherwise opt that test out of randomized settings.
There was a problem hiding this comment.
Already addressed on master: #111502 pinned max_bytes_before_external_group_by and max_bytes_ratio_before_external_group_by to 0 in both settings arrays of 04509_hash_table_sizes_stats_table_functions.sh (commit c781f06), in addition to 04625 (commit 9650bb8). So the sibling test is no longer exposed to the randomized-spill failure mode, and this PR is a duplicate of that one — nothing left to implement here.
|
This PR is obsolete: the same fix already landed on The AI review finding about the sibling test is also already addressed on The sole CI red here ( Nothing to rework or merge — recommending closing this as a duplicate of #111502. |
Changelog category (leave one):
Documentation entry for user-facing changes
Description
Fixes the flaky
04625_hash_table_sizes_stats_table_expression_modifiers(added in #109847), e.g. this MasterCI run:The test asserts the exact number of elements preallocated in the shard-side aggregation hash tables, and the settings randomizer enables external aggregation in a fraction of the runs. All 15 failures in the CI database over the last five days (master and PRs, across
amd_tsan,amd_asan_ubsan,arm_asan_ubsan,arm_binary,amd_msan) name the same culprit —max_bytes_before_external_group_by.When the first run of a pair spills,
Aggregator::writeToTemporaryFilere-inits the hash table after each flush, so the sizesupdateStatisticsreads at the end of the query are the post-spill remainder instead of the real group count. The stats cache entry then sits below the 500e3 lower bound ingetSizeHint, so the second (-prealloc) run preallocates nothing andAggregationPreallocatedElementsInHashTablesis 0.Pinning both thresholds to 0 is enough — the test is about the stats cache key including table expression modifiers, not about spilling. Everything else stays randomized.
Verified locally against a server with
process_query_plan_packet, forcing the culprit through--client-option:max_bytes_before_external_group_by=67836231max_bytes_ratio_before_external_group_by=0.0001no-final-prealloc 0, same diff as CI)The ratio-based variant of the randomizer breaks the test the same way, hence pinning both.
🤖 Generated with Claude Code