Merge branch 'thread_state_improvements' into database_replicated

This commit is contained in:
Alexander Tokmakov 2021-02-03 20:19:35 +03:00
commit 87502d0220
6 changed files with 9 additions and 10 deletions

View File

@ -99,8 +99,10 @@ ThreadStatus::~ThreadStatus()
/// We've already allocated a little bit more than the limit and cannot track it in the thread memory tracker or its parent.
}
#if !defined(ARCADIA_BUILD)
/// It may cause segfault if query_context was destroyed, but was not detached
assert((!query_context && query_id.empty()) || (query_id == query_context->getCurrentQueryId()));
assert((!query_context && query_id.empty()) || (query_context && query_id == query_context->getCurrentQueryId()));
#endif
if (deleter)
deleter();

View File

@ -1139,12 +1139,6 @@ String Context::getCurrentDatabase() const
}
String Context::getCurrentQueryId() const
{
return client_info.current_query_id;
}
String Context::getInitialQueryId() const
{
return client_info.initial_query_id;

View File

@ -444,7 +444,7 @@ public:
StoragePtr getViewSource();
String getCurrentDatabase() const;
String getCurrentQueryId() const;
String getCurrentQueryId() const { return client_info.current_query_id; }
/// Id of initiating query for distributed queries; or current query id if it's not a distributed query.
String getInitialQueryId() const;

View File

@ -343,8 +343,10 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
{
const auto current_time = std::chrono::system_clock::now();
#if !defined(ARCADIA_BUILD)
assert(internal || CurrentThread::get().getQueryContext());
assert(internal || CurrentThread::get().getQueryContext()->getCurrentQueryId() == CurrentThread::getQueryId());
#endif
const Settings & settings = context.getSettingsRef();

View File

@ -652,7 +652,6 @@ namespace
/// Create context.
query_context.emplace(iserver.context());
query_scope.emplace(*query_context);
/// Authentication.
query_context->setUser(user, password, user_address);
@ -670,6 +669,8 @@ namespace
query_context->setSessionContext(session->context);
}
query_scope.emplace(*query_context);
/// Set client info.
ClientInfo & client_info = query_context->getClientInfo();
client_info.query_kind = ClientInfo::QueryKind::INITIAL_QUERY;

View File

@ -3701,7 +3701,7 @@ void StorageReplicatedMergeTree::shutdown()
/// We clear all old parts after stopping all background operations. It's
/// important, because background operations can produce temporary parts
/// which will remove themselves in their destrutors. If so, we may have
/// which will remove themselves in their destructors. If so, we may have
/// race condition between our remove call and background process.
clearOldPartsFromFilesystem(true);
}