Skip to content

Commit

Permalink
one more attempt (#143)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksandr Shevchuk <[email protected]>
  • Loading branch information
teem0n and Aleksandr Shevchuk authored Oct 19, 2024
1 parent 4370042 commit 6759a4f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jepsen_test:
timeout 600 docker exec mysync_mysql1_1 setup.sh
timeout 600 bash ./tests/images/copy_keys.sh
mkdir -p ./tests/logs
(docker exec mysync_jepsen_1 /root/jepsen/run.sh > ./tests/logs/jepsen.log 2>&1 && tail -n 4 ./tests/logs/jepsen.log) || ./tests/images/jepsen_main/save_logs.sh
(docker exec mysync_jepsen_1 /root/jepsen/run.sh > ./tests/logs/jepsen.log 2>&1 && tail -n 50 ./tests/logs/jepsen.log) || ./tests/images/jepsen_main/save_logs.sh
docker compose -p mysync -f ./tests/images/jepsen-compose.yml down --rmi all

clean:
Expand Down
34 changes: 25 additions & 9 deletions tests/images/jepsen_main/jepsen/src/jepsen/mysync.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
client/Reusable
(reusable? [_ test] true)))

(defn read_portion [c n chunk_size]
(def q (str "select value from test1.test_set order by value desc limit " chunk_size " offset " (* n chunk_size)))
(info (str "Query: " q))
(def result_value (->> (j/query c [q]
{:row-fn :value})
(vec)
(set)))
result_value)

(defn mysql-client
"MySQL client"
[conn]
Expand All @@ -93,15 +102,22 @@
(try
(with-conn [c conn]
(case (:f op)
:read (timeout 600000 (assoc op :type :info, :error "read-timeout")
(cond (= (count (j/query c ["show slave status for channel ''"])) 0)
:read (timeout 1200000 (assoc op :type :info, :error "read-timeout")
(cond (= (count (j/query c ["show slave status for channel ''"])) 0)
(do
(def value_cnt (:count (first (j/query c ["select count(*) as count from test1.test_set"]))))
(def chunk_size 5000)
(def portion_cnt (Math/ceil (/ value_cnt chunk_size)))
(info (str "Values count: " value_cnt))
(info (str "Portions count: " portion_cnt))
(def result_set (set '()))
(dotimes [n (+ portion_cnt 1)]
(info (str "Reading portion " n))
(def result_set (set/union result_set (read_portion c n chunk_size))))
(assoc op :type :ok,
:value (->> (j/query c ["select value from test1.test_set"]
{:row-fn :value})
(vec)
(set)))
true
(assoc op :type :info, :error "read-only")))
:value result_set))
true
(assoc op :type :info, :error "read-only")))
:add (timeout 5000 (assoc op :type :info, :error "add-timeout")
(do
(info (str "Adding: " (get op :value) " to " (get c :subname)))
Expand Down Expand Up @@ -276,7 +292,7 @@
(gen/nemesis
(fn [] (map gen/once
[{:type :info, :f :stop}
{:type :sleep, :value 600}])))
{:type :sleep, :value 1200}])))
(gen/time-limit 1200)))
:checker mysync-set
:remote control/ssh})

0 comments on commit 6759a4f

Please sign in to comment.