starts logging in the event of an issue.
This commit is contained in:
@@ -831,3 +831,25 @@
|
||||
;; this is temporary for any new stuff that needs to be asserted for cloud migration.
|
||||
(dc/transact conn
|
||||
{:tx-data (edn/read-string (slurp (io/resource "cloud-migration-schema.edn")))}))
|
||||
|
||||
(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 transact-with-backoff
|
||||
([tx ] (transact-with-backoff tx 0))
|
||||
([tx attempt]
|
||||
(try
|
||||
(dc/transact conn {:tx-data tx})
|
||||
(catch Exception e
|
||||
(if (< attempt 10)
|
||||
(do
|
||||
(Thread/sleep (backoff attempt))
|
||||
(mu/log ::transact-failed
|
||||
:exception e
|
||||
:status "WARN")
|
||||
(transact-with-backoff tx (inc attempt)))
|
||||
(throw e))))))
|
||||
|
||||
Reference in New Issue
Block a user