There are methods like getThreadGroup() and ThreadGroupSwitcher class,
so seems that this is logical.
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
Some of such places:
- push from Buffer
- push from Distributed sends
- system.*_log workers
Before #47564 it simply does not work, but after it throws LOGICAL_ERROR
in such situation.
v2: remove expired() check after #46709 got merged
v3: use ThreadGroupStatus ctor with ContextPtr (after #47564)
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
* save format string for NetException
* format exceptions
* format exceptions 2
* format exceptions 3
* format exceptions 4
* format exceptions 5
* format exceptions 6
* fix
* format exceptions 7
* format exceptions 8
* Update MergeTreeIndexGin.cpp
* Update AggregateFunctionMap.cpp
* Update AggregateFunctionMap.cpp
* fix
To further shrink the critical section for releasing memory of the
profile events (ProfileEventsCountersAndMemory), this commit puts
the dealloaction out of the critical section while keeping the
memory move under lock. This change could mitigate the contention
for ThreadGroupStatus::mutex.
After #40732 it became possible that getrusage() (from detachQuery(),
from buildPushingToViewsChain()) will be called for incorrect thread,
and so when the difference will be calculated it will be simply garbage.
But actually the root of this problem is #25714, after which it became
possible to have multiple ThreadStatus for one thread, and this is very
tricky (sigh).
Here are some other thoughts about it:
- Make ThreadStatus nested - decided that complexity does not worth it,
at least only for this case
- Move some members into ThreadGroupStatus - will break per-thread
statistics (and hence query_thread_log, BTW does somebody uses it?)
- Move some members into a separate structure
But decided to fix the issue w/o any refactoring, to make easy for
backport.
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
- lots of static_cast
- add safe_cast
- types adjustments
- config
- IStorage::read/watch
- ...
- some TODO's (to convert types in future)
P.S. That was quite a journey...
v2: fixes after rebase
v3: fix conflicts after #42308 merged
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
The release of ThreadGroupStatus::finished_threads_counters_memory
via the getProfileEventsCountersAndMemoryForThreads method brings
lots of lock contentions for ThreadGroupStatus::mutex and lowers
the overall performance. This commit optimizes this performance
issue by replacing the method call with an equivalent but more
lightweight code block.