From 93a764bf61f3e8a298f56ce3febc237c60a763c1 Mon Sep 17 00:00:00 2001 From: you06 Date: Thu, 11 Dec 2025 14:36:45 +0900 Subject: [PATCH 1/2] wait thread done when timeout Signed-off-by: you06 --- jepsen/src/jepsen/util.clj | 5 +++++ tidb/src/tidb/bank.clj | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jepsen/src/jepsen/util.clj b/jepsen/src/jepsen/util.clj index 0db250fb9..c3521f874 100644 --- a/jepsen/src/jepsen/util.clj +++ b/jepsen/src/jepsen/util.clj @@ -341,6 +341,11 @@ (throw (.getCause ee#))))] (if (= retval# ::timeout) (do (future-cancel worker#) + ; Wait until the worker actually finishes after cancellation. + (loop [] + (when-not (future-done? worker#) + (Thread/sleep 1) + (recur))) ~timeout-val) retval#))) diff --git a/tidb/src/tidb/bank.clj b/tidb/src/tidb/bank.clj index 56c5f7677..4589b7106 100644 --- a/tidb/src/tidb/bank.clj +++ b/tidb/src/tidb/bank.clj @@ -27,8 +27,7 @@ (defn insert-bank-record! [conn {:keys [from to amount]}] (c/execute! conn ["insert into records(account_id, amount) values (?, ?), (?, ?)" from (- amount) - to amount] - {:transaction? false})) + to amount])) (defn single-stmt-transfer! [conn test op] (let [{:keys [from to amount]} (:value op)] @@ -84,7 +83,7 @@ op))] ; the :txn-info from fk-op is attached as :fk-txn-info (cond-> op - (:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op)))) + (:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op)))) op)] (with-txn op [c conn {:isolation (util/isolation-level test) From 613f5d4495df8f782b4edc2136cab3e3ee9d7f28 Mon Sep 17 00:00:00 2001 From: you06 Date: Fri, 12 Dec 2025 16:37:43 +0900 Subject: [PATCH 2/2] Close foreign key remaining transactions Signed-off-by: you06 --- jepsen/src/jepsen/util.clj | 5 ----- tidb/src/tidb/bank.clj | 8 +++++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/jepsen/src/jepsen/util.clj b/jepsen/src/jepsen/util.clj index c3521f874..0db250fb9 100644 --- a/jepsen/src/jepsen/util.clj +++ b/jepsen/src/jepsen/util.clj @@ -341,11 +341,6 @@ (throw (.getCause ee#))))] (if (= retval# ::timeout) (do (future-cancel worker#) - ; Wait until the worker actually finishes after cancellation. - (loop [] - (when-not (future-done? worker#) - (Thread/sleep 1) - (recur))) ~timeout-val) retval#))) diff --git a/tidb/src/tidb/bank.clj b/tidb/src/tidb/bank.clj index 4589b7106..b6c5fd21f 100644 --- a/tidb/src/tidb/bank.clj +++ b/tidb/src/tidb/bank.clj @@ -81,9 +81,11 @@ (let [{:keys [from to amount]} (:value op)] (insert-bank-record! c {:from from :to to :amount amount}) op))] - ; the :txn-info from fk-op is attached as :fk-txn-info - (cond-> op - (:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op)))) + ; set the auto-commit back to true after the foreign key txn + (c/set-auto-commit! conn true) + ; the :txn-info from fk-op is attached as :fk-txn-info + (cond-> op + (:txn-info fk-op) (assoc :fk-txn-info (:txn-info fk-op)))) op)] (with-txn op [c conn {:isolation (util/isolation-level test)