add more log for NamedSessionsStorage

This commit is contained in:
Sema Checherinda 2022-09-29 23:14:21 +02:00
parent c976b28104
commit cf90692fb8

View File

@ -117,6 +117,8 @@ public:
if (!thread.joinable())
thread = ThreadFromGlobalPool{&NamedSessionsStorage::cleanThread, this};
LOG_DEBUG(log, "Create new session in storage with session_id: {}, user_id: {}", key.second, key.first);
return {session, true};
}
else
@ -124,6 +126,8 @@ public:
/// Use existing session.
const auto & session = it->second;
LOG_TEST(log, "Reuse session from storage with session_id: {}, user_id: {}", key.second, key.first);
if (!session.unique())
throw Exception("Session is locked by a concurrent client.", ErrorCodes::SESSION_IS_LOCKED);
return {session, false};
@ -173,6 +177,10 @@ private:
close_times.resize(close_index + 1);
close_times[close_index].emplace_back(session.key);
}
LOG_TEST(log, "Schedule closing session with session_id: {}, user_id: {}",
session.key.second, session.key.first);
}
void cleanThread()
@ -214,12 +222,17 @@ private:
{
if (!session->second.unique())
{
LOG_TEST(log, "Delay closing session with session_id: {}, user_id: {}", key.second, key.first);
/// Skip but move it to close on the next cycle.
session->second->timeout = std::chrono::steady_clock::duration{0};
scheduleCloseSession(*session->second, lock);
}
else
{
LOG_DEBUG(log, "Close session from storage with session_id: {}, user_id: {}", key.second, key.first);
sessions.erase(session);
}
}
}
@ -231,6 +244,8 @@ private:
std::condition_variable cond;
ThreadFromGlobalPool thread;
bool quit = false;
Poco::Logger * log = &Poco::Logger::get("NamedSessionsStorage");
};
@ -257,7 +272,7 @@ Session::Session(const ContextPtr & global_context_, ClientInfo::Interface inter
Session::~Session()
{
LOG_DEBUG(log, "{} Destroying {}",
LOG_DEBUG(log, "{} Releasing {}",
toString(auth_id),
(named_session ? "named session '" + named_session->key.second + "'" : "unnamed session")
);