Repository navigation
Fix flaky test_trace_log_memory_context: force a new global memory peak - #113688
Merged
alexey-milovidov merged 3 commits intoAug 9, 2026
Merged
Conversation
The test asserts that `MemoryPeak` events with `memory_context = 'Global'` appear in `system.trace_log`, but such events are sent only when the server-wide memory usage grows past its previous peak by at least `total_memory_profiler_step` (4 MiB). When the peak reached during server startup is higher than anything the test's small queries allocate, no `MemoryPeak` event can ever be produced and the existing retry loop cannot help - the test fails with `assert 0 > 0`. Force a new global peak by allocating an increasing amount of memory (~100 MB more per attempt) inside the retry loop. Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102402&sha=f8b38f834a2e63df6820ad1e750205d84276799a&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%202%2F4%29 of #102402 Co-Authored-By: Claude Fable 5 <[email protected]>
Merged
1 task done
Contributor
|
Workflow [PR], commit [574e83e] Summary: ✅ AI ReviewSummaryThis PR stabilizes Final Verdict✅ No remaining review findings. |
Address review: run and escalate the `groupArray` peak-forcing query only while the `Global`/`Max` `Memory`/`MemoryPeak` events are still missing, so retries that only miss a probabilistic `MemorySample`/`JemallocSample` do not keep increasing the allocation size. Pin `max_threads = 1` to keep the growth per attempt close to ~100 MB. Co-Authored-By: Claude Fable 5 <[email protected]>
…memory-context-global-peak
alexey-milovidov
deleted the
fix/test-trace-log-memory-context-global-peak
branch
August 9, 2026 20:01
1 task done
pull Bot
pushed a commit
to Mu-L/ClickHouse
that referenced
this pull request
Aug 28, 2026
…peak to its own query test_memory_context_in_trace_log required `Global`/`Memory` and `Global`/`MemoryPeak` trace events with `empty(query_id)`, that is, emitted by a thread with no query attached. It failed on 8 unrelated PRs in 120 days, 0 on master, on both `amd_binary_excluded_from_llvm` and `arm_binary distributed plan`. `MemoryTracker::commitAllocation` emits a `Global` `MemoryPeak` event only when one and the same allocation both crosses `total_memory_profiler_step` on `total_memory_tracker` and sets a new global peak, and `TraceSender::send` stamps the event with the emitting thread's query id. Both watermarks only ever grow for the life of the server, so the assertion depended on a race that a query-less background thread had to win. ClickHouse#113688 forces the peak with a query: its own events carry that query's id and were therefore excluded, and each escalation raised both watermarks further, so retrying made the next attempt less likely to help rather than more. Count the events of the query that forces the peak instead, in the loop's break condition and in the assertion together so the two cannot diverge. That is stricter than before rather than weaker: a `Global`-context `Memory` and `MemoryPeak` row with `memory_blocked_context = 'Max'` are both still required, and they are now tied to a known query id. `01092_memory_profiler.sql` already scopes `MemoryPeak` to the allocating query. Rebuilding the failing run's own `system.trace_log` from its artifacts shows the old predicate reading 0 and the new one reading 6 over 5 query ids, every one of them an escalation query. 30 runs of the same CI job config pass, converging on the first forcing query in 29 of 30; the bounded retry loop absorbs the rest. Shrinking the forcing query to `numbers(1)` makes the new assertion fail, so it still catches a regression.
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.
test_trace_log_memory_context::test_memory_context_in_trace_logasserts thatMemoryPeakevents withmemory_context = 'Global'appear insystem.trace_log. Such events are sent only when the server-wide memory usage grows past its previous peak by at leasttotal_memory_profiler_step(4 MiB). When the peak reached during server startup is higher than anything the test's small queries allocate, noMemoryPeakevent can ever be produced and the existing retry loop cannot help — the test fails withassert 0 > 0(labelledretry_ok). Fix by forcing a new global peak: allocate an increasing amount of memory (~100 MB more per attempt,max_threads = 1) inside the retry loop — only on attempts where the globalMemory/MemoryPeakevents are still missing, so retries that only miss a probabilisticMemorySample/JemallocSampledo not escalate the allocation.Seen in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=102402&sha=f8b38f834a2e63df6820ad1e750205d84276799a&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%202%2F4%29
Related: #102402
Changelog category (leave one):
Version info
26.8.1.1045(included in26.8and later)