I use Clojure with JDBC to select and insert records from two different databases (notably MySQL and Vertica) in response to the event. I would like all this to happen as part of a single transaction that could be discarded if something went wrong with any team.
(defn handle-request
[request]
(jdbc/with-db-transaction [mysql-conn config/mysql-db-spec]
(jdbc/with-db-transaction [vertica-conn config/vertica-db-spec]
(let [record (query-some-data mysql-conn request)]
(update-some-data! mysql-conn record)
(insert-some-vertica-data! vertica-conn record)))))
I am worried that this could lead to a successful Vertica transaction, but not MySQL. What would be the most idiomatic Clojure way to handle this operation?
source
share