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

test

parent 0dadde87
Loading
Loading
Loading
Loading
Loading
+19 −6
Changes for src/cluster.cpp: 19 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -598,25 +598,38 @@ namespace authdb {
                  << " sgid=" << sgid << " sid_gid=" << sid_gid
                  << " data_size=" << data.size() << std::endl;

        // Dedicated session client — no contention with domain fetches
        std::unique_lock<std::timed_mutex> lock(session_client_mutex_, std::chrono::seconds(2));
        if (!lock.owns_lock())
            throw AuthBackendError("cluster busy — session push timeout");
        // Dedicated session client — retry loop with short lock attempts
        for (int attempt = 0; attempt < 5; ++attempt) {
            std::unique_lock<std::timed_mutex> lock(session_client_mutex_, std::chrono::milliseconds(200));
            if (!lock.owns_lock()) {
                std::cerr << "[CLUSTER-SESSION] pushSession: lock attempt " << attempt + 1
                          << "/5 failed, retrying..." << std::endl;
                std::this_thread::sleep_for(std::chrono::milliseconds(100));
                continue;
            }
            try {
                session_client_->store(sgid, data.data(), data.size());
                session_client_->store(sid_gid, data.data(), data.size());
            } catch (const std::exception &e) {
            std::cerr << "[CLUSTER-SESSION] pushSession: store FAILED: " << e.what() << std::endl;
                std::cerr << "[CLUSTER-SESSION] pushSession: store attempt " << attempt + 1
                          << "/5 FAILED: " << e.what() << std::endl;
                if (attempt < 4) {
                    std::this_thread::sleep_for(std::chrono::milliseconds(200));
                    continue;
                }
                throw;
            }

        // Immediately verify local shard exists
            // Verify and return on success
            try {
                auto verify = session_client_->retrieve(sid_gid);
                std::cerr << "[CLUSTER-SESSION] pushSession: stored OK, verify=" << verify.size() << " bytes" << std::endl;
            } catch (const std::exception &e) {
                std::cerr << "[CLUSTER-SESSION] pushSession: stored but verify failed: " << e.what() << std::endl;
            }
            return;
        }
        throw AuthBackendError("cluster busy — session push timeout after 5 retries");
    }

    void Cluster::queuePush(const SessionData &sess) {