Merge pull request #6001 from yandex/fixed-error-with-query-id-printing

Fixed error with query_id printing
This commit is contained in:
alexey-milovidov 2019-07-16 00:46:11 +03:00 committed by GitHub
commit 37f9206925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -29,11 +29,10 @@ namespace ErrorCodes
void ThreadStatus::attachQueryContext(Context & query_context_)
{
query_context = &query_context_;
query_id = query_context->getCurrentQueryId();
if (!global_context)
global_context = &query_context->getGlobalContext();
query_id = query_context->getCurrentQueryId();
if (thread_group)
{
std::lock_guard lock(thread_group->mutex);
@ -106,6 +105,9 @@ void ThreadStatus::attachQuery(const ThreadGroupStatusPtr & thread_group_, bool
thread_group->thread_numbers.emplace_back(thread_number);
}
if (query_context)
query_id = query_context->getCurrentQueryId();
#if defined(__linux__)
/// Set "nice" value if required.
if (query_context)
@ -269,7 +271,7 @@ void CurrentThread::attachQueryContext(Context & query_context)
{
if (unlikely(!current_thread))
return;
return current_thread->attachQueryContext(query_context);
current_thread->attachQueryContext(query_context);
}
void CurrentThread::finalizePerformanceCounters()

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
set -e
# No log lines without query id
$CLICKHOUSE_CLIENT --send_logs_level=trace --query_id=hello --query="SELECT count() FROM numbers(10)" 2>&1 | grep -vF ' {hello} ' | grep -P '<\w+>' ||: