return the early release and instead restore prepared_client_info and reset session_context

This commit is contained in:
Yakov Olkhovskiy 2023-12-14 17:25:47 +00:00
parent f8a0cfbc1a
commit 6d20082134
2 changed files with 12 additions and 0 deletions

View File

@ -293,6 +293,10 @@ Session::Session(const ContextPtr & global_context_, ClientInfo::Interface inter
Session::~Session() Session::~Session()
{ {
/// Early release a NamedSessionData.
if (named_session)
named_session->release();
if (notified_session_log_about_login) if (notified_session_log_about_login)
{ {
LOG_DEBUG(log, "{} Logout, user_id: {}", toString(auth_id), toString(*user_id)); LOG_DEBUG(log, "{} Logout, user_id: {}", toString(auth_id), toString(*user_id));
@ -700,6 +704,10 @@ void Session::releaseSessionID()
{ {
if (!named_session) if (!named_session)
return; return;
prepared_client_info = getClientInfo();
session_context.reset();
named_session->release(); named_session->release();
named_session = nullptr; named_session = nullptr;
} }

View File

@ -569,6 +569,8 @@ void HTTPHandler::processQuery(
/// The user could specify session identifier and session timeout. /// The user could specify session identifier and session timeout.
/// It allows to modify settings, create temporary tables and reuse them in subsequent requests. /// It allows to modify settings, create temporary tables and reuse them in subsequent requests.
SCOPE_EXIT({ session->releaseSessionID(); });
String session_id; String session_id;
std::chrono::steady_clock::duration session_timeout; std::chrono::steady_clock::duration session_timeout;
bool session_is_set = params.has("session_id"); bool session_is_set = params.has("session_id");
@ -904,6 +906,8 @@ void HTTPHandler::processQuery(
{}, {},
handle_exception_in_output_format); handle_exception_in_output_format);
session->releaseSessionID();
if (used_output.hasDelayed()) if (used_output.hasDelayed())
{ {
/// TODO: set Content-Length if possible /// TODO: set Content-Length if possible