Repository navigation
Do not correct the global memory tracker below jemalloc stats.allocated - #126176
Conversation
Since `memory_worker_correct_memory_tracker` is enabled by default, the memory worker resets the global memory tracker to RSS. RSS does not include memory that is allocated but not yet touched, so the concurrent `GROUP BY` queries of `test_multiple_queries` can allocate more than `max_server_memory_usage`, and the container is killed by the OOM killer (seen on arm with 64 KiB pages). The test keeps checking the behavior with the correction disabled. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=85c3bde0916bfd25994ff4636169741f354d5fd9&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [ac2bb17] Summary: ✅
AI ReviewSummaryThe PR corrects the global memory tracker to the maximum of measured resident memory and jemalloc's Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
alexey-milovidov
left a comment
There was a problem hiding this comment.
This is not good... Maybe we should only ever correct upwards?
…ted` The memory worker corrected the tracker to the resident memory, which does not include memory that is allocated but not touched yet. Concurrent queries were admitted past `max_server_memory_usage`, and in `test_memory_limit/test.py::test_multiple_queries` the container was killed by the OOM killer instead of the server throwing `MEMORY_LIMIT_EXCEEDED`. Correct to the maximum of the resident memory and jemalloc `stats.allocated`. All allocations go through jemalloc, so phantom drift (tracked bytes without an allocation behind them) is still removed, while allocated-but-untouched memory stays accounted. Revert the override in the test, which now runs with the correction enabled. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=85c3bde0916bfd25994ff4636169741f354d5fd9&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29 Review: #126176 (review) Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_memory_limitstats.allocated
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=126176&sha=e583caaad9cdafafcf5566cbadbf13ee1114e580&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 ( On the review question "maybe we should only ever correct upwards?": correcting only upwards would bring back the drift that #118094 fixes, because that drift is upwards and only a downward correction removes it. So the current commit still corrects downwards, but never below jemalloc |
|
Not caused by this PR. The stress phase ran the previous release, v26.9.19.9. There, This is the rolled-back empty part leak that #122375 fixes on master (merged 2026-10-09), so no new PR or tracking issue is needed. The check upgrades from the newest release older than the tested version ( |
alexey-milovidov
left a comment
There was a problem hiding this comment.
All good now.
…rallel formatting The setup INSERT writes 2000 one-row CSV objects with PARTITION BY. Until the sink finishes, every partition keeps a 1 MiB WriteBufferFromS3 buffer and a ParallelFormattingOutputFormat whose units are resized to 1 MiB, so the query peaks at 5.90 GiB for 8 KB of data. Since ClickHouse#126176 the global memory tracker is not corrected below jemalloc's allocated bytes, so on the 12 GiB arm runner it reaches max_server_memory_usage while RSS is ~1.6 GiB, and the INSERT is stopped by the OvercommitTracker (Integration tests (arm_binary, 3/4)). With output_format_parallel_formatting = 0 the INSERT peaks at 1.98 GiB. The test still writes 2000 objects (two ListObjectsV2 pages) and the SELECT side is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #126176 to 26.8: Do not correct the global memory tracker below jemalloc `stats.allocated`
…low jemalloc `stats.allocated`
Backport #126176 to 26.10: Do not correct the global memory tracker below jemalloc `stats.allocated`
Backport #126176 to 26.8: Do not correct the global memory tracker below jemalloc `stats.allocated`
Since #118094 enabled
memory_worker_correct_memory_trackerby default, the memory worker resets the global memory tracker to the resident memory on every tick. The resident memory does not include memory that is allocated but not touched yet, so concurrent queries were admitted pastmax_server_memory_usage. Intest_memory_limit/test.py::test_multiple_querieson arm, the container with a 4 GiB limit was killed by the OOM killer, and the server never threwMEMORY_LIMIT_EXCEEDED: three queries reported 1.5 GiB each while the global tracker peaked at 3.6 GiB. 64 KiB pages on the arm runners make the gap larger.Correcting only upwards would bring back the problem that #118094 fixes: the drift is upwards, and only a downward correction removes it. Instead, the tracker is now corrected to the maximum of the resident memory and jemalloc's
stats.allocated. Every allocation ofAllocatorgoes through jemalloc, sostats.allocatedincludes memory that is allocated but not touched yet. Phantom drift, meaning bytes counted in the tracker with no allocation behind them, is still removed. Sanitizer builds keep using__sanitizer_get_current_allocated_bytes.The previous commit of this PR disabled the correction in the test. That override is reverted, and the test now passes with the correction enabled: 4 out of 4 local runs on aarch64.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=85c3bde0916bfd25994ff4636169741f354d5fd9&name_0=MasterCI&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%203%2F4%29
Related: #118094
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126176]
Version info
26.11.1.382-master(included in26.11and later)26.10.7.22,26.8.41.13