(cloud) more aggressive exponential backoff.

This commit is contained in:
2023-03-30 10:33:04 -07:00
parent 4bfe43e235
commit 744c4b60f7

View File

@@ -43,6 +43,13 @@
(def loaded (atom #{}))
(defn backoff [n]
(let [base-timeout 500
max-timeout 300000 ; 5 minutes
max-retries 10
backoff-time (* base-timeout (Math/pow 2 (min n max-retries)))]
(min (+ backoff-time (rand-int base-timeout)) max-timeout)))
(defn upsert-batch-impl
([batch ] (upsert-batch-impl batch 0))
([batch attempt]
@@ -52,7 +59,7 @@
(catch Exception e
(if (< attempt 10)
(do
(Thread/sleep (* attempt 1000))
(Thread/sleep (backoff attempt))
(upsert-batch-impl batch (inc attempt)))
(throw e))))))