Skip to content

Commit

Permalink
cockroachdb: fix idempotence detection in multi-register test
Browse files Browse the repository at this point in the history
  • Loading branch information
nvanbenschoten committed Apr 5, 2019
1 parent a17fa77 commit 2a1f1cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions cockroachdb/src/jepsen/cockroach/client.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@
(assoc op :type :fail)
op))

(defn with-idempotent-txn
"Takes a predicate on operation functions, and a txn op, presumably resulting
from a client call. If idempotent? is truthy for all of the txn's operations,
remaps :info types to :fail."
[idempotent? op]
(let [[_ txn] (:value op)
fs (map first txn)]
(if (and (every? idempotent? fs) (= :info (:type op)))
(assoc op :type :fail)
op)))

(defmacro with-timeout
"Like util/timeout, but throws (RuntimeException. \"timeout\") for timeouts.
Throwing means that when we time out inside a with-conn, the connection state
Expand Down
6 changes: 3 additions & 3 deletions cockroachdb/src/jepsen/cockroach/multiregister.clj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
(info "Created table" t))))))

(invoke! [this test op]
(c/with-idempotent #{:read}
(c/with-idempotent-txn #{:read}
(c/with-exception->op op
(c/with-conn [c conn]
(c/with-timeout
Expand All @@ -73,7 +73,7 @@
(let [[ik txn] (:value op)
txn' (mapv
(fn [[f id val]]
(let [t (id->table id)
(let [t (id->table id)
val' (case f
:read
(-> c
Expand Down Expand Up @@ -115,7 +115,7 @@
(fn [k]
(->> (gen/mix [r w])
(gen/stagger 1/100)
(gen/limit 100))))}
(gen/limit 60))))}
:model (model/multi-register {})
:checker (checker/compose
{:perf (checker/perf)
Expand Down

0 comments on commit 2a1f1cf

Please sign in to comment.