mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
Send log message about peak memory usage to client #3230
This commit is contained in:
parent
99927a3518
commit
30da8de1b6
@ -199,8 +199,10 @@ void TCPHandler::runImpl()
|
||||
else
|
||||
processOrdinaryQuery();
|
||||
|
||||
sendLogs();
|
||||
/// Do it before sending end of stream, to have a chance to show log message in client.
|
||||
query_scope->logPeakMemoryUsage();
|
||||
|
||||
sendLogs();
|
||||
sendEndOfStream();
|
||||
|
||||
query_scope.reset();
|
||||
|
@ -80,6 +80,9 @@ public:
|
||||
{
|
||||
explicit QueryScope(Context & query_context);
|
||||
~QueryScope();
|
||||
|
||||
void logPeakMemoryUsage();
|
||||
bool log_peak_memory_usage_in_destructor = true;
|
||||
};
|
||||
|
||||
/// Implicitly finalizes current thread in the destructor
|
||||
|
@ -237,12 +237,18 @@ CurrentThread::QueryScope::QueryScope(Context & query_context)
|
||||
CurrentThread::attachQueryContext(query_context);
|
||||
}
|
||||
|
||||
void CurrentThread::QueryScope::logPeakMemoryUsage()
|
||||
{
|
||||
log_peak_memory_usage_in_destructor = false;
|
||||
CurrentThread::getGroup()->memory_tracker.logPeakMemoryUsage();
|
||||
}
|
||||
|
||||
CurrentThread::QueryScope::~QueryScope()
|
||||
{
|
||||
try
|
||||
{
|
||||
/// For better logging ({query_id} will be shown here)
|
||||
CurrentThread::getGroup()->memory_tracker.logPeakMemoryUsage();
|
||||
if (log_peak_memory_usage_in_destructor)
|
||||
logPeakMemoryUsage();
|
||||
|
||||
CurrentThread::detachQueryIfNotDetached();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user