From 110beb01f9273e5c58bf185f03f5f2b85f9eb433 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 15 Dec 2023 21:34:20 +0100 Subject: [PATCH] add exp backoff --- scalardb/src/scalardb/core.clj | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/scalardb/src/scalardb/core.clj b/scalardb/src/scalardb/core.clj index caa9c8d..92914fe 100644 --- a/scalardb/src/scalardb/core.clj +++ b/scalardb/src/scalardb/core.clj @@ -31,21 +31,17 @@ (loop [retries RETRIES] (when (zero? retries) (throw (ex-info "Failed to set up tables" {:schema schema}))) + (when (< retries RETRIES) + (try + (SchemaLoader/unload properties schema true) + (catch Exception e (warn (.getMessage e)))) + (exponential-backoff (- RETRIES retries))) (let [schema (cheshire/generate-string schema) result (try - (SchemaLoader/load properties - schema - options - true) + (SchemaLoader/load properties schema options true) :success (catch Exception e (warn (.getMessage e)) - (try - (SchemaLoader/unload properties - schema - true) - (catch Exception e - (warn (.getMessage e)))) :fail))] (when (= result :fail) (recur (dec retries))))))))