diff --git a/tidb/src/tidb/bank.clj b/tidb/src/tidb/bank.clj index 56c5f7677..b6c5fd21f 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)] @@ -82,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)