Skip to content

Apply the memory limit of the external DISTINCT tests only to the queries under test - #123286

Merged
nihalzp merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-external-distinct-tests-memory-limit-scope
Oct 5, 2026
Merged

nihalzp merged 1 commit into
ClickHouse:masterfrom
groeneai:fix-external-distinct-tests-memory-limit-scope

Conversation

@groeneai

@groeneai groeneai commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118757
Related: #121772

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

05241_external_distinct_coalescing failed in Stateless tests (amd_debug, parallel) on #118757 (reported there). The four queries under test returned the expected rows; the final system.query_log check failed with Query memory limit exceeded: would use 128.03 MiB ... maximum: 128.00 MiB: (while reading column ProfileEvents.key_ExternalDistinctWritePart).

Cause. The test's SET max_memory_usage = 134217728 is session-wide, so it also caps that check. With the randomized use_uncompressed_cache = 1, the check is charged for every block it decompresses into the uncompressed cache (CachedCompressedReadBuffer::nextImpl). In a parallel run the granules around the four matching rows hold the ProfileEvents of many other tests, so the charge depends on the whole run, not on this test.

Change. Move the limit into the SETTINGS of the four queries under test, so the check runs with the job's normal limits. 05242_external_distinct_limit_remerge has the same construction (512 MiB) and gets the same change. The queries under test keep their limit, and the references are unchanged.

Validation. On a copy of query_log made of this test's rows (303 MiB of ProfileEvents), the check with the old settings fails with Code: 241 3/3 with the cache on (13.66 MiB peak with it off), and passes 3/3 with the new ones (338.8 MiB peak). 50 randomized runs of each test pass; query_log shows the 400 queries under test with their limit and with spilling and merging, and the 100 checks without it.


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

Version info

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

…ries under test

05241_external_distinct_coalescing set max_memory_usage = 128 MiB for the
whole session, so the limit also applied to the final system.query_log
check. With the randomized use_uncompressed_cache = 1, that check is charged
for every block it decompresses into the uncompressed cache
(CachedCompressedReadBuffer::nextImpl allocates the cache cell under the
query's memory tracker), and in a parallel run the granules around the four
matching rows hold the ProfileEvents of many other tests. The check then
failed with MEMORY_LIMIT_EXCEEDED while the queries under test were fine
(Stateless tests (amd_debug, parallel) on ClickHouse#118757).

Move the limit into the SETTINGS of the four queries under test, so the
check runs with the job's normal limits. 05242_external_distinct_limit_remerge
has the same construction (512 MiB) and gets the same change. The queries
under test keep the same limit; the references are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 1, 2026
@groeneai

groeneai commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ The tests do not assert that max_memory_usage is set only on the queries under test DISAGREE That property lives in the test's own text, so an in-file assertion could only fail if this file were edited. I verified it once with query_log instead: in 50 randomized runs per test, 400/400 queries under test carry their cap and still spill and merge, 100/100 checks carry the profile limit, and the unfixed file's check carries the cap. A 20 MB per-query cap fails the whole query with Code: 241.
2 💡 02402_external_disk_metrics combines a session cap with a query_log read in the same way DISAGREE no-parallel, 410 MiB cap, no failures; not touched.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-9:20261001-142500

@clickhouse-gh

clickhouse-gh Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [18c25ed]

Summary: ✅


AI Review

Summary

This PR narrows max_memory_usage from session scope to per-query SETTINGS in the two external DISTINCT stateless tests so the trailing system.query_log verification no longer inherits the low cap and flakes under parallel runs. I do not see a correctness, coverage, or PR-metadata issue in the current patch: the memory cap still applies to each query under test, the log-based assertions stay intact, and the unchanged references remain consistent with the new setting scope.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 1, 2026
@nihalzp nihalzp self-assigned this Oct 1, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 1, 2026
@groeneai

groeneai commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 18c25ed

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) / 04549_sqlite_database_engine_missing_file flaky, not PR-caused (this PR changes only the two external DISTINCT tests): the test's sqlite3 CLI write got database is locked (5) because a concurrent test enumerating all databases opened the just-created SQLite file, so t1 stayed empty #123316 (mine, open)
Mergeable Check, PR rollups, red only because of the row above #123316 (mine, open)
CH Inc sync - CH Inc sync (private, not actionable by me)

146 of 146 check runs completed and Finish Workflow is green; CH Inc sync is still pending. CIDB has no other FAIL or ERROR test row on this head.

Session id: cron:our-pr-ci-monitor:20261001-190203

@nihalzp
nihalzp added this pull request to the merge queue Oct 5, 2026
Merged via the queue into ClickHouse:master with commit 47422e4 Oct 5, 2026
294 of 295 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 5, 2026
@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