Skip to content

Fix flaky 04625_hash_table_sizes_stats_table_expression_modifiers under randomized external aggregation - #111502

Merged
alexey-milovidov merged 6 commits into
masterfrom
fix-04625-external-group-by
Jul 27, 2026
Merged

alexey-milovidov merged 6 commits into
masterfrom
fix-04625-external-group-by

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • CI Fix or improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix flaky 04625_hash_table_sizes_stats_table_expression_modifiers (and the sibling 04509_hash_table_sizes_stats_table_functions) under randomized external aggregation.

With a randomized low max_bytes_before_external_group_by the shard-side aggregation spills to disk, which stops the hash-table-stats collection for the query, so the test reported 0 preallocated elements instead of the expected 650000 (the no-final-prealloc line). The randomized-settings diagnoser identified --max_bytes_before_external_group_by 62155255 as the culprit. Pin external aggregation off in the test's fixed settings.

The sibling test 04509_hash_table_sizes_stats_table_functions checks the same cold/hot AggregationPreallocatedElementsInHashTables invariant and was exposed to the same flake, so the same two settings are pinned to 0 in both of its settings arrays as well (addressing review feedback).

Failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110886&sha=e8f45ccc035836cbca5147cb6c7d9a37d6bb9d29&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29

Related: #110886

Version info

  • Merged into: 26.8.1.207 (included in 26.8 and later)

…er randomized external aggregation

With a randomized low `max_bytes_before_external_group_by` the shard-side aggregation spills to
disk, which stops the hash-table-stats collection for the query, so the test reported 0
preallocated elements instead of the expected 650000. Pin external aggregation off.

Failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110886&sha=e8f45ccc035836cbca5147cb6c7d9a37d6bb9d29&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20distributed%20plan%2C%20parallel%29
Related: #110886
@clickhouse-gh

clickhouse-gh Bot commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [569cd0b]

Summary: ✅


AI Review

Summary

This PR makes the two hash-table-stats flaky tests deterministic under randomized settings by pinning both external GROUP BY spill thresholds to 0 everywhere those tests execute. I verified the current code, the PR diff, the prior review thread, and the latest Praktika report; the earlier gap in 04509_hash_table_sizes_stats_table_functions.sh is fixed, the resolved thread should stay resolved, and I did not find any remaining correctness or coverage issue in the current patch.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 23, 2026
…s_stats_table_functions too

The sibling test `04509_hash_table_sizes_stats_table_functions` checks the same
cold/hot `AggregationPreallocatedElementsInHashTables` invariant and was equally
exposed to randomized low `max_bytes_before_external_group_by` /
`max_bytes_ratio_before_external_group_by` thresholds: any spill stops
hash-table-stats collection and zeroes the preallocation event. Pin both
settings to 0 in its `settings` and `dist_settings` arrays, as already done
for `04625`.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failures in this run (all unrelated to this settings-only test fix; each fails regularly across many other PRs per CIDB):

Provide a fix in a separate PR (or file tracking issues). If a fix is already in progress, link it here. The amd_llvm_coverage failure (Got read request from replica A for unknown stream B + server died) is already tracked in #110518.

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated all three. Confirmed: all are the amd_asan_ubsan, distributed plan, parallel shard's host memory-pressure cohort (server total-RSS grazing the 44.83 GiB cap, OvercommitTracker cancels the in-flight query with Code 241; neighbours get Timeout! / connection resets). All started with the 2026-07-15 fleet OOM window, 0 failures on master, so all unrelated to this settings-only fix, as you said.

01661_extract_all_groups_throw_fast - fix in progress: #111513 (open). The old fixture built a ~1.3 GB haystack column purely to trip a per-row TOO_LARGE_ARRAY_SIZE throw that fires on row 1; under shared-runner pressure the column build hit MEMORY_LIMIT_EXCEEDED before the throw. #111513 trips the same throw at ~1 KB with a 100 MB max_memory_usage cap (revert-proof).

02481_async_insert_dedup - 6/6 failures on this shard, all Timeout! or a connection reset in the background fetch_and_insert_data thread. It is a heavy long ZK test with no wasteful fixture to trim, so it is pure OOM collateral, not a reducible-footprint case like 01661. No separate test-side fix is justified.

03216_arrayWithConstant_limits - Code 241 on this shard (30) plus arm_asan_ubsan, azure, parallel (13). Its large arrays are the deliberate near-limit boundary coverage the test exists to verify (query 3 allocates ~1 GB just under the 1e9-byte arrayWithConstant limit), so trimming them would weaken the test's intent. Also OOM collateral.

The structural capacity fix for this shard is already tracked in the open issue #111304 ("fix the runner RAM, not the ratio"), and two mitigations are already merged and have cleaned master: #110574 (0.7 ratio + reduced concurrency + 0.75 ratio for this job) and #110503 ((total) memory limit exceeded added to the retry set). So 02481 and 03216 belong to #111304 rather than a code fix from us; 01661 has its own targeted footprint reduction in #111513.

The amd_llvm_coverage failure is #110518 as you noted.

@Algunenano
Algunenano requested a review from azat July 23, 2026 16:05
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The only failure on 901731fe (Stateless amd_llvm_coverage 2/3: Server died + logical error Arguments of 'multiply' have incorrect data types during ActionsDAG::updateHeader) is the known race between EXCHANGE TABLES and SELECT from 03915_exchange_tables_race, unrelated to this settings-only test fix.

Related: #110133
Fixes in progress: #110048, #109747

AI review is ✅ Approve and there are no unresolved review threads — this is ready for a human merge decision.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI triage on `955837af` — the only non-green public results were infra, and both CH Inc sync failures are unrelated to this settings-only test change:

  • Public Mergeable Check / PR: the sole non-success job was Fast test (arm_darwin), which was DROPPED/CANCELLED by the runner, not failed. Every stateless job passed, including all four flaky checks (amd_debug, amd_asan_ubsan, amd_tsan, amd_msan), each of which runs the two tests changed here ~100 times.
  • CH Inc sync (ClickHouse/clickhouse-private#65532) reported tests failed, with two red jobs:
    • Stateless tests (amd_asan_ubsan, flaky check, s3 storage, meta in keeper): 04625_hash_table_sizes_stats_table_expression_modifiers was OK in 99 of 100 repeats and hit Reason: Test runs too long (> 180s) once (356 s, versus 40-75 s in the other 99 runs on the same job) under the 100-way parallel load of that shard. Runner contention, not a semantic failure; note the same test passed 100/100 in all four public flaky checks.
    • Stress test (arm_asan_ubsan, meta in keeper): 00234_disjunctive_equality_chains_optimization failed with Query memory tracker: fault injected. Would use 6.00 MiB ... (MEMORY_LIMIT_EXCEEDED) — the stress harness's deliberate memory fault injection, on a test this PR does not touch.

Merged the latest master (258 commits, clean merge) to re-roll CI and pick up the intervening flake fixes. The PR diff is unchanged: +11 lines across 04509_hash_table_sizes_stats_table_functions.sh and 04625_hash_table_sizes_stats_table_expression_modifiers.sh.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

CI triage on 21a16041 — the single red is unrelated to this settings-only test change.

Merged the latest master (197 commits, clean merge) to re-roll CI. The PR diff is unchanged: +11 lines across 04509_hash_table_sizes_stats_table_functions.sh and 04625_hash_table_sizes_stats_table_expression_modifiers.sh.

AI review is ✅ Approve and there are no unresolved review threads — ready for a human merge decision.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Jul 27, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 27, 2026
Merged via the queue into master with commit a919ba2 Jul 27, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-04625-external-group-by branch July 27, 2026 12:43
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants