Loading src/cluster.cpp +16 −0 Changes for src/cluster.cpp: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -573,11 +573,17 @@ namespace authdb { uint64_t sgid = sessionGroupId(uid, did); uint64_t sid_gid = sidGroupId(sid); std::cerr << "[CLUSTER-SESSION] pushSession: sid=" << sid.c_str() << " sgid=" << sgid << " sid_gid=" << sid_gid << " data_size=" << data.size() << std::endl; // Synchronous push — block until lock acquired, throw on failure. // The caller (addSession) retries, so no queuing needed here. std::unique_lock<std::timed_mutex> lock(client_mutex_); pclient_->store(sgid, data.data(), data.size()); pclient_->store(sid_gid, data.data(), data.size()); std::cerr << "[CLUSTER-SESSION] pushSession: stored OK" << std::endl; } void Cluster::queuePush(const SessionData &sess) { Loading Loading @@ -805,16 +811,26 @@ namespace authdb { std::vector<std::pair<uuid::uuid, bool>> &gpo_results) { uint64_t sid_gid = sidGroupId(session_id); std::cerr << "[CLUSTER-SESSION] fetchBySid: sid=" << session_id.c_str() << " sid_gid=" << sid_gid << std::endl; if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); auto data = pclient_->retrieve(sid_gid); std::cerr << "[CLUSTER-SESSION] fetchBySid: retrieved " << data.size() << " bytes" << std::endl; if (!data.empty()) { if (SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results)) { std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialized OK, sid=" << sid.c_str() << std::endl; return true; } std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialize FAILED" << std::endl; } } catch (const std::exception &e) { std::cerr << "[CLUSTER-SESSION] fetchBySid: exception: " << e.what() << std::endl; return false; } catch (...) { std::cerr << "[CLUSTER-SESSION] fetchBySid: unknown exception" << std::endl; return false; } } Loading src/session.cpp +5 −8 Changes for src/session.cpp: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -491,10 +491,8 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session } } // Fetch from cluster — retry every 150ms until success or 5s timeout // Single cluster fetch — no long retry loop to avoid blocking the API response if (g_Cluster && g_Cluster->isRunning()) { auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(5); while (std::chrono::steady_clock::now() < deadline) { uuid::uuid sid, uid, did; std::vector<uuid::uuid> members; std::string username; Loading @@ -510,18 +508,17 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session appendLocal(imported); return imported; } std::this_thread::sleep_for(std::chrono::milliseconds(150)); } // All retries exhausted — keep stale cache entry if available std::cerr << "[SESSION] getSession: sid=" << sessionid.c_str() << " not found in cluster" << std::endl; // Return stale cache if available std::lock_guard<std::mutex> guard(_lock); SessionData *stale = findLocal(sessionid); if (stale) { stale->_lastClusterSync = std::chrono::steady_clock::now(); return stale; } throw AuthBackendError("cluster session fetch failed after retries"); } return nullptr; Loading Loading
src/cluster.cpp +16 −0 Changes for src/cluster.cpp: 16 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -573,11 +573,17 @@ namespace authdb { uint64_t sgid = sessionGroupId(uid, did); uint64_t sid_gid = sidGroupId(sid); std::cerr << "[CLUSTER-SESSION] pushSession: sid=" << sid.c_str() << " sgid=" << sgid << " sid_gid=" << sid_gid << " data_size=" << data.size() << std::endl; // Synchronous push — block until lock acquired, throw on failure. // The caller (addSession) retries, so no queuing needed here. std::unique_lock<std::timed_mutex> lock(client_mutex_); pclient_->store(sgid, data.data(), data.size()); pclient_->store(sid_gid, data.data(), data.size()); std::cerr << "[CLUSTER-SESSION] pushSession: stored OK" << std::endl; } void Cluster::queuePush(const SessionData &sess) { Loading Loading @@ -805,16 +811,26 @@ namespace authdb { std::vector<std::pair<uuid::uuid, bool>> &gpo_results) { uint64_t sid_gid = sidGroupId(session_id); std::cerr << "[CLUSTER-SESSION] fetchBySid: sid=" << session_id.c_str() << " sid_gid=" << sid_gid << std::endl; if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); auto data = pclient_->retrieve(sid_gid); std::cerr << "[CLUSTER-SESSION] fetchBySid: retrieved " << data.size() << " bytes" << std::endl; if (!data.empty()) { if (SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results)) { std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialized OK, sid=" << sid.c_str() << std::endl; return true; } std::cerr << "[CLUSTER-SESSION] fetchBySid: deserialize FAILED" << std::endl; } } catch (const std::exception &e) { std::cerr << "[CLUSTER-SESSION] fetchBySid: exception: " << e.what() << std::endl; return false; } catch (...) { std::cerr << "[CLUSTER-SESSION] fetchBySid: unknown exception" << std::endl; return false; } } Loading
src/session.cpp +5 −8 Changes for src/session.cpp: 5 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -491,10 +491,8 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session } } // Fetch from cluster — retry every 150ms until success or 5s timeout // Single cluster fetch — no long retry loop to avoid blocking the API response if (g_Cluster && g_Cluster->isRunning()) { auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(5); while (std::chrono::steady_clock::now() < deadline) { uuid::uuid sid, uid, did; std::vector<uuid::uuid> members; std::string username; Loading @@ -510,18 +508,17 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session appendLocal(imported); return imported; } std::this_thread::sleep_for(std::chrono::milliseconds(150)); } // All retries exhausted — keep stale cache entry if available std::cerr << "[SESSION] getSession: sid=" << sessionid.c_str() << " not found in cluster" << std::endl; // Return stale cache if available std::lock_guard<std::mutex> guard(_lock); SessionData *stale = findLocal(sessionid); if (stale) { stale->_lastClusterSync = std::chrono::steady_clock::now(); return stale; } throw AuthBackendError("cluster session fetch failed after retries"); } return nullptr; Loading