News for hackers. Stuff that matters.
Re:JVM exceptions are weird: a decompiler perspective by immibis on Monday November 10, 2025 @09:32AM (#45876389)
This code is wrong. You don't want to commit a transaction if an exception is thrown during the transaction.
Re:JVM exceptions are weird: a decompiler perspective by maxdamantus on Monday November 10, 2025 @04:11PM (#45880999)
You want to at least check that the exception was raised in the absence of read anomalies. The check for read anomalies in OCC happens during the commit phase.

Setting a transaction to read-only on error is possible using the code (using a rethrowing catch within the transaction), but this is not universally desirable.

If you're using transactions to run fairly arbitrary code atomically (assuming no static state outside of the transaction), the expected behaviour would be that modifications leading up to an exception are still persisted. Eg, imagine the code within the transaction is updating a persisted retry counter before performing a fallible operation. In this case you want the counter to be updated so that the transaction doesn't just fail an infinite number of times, since each time you roll back on error you're just restoring the state that leads to the error.