Skip to content

Commit b3f0c12

Browse files
committed
Send write operations to primary nodes only
Jepsen generate operations randomly for each node but in a Tarantool cluster write operations (like INSERT, UPSERT etc) should be done only on a master node.
1 parent a500a9a commit b3f0c12

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/tarantool/counter.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
(cl/with-error-handling op
3939
(cl/with-txn-aborts op
4040
(case (:f op)
41-
:add (do (j/execute! conn
42-
[(str "UPDATE " table-name " SET count = count + ? WHERE id = 0") (:value op)])
41+
:add (let [con (cl/open (jepsen/primary test) test)]
42+
(do (j/execute! con
43+
[(str "UPDATE " table-name " SET count = count + ? WHERE id = 0") (:value op)]))
4344
(assoc op :type :ok))
4445

4546
:read (let [value (:COUNT

src/tarantool/sets.clj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[checker :as checker]
77
[generator :as gen]
88
[independent :as independent]]
9+
[clojure.tools.logging :refer [info warn]]
910
[next.jdbc :as j]
1011
[next.jdbc.sql :as sql]
1112
[tarantool.client :as cl]
@@ -37,8 +38,9 @@
3738
(cl/with-error-handling op
3839
(cl/with-txn-aborts op
3940
(case (:f op)
40-
:add (do (sql/insert! conn table-name {:value v})
41-
(assoc op :type :ok))
41+
:add (let [con (cl/open (jepsen/primary test) test)]
42+
(do (sql/insert! con table-name {:value v})
43+
(assoc op :type :ok)))
4244

4345
:read (->> (sql/query conn [(str "SELECT * FROM " table-name)])
4446
(mapv :VALUE)

0 commit comments

Comments
 (0)