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

test

parent ad973481
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
mediadb (20260503+11) unstable; urgency=high

  * cluster/sync: add runtime setting MEDIADB_SYNC_INTERVAL_SEC (1..300,
    default 5) to tune background sync cadence and reduce import-time
    contention on busy clusters

 -- Jan Koester <jan.koester@tuxist.de>  Sun, 03 May 2026 20:35:00 +0200

mediadb (20260503+10) unstable; urgency=high

  * cluster: add runtime switch MEDIADB_AUTO_REPAIR=0 to disable automatic
+12 −1
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@

#include <algorithm>
#include <atomic>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <unordered_set>
@@ -15,6 +16,15 @@

namespace mediadb {

static int sync_interval_seconds() {
    const char* v = std::getenv("MEDIADB_SYNC_INTERVAL_SEC");
    if (!v || v[0] == '\0') return 5;
    int x = std::atoi(v);
    if (x < 1) x = 1;
    if (x > 300) x = 300;
    return x;
}

// Zero-copy read-only streambuf over a contiguous byte buffer
class MemBuf : public std::streambuf {
public:
@@ -3746,9 +3756,10 @@ void ClusterMediaBackend::repair_replication() {
void ClusterMediaBackend::sync_loop() {
    int cycle = 0;
    while (sync_running_) {
        const int interval_sec = sync_interval_seconds();
        {
            std::unique_lock<std::mutex> lock(sync_mutex_);
            sync_cv_.wait_for(lock, std::chrono::seconds(5),
            sync_cv_.wait_for(lock, std::chrono::seconds(interval_sec),
                              [this]{ return !sync_running_.load(); });
        }
        if (!sync_running_) break;