Skip to content

Trim test_max_bytes_ratio_before_external_distinct to fit the client timeout - #121096

Merged
nihalzp merged 1 commit into
ClickHouse:masterfrom
groeneai:trim-external-distinct-ratio-test
Sep 21, 2026
Merged

nihalzp merged 1 commit into
ClickHouse:masterfrom
groeneai:trim-external-distinct-ratio-test

Conversation

@groeneai

@groeneai groeneai commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #116569
Related: #104965

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 into CHANGELOG.md):

Sized test_max_bytes_ratio_before_external_distinct to fit the integration harness's 600 second per-query timeout.

Description

test_max_bytes_ratio_before_external_distinct[server] and [user] time out at the harness's hard 600 second per-query cap on Integration tests (amd_asan_ubsan, db disk, 1/8): over 30 days it ran [server] 1031 times at a median of 572s, 260 of them at or above 595s, while sort and group_by in the same file have 0 runs over 540s. The cap is DEFAULT_QUERY_TIMEOUT in helpers/client.py, applied unconditionally, so the test cannot raise it; the timeout= kwarg only arms an additional, earlier timer.

Not a release-build regression: on arm_binary this test takes 36s against 41s for its sort sibling; the 15.6x sanitizer factor comes from a single-threaded comparison-based spill path, on builds that are not shipped. long_run, the other remedy, would delete the coverage (pytest.ini carries addopts = -m 'not long_run and not e2e' and no job selects the marker). The merged sibling test_external_distinct_disk_limits covers this feature at 16k to 262k rows.

The test asserts a memory-limit behaviour by consuming memory up to the node's limit, so its runtime has a floor set by that limit, and shrinking the workload alone would break the oracle: the unspilled peak must still exceed the limit for the ratio=0 half to be rejected. So limit and workload come down together, on a dedicated instance pair, leaving group_by and sort on their untouched 10Gi configs: 7M keys of exactly 800 bytes against 4Gi, sized for RSS headroom rather than minimality.

Each param asserts which tracker rejected it, (total) or User at maximum: 4.00 GiB; both pass on address,undefined and non-sanitizer builds, and swapping the expected texts reddens both. The spilling half asserts that it spilled, so the trim strengthens that arm. The spilling query drops from 411s to 42s and the file from about 1850s to 1031s; the two added idle instances cost 1.5s of startup.

Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=104965&sha=81348dcffea1f5d0c73f4894d63a28a718bcbdfa&name_0=PR&name_1=Integration%20tests%20(amd_asan_ubsan%2C%20db%20disk%2C%201%2F8)

30 days of per-param timings on the failing job, and the query
SELECT
    splitByString('::', test_name)[2] AS param,
    count() AS runs,
    round(quantile(0.5)(test_duration_ms)/1000) AS p50_s,
    round(quantile(0.9)(test_duration_ms)/1000) AS p90_s,
    round(max(test_duration_ms)/1000) AS max_s,
    countIf(test_duration_ms > 540000) AS over_540s,
    countIf(test_duration_ms >= 595000) AS over_595s,
    countIf(test_status IN ('FAIL', 'ERROR')) AS failures
FROM checks
WHERE check_start_time > now() - INTERVAL 30 DAY
  AND check_name = 'Integration tests (amd_asan_ubsan, db disk, 1/8)'
  AND test_name LIKE 'test_max_bytes_ratio_before_external_order_group_by_for_server/test.py::%'
GROUP BY param
ORDER BY p50_s DESC
┌─param─────────────────────────────────────────────────┬─runs─┬─p50_s─┬─p90_s─┬─max_s─┬─over_540s─┬─over_595s─┬─failures─┐
│ test_max_bytes_ratio_before_external_distinct[server] │ 1031 │   572 │   608 │   656 │       801 │       260 │        3 │
│ test_max_bytes_ratio_before_external_distinct[user]   │ 1031 │   547 │   582 │   649 │       571 │        23 │        1 │
│ test_max_bytes_ratio_before_external_sort[server]     │ 1660 │   275 │   313 │   399 │         0 │         0 │        2 │
│ test_max_bytes_ratio_before_external_sort[user]       │ 1660 │   265 │   286 │   387 │         0 │         0 │        2 │
│ test_max_bytes_ratio_before_external_group_by[user]   │ 1660 │   236 │   271 │   512 │         0 │         0 │        2 │
│ test_max_bytes_ratio_before_external_group_by[server] │ 1660 │   228 │   245 │   482 │         0 │         0 │        2 │
└───────────────────────────────────────────────────────┴──────┴───────┴───────┴───────┴───────────┴───────────┴──────────┘

Workflow [PR]
Sync PR [sync-upstream/pr/121096]

Version info

  • Merged into: 26.10.1.372-master (included in 26.10 and later)

…timeout

test_max_bytes_ratio_before_external_distinct[server] and [user] hit the
integration harness's hard 600 second per-query cap on
Integration tests (amd_asan_ubsan, db disk, 1/8). The cap is
DEFAULT_QUERY_TIMEOUT in tests/integration/helpers/client.py and is applied
unconditionally, so it cannot be raised from the test: the timeout= kwarg of
node.query() only arms an additional, earlier timer.

The test asserts a memory-limit behaviour by actually consuming memory up to
the node's limit, so its runtime has a floor set by that limit. At 100M keys
against 10Gi the floor exceeds the cap on the slowest sanitizer flavour: over
30 days that job ran the param 918 times with a p50 of 573s, 727 runs over
540s and 233 over 595s, while the sort and group_by params in the same file
have 0 runs over 540s. It is not a release-build regression: on arm_binary
the same test takes 36s versus 41s for its sort sibling, and the 15.6x
sanitizer factor is a property of a single-threaded comparison-based spill
path that is not shipped.

Reducing the workload alone would break the oracle, because the unspilled
peak must still exceed the node limit for the ratio=0 half to be rejected.
So the limit and the workload come down together, on a dedicated instance
pair so that the group_by and sort params keep their 10Gi configs untouched:
7M keys of exactly 800 bytes against a 4Gi limit. Which tracker refuses the
ratio=0 half is now asserted rather than argued from the server logs: each
parametrize row carries its own expected text, so [server] requires
"(total) memory limit exceeded" and [user] requires "User memory limit
exceeded", both with "maximum: 4.00 GiB", and swapping the two expectations
reddens both params. Those two substrings are the only ones common to the
tracked and the RSS arm of the limit check, so they hold on an
address,undefined build and on a non-sanitizer one alike.

The spilling half also gains an assertion that it really spilled, using the
query_id plus ProfileEvents['ExternalDistinctWritePart'] idiom already used
by test_external_distinct_disk_limits, so shrinking the scale makes that arm
strictly stronger than before instead of weaker.

Measured on the address,undefined build: the spilling query drops from 410.8s
to 42.6s, the whole file from 6 passed in about 1850s to 6 passed in 1030.7s,
and the two added idle instances cost 1.5s of cluster startup.
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Sep 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (1 major fixed and re-verified, 2 refuted with evidence, 4 noted)

Before opening this I ran an independent cold review plus a second-model gate over the diff and
adjudicated every finding against the code and the recorded runs. The one substantive finding was
fixed, and the fixed tree went through both passes again with no findings on the head published here.

❌ Fixed before this PR opened

  • The ratio=0 half did not prove which memory limit rejected the query. It asserted only pytest.raises(QueryRuntimeException), which fires for any nonzero client exit or non-ignored stderr (helpers/client.py), and lowering the user limit to 4Gi left the node's default global limit (10.80 GiB) as a second candidate rejecter; each param now asserts its own tracker's text plus maximum: 4.00 GiB, the only part of the message that names the tracker (MemoryTracker.cpp) and distinguishes the small node's limit from the default, verified on address,undefined and non-sanitizer builds, and swapping the two expected strings reddens both params on that assertion alone.

⚠️ Raised and refuted, with evidence

  • "No execution proof that the reduced workload keeps the oracle and fits under 600s." On the address,undefined build the two params pass in 130s total with the spilling query at 42.5s against the 600s cap and ten further runs between 41.7s and 44.1s, the spill is confirmed both by the server log (Adjusting memory limit before external DISTINCT with 1.20 GiB) and by the new profile-event assertion, and both ratio=0 rejections carry maximum: 4.00 GiB on their own tracker's message with no such line on the untouched 10Gi pair; what I cannot produce locally is a run on the CI runner itself, which is this PR's own CI.
  • The new server node's 4Gi limit could fail cluster.start() on TSan or MSan. add_instance runs at import so both new nodes start on every flavour including the ones where this test skips, and TSan and MSan are not measurable on my hardware, so I checked master instead: test_dirty_pages_force_purge already runs an ungated max_server_memory_usage: 4Gi server and over 30 days reports SKIPPED, never ERROR, 9,103 times on amd_msan and 10,817 times on amd_tsan, and a skip can only be recorded if that server started (idle footprint here: 0.995 GiB).

💡 Noted, not blocking

  • The module now starts four servers instead of two on every flavour, about 1 GiB of idle RSS and 1.5s of startup each on shards where this test does not run: inside the harness's own 20 GiB per-worker budget, and cheaper than the 570s at a 10Gi limit it replaces.
  • The ratio=0 halves of the group_by and sort params still assert only the exception class; their limits are untouched by this change, so I left them alone rather than widen the diff.
  • The query keeps FORMAT Null, so the DISTINCT result itself is still unchecked: affordable at 7M rows, but out of scope, and the feature's own test does the same.
  • Four invariant carriers I checked that the change does not have to handle: log_queries is on by default and integration tests do not remove query_log, so the new assertion has a data source; the enforced RSS figure is cgroup anon + sock, so the spilled files' page cache does not count against the 4Gi ceiling; the batch-balancing duration table is regenerated from the CI database.

@clickhouse-gh clickhouse-gh Bot closed this Sep 19, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, by construction rather than statistically: a fixed 600s client cap against a query that sits at it, 410.8s locally on address,undefined and a 30 day median of 572s on the failing job with 260 of 1031 runs at or above 595s (pytest .../test.py -k distinct --timeout 1800, CLICKHOUSE_USE_DATABASE_DISK=1).
b Root cause explained? Yes: the test consumes memory up to the node's limit, so its runtime has a floor set by that limit, and at 100M keys against 10Gi the floor exceeds DEFAULT_QUERY_TIMEOUT (helpers/client.py:11), which wait_and_read_output applies unconditionally and the timeout= kwarg cannot raise (client.py:243-247); the spill path is single threaded (DistinctStep.cpp:213-214), which the sanitizer amplifies 15.6x.
c Fix matches root cause? Yes: it removes the runtime floor by lowering the limit and keeps the assertion by lowering the workload in proportion, not a widened bound, a skip, a raised timeout or a weakened assertion.
d Test intent preserved / new tests added? Yes, strictly stronger, both halves gained an assertion on the same code path (DistinctStep.cpp:234 to ExternalDistinctTransform): the spilling half now asserts the spill happened via ProfileEvents['ExternalDistinctWritePart'], and the rejected half, which previously asserted only the exception class, now requires its own tracker's text at maximum: 4.00 GiB.
e Both directions demonstrated? Yes: 410.8s before against 41.9s after (pair in 120.5s), 29 fresh runs with 0 unintended failures and under 5% spread, and three mutation arms redden, halving the rows, removing the spill, and swapping the two expected tracker texts between the params.
f Fix is general across code paths? Yes: all 13 carriers of the invariant enumerated, the two sibling params that share it deliberately left untouched and proven untouched (0 memory limit lines on their nodes in the same runs), and the sizing fixed in the test rather than guarded at the timeout site.
g Fix generalizes across inputs? Yes for the matrix that applies: both params (server level and user level limits, enforced against different quantities) times both build flavours with opposite worst cases, all four measured, and numbers(10000000, 7000000) makes every key exactly 800 bytes and distinct.
h Backward compatible? Yes, trivially: test only, no setting default, no SettingsChangesHistory.cpp entry, no serialization or protocol change, and the two new config files are additive and scoped to this test module.
i Invariants and contracts preserved? Yes: the two existing tests keep their instances, configs, workloads, thresholds and skip conditions byte for byte, and the one new obligation, that an idle small limit node stays below its own server level limit or module startup fails, was measured at 0.995 GiB against 4 GiB.

Session id: cron:clickhouse-impl-slot-4:20260919-222200

@clickhouse-gh

clickhouse-gh Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ff2c752]

Summary: ✅


AI Review

Summary

This PR trims test_max_bytes_ratio_before_external_distinct by moving it onto dedicated 4 GiB server/user nodes, scaling the dataset down to match that ceiling, and strengthening the oracle with both a spill assertion from system.query_log and tracker-specific failure-message checks. I did not find review issues in the current diff; the revised test still exercises the same max_bytes_ratio_before_external_distinct contract, and its failure-side assertion is stronger than the previous class-only check.

Missing context / blind spots
  • ⚠️ I did not re-run this heavy integration test locally. The remaining uncertainty is limited to exact runtime headroom on the amd_asan_ubsan CI workers; I did not find a logic or coverage gap in the revised test itself.
Final Verdict

✅ No blocking or major review findings.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Sep 19, 2026
@nihalzp nihalzp self-assigned this Sep 20, 2026
@nihalzp
nihalzp added this pull request to the merge queue Sep 21, 2026
Merged via the queue into ClickHouse:master with commit 0f8787e Sep 21, 2026
176 of 349 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 21, 2026
pull Bot pushed a commit to sonvt1710/ClickHouse that referenced this pull request Sep 22, 2026
`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 ClickHouse#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 ClickHouse#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: ClickHouse#121096
@groeneai

Copy link
Copy Markdown
Collaborator Author

The revert and #121454 interleaved, and the tree that shipped is a combination neither change was measured against.

#121454 was opened 2026-09-21 22:54Z against a master that still carried this PR. Its description says "[user] is unaffected by construction", measured at 33 passes and 0 failures, and it skips only [server]. The revert merged 2026-09-22 02:58Z, 9h45m before #121454 merged, and #121454 picked it up through a master merge into its branch. So master now has the ASan skip for [server] sitting on top of the restored 10Gi nodes and 100M-key workload.

Measured on Integration tests (amd_asan_ubsan, db disk, 1/8) since both merges: [user] has a p50 wall time of 585s over 598 passes, and it has failed 3 times in the last 39 hours, at 608s, 610s and 608s. Each failure is subprocess.TimeoutExpired after 600 seconds with no Code: 241, and the only frame is test.py:134, the ratio = 0.3 spilling call. That 600 is DEFAULT_QUERY_TIMEOUT in tests/integration/helpers/client.py:11, applied unconditionally at line 270, so the timeout= argument of node.query cannot raise it. All three trees contain both merge commits, behind_by = 0 against each, so these are not stale branches. [server] is at 553 skipped on that job, so the timeout mode is now visible only on [user]; before the trim it hit [server] as well, at 601s to 603s on 09-17, 09-18, 09-19 and 09-21.

Separately, the skip's comment cites current RSS: 3.95 GiB and "the remaining 1.3 GiB of headroom". Those are the 4Gi figures from the node_server_small instance this PR added, and the revert deleted that instance, so the comment now describes a configuration the file no longer has.

You own this test and ExternalDistinctTransform.cpp, and #121772 is in flight, so I would rather ask than open a third PR on this file. @nihalzp which of these do you want:

A. I re-land only the [user] half of this PR, its small node plus the 7M-key workload for that parameter, and leave [server] exactly as it is now. The [server] RSS failures that motivated the revert cannot come back, because #121454 skips that parameter on ASan independently of the workload.
B. I add [user] to the ASan skip as a stopgap until #121772 lands.
C. Nothing, because you expect #121772's reader-memory and tail-spill changes to bring the runtime far enough under the cap.

A is the only one of the three that keeps any ASan coverage of this oracle, which is why I would pick it, but the call is yours.

clickhouse-gh Bot pushed a commit that referenced this pull request Sep 25, 2026
Edited by the nightly changelog CI job following .claude/skills/edit-changelog/SKILL.md.

Changelog-revert: 119274 118919 Revert "Carry the mutation version onto a rewritten lightweight `DELETE`"
Changelog-revert: 119306 119274 Revert "Revert "Carry the mutation version onto a rewritten lightweight `DELETE`""
Changelog-revert: 119334 117356 Revert "Unify the spill trigger for hash joins"
Changelog-revert: 119335 119334 Revert "Revert "Unify the spill trigger for hash joins""
Changelog-revert: 121135 118279 Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer"
Changelog-revert: 121136 121135 Revert "Revert "Test the ESCAPE route into the ngram LIKE-pattern tokenizer""
Changelog-revert: 121258 118216 Revert "Do not invert an ordered comparison that can see a `NaN` in the CNF form"
Changelog-revert: 121298 117578 Revert "Bound the docker buildx retry ladder by wall clock, not by the timeout divisor"
Changelog-revert: 121443 114465 Revert "Fix an error reading an Iceberg table whose `current-snapshot-id` is JSON null"
Changelog-revert: 121477 121096 Revert "Trim `test_max_bytes_ratio_before_external_distinct` to fit the client timeout"
Changelog-revert: 121901 121869 Revert "docs(managed-postgres): updated Private Service Connect"
Changelog-revert: 122110 118223 Revert "Correct nightly coverage selection and share PR test manifests"
Changelog-revert: 122140 120312 Revert "Refuse a `Set` table on the right side of `IN` when a row policy applies to it"
Changelog-deleted-entry: 114465 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed an error when reading an Iceberg table whose `current-snapshot-id` is JSON null, which some writers emit for a table with no current snapshot. [#114465](#114465) ([Shaohua Wang](https://github.com/tiandiwonder)).
Changelog-deleted-entry: 118216 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed `convert_query_to_cnf = 1` silently dropping rows with a `NaN` in a floating point column: the conversion rewrote `NOT (x < c)` into `x >= c`, which is not an equivalent condition for `NaN`. [#118216](#118216) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Changelog-deleted-entry: 118223 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Correct nightly coverage selection and share PR test manifests. [#118223](#118223) ([Nikita Fomichev](https://github.com/fm4v)).
Changelog-deleted-entry: 120312 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * A row policy on a `Set`-engine table was accepted but never applied: the right side of `IN` read the prebuilt set directly and returned the rows the policy hides. Such a query now fails with `ACCESS_DENIED`, because the `Set` engine has no read path that could filter the rows. Queries that used a `Set` table covered by a database-wide row policy ran unfiltered before and now throw. [#120312](#120312) ([Harikrishnan Prabakaran](https://github.com/harikrishnan94)).
Changelog-deleted-entry: 121096 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Sized `test_max_bytes_ratio_before_external_distinct` to fit the integration harness's 600 second per-query timeout. [#121096](#121096) ([Groene AI](https://github.com/groeneai)).
@groeneai

Copy link
Copy Markdown
Collaborator Author

@ alexey-milovidov asked for a fix on #118637, so I went with A in #122494, with the 4 GiB limit set in the [user] query instead of on a separate node. If you would rather have B, please say so there.

pull Bot pushed a commit to Dream-hu/ClickHouse that referenced this pull request Sep 27, 2026
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]>
@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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