sql 2025-08-29

digging into the nitty gritty: what is the purpose of this (locking this. It feels strange to be locking on a method param

(extend-protocol p/Transactable
  java.sql.Connection
  (-transact [this body-fn opts]
    (let [raw (raw-connection this)]
      (cond
        (and (not (contains? *active-tx* raw)) (= :ignore *nested-tx*))
        ;; #245 do not lock when in c.j.j compatibility mode:
        (binding [*active-tx* (conj *active-tx* raw)]
          (transact* this body-fn opts))
        (or (not (contains? *active-tx* raw)) (= :allow *nested-tx*))
        (locking this
          (binding [*active-tx* (conj *active-tx* raw)]
            (transact* this body-fn opts)))

It's locking on an instance of java.sql.Connection. And that class is not thread-safe.

right - but why

almost everything else (i think) is assuming single threaded use...right?

Not at all, why would you assume that?

the try/finallys with calls to .set*

But those are within the critical section, no?