Loading src/cluster.cpp +10 −9 Original line number Original line Diff line number Diff line Loading @@ -555,9 +555,9 @@ namespace authdb { try { try { std::cerr << "[CLUSTER] pushSession: acquiring lock" << std::endl; std::cerr << "[CLUSTER] pushSession: acquiring lock" << std::endl; std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(1)); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(3)); if (!lock.owns_lock()) { if (!lock.owns_lock()) { std::cerr << "[CLUSTER] pushSession: lock timeout (1s)" << std::endl; std::cerr << "[CLUSTER] pushSession: lock timeout (3s)" << std::endl; return; return; } } auto t1 = std::chrono::steady_clock::now(); auto t1 = std::chrono::steady_clock::now(); Loading Loading @@ -684,13 +684,14 @@ namespace authdb { // No local store — retrieve via erasure coding // No local store — retrieve via erasure coding uint64_t sid_gid = sidGroupId(session_id); uint64_t sid_gid = sidGroupId(session_id); if (pclient_) { if (pclient_) { try { // Let exceptions propagate so caller can distinguish std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); // "not found" (return false) from "cluster error" (exception) std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); auto data = pclient_->retrieve(sid_gid); auto data = pclient_->retrieve(sid_gid); if (!data.empty()) { if (!data.empty()) { return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); } } } catch (...) {} } } return false; return false; } } Loading src/session.cpp +18 −11 Original line number Original line Diff line number Diff line Loading @@ -513,6 +513,7 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session std::vector<uuid::uuid> c_members; std::vector<uuid::uuid> c_members; std::string c_username; std::string c_username; std::vector<std::pair<uuid::uuid, bool>> c_gpo; std::vector<std::pair<uuid::uuid, bool>> c_gpo; try { bool localOk = g_Cluster->fetchSessionLocalBySid(sessionid, c_sid, c_uid, c_did, bool localOk = g_Cluster->fetchSessionLocalBySid(sessionid, c_sid, c_uid, c_did, c_members, c_username, c_gpo); c_members, c_username, c_gpo); std::cerr << "[SESSION] getSession: fetchLocalBySid=" << localOk << std::endl; std::cerr << "[SESSION] getSession: fetchLocalBySid=" << localOk << std::endl; Loading @@ -526,6 +527,12 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session removeLocal(sessionid); removeLocal(sessionid); return nullptr; return nullptr; } } } catch (const std::exception &e) { // Cluster fetch error — keep local session, retry later std::cerr << "[SESSION] getSession: cluster sync error: " << e.what() << ", keeping local session" << std::endl; cur->_lastClusterSync = std::chrono::steady_clock::now(); } } } } } return cur; return cur; Loading Loading
src/cluster.cpp +10 −9 Original line number Original line Diff line number Diff line Loading @@ -555,9 +555,9 @@ namespace authdb { try { try { std::cerr << "[CLUSTER] pushSession: acquiring lock" << std::endl; std::cerr << "[CLUSTER] pushSession: acquiring lock" << std::endl; std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(1)); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(3)); if (!lock.owns_lock()) { if (!lock.owns_lock()) { std::cerr << "[CLUSTER] pushSession: lock timeout (1s)" << std::endl; std::cerr << "[CLUSTER] pushSession: lock timeout (3s)" << std::endl; return; return; } } auto t1 = std::chrono::steady_clock::now(); auto t1 = std::chrono::steady_clock::now(); Loading Loading @@ -684,13 +684,14 @@ namespace authdb { // No local store — retrieve via erasure coding // No local store — retrieve via erasure coding uint64_t sid_gid = sidGroupId(session_id); uint64_t sid_gid = sidGroupId(session_id); if (pclient_) { if (pclient_) { try { // Let exceptions propagate so caller can distinguish std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); // "not found" (return false) from "cluster error" (exception) std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(5)); if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout"); auto data = pclient_->retrieve(sid_gid); auto data = pclient_->retrieve(sid_gid); if (!data.empty()) { if (!data.empty()) { return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); } } } catch (...) {} } } return false; return false; } } Loading
src/session.cpp +18 −11 Original line number Original line Diff line number Diff line Loading @@ -513,6 +513,7 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session std::vector<uuid::uuid> c_members; std::vector<uuid::uuid> c_members; std::string c_username; std::string c_username; std::vector<std::pair<uuid::uuid, bool>> c_gpo; std::vector<std::pair<uuid::uuid, bool>> c_gpo; try { bool localOk = g_Cluster->fetchSessionLocalBySid(sessionid, c_sid, c_uid, c_did, bool localOk = g_Cluster->fetchSessionLocalBySid(sessionid, c_sid, c_uid, c_did, c_members, c_username, c_gpo); c_members, c_username, c_gpo); std::cerr << "[SESSION] getSession: fetchLocalBySid=" << localOk << std::endl; std::cerr << "[SESSION] getSession: fetchLocalBySid=" << localOk << std::endl; Loading @@ -526,6 +527,12 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session removeLocal(sessionid); removeLocal(sessionid); return nullptr; return nullptr; } } } catch (const std::exception &e) { // Cluster fetch error — keep local session, retry later std::cerr << "[SESSION] getSession: cluster sync error: " << e.what() << ", keeping local session" << std::endl; cur->_lastClusterSync = std::chrono::steady_clock::now(); } } } } } return cur; return cur; Loading