Loading src/cluster.cpp +23 −11 Changes for src/cluster.cpp: 23 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -577,9 +577,10 @@ namespace authdb { << " 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_); // Synchronous push — 2s timeout to avoid blocking backend lock. std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) throw AuthBackendError("cluster busy — session push timeout"); pclient_->store(sgid, data.data(), data.size()); pclient_->store(sid_gid, data.data(), data.size()); Loading Loading @@ -695,7 +696,8 @@ namespace authdb { std::vector<uint8_t> data; if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; data = pclient_->retrieve(sgid); if (!data.empty()) { uuid::uuid d_uid, d_did; Loading @@ -717,7 +719,8 @@ namespace authdb { // Fetch session to get the SID for removing the SID-keyed entry if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; std::vector<uint8_t> data = pclient_->retrieve(sgid); if (!data.empty()) { uuid::uuid sid, d_uid, d_did; Loading @@ -740,7 +743,8 @@ namespace authdb { // Fetch session data to get uid+did key if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; std::vector<uint8_t> data = pclient_->retrieve(sid_gid); if (!data.empty()) { uuid::uuid sid, uid, did; Loading @@ -762,7 +766,8 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sgid); if (!data.empty()) return true; } catch (...) {} Loading @@ -781,7 +786,8 @@ namespace authdb { if (pclient_) { // Let exceptions propagate so caller can distinguish // "not found" (return false) from "cluster error" (exception) std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sid_gid); if (!data.empty()) { return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); Loading @@ -795,7 +801,8 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sid_gid); if (!data.empty()) return true; } catch (...) {} Loading @@ -816,7 +823,11 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) { std::cerr << "[CLUSTER-SESSION] fetchBySid: client_mutex_ timeout" << std::endl; return false; } auto data = pclient_->retrieve(sid_gid); std::cerr << "[CLUSTER-SESSION] fetchBySid: retrieved " << data.size() << " bytes" << std::endl; if (!data.empty()) { Loading Loading @@ -846,7 +857,8 @@ namespace authdb { // Collect all group IDs across all nodes std::set<uint64_t> all_groups; try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; size_t n = pclient_->get_cluster_status().nodes_total; for (size_t i = 0; i < n; i++) { std::vector<uint64_t> node_groups; Loading Loading
src/cluster.cpp +23 −11 Changes for src/cluster.cpp: 23 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -577,9 +577,10 @@ namespace authdb { << " 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_); // Synchronous push — 2s timeout to avoid blocking backend lock. std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) throw AuthBackendError("cluster busy — session push timeout"); pclient_->store(sgid, data.data(), data.size()); pclient_->store(sid_gid, data.data(), data.size()); Loading Loading @@ -695,7 +696,8 @@ namespace authdb { std::vector<uint8_t> data; if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; data = pclient_->retrieve(sgid); if (!data.empty()) { uuid::uuid d_uid, d_did; Loading @@ -717,7 +719,8 @@ namespace authdb { // Fetch session to get the SID for removing the SID-keyed entry if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; std::vector<uint8_t> data = pclient_->retrieve(sgid); if (!data.empty()) { uuid::uuid sid, d_uid, d_did; Loading @@ -740,7 +743,8 @@ namespace authdb { // Fetch session data to get uid+did key if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; std::vector<uint8_t> data = pclient_->retrieve(sid_gid); if (!data.empty()) { uuid::uuid sid, uid, did; Loading @@ -762,7 +766,8 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sgid); if (!data.empty()) return true; } catch (...) {} Loading @@ -781,7 +786,8 @@ namespace authdb { if (pclient_) { // Let exceptions propagate so caller can distinguish // "not found" (return false) from "cluster error" (exception) std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sid_gid); if (!data.empty()) { return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results); Loading @@ -795,7 +801,8 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return false; auto data = pclient_->retrieve(sid_gid); if (!data.empty()) return true; } catch (...) {} Loading @@ -816,7 +823,11 @@ namespace authdb { if (pclient_) { try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) { std::cerr << "[CLUSTER-SESSION] fetchBySid: client_mutex_ timeout" << std::endl; return false; } auto data = pclient_->retrieve(sid_gid); std::cerr << "[CLUSTER-SESSION] fetchBySid: retrieved " << data.size() << " bytes" << std::endl; if (!data.empty()) { Loading Loading @@ -846,7 +857,8 @@ namespace authdb { // Collect all group IDs across all nodes std::set<uint64_t> all_groups; try { std::unique_lock<std::timed_mutex> lock(client_mutex_); std::unique_lock<std::timed_mutex> lock(client_mutex_, std::chrono::seconds(2)); if (!lock.owns_lock()) return; size_t n = pclient_->get_cluster_status().nodes_total; for (size_t i = 0; i < n; i++) { std::vector<uint64_t> node_groups; Loading