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

cluster: add temporary [SESSIONS-DIAG] logging to listAllSessions() and push_worker_loop()

Both paths currently swallow every failure silently (catch(...) {}, and
push_worker_loop only logs a drop after 5 retries, never a success) so
there's no way to tell from logs whether session groups are missing,
retrieve()/deserialize is failing, or the write side never lands.
Remove once the empty-admin-session-list issue is root-caused.
parent 8f58479c
Loading
Loading
Loading
Loading
+36 −6
Changes for src/cluster.cpp: 36 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -775,7 +775,14 @@ namespace authdb {
            if (!running_) break;

            // Don't try to push while critical
            if (critical_) continue;
            if (critical_) {
                if (!push_queue_.empty() || !data_push_queue_.empty()) {
                    std::cerr << "[SESSIONS-DIAG] push_worker_loop: skipped, cluster critical, "
                              << "pending_sessions=" << push_queue_.size()
                              << " pending_data=" << data_push_queue_.size() << std::endl;
                }
                continue;
            }

            // Drain ALL pending session pushes FIRST (more time-critical)
            std::vector<PendingPush> sess_batch;
@@ -797,6 +804,8 @@ namespace authdb {
            for (auto &item : sess_batch) {
                try {
                    session_client_->store(item.sid_gid, item.data.data(), item.data.size());
                    std::cerr << "[SESSIONS-DIAG] push_worker: stored session gid=" << item.sid_gid
                              << " data_size=" << item.data.size() << std::endl;
                } catch (const std::exception &e) {
                    item.retries++;
                    if (item.retries < 5) {
@@ -972,12 +981,17 @@ namespace authdb {
        std::set<uint64_t> all_groups;
        try {
            size_t n = session_read_client_->get_cluster_status().nodes_total;
            std::cerr << "[SESSIONS-DIAG] listAllSessions: nodes_total=" << n << std::endl;
            for (size_t i = 0; i < n; i++) {
                std::vector<uint64_t> node_groups;
                if (session_read_client_->list_groups_on_node(i, node_groups)) {
                bool ok = session_read_client_->list_groups_on_node(i, node_groups);
                std::cerr << "[SESSIONS-DIAG] list_groups_on_node(" << i << ") ok=" << ok
                          << " groups=" << node_groups.size() << std::endl;
                if (ok) {
                    all_groups.insert(node_groups.begin(), node_groups.end());
                }
            }
            std::cerr << "[SESSIONS-DIAG] all_groups (union) size=" << all_groups.size() << std::endl;

            // Try to retrieve and deserialize each group as a session
            for (uint64_t gid : all_groups) {
@@ -990,20 +1004,36 @@ namespace authdb {
                    // session in the cluster instead of failing that group closed.
                    auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(5);
                    auto data = session_read_client_->retrieve(gid, deadline);
                    std::cerr << "[SESSIONS-DIAG] retrieve gid=" << gid
                              << " data_size=" << data.size() << std::endl;
                    if (data.empty()) continue;
                    SessionInfo info;
                    if (SessionBlock::deserialize(data, info.sid, info.uid, info.did,
                    bool deser = SessionBlock::deserialize(data, info.sid, info.uid, info.did,
                                                  info.members, info.username, info.gpo_results,
                                                  info.created_at)) {
                                                  info.created_at);
                    std::cerr << "[SESSIONS-DIAG] deserialize gid=" << gid
                              << " ok=" << deser
                              << " sid=" << (deser ? info.sid.c_str() : "?") << std::endl;
                    if (deser) {
                        std::string key = info.sid.c_str();
                        if (!info.sid.empty() && seen_sids.find(key) == seen_sids.end()) {
                            seen_sids.insert(key);
                            out.push_back(std::move(info));
                        }
                    }
                } catch (...) {}
                } catch (const std::exception &e) {
                    std::cerr << "[SESSIONS-DIAG] retrieve/deserialize gid=" << gid
                              << " EXCEPTION: " << e.what() << std::endl;
                } catch (...) {
                    std::cerr << "[SESSIONS-DIAG] retrieve/deserialize gid=" << gid
                              << " unknown exception" << std::endl;
                }
            }
        } catch (const std::exception &e) {
            std::cerr << "[SESSIONS-DIAG] listAllSessions outer EXCEPTION: " << e.what() << std::endl;
        } catch (...) {
            std::cerr << "[SESSIONS-DIAG] listAllSessions outer unknown exception" << std::endl;
        }
        } catch (...) {}
    }

    // --- DataOpBlock serialization ---