Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid MEMORY_LIMIT_EXCEEDED during INSERT into Buffer with AggregateFunction #35072

Merged
merged 3 commits into from Mar 14, 2022

Conversation

azat
Copy link
Collaborator

@azat azat commented Mar 5, 2022

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Avoid possible MEMORY_LIMIT_EXCEEDED during INSERT into Buffer with AggregateFunction

In case of Buffer table has columns of AggregateFunction type,
aggregate states for such columns will be allocated from the query
context but those states can be destroyed from the server context (in
case of background flush), and thus memory will be leaked from the query
since aggregate states can be shared, and eventually this will lead to
MEMORY_LIMIT_EXCEEDED error.

To avoid this, prohibit sharing the aggregate states.

But note, that this problem only about memory accounting, not memory
usage itself.

azat added 2 commits March 9, 2022 10:57
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
…unction

In case of Buffer table has columns of AggregateFunction type,
aggregate states for such columns will be allocated from the query
context but those states can be destroyed from the server context (in
case of background flush), and thus memory will be leaked from the query
since aggregate states can be shared, and eventually this will lead to
MEMORY_LIMIT_EXCEEDED error.

To avoid this, prohibit sharing the aggregate states.

But note, that this problem only about memory accounting, not memory
usage itself.

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
@azat azat force-pushed the buffer-memory-tracker-leak branch from 106111d to e2960e1 Compare March 9, 2022 07:58
@azat azat marked this pull request as ready for review March 9, 2022 07:58
@antonio2368 antonio2368 self-assigned this Mar 10, 2022
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
@antonio2368 antonio2368 merged commit ed3d71d into ClickHouse:master Mar 14, 2022
@azat azat deleted the buffer-memory-tracker-leak branch March 14, 2022 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-improvement Pull request with some product improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants