mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Read memory/thread related settings in ThreadStatus::attachQueryContext()
Previous it was read only ThreadStatus::initializeQuery() but there is no context there yet. Plus executeQueryImpl() calls only attachQueryContext() and nothing more. This is an issue only for queries via HTTP, since via TCP there is PullingAsyncPipelineExecutor which calls attachTo() by itself.
This commit is contained in:
parent
42395053e4
commit
c694bbe822
@ -35,6 +35,27 @@ void ThreadStatus::attachQueryContext(Context & query_context_)
|
||||
{
|
||||
query_context = &query_context_;
|
||||
query_id = query_context->getCurrentQueryId();
|
||||
|
||||
const Settings & settings = query_context->getSettingsRef();
|
||||
|
||||
untracked_memory_limit = settings.max_untracked_memory;
|
||||
if (settings.memory_profiler_step && settings.memory_profiler_step < UInt64(untracked_memory_limit))
|
||||
untracked_memory_limit = settings.memory_profiler_step;
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
/// Set "nice" value if required.
|
||||
Int32 new_os_thread_priority = settings.os_thread_priority;
|
||||
if (new_os_thread_priority && hasLinuxCapability(CAP_SYS_NICE))
|
||||
{
|
||||
LOG_TRACE(log, "Setting nice to {}", new_os_thread_priority);
|
||||
|
||||
if (0 != setpriority(PRIO_PROCESS, thread_id, new_os_thread_priority))
|
||||
throwFromErrno("Cannot 'setpriority'", ErrorCodes::CANNOT_SET_THREAD_PRIORITY);
|
||||
|
||||
os_thread_priority = new_os_thread_priority;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!global_context)
|
||||
global_context = &query_context->getGlobalContext();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user