java.jdbc

Transactions do not rollback on non-Exception Throwables

Details

  • Type: Defect Defect
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    0.2.3

Description

transaction* currently catches Exceptions for its rollback logic. This means Throwables subclassing java.lang.Error are not caught, and indeed the transaction seems to be immediately committed in this case (at least if the connection has autocommit set to true).

This happened to me in the case of an OutOfMemoryError. Another example is that the following code commits:

(transaction
  (insert-records "table" {:foo 12})
  (assert false))

Presumably this can be fixed by catching Throwable instead of Exception. I'll prepare a patch to that effect.

Activity

Hide
Sean Corfield added a comment -

Thanx Gary. In the latest source there may be two pieces of transaction logic so please check for anywhere else that Exception is mentioned!

Show
Sean Corfield added a comment - Thanx Gary. In the latest source there may be two pieces of transaction logic so please check for anywhere else that Exception is mentioned!
Hide
Gary Fredericks added a comment -

This patch changes Exception to Throwable in two places – transaction* and db-transaction*. The tests pass.

Show
Gary Fredericks added a comment - This patch changes Exception to Throwable in two places – transaction* and db-transaction*. The tests pass.
Hide
Sean Corfield added a comment -

Patch applied.

Show
Sean Corfield added a comment - Patch applied.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: