From df09759fb96dd2f103d41b41ac630dee31ef1f41 Mon Sep 17 00:00:00 2001 From: Brandon Mitchell Date: Mon, 4 Mar 2019 14:00:09 -0800 Subject: [PATCH] Initialization must be idempotent due to retries. --- src/jepsen/faunadb/bank.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jepsen/faunadb/bank.clj b/src/jepsen/faunadb/bank.clj index 2a78b2dad..84cc82ad0 100644 --- a/src/jepsen/faunadb/bank.clj +++ b/src/jepsen/faunadb/bank.clj @@ -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