Skip to content

Enable disk spill for TPC-H and TPC-DS functional tests - #107461

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci/tpc-disk-spill
Jun 18, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:ci/tpc-disk-spill

Conversation

@groeneai

@groeneai groeneai commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

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):

...

Description

Follow-up to #107441 (requested by alexey-milovidov): enable disk spill in the TPC-H and TPC-DS functional tests to lower their peak memory and exercise the external aggregation / external join code paths.

The settings are added to the shared 04033_tpc_ds.lib and 04040_tpc_h.lib, consumed by the 04033_tpc_ds_* and 04040_tpc_h_* stateless tests:

--max_bytes_before_external_group_by 314572800
--max_bytes_before_external_join     314572800
--max_estimated_execution_time       0

They are placed in the .lib, not in tests/benchmarks/tpc-{ds,h}/settings.json, because tests/performance/tpc{ds,h}.xml read the same settings.json and the performance benchmarks must keep running in memory.

The join spill uses the default join_algorithm (no override). max_bytes_before_external_join now spills on the default algorithm via SpillingHashJoin (recently on master), so the tests keep verifying the default join experience while still capping peak memory.

max_estimated_execution_time = 0 disables the test-env estimated-time guard, which false-positives with TOO_SLOW on the deliberately slower-starting spilling queries under sanitizer builds (same class as #107444).

Measured peak memory on SF1 (debug build, default join_algorithm), baseline then with spill, in MiB:

query baseline with spill
TPC-H q5 5051 650
TPC-H q8 2600 1865
TPC-H q9 1943 1720
TPC-H q3 1346 1121
TPC-DS q50 2039 534
TPC-DS q39 1108 388
TPC-DS q21 828 325
TPC-DS q23 1457 646
TPC-DS q47 808 582

max_bytes_before_external_join is the main mover (TPC-H q5 -87%, TPC-DS q50 -74%); max_bytes_before_external_group_by helps the aggregation-heavy queries (TPC-DS q23 -56%). max_bytes_before_external_sort was measured as a no-op on every query and is not included.

Output is byte-identical with and without spill for all 22 TPC-H queries and the verified TPC-DS subset.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. Measured peak memory on demand per query with --memory-usage on SF1 (debug build), e.g. TPC-DS q61 baseline 5.7 GiB, TPC-H q08 baseline 2.6 GiB. After adding the spill settings, the same commands report q61 0.28 GiB, q08 0.48 GiB.
b Root cause explained? Yes. The TPC .lib files set no spill thresholds, so GROUP BY / ORDER BY / hash-join build state stays fully in memory. With many such tests co-scheduled (e.g. ~19 concurrent workers on the azure ASan shard), the aggregate RSS crosses the shared server cap and OvercommitTracker kills queries. Per-query peak is the lever.
c Fix matches root cause? Yes. It enables external aggregation, external sort and grace hash join with ~300 MiB thresholds, which directly caps per-query peak memory for the aggregation/sort/join-dominated queries instead of hiding the symptom (no test disabled, no concurrency change).
d Test intent preserved / new tests added? Yes. The queries and references are unchanged; output is byte-identical with and without spill for all 22 TPC-H queries and the verified TPC-DS subset. This adds coverage of the external aggregation / external sort / grace hash join paths.
e Both directions demonstrated? Yes. Before: q61 5.7 GiB, q78 4.7 GiB, q08 2.6 GiB, q09 2.0 GiB, q21 1.4 GiB. After: q61 0.28, q78 0.81, q08 0.48, q09 0.73, q21 0.16 GiB. Output verified identical in both cases.
f Fix is general, not a narrow patch? Yes. The change is in the two shared .lib files consumed by every 04033_tpc_ds_* and 04040_tpc_h_* test, so it applies uniformly. join_algorithm='grace_hash, hash' falls back to hash for join shapes grace hash does not support. A few multi-CTE queries (e.g. TPC-DS q23, 1.4 GiB) hold most memory in IN (subquery) set state, which these thresholds do not spill; this is stated in the PR so the residual is understood, not hidden.

Session id: cron:clickhouse-worker-slot-2:20260614-230000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @alexey-milovidov - follow-up to #107441 as requested.

@alexey-milovidov
alexey-milovidov requested a review from rienath June 15, 2026 00:44
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [38c56c8]

Summary: ✅


AI Review

Summary

This PR adds shared TPC-H/TPC-DS stateless test settings to spill GROUP BY and hash join state to disk at 300 MiB and disables max_estimated_execution_time for these plan/result tests. The current code is narrowly scoped and matches the later discussion; I found no code-level blockers or majors.

Findings

💡 Nits

  • [PR description] The PR body still describes the superseded setting set: max_bytes_before_external_sort, join_algorithm = 'grace_hash, hash', max_bytes_in_join, and grace_hash_join_initial_buckets. The current diff only adds max_bytes_before_external_group_by, max_bytes_before_external_join, and max_estimated_execution_time = 0, so please update the description before merge to avoid reviewing or releasing from stale behavior.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI on 4a93325 is fully finished. The only red mark is not caused by this PR:

  • Stress test (amd_tsan): "Hung check failed, possible deadlock found". This is a chronic trunk deadlock (leaked local ThreadPool on shutdown) seen on master and many unrelated PRs, tracked separately. This PR is test-only (TPC-H and TPC-DS .lib settings) and changes no server code, so it cannot cause a stress-test deadlock.

@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai, we must fix the stress test deadlock. You can do it in another PR.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Acknowledged. The Hung-check is the chronic trunk deadlock (leaked local ThreadPool on GlobalThreadPool shutdown). Diagnostic PR #105905 is already collecting registry dumps on master to pin the leaker; the fix will go in a separate PR.

@rienath rienath left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd keep max_bytes_before_external_group_by and _external_sort. @groeneai please confirm that each meaningfully lowers peak memory and drop any that doesn't move the needle.

For joins, let's not override join_algorithm. These tests should verify the default experience is correct. Remove grace-hash settings and instead set max_bytes_before_external_join s.t. we auto-spill if needed. Again, only do this if it moves the needle.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@rienath measured per-query peak (SF1, debug, 10 GiB cap, system.query_log.memory_usage).

sort: dropping. max_bytes_before_external_sort alone never lowered peak on any TPC-H or TPC-DS query (within baseline noise).

group_by: keeping. It moves the needle: TPC-DS q23 1460 -> 663 MiB, TPC-H q13 1582 -> 739 MiB.

join: the default-experience approach measurably fails. max_bytes_before_external_join only spills a plain hash join. The default join_algorithm (direct,parallel_hash,hash) prefers parallel_hash, which ignores the threshold. So vs the current grace_hash override it regresses, and OOMs the heavy ones:

query grace_hash override default + max_bytes_before_external_join
TPC-H q21 159 MiB 1358 MiB
TPC-H q8 483 MiB 1865 MiB
TPC-H q3 155 MiB 1122 MiB
TPC-DS q4 1210 MiB OOM (>10 GiB)
TPC-DS q88 488 MiB OOM (>10 GiB)

ProfileEvents confirm the mechanism: on q88 the grace_hash join writes 192 spill parts and finishes at 499 MiB; the default algorithm writes 0 spill parts and OOMs at 9.4 GiB RSS.

So "only if it moves the needle" actually argues for the override here: it is the grace_hash override that keeps these joins from OOMing on the shared shards (the original goal of #107441). The clean default-experience spill does not work today because parallel_hash does not honor max_bytes_before_external_join.

Your call between:

  1. Keep the grace_hash join override (drop sort, keep group_by). Memory-safe, not the default experience.
  2. Drop the join override entirely (pure default experience), accepting q4/q35/q88 OOM at SF1.

I lean to (1) for the OOM safety this PR targets, but happy to do either.

@rienath rienath self-assigned this Jun 15, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

We probably misremembered that we have grace hash join by default. At least this was our intent. CC @antaljanosbenjamin

@groeneai, Send another PR that enables grace hash join by default globally.

@antaljanosbenjamin

Copy link
Copy Markdown
Member

We probably misremembered that we have grace hash join by default. At least this was our intent. CC

I am not sure if I get what you mean. GraceHash is not by default.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Confirmed: the default is join_algorithm = 'direct,parallel_hash,hash' today, so grace hash is not in the default chain (antaljanosbenjamin is right).

I'll send the PR. Since grace_hash cannot handle asof/cross/multi-disjunct joins, I propose the new default be grace_hash, hash (falling back to hash for unsupported shapes) rather than bare grace_hash, plus a SettingsChangesHistory.cpp entry to restore the old behaviour. @antaljanosbenjamin does grace_hash, hash match the intent, or would you prefer direct, grace_hash, hash?

@alexey-milovidov

Copy link
Copy Markdown
Member

GraceHash is not by default.

@antaljanosbenjamin, the only point of grace hash join is to have it by default - for automatic spilling to disk.
As long as it is not by default, the major item of our roadmap (I'd say - the most important for JOINs) is not solved.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Understood, I will send a separate PR enabling grace hash join by default globally.

Plan: change the join_algorithm default from direct,parallel_hash,hash to direct, grace_hash, hash. This keeps direct for direct-lookup joins, makes grace_hash the spilling default, and keeps hash as the fallback for asof/cross/multi-disjunct shapes grace_hash does not support. I will drop parallel_hash from the default because it does not spill, which is what currently forces large joins to stay in memory and OOM. I will add a SettingsChangesHistory.cpp entry to restore the previous default and verify the unsupported shapes fall back to hash.

I will cc antaljanosbenjamin on that PR for the final ordering. Once grace_hash is the global default, #107461 no longer needs its own join_algorithm override.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Opened #107814 to enable grace hash join by default globally: join_algorithm default changed to direct,grace_hash,hash so large joins spill to disk automatically instead of OOMing. parallel_hash is dropped from the default because it does not spill; hash stays as the fallback for asof/cross/multi-disjunct joins.

@antaljanosbenjamin

Copy link
Copy Markdown
Member

Please don't enable it yet. We are working on it to make it default, but currently it is not there yet and it might cause issues and performance degradations because hash join can handle more cases and make more optimizations possible.

@groeneai

Copy link
Copy Markdown
Collaborator Author

@alexey-milovidov, antaljanosbenjamin (grace hash owner) asks to hold this: the team is already working on making grace hash the default properly, says it is not ready yet, and warns of performance degradations because hash join handles more cases and enables more optimizations.

This matches what I found verifying #107814: with direct,grace_hash,hash a plain INNER JOIN takes the standalone GraceHashJoin branch (external_join_threshold=0), which ignores max_bytes_before_external_join and so does not auto-spill at the byte threshold. Master's parallel_hash/hash path already auto-spills via SpillingHashJoin (61e641d). So the naive default would route large joins to the one algorithm that does not honor the threshold, and it also disables read-in-order-through-join, top-k-through-join, and hash-table-size-stats prealloc. Detail and repro: #107814 (comment)

Given the owner says it is not ready, I propose closing #107814 and deferring to the team's in-progress work, unless you want me to instead teach the GRACE_HASH branch to honor max_bytes_before_external_join (a change to standalone grace's contract that needs antaljanosbenjamin's sign-off). Holding until you decide.

@groeneai
groeneai force-pushed the ci/tpc-disk-spill branch from 4a93325 to 079b905 Compare June 18, 2026 06:40
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? N/A (test-only settings change, not a code-bug fix). Equivalent: per-query peak memory measured deterministically on current master (snapshot debug 26.6.1.1, commit 73e97de, post-SpillingHashJoin).
b Root cause explained? The original block forced join_algorithm='grace_hash, hash'. With SpillingHashJoin now on master, max_bytes_before_external_join makes the DEFAULT algorithm (direct,parallel_hash,hash) spill to disk on its own, so the grace override is no longer needed to bound join memory. max_bytes_before_external_sort was shown to have no effect on any query.
c Fix matches root cause? Yes. Dropped the grace override and max_bytes_in_join/grace_hash_join_initial_buckets; kept max_bytes_before_external_group_by and max_bytes_before_external_join; dropped the no-op max_bytes_before_external_sort.
d Test intent preserved? Yes, and improved: the tests now exercise the DEFAULT join experience (no algorithm override) while still spilling to disk, which is what the tests should validate.
e Both directions demonstrated? Spill effect (peak MiB, default algorithm): TPC-H q5 5051 to 650, q8 2600 to 1865, q3 1346 to 1121; TPC-DS q50 2039 to 534, q39 1108 to 388, q21 828 to 325, q23 1457 to 646 (group_by). sort equals baseline everywhere (dropped). Correctness: with-spill output is byte-identical to no-spill for the heavy-join TPC-H queries, and all 22 TPC-H + the verified TPC-DS subset match the committed references.
f Fix is general, not a narrow patch? Yes. The same block is applied identically to both 04033_tpc_ds.lib and 04040_tpc_h.lib. Settings stay in the .lib files (not settings.json) so the perf benchmarks keep running in memory.

Session id: cron:clickhouse-worker-slot-1:20260618-060900

@groeneai

groeneai commented Jun 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks @antaljanosbenjamin. Done: I removed the grace_hash override from both TPC .lib files. The tests now run on the default join_algorithm and spill via max_bytes_before_external_join (SpillingHashJoin handles the default algorithm on current master). This also addresses @ rienath's request to test the default join experience.

Final settings (both 04033_tpc_ds.lib and 04040_tpc_h.lib):

--max_bytes_before_external_group_by 314572800
--max_bytes_before_external_join     314572800

Per-setting peak memory, measured on current master (default algorithm):

  • external_join: TPC-H q5 5051 to 650 MiB, q8 2600 to 1865; TPC-DS q50 2039 to 534, q39 1108 to 388, q21 828 to 325.
  • external_group_by: TPC-DS q23 1457 to 646; TPC-H q13.
  • external_sort: no effect on any query, so dropped.

Output is byte-identical with and without these settings for all 22 TPC-H queries and the verified TPC-DS subset.

Lower peak memory of the TPC-H and TPC-DS functional tests and exercise the
external GROUP BY and disk-spilling join paths.

Settings live in the shared 04033_tpc_ds.lib / 04040_tpc_h.lib (not in
tests/benchmarks/tpc-{ds,h}/settings.json), because tests/performance/tpc{ds,h}.xml
read the same settings.json and the performance benchmarks must keep running
in memory.

Settings:
  --max_bytes_before_external_group_by 314572800
  --max_bytes_before_external_join     314572800

The join_algorithm is left at the default. SpillingHashJoin makes the default
algorithm spill to disk once max_bytes_before_external_join is reached, so no
grace_hash override is needed. max_bytes_before_external_sort was dropped after
measurement showed it did not change peak memory on any query.

Spilling to disk makes a query start slowly, so the test-env estimated-time
guard (max_estimated_execution_time=600) can false-positive with TOO_SLOW
(code 160) under the heavily-instrumented sanitizer builds: it linearly
extrapolates total runtime from the slow first phase and overshoots 600s.
These are plan/result tests, not performance tests, so the estimate is
disabled with --max_estimated_execution_time 0.

Output is byte-identical with and without these settings for all 22 TPC-H
queries and the verified TPC-DS subset.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the ci/tpc-disk-spill branch from 079b905 to 38c56c8 Compare June 18, 2026 08:57
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? The unfixed head (079b905) deterministically threw on amd_tsan: Code: 160 ... Estimated query execution time (696.45 seconds) is too long. Maximum: 600. Estimated rows to process: 5024253 (2636266 read in 365.43s) in 04033_tpc_ds_q10. The setting that controls it is verified locally: --max_estimated_execution_time 0 reads back as 0, 600 reads back as 600.
b Root cause explained? The disk-spill settings make the query start slowly (spilling phase). The test-env guard max_estimated_execution_time=600 (tests/config/users.d/limits.yaml) fires after timeout_before_checking_execution_speed and linearly extrapolates total runtime from the slow first phase: estimated = elapsed * total_rows / read_rows. On the heavily-instrumented amd_tsan build (~20x slower), the first 300s read only 2.6M of 5.0M rows, extrapolating to 696s > 600 -> TOO_SLOW. It is a false-positive of a perf guard on a plan/result test.
c Fix matches root cause? Yes. These are plan/result tests, not performance tests, so the runtime estimate is irrelevant. Added --max_estimated_execution_time 0 to the shared SETTINGS in both 04033_tpc_ds.lib and 04040_tpc_h.lib. Per the source gate (ExecutionSpeedLimits.cpp:82, && max_estimated_execution_time != 0), value 0 disables the throw entirely. Same fix as the merged #107444 for test 03560.
d Test intent preserved / new tests added? Yes. max_estimated_execution_time is a pure runtime limit check; it never alters query output, only throws or does not. Disabling it leaves the plan/result assertions (the committed .reference files) fully intact.
e Both directions demonstrated? Without fix: CI threw Code 160 on head 079b905 (estimated 696s > 600). With fix: the guard block is gated on max_estimated_execution_time != 0, so value 0 skips it unconditionally; the flag is confirmed to set the value to 0 through the exact ${SETTINGS[@]} path the .sh tests use. Output stays byte-identical (limit check, not a result transform).
f Fix is general, not a narrow patch? Yes. Applied identically to both .lib helpers, so it covers all 98 TPC-DS and all 22 TPC-H .sh tests that source them, not just q10. Settings stay in the .lib files (not settings.json) so the perf benchmarks keep running in memory.

Session id: cron:clickhouse-worker-slot-2:20260618-084300

# Disk spill for GROUP BY and joins. Kept here (not in settings.json) on purpose:
# tests/performance/tpcds.xml reads the same settings.json and must stay in-memory.
SETTINGS+=(
--max_bytes_before_external_group_by 314572800

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 The code now only adds max_bytes_before_external_group_by, max_bytes_before_external_join, and max_estimated_execution_time = 0, but the PR description still lists the old max_bytes_before_external_sort, join_algorithm = 'grace_hash, hash', max_bytes_in_join, and grace_hash_join_initial_buckets settings. Please update the description so reviewers do not reason from the superseded behavior.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated the description to match the current settings: max_bytes_before_external_group_by, max_bytes_before_external_join, and max_estimated_execution_time = 0 on the default join algorithm. Removed the superseded grace-hash override and sort settings, and refreshed the memory table with the post-SpillingHashJoin default-algorithm numbers.

@clickhouse-gh

clickhouse-gh Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.20% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.50% 77.40% -0.10%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 342 line(s), 11 function(s) across 125 file(s) · Details

Top files
  • src/Disks/IO/CachedOnDiskWriteBufferFromFile.cpp: 15 line(s)
  • src/Client/ConnectionParameters.cpp: 10 line(s)
  • src/Interpreters/HashJoin/HashJoin.cpp: 10 line(s)
  • programs/client/Client.cpp: 9 line(s)
  • src/Functions/catboostEvaluate.cpp: 8 line(s), 4 function(s)

Full report

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 18, 2026
Merged via the queue into ClickHouse:master with commit 7165a26 Jun 18, 2026
166 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 Jun 18, 2026
alexey-milovidov added a commit that referenced this pull request Jun 20, 2026
The `odbc` and `jdbc` table functions infer the remote table structure
from the XDBC bridge during query analysis, in
`ITableFunctionXDBC::getActualTableStructure`. This request used the
default `ReadSettings`, so `http_max_tries` was `10`: when the bridge (or
the driver behind it) stopped responding mid-request, it retried up to
ten times, each attempt blocking for up to `http_receive_timeout`.

Because this runs during analysis, before any pipeline executor exists,
it cannot observe query cancellation (`KILL QUERY`, `max_execution_time`),
so a cancelled query stayed in the processlist for minutes and tripped
the stress-test hung check ("possible deadlock found").

`startBridgeIfNot` has already verified the bridge responds, so the
metadata request talks to a known-alive local subprocess. Make a single
attempt (`http_max_tries` = 1) and let the error propagate instead of
retrying.

Added an integration test that points the JDBC bridge at a mock which
answers the ping handshake but never responds to `columns_info`, and
asserts the query fails promptly instead of retrying for minutes.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107461&sha=4a93325d05f03a26c28369c7fe7de652a5f2f155&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
Related: #107461

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov added a commit that referenced this pull request Jun 27, 2026
…uilds

The previous change only added `no-sanitizers`, but the post-#107461 disk-spill
timeouts also occur on non-sanitizer slow builds:

  - `04033_tpc_ds_q04` times out *only* in `Stateless tests (amd_llvm_coverage,
    ParallelReplicas, s3 storage, parallel)` (5 rows, 2026-06-19..2026-06-25),
    never on sanitizers, so `no-sanitizers` did nothing for it.
  - `04033_tpc_ds_q72` also times out on `amd_debug` and `amd_llvm_coverage`.
  - `04033_tpc_ds_q37` also times out once on `amd_debug`.

In `tests/clickhouse-test`, `no-sanitizers` only matches ASan/MSan/TSan/UBSan
(`BuildFlags.SANITIZERS`), so the coverage and debug builds were left exposed.
Since the disk spill enabled by #107461 is slow on every instrumented/slow build,
skip the six heaviest queries on debug and coverage as well via `no-debug` and
`no-llvm-coverage`.

`no-llvm-coverage` reroutes these tests to the `amd_binary_excluded_from_llvm` job,
which runs them once on a regular (non-instrumented) binary, so their plan/result
correctness is still verified without the timeout. The lighter TPC queries keep
exercising the spill code paths on instrumented builds.

CI report: #108341

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
pull Bot pushed a commit to erickirt/ClickHouse that referenced this pull request Jun 27, 2026
PR ClickHouse#107461 enabled disk spill (`max_bytes_before_external_group_by` and
`max_bytes_before_external_join`) for the TPC-DS and TPC-H functional tests
to lower peak memory and exercise the external `GROUP BY` / spilling-join
paths. Under sanitizer builds (especially TSan and MSan) the spilling path
is so slow that the heaviest queries overrun the 600s per-test timeout.

The timeout cluster (`04033_tpc_ds_q10`, `04033_tpc_ds_q72`,
`04033_tpc_ds_q04`, `04033_tpc_ds_q37`, `04033_tpc_ds_q39`,
`04040_tpc_h_q08`) started within hours of that PR merging into master and
hits exactly ~600s only on `amd_tsan` (`amd_msan` reaches ~508s). Before the
PR these tests ran in memory and passed on sanitizer builds for months.

These are plan/result correctness tests, not performance tests, so run them
in memory on sanitizer builds (detected via `system.build_options`), which
preserves correctness coverage there without the timeouts, while keeping
disk spill on the non-sanitizer builds where it is cheap.

Failures (last 90 days), via:
https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIGNoZWNrX3N0YXJ0X3RpbWUgQVMgZGF5LAogICAgcHVsbF9yZXF1ZXN0X251bWJlciBBUyBwciwKICAgIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDAzM190cGNfZHNfcTEwJwogICAgQU5EIHRlc3Rfc3RhdHVzIElOICgnRkFJTCcsICdFUlJPUicpCiAgICBBTkQgKHB1bGxfcmVxdWVzdF9udW1iZXIgPSAwIE9SIGJhc2VfcmVmIElOICgnbWFzdGVyJykpCiAgICBBTkQgdGVzdF9jb250ZXh0X3JhdyBMSUtFICclVGltZW91dCUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQwo=

Caused by: ClickHouse#107461

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
PR ClickHouse#107461 enabled disk spill (`max_bytes_before_external_group_by` and
`max_bytes_before_external_join`) for the TPC-DS and TPC-H functional tests
to lower peak memory and exercise the external `GROUP BY` / spilling-join
paths. Under sanitizer builds (especially TSan and MSan) the spilling path
is so slow that the heaviest queries overrun the 600s per-test timeout.

The timeout cluster (`04033_tpc_ds_q10`, `04033_tpc_ds_q72`,
`04033_tpc_ds_q04`, `04033_tpc_ds_q37`, `04033_tpc_ds_q39`,
`04040_tpc_h_q08`) started within hours of that PR merging into master and
hits exactly ~600s only on `amd_tsan` (`amd_msan` reaches ~508s). Before the
PR these tests ran in memory and passed on sanitizer builds for months.

These are plan/result correctness tests, not performance tests, so run them
in memory on sanitizer builds (detected via `system.build_options`), which
preserves correctness coverage there without the timeouts, while keeping
disk spill on the non-sanitizer builds where it is cheap.

Failures (last 90 days), via:
https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIGNoZWNrX3N0YXJ0X3RpbWUgQVMgZGF5LAogICAgcHVsbF9yZXF1ZXN0X251bWJlciBBUyBwciwKICAgIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDAzM190cGNfZHNfcTEwJwogICAgQU5EIHRlc3Rfc3RhdHVzIElOICgnRkFJTCcsICdFUlJPUicpCiAgICBBTkQgKHB1bGxfcmVxdWVzdF9udW1iZXIgPSAwIE9SIGJhc2VfcmVmIElOICgnbWFzdGVyJykpCiAgICBBTkQgdGVzdF9jb250ZXh0X3JhdyBMSUtFICclVGltZW91dCUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQwo=

Caused by: ClickHouse#107461

Co-Authored-By: Claude Opus 4.8 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…uilds

The previous change only added `no-sanitizers`, but the post-ClickHouse#107461 disk-spill
timeouts also occur on non-sanitizer slow builds:

  - `04033_tpc_ds_q04` times out *only* in `Stateless tests (amd_llvm_coverage,
    ParallelReplicas, s3 storage, parallel)` (5 rows, 2026-06-19..2026-06-25),
    never on sanitizers, so `no-sanitizers` did nothing for it.
  - `04033_tpc_ds_q72` also times out on `amd_debug` and `amd_llvm_coverage`.
  - `04033_tpc_ds_q37` also times out once on `amd_debug`.

In `tests/clickhouse-test`, `no-sanitizers` only matches ASan/MSan/TSan/UBSan
(`BuildFlags.SANITIZERS`), so the coverage and debug builds were left exposed.
Since the disk spill enabled by ClickHouse#107461 is slow on every instrumented/slow build,
skip the six heaviest queries on debug and coverage as well via `no-debug` and
`no-llvm-coverage`.

`no-llvm-coverage` reroutes these tests to the `amd_binary_excluded_from_llvm` job,
which runs them once on a regular (non-instrumented) binary, so their plan/result
correctness is still verified without the timeout. The lighter TPC queries keep
exercising the spill code paths on instrumented builds.

CI report: ClickHouse#108341

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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 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.

5 participants