Repository navigation
Cherry pick #126176 to 26.8: Do not correct the global memory tracker below jemalloc stats.allocated - #131849
Merged
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]>
…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]>
Do not correct the global memory tracker below jemalloc `stats.allocated`
Contributor
|
Dear @alexey-milovidov, this cherry-pick PR has not been updated for 3d0h4m28s. Please resolve the conflicts to backport #126176, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity. |
Resolve the conflicts in `MemoryWorker.cpp` and `ServerSettings.cpp`. 26.8 lacks #118094: `getMemoryUsage` returns a plain resident value (no `MemoryUsage` struct) and `memory_worker_correct_memory_tracker` is off by default. The fix is adapted inline: whenever the memory worker corrects the global memory tracker in a jemalloc build, it uses the maximum of the measured resident memory and jemalloc `stats.allocated`, refreshing the jemalloc `epoch` when the measurement came from cgroups. The setting description gets the same note as in the original PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
🕵 Resolved the conflicts by merging |
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.
Original pull-request #126176
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job