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

test

parent 6af1ad2f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ mediadb (20260503+2) unstable; urgency=medium
    counters when cluster recovers (reset_import_client vs warmup-only)
  * cluster: fall back to pclient_ for media replication if import_client_
    is persistently broken but cluster is otherwise healthy
  * import: make fallback replication stricter and fully synchronous:
    pclient_ fallback now retries with exponential backoff before failing

 -- Jan Koester <jan.koester@tuxist.de>  Sat, 03 May 2026 17:00:00 +0200

+13 −4
Original line number Diff line number Diff line
@@ -3117,10 +3117,11 @@ std::unique_ptr<ImportSession> ClusterMediaBackend::begin_import() {
    importing_.store(true);

    // Synchronous replicate: use pclient_ for metadata (store/index),
    // import_client_ for media data. Retry with reset on failure;
    // final fallback uses pclient_ in case import_client_ is persistently broken.
    // import_client_ for media data. If import_client_ keeps failing,
    // fall back to pclient_ with its own retry loop before giving up.
    auto replicate_fn = [this](const std::string& key, const uint8_t* d, size_t len) -> bool {
        static constexpr int MAX_RETRIES = 3;
        static constexpr int FALLBACK_RETRIES = 5;
        const bool use_pclient = (key == "index" || key.compare(0, 6, "store:") == 0);
        for (int attempt = 0; attempt < MAX_RETRIES; ++attempt) {
            if (attempt > 0) {
@@ -3142,9 +3143,17 @@ std::unique_ptr<ImportSession> ClusterMediaBackend::begin_import() {
        if (!use_pclient) {
            std::cerr << "[CLUSTER-IMPORT-STREAM] import_client_ exhausted, "
                         "falling back to pclient_ for key=" << key << "\n";
            for (int attempt = 0; attempt < FALLBACK_RETRIES; ++attempt) {
                if (attempt > 0) {
                    std::cerr << "[CLUSTER-IMPORT-STREAM] pclient fallback retry " << attempt
                              << " key=" << key << " size=" << len << "\n";
                    std::this_thread::sleep_for(
                        std::chrono::milliseconds(1000 * (1 << (attempt - 1))));
                }
                cluster_.warmup_read_clients();
                if (cluster_.replicate(key, d, len)) return true;
            }
        }
        std::cerr << "[CLUSTER-IMPORT-STREAM] replicate FAILED key=" << key << "\n";
        return false;
    };