Commit 83998d0f authored by jan.koester's avatar jan.koester
Browse files

test

parent ea28cc62
Loading
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -555,9 +555,9 @@ namespace authdb {

        try {
            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()) {
                std::cerr << "[CLUSTER] pushSession: lock timeout (1s)" << std::endl;
                std::cerr << "[CLUSTER] pushSession: lock timeout (3s)" << std::endl;
                return;
            }
            auto t1 = std::chrono::steady_clock::now();
@@ -684,13 +684,14 @@ namespace authdb {
        // No local store — retrieve via erasure coding
        uint64_t sid_gid = sidGroupId(session_id);
        if (pclient_) {
            try {
                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");
            // 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::chrono::seconds(5));
            if (!lock.owns_lock()) throw std::runtime_error("cluster client lock timeout");
            auto data = pclient_->retrieve(sid_gid);
            if (!data.empty()) {
                return SessionBlock::deserialize(data, sid, uid, did, members, username, gpo_results);
            }
            } catch (...) {}
        }
        return false;
    }
+18 −11
Original line number Diff line number Diff line
@@ -513,6 +513,7 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session
                    std::vector<uuid::uuid> c_members;
                    std::string c_username;
                    std::vector<std::pair<uuid::uuid, bool>> c_gpo;
                    try {
                        bool localOk = g_Cluster->fetchSessionLocalBySid(sessionid, c_sid, c_uid, c_did,
                                                              c_members, c_username, c_gpo);
                        std::cerr << "[SESSION] getSession: fetchLocalBySid=" << localOk << std::endl;
@@ -526,6 +527,12 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session
                            removeLocal(sessionid);
                            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;