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

test

parent 0951dac1
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1026,6 +1026,9 @@ function loadClusterStatus() {
            html += '<tr><td>Overall Status</td><td class="' + statusClass + '">' + data.status + '</td></tr>';
            html += '<tr><td>Nodes Total</td><td>' + data.nodes_total + '</td></tr>';
            html += '<tr><td>Nodes Online</td><td>' + data.nodes_online + '</td></tr>';
            if (data.scrub_running) {
                html += '<tr><td>Scrub / Rebalance</td><td class="msg-error">Running</td></tr>';
            }
            html += '</table>';

            if (data.nodes && data.nodes.length > 0) {
+3 −0
Original line number Diff line number Diff line
@@ -660,6 +660,9 @@ namespace authdb {
                json_object_object_add(jobj, "nodes", jnodes);
            }

            json_object_object_add(jobj, "scrub_running",
                json_object_new_boolean(g_Cluster->isScrubRunning()));

            sendJson(curreq, jobj);
            json_object_put(jobj);
        }
+4 −0
Original line number Diff line number Diff line
@@ -654,6 +654,7 @@ namespace authdb {
                        std::thread([this](){
                            std::unique_lock<std::mutex> lk(scrub_mutex_, std::try_to_lock);
                            if (!lk.owns_lock()) return; // scrub running, skip
                            scrub_running_ = true;
                            try {
                                auto rb = pclient_->rebalance();
                                if (rb.rebalanced > 0) {
@@ -662,6 +663,7 @@ namespace authdb {
                                    pclient_->vacuum_all_nodes();
                                }
                            } catch (...) {}
                            scrub_running_ = false;
                        }).detach();
                    }
                } else if (health.nodes_online >= k) {
@@ -1065,6 +1067,7 @@ namespace authdb {
            std::cerr << "[SCRUB] skipped — another scrub/rebalance is already running" << std::endl;
            return result;
        }
        scrub_running_ = true;

        size_t n = cfg_.data_blocks + cfg_.parity_blocks;

@@ -1149,6 +1152,7 @@ namespace authdb {
                  << " repaired=" << result.groups_repaired
                  << " failed=" << result.groups_failed << std::endl;

        scrub_running_ = false;
        return result;
    }

+3 −0
Original line number Diff line number Diff line
@@ -229,6 +229,8 @@ namespace authdb {
            return std::unique_lock<std::mutex>(scrub_mutex_, std::try_to_lock);
        }

        bool isScrubRunning() const { return scrub_running_.load(); }

    private:
        ClusterConfig cfg_;
        std::atomic<bool> running_{false};
@@ -243,6 +245,7 @@ namespace authdb {
        std::mutex push_mutex_;
        std::condition_variable push_cv_;
        std::mutex scrub_mutex_;  // prevents concurrent scrub / rebalance
        std::atomic<bool> scrub_running_{false};

        struct PendingPush {
            std::vector<uint8_t> data;