Fix deadlock in OvercommitTracker logging#38246
Conversation
|
I'd rather tried to get rid of all allocations (as much as possible) in the OvercommitMemoryTracker. Because that code will work under high memory pressure and that could be an issue when we are trying to allocate more memory when we have to free it for another query. |
|
@nikitamikhaylov The problem here is that we have logging inside of the OvercommitTracker (for debug purposes). And logging may lead to the allocation of the memory. I can't get rid of these allocations (if we remove logs from here, I don't know how to debug it). |
|
@novikd, there's another problem and it's not only about logging. When some code does memory allocations it may throw exceptions like ClickHouse/src/Common/OvercommitTracker.cpp Lines 65 to 68 in 60b9d81 Looks like the line 68 may allocate memory and therefore throw (at least it's not clear from the code why it cannot). In this case changes to |
|
@tavplubix @nikitamikhaylov I removed usage of unordered_map in OvercommitTracker, and now we have no allocations there. But at some point, we'd like to have a FIFO order for thread releasing, which will highly likely require memory allocations. |
Let's add |
|
Isn't logging itself doing allocations when formatting strings? |
It is. We can use something like Or a bit more paranoid: |
|
Maybe do it in the macro, like this: |
|
@Mergifyio update |
✅ Branch has been successfully updated |
|
@Mergifyio update |
✅ Branch has been successfully updated |
Ok. No tests added. |
Backport #38246 to 22.6: ('Fix deadlock in OvercommitTracker logging',)
Backport #38246 to 22.5: ('Fix deadlock in OvercommitTracker logging',)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Do not allow recursive usage of OvercommitTracker during logging. Fixes #37794
cc @tavplubix @davenger