Skip to content

Commit

Permalink
DB/Add exponential backoff before trying the table creation (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 authored Dec 20, 2023
1 parent 2f774a4 commit 123fc61
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions scalardb/src/scalardb/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))))))))
Expand Down

0 comments on commit 123fc61

Please sign in to comment.