diff --git a/src/graph/session/GraphSessionManager.cpp b/src/graph/session/GraphSessionManager.cpp index e11fbc57d03..fbd7d02fd43 100644 --- a/src/graph/session/GraphSessionManager.cpp +++ b/src/graph/session/GraphSessionManager.cpp @@ -84,10 +84,7 @@ folly::Future>> GraphSessionManager::fin return Status::Error("Insert session to local cache failed."); } std::string key = session.get_user_name() + session.get_client_ip(); - bool addResp = addSessionCount(key); - if (!addResp) { - return Status::Error("Insert userIpSessionCount to local cache failed."); - } + addSessionCount(key); // update the space info to sessionPtr if (!spaceName.empty()) { @@ -148,10 +145,7 @@ folly::Future>> GraphSessionManager::cre return Status::Error("Insert session to local cache failed."); } std::string sessionKey = userName + clientIp; - bool addResp = addSessionCount(sessionKey); - if (!addResp) { - return Status::Error("Insert userIpSessionCount to local cache failed."); - } + addSessionCount(sessionKey); updateSessionInfo(sessionPtr.get()); return sessionPtr; } @@ -337,10 +331,7 @@ Status GraphSessionManager::init() { if (!ret.second) { return Status::Error("Insert session to local cache failed."); } - bool addResp = addSessionCount(key); - if (!addResp) { - return Status::Error("Insert userIpSessionCount to local cache failed."); - } + addSessionCount(key); updateSessionInfo(sessionPtr.get()); loadSessionCount++; } @@ -371,29 +362,25 @@ void GraphSessionManager::removeSessionFromLocalCache(const std::vectorsecond.get()->fetch_add(1); } else { - auto ret1 = userIpSessionCount_.emplace(key, std::make_shared()); - if (!ret1.second) { - return false; - } + userIpSessionCount_.insert_or_assign(key, std::make_shared()); } - return true; } -bool GraphSessionManager::subSessionCount(std::string& key) { +void GraphSessionManager::subSessionCount(std::string& key) { auto countFindPtr = userIpSessionCount_.find(key); if (countFindPtr == userIpSessionCount_.end()) { - return false; + VLOG(1) << "Session count not found for key: " << key; + return; } auto count = countFindPtr->second.get()->fetch_sub(1); if (count <= 0) { userIpSessionCount_.erase(countFindPtr); } - return true; } } // namespace graph } // namespace nebula diff --git a/src/graph/session/GraphSessionManager.h b/src/graph/session/GraphSessionManager.h index 749e1a06cec..cc13f1a956e 100644 --- a/src/graph/session/GraphSessionManager.h +++ b/src/graph/session/GraphSessionManager.h @@ -114,10 +114,10 @@ class GraphSessionManager final : public SessionManager { void updateSessionInfo(ClientSession* session); // add sessionCount - bool addSessionCount(std::string& key); + void addSessionCount(std::string& key); // sub sessionCount - bool subSessionCount(std::string& key); + void subSessionCount(std::string& key); }; } // namespace graph