Repository navigation
Measure exact query memory in 04072_columns_cache_memory_usage - #123949
Merged
PedroTadim merged 2 commits intoNov 2, 2026
Merged
PedroTadim merged 2 commits into
PedroTadim merged 2 commits into
Conversation
Part 2 of the test compares the `memory_usage` peaks of two identical cache-served scans and failed with "memory ratio: 135.35" (small scan 4768 B, large scan 645344 B). The only big allocation of such a scan is the copy of the cached rows into the result block (~640 KB, in `MergeTreeReaderWide::serveRowsFromColumnsCache`), which is below the 1 MiB `max_untracked_memory` of the test profile. Whether the copy reaches the query's memory tracker then depends on when the per-thread batch or the per-CPU untracked budget (shared with other threads) forces a flush, not on the query: 645344 - 4768 = 640576 is the copy. With `max_untracked_memory = 0` every allocation is accounted immediately, so `memory_usage` is the real peak. The flag goes on the client command line, so it is applied to the query context before the TCP thread attaches. Part 1 reads the same peak and gets the same flag. Precedent: 01526_max_untracked_memory.sh. Forcing the flush schedule with `max_per_cpu_untracked_memory` on a server reload (budget off before the small scan, every allocation flushed before the large one) reproduces the failure deterministically without this change (ratio 136.28, 7/7) and passes with it (ratio 1.00, 30/30 over three orders). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collaborator
Author
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review of the diff (0 blocker/major findings). Nothing to adjudicate. Severity: ❌ blocker / |
Contributor
|
Workflow [PR], commit [aee381e] Summary: ✅ AI ReviewSummaryPR #123949, reviewed at Missing context / blind spots
Final VerdictStatus: ✅ Approve |
This was referenced Oct 5, 2026
groeneai
added a commit
to groeneai/ClickHouse
that referenced
this pull request
Oct 8, 2026
…off parallel replicas 04070, 04072, 05029, 05055, 05155 and 05210 assert `ColumnsCacheHits`/`ColumnsCacheMisses` from the initiator's `system.query_log` row, the same oracle as the nine tests fixed in the previous commit. They have not failed in the `ParallelReplicas` lane yet, but they carry the same precondition: when a remote replica reads all marks of a measured read, the initiator row has no cache events. With `parallel_replicas_local_plan = 0` on a local `ParallelReplicas` rig the unmodified tests fail 18/18 with exactly that shape, and pass 55/55 with the pin. The pinned runs have no secondary replica query for any measured read. In all six tests the measured reads depend on the cache state left by the reads before them, so the pin covers the whole test: a session `SET`, and for the shell test 04072 the client option, which keeps it apart from the lines changed by ClickHouse#123949. Also quote the setting and table names in the comments of the pins, as the in-tree style asks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
@alexey-milovidov you should quickly review this PR to fix CI |
PedroTadim
approved these changes
Nov 2, 2026
clickhouse-gh Bot
added a commit
that referenced
this pull request
Nov 2, 2026
Backport #123949 to 26.10: Measure exact query memory in `04072_columns_cache_memory_usage`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #96844
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04072_columns_cache_memory_usagefails in Part 2 withFAIL: query memory grew with the cached data (cache growth: 6.00, memory ratio: 135.35). It was seen on ClickHouse's internal CI (sanitizer builds, about 1% of runs); public CI has no failure of it yet. The test was added by #96844.The two measured scans are identical cache hits whose only big allocation is the copy of the cached rows into the result block (~640 KB). That is below the 1 MiB
max_untracked_memoryof the test profile (tests/config/users.d/memory_profiler.xml), so whether the copy reaches the query's memory tracker depends on when the thread's batch or the per-CPU untracked budget (max_per_cpu_untracked_memory, shared with the other threads on that CPU) forces a flush, not on the query. The failing numbers decompose exactly so: small scan 4768 B (copy not seen), large scan 645344 B, and 645344 - 4768 = 640576 is the copy.The five measured queries now run with
--max_untracked_memory=0, as01526_max_untracked_memory.shdoes, somemory_usageis the real peak. Only the test changes.Validation on the MasterCI
amd_asan_ubsanbinary of the base commit, with the CI test config:SYSTEM RELOAD CONFIG): without this change 7/7 FAIL, ratio 136.28 (small 4768 B, large 649792 B); with it 30/30 PASS, ratio 1.00, in three switch orders.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123949]
Version info
26.11.1.1077-master(included in26.11and later)