Skip to content

Cherry pick #122494 to 26.9: Run the user-limit case of the external DISTINCT ratio test at 4 GiB to fit the ASan query timeout - #128907

Merged
robot-clickhouse-ci-1 merged 3 commits into
backport/26.9/122494from
cherrypick/26.9/122494
Nov 4, 2026
Merged

robot-clickhouse-ci-1 merged 3 commits into
backport/26.9/122494from
cherrypick/26.9/122494

Conversation

@robot-ch-test-poll4

Copy link
Copy Markdown
Contributor

Original pull-request #122494

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 2 commits September 27, 2026 01:11
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 #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. #121096 had moved both parameters to 4Gi instances with 7M keys
of 800 bytes; #121454 then skipped [server] under ASan, measured on that
tree, and kept [user] because a user limit counts tracked bytes, not RSS;
#121477 reverted #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
#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]>
…-4gib

Run the user-limit case of the external `DISTINCT` ratio test at 4 GiB to fit the ASan query timeout
@robot-ch-test-poll4 robot-ch-test-poll4 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Nov 3, 2026
Resolve the conflict in
test_max_bytes_ratio_before_external_order_group_by_for_server/test.py.
26.9 has neither #120751 (the `sanitizer_build` dict) nor #121454 (the
`limit_follows_rss` parameter and the ASan skip of the `[server]` case),
so only the change of #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]>
@groeneai

groeneai commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

The conflict is in the pytest.mark.parametrize block of test_max_bytes_ratio_before_external_distinct. On master that block has the limit_follows_rss column from #121454 and the sanitizer_build checks from #120751, and 26.9 has neither. I kept the 26.9 side and ported only the change from #122494: each case's query moves into its parametrize row, and [user] runs the 7M x 800-byte query with max_memory_usage_for_user = '4Gi'. Against backport/26.9/122494, the merge changes only that test.py (+16/-9).

I ran the 26.9 ASan build of #128781 (26.9.26.1): the [user] case passed 10 of 10 at 53 to 55 s each, and its ratio = 0 half was rejected with User memory limit exceeded ... maximum: 4.00 GiB. On the same 26.9 CI job, the current [user] case has a median duration of 545 s, against a 600 s per-query cap. With the official 26.9.26.11, the whole module passes (6 of 6).

This leaves [server] as it is. The red on #128781 was [server] hitting the 600 s cap under ASan, and on master #121454 skips that case under ASan.

I cannot push to cherrypick/26.9/122494. The merge is on my fork, and its first parent is this PR's head d20ff423a99b, so applying it is a fast-forward:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/resolve-26.9-cherrypick-122494
git push origin FETCH_HEAD:cherrypick/26.9/122494

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Pushed the resolution from groeneai's fork as a fast-forward (d20ff423a99b..c1cc4304f5dc). I checked it: against backport/26.9/122494 it changes only test_max_bytes_ratio_before_external_order_group_by_for_server/test.py (+16/-9), and that diff matches the change from #122494, without the limit_follows_rss/sanitizer_build prerequisites that 26.9 doesn't have. Thanks!

@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit 1fa9b24 into backport/26.9/122494 Nov 4, 2026
1 check passed
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.9/122494 branch November 4, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants