(cloud) more aggressive exponential backoff.
This commit is contained in:
@@ -43,6 +43,13 @@
|
|||||||
|
|
||||||
(def loaded (atom #{}))
|
(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
|
(defn upsert-batch-impl
|
||||||
([batch ] (upsert-batch-impl batch 0))
|
([batch ] (upsert-batch-impl batch 0))
|
||||||
([batch attempt]
|
([batch attempt]
|
||||||
@@ -52,7 +59,7 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
(if (< attempt 10)
|
(if (< attempt 10)
|
||||||
(do
|
(do
|
||||||
(Thread/sleep (* attempt 1000))
|
(Thread/sleep (backoff attempt))
|
||||||
(upsert-batch-impl batch (inc attempt)))
|
(upsert-batch-impl batch (inc attempt)))
|
||||||
(throw e))))))
|
(throw e))))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user