Commit caab8201 authored by jan.koester's avatar jan.koester
Browse files

test

parent 67bcd3b9
Loading
Loading
Loading
Loading
Loading
+23 −11
Changes for src/cluster.cpp: 23 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -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());

@@ -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;
@@ -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;
@@ -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;
@@ -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 (...) {}
@@ -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);
@@ -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 (...) {}
@@ -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()) {
@@ -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;