Fix possible overestimate memory tracking#73081
Merged
Algunenano merged 2 commits intoClickHouse:masterfrom Dec 11, 2024
Merged
Fix possible overestimate memory tracking#73081Algunenano merged 2 commits intoClickHouse:masterfrom
Algunenano merged 2 commits intoClickHouse:masterfrom
Conversation
88bf437 to
f7bd625
Compare
Contributor
|
This is an automated comment for commit fb7cd9f with description of existing statuses. It's updated for the latest CI running ✅ Click here to open a full report in a separate page Successful checks
|
Before this patch the untracked_memory was dumped before reseting the current_thread which could lead to leaking some of untracked_memory in `ThreadStatus::detachFromGroup` [1]. In particular I found that the local_data (which is 136 bytes) can be "leaked" that way. [1]: https://github.com/ClickHouse/ClickHouse/blob/8999fdd95ea98fa083133d5cdf64ee149cd7f864/src/Interpreters/ThreadStatusExt.cpp#L292-L306 This pops up on one of clusters where I noticed that the difference between MemoryTracking and MemoryResident keeps growing over the time. the difference grows ~200KiB per second - 16.5GiB per day. That cluster has tons MVs triggered from Buffer/Distributed (i.e. now query context), and this is indeed is the reason for leaking local_data, since in this case there is no thread group in the query, and it is created explicitly in `InterpreterInsertQuery::buildChain` [1]. [1]: https://github.com/ClickHouse/ClickHouse/blob/20ccb638ba00103f116855afbc473950ef2b867b/src/Interpreters/InterpreterInsertQuery.cpp#L321 Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
f7bd625 to
9072d1b
Compare
niki-timofe
approved these changes
Dec 11, 2024
Algunenano
reviewed
Dec 11, 2024
Algunenano
reviewed
Dec 11, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
Cherry pick #73081 to 24.3: Fix possible overestimate memory tracking
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
This was referenced Dec 11, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
Cherry pick #73081 to 24.8: Fix possible overestimate memory tracking
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
This was referenced Dec 11, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
Cherry pick #73081 to 24.9: Fix possible overestimate memory tracking
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
This was referenced Dec 11, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
Cherry pick #73081 to 24.10: Fix possible overestimate memory tracking
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
This was referenced Dec 11, 2024
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
Cherry pick #73081 to 24.11: Fix possible overestimate memory tracking
robot-clickhouse
added a commit
that referenced
this pull request
Dec 11, 2024
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
Dec 11, 2024
Backport #73081 to 24.9: Fix possible overestimate memory tracking
robot-ch-test-poll1
added a commit
that referenced
this pull request
Dec 11, 2024
Backport #73081 to 24.11: Fix possible overestimate memory tracking
Algunenano
added a commit
that referenced
this pull request
Dec 12, 2024
Backport #73081 to 24.8: Fix possible overestimate memory tracking
Algunenano
added a commit
that referenced
this pull request
Dec 12, 2024
Backport #73081 to 24.10: Fix possible overestimate memory tracking
Algunenano
added a commit
that referenced
this pull request
Dec 12, 2024
Backport #73081 to 24.3: Fix possible overestimate memory tracking
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix possible overestimate memory tracking (difference between
MemoryTrackingandMemoryResidentkept growing)Before this patch the untracked_memory was dumped before reseting the current_thread which could lead to leaking some of untracked_memory in
ThreadStatus::detachFromGroup1.In particular I found that the local_data (which is 136 bytes) can be "leaked" that way.
This pops up on one of clusters where I noticed that the difference between MemoryTracking and MemoryResident keeps growing over the time. the difference grows ~200KiB per second - 16.5GiB per day.
That cluster has tons MVs triggered from Buffer/Distributed (i.e. no query context), and this is indeed is the reason for leaking local_data, since in this case there is no thread group in the query, and it is created explicitly in
InterpreterInsertQuery::buildChain2.Fixes: #71511
Fixes: #71906
Example of stacktrace: https://gist.github.com/azat/96a015046ebe72ddcb59bc89ca91a20e