Skip to content

Commit

Permalink
Merge pull request cockroachdb#23 from fauna/trytryagain
Browse files Browse the repository at this point in the history
Initialization must be idempotent due to retries.
  • Loading branch information
bitbckt authored Mar 5, 2019
2 parents 6459db9 + df09759 commit d22ae31
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/jepsen/faunadb/bank.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@
"Creates the initial accounts for a test"
[test conn]
; And initial account
(f/query conn (f/upsert-by-ref (q/ref accounts (first (:accounts test)))
{:data {:balance (:total-amount test)}}))
(f/query conn (q/let [ref (q/ref accounts (first (:accounts test)))]
(q/when (q/not (q/exists? ref))
(q/create ref {:data {:balance (:total-amount test)}}))))

(when (:fixed-instances test)
; Create remaining accounts up front
(f/query conn
Expand Down

0 comments on commit d22ae31

Please sign in to comment.