Avoid leaking of tracked memory for async logging and text_log#87584
Avoid leaking of tracked memory for async logging and text_log#87584azat merged 13 commits intoClickHouse:masterfrom
Conversation
|
Workflow [PR], commit [97e95fa] Summary: ❌
|
Algunenano
left a comment
There was a problem hiding this comment.
LGTM. A few of comments:
- Could you please leave a comment explaining why it's done. It's obvious to me now, but probably not to everyone and not me in a few months.
- I think we can remove since a) it's already covered here and b) it's also covered by
ClickHouse/src/Loggers/OwnSplitChannel.cpp
Line 135 in 4117df8
SystemLogQueue<LogElement>::push. - Could this have been an issue inside sync logging when calling
pushExtendedMessageToInternalTCPTextLogQueue? It seems it might grow the queue, allocating extra memory that's not freed but it's tied toCurrentThreadso probably accounting was kept correctly. - This makes me wonder what happens in logging threads if an exception is thrown when logging, inside
while (is_open). It seems the thread might stop and never recover. I'll investigate further
|
Thanks @Algunenano, decent comments!
Sure
The reason for it is very different, it is to avoid polluting
Exactly.
Likely, but the memory exceptions are blocked in that function. |
Actually I think for this case it should be accounted properly, since |
64e5696 to
e1464e8
Compare
Yes, but I'm guessing there might be other functions, like a temporal disk failure or something similar (thinking about a remote syslog for example). I'll do some more digging and probably cover it with a try...catch(...) just in case |
|
Note that we can remove blocker for SystemLogBase::push() since it is done from logSplit() method
This is likely redundant since we have it in push() which does big allocations, add() should not exceed 16 MiBs
e1464e8 to
c90ae43
Compare
|
There can be some other issues (since we seen that memory usage was very low, so likely we have some places where we allocate with blocked memory tracker, or from another context, but free w/o blocking tracker), but, those will be done separately, this was the major one, others should be less significant (if any). Merging. |
5fb4d67
Cherry pick #87584 to 25.9: Avoid leaking of tracked memory for async logging and text_log
Cherry pick #87584 to 25.8: Avoid leaking of tracked memory for async logging and text_log
Cherry pick #87584 to 25.7: Avoid leaking of tracked memory for async logging and text_log
Backport #87584 to 25.7: Avoid leaking of tracked memory for async logging and text_log
Backport #87584 to 25.8: Avoid leaking of tracked memory for async logging and text_log
Backport #87584 to 25.9: Avoid leaking of tracked memory for async logging and text_log
I should have done this before: #88814 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Avoid leaking of tracked memory for async logging (can have a significant drift, for 10 hours, ~100GiB) and text_log (almost same drift is possible).
Fixes: #82036