Merge pull request #7523 from ClickHouse/fix-thread-context-attach

Disable context replacement for internal queries
This commit is contained in:
alexey-milovidov 2019-10-31 00:07:13 +03:00 committed by GitHub
commit 883c868b36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View File

@ -104,12 +104,11 @@ void ThreadStatus::attachQuery(const ThreadGroupStatusPtr & thread_group_, bool
}
if (query_context)
{
query_id = query_context->getCurrentQueryId();
#if defined(__linux__)
/// Set "nice" value if required.
if (query_context)
{
/// Set "nice" value if required.
Int32 new_os_thread_priority = query_context->getSettingsRef().os_thread_priority;
if (new_os_thread_priority && hasLinuxCapability(CAP_SYS_NICE))
{
@ -120,8 +119,8 @@ void ThreadStatus::attachQuery(const ThreadGroupStatusPtr & thread_group_, bool
os_thread_priority = new_os_thread_priority;
}
}
#endif
}
initPerformanceCounters();
initQueryProfiler();

View File

@ -192,8 +192,13 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
{
time_t current_time = time(nullptr);
context.makeQueryContext();
CurrentThread::attachQueryContext(context);
/// If we already executing query and it requires to execute internal query, than
/// don't replace thread context with given (it can be temporary). Otherwise, attach context to thread.
if (!internal)
{
context.makeQueryContext();
CurrentThread::attachQueryContext(context);
}
const Settings & settings = context.getSettingsRef();

View File

@ -21,7 +21,7 @@ void executeQuery(
Context & context, /// DB, tables, data types, storage engines, functions, aggregate functions...
std::function<void(const String &)> set_content_type, /// If non-empty callback is passed, it will be called with the Content-Type of the result.
std::function<void(const String &)> set_query_id /// If non-empty callback is passed, it will be called with the query id.
);
);
/// More low-level function for server-to-server interaction.
@ -45,7 +45,7 @@ BlockIO executeQuery(
QueryProcessingStage::Enum stage = QueryProcessingStage::Complete, /// To which stage the query must be executed.
bool may_have_embedded_data = false, /// If insert query may have embedded data
bool allow_processors = true /// If can use processors pipeline
);
);
QueryPipeline executeQueryWithProcessors(