Commit 8e386b2a authored by jan.koester's avatar jan.koester
Browse files

test

parent 72df0be9
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -783,6 +783,11 @@ int main(int argc,char *argv[]){
        if (backend.end() > sizeof(authdb::AuthHeader))
            authdb.warmDomainCache();

        // Signal cluster that domain backends are loaded — scrub may now
        // safely identify orphaned groups without risking data loss.
        if (clusterEnabled)
            cluster.setDomainsReady();

        if(cmd.getCmdbyKey("debug")->getValue()=="true"){
            authdb::DEBUG=true;
            authdb.threads=1;
+8 −1
Original line number Diff line number Diff line
@@ -1168,7 +1168,10 @@ namespace authdb {
        }

        // Remove orphaned groups (old per-entity groups or stale data)
        if (!orphaned_groups.empty()) {
        // Safety: never delete orphaned groups before domain backends are
        // loaded — knownDomainGroupIds() would return an incomplete set and
        // valid domain data would be wiped out.
        if (!orphaned_groups.empty() && domains_ready_.load() && !known_domain_gids.empty()) {
            std::cerr << "[SCRUB] removing " << orphaned_groups.size()
                      << " orphaned groups" << std::endl;
            for (uint64_t gid : orphaned_groups) {
@@ -1176,6 +1179,10 @@ namespace authdb {
                    pclient_->remove(gid);
                } catch (...) {}
            }
        } else if (!orphaned_groups.empty()) {
            std::cerr << "[SCRUB] skipping " << orphaned_groups.size()
                      << " orphaned groups — domains not ready yet"
                      << std::endl;
        }

        std::cerr << "[SCRUB] found " << group_nodes.size()
+6 −0
Original line number Diff line number Diff line
@@ -236,11 +236,17 @@ namespace authdb {

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

        // Signal that all domain backends have been loaded into cache.
        // Scrub will not remove orphaned groups until this is set.
        void setDomainsReady() { domains_ready_ = true; }
        bool domainsReady() const { return domains_ready_.load(); }

    private:
        ClusterConfig cfg_;
        std::atomic<bool> running_{false};
        std::atomic<bool> degraded_{false};
        std::atomic<bool> critical_{false};
        std::atomic<bool> domains_ready_{false};
        std::atomic<uint64_t> recovery_epoch_{0};
        std::thread server_thread_;
        std::thread health_monitor_thread_;