Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback should not be called when TransactionListener.commitEnd() throws exception #8413

Closed
johnlcox opened this issue Mar 13, 2019 · 4 comments

Comments

@johnlcox
Copy link

Expected behavior and actual behavior:

I'm not entirely sure what the expected behavior would be, but the actual behavior is that if a TransactionListener throws an exception from #commitEnd the call to TransactionProvider#rollback throws a NoSuchElementException. This occurs because the transaction was already successfully commited so a rollback can't occur and the transaction provider is expecting an element in the configurations Deque.

The NoSuchElementException is added to the suppressed exception list so the actual exception still bubbles up, but it is a bit weird. Even without the NoSuchElementException this presents a case where calls to DSLContext#transactionResult result in a RuntimeException but that a rollback did not occur; counter to the Javadoc 'indicating that a rollback has occurred.'

Steps to reproduce the problem (if possible, create an MCVE: https://github.com/jOOQ/jOOQ-mcve):

https://github.com/johnlcox/jOOQ-mcve/tree/NoSuchElementException

Versions:

  • jOOQ: 3.11.10
  • Java: 8
  • Database (include vendor): N/A
  • OS: N/A
  • JDBC Driver (include name if inofficial driver): N/A
@lukaseder
Copy link
Member

Thanks a lot for the MCVE. I can reproduce the problem. Will investigate

@lukaseder
Copy link
Member

The problem only appears in the ThreadLocalTransactionProvider, not the DefaultTransactionProvider

@lukaseder
Copy link
Member

Clearly, the rollback logic must not be invoked when commit was successful.

@lukaseder lukaseder changed the title TransactionProvider#rollback throws a NoSuchElementException, if TransactionListener#commitEnd throws an exception Rollback should not be called when TransactionListener.commitEnd() throws exception Mar 14, 2019
lukaseder added a commit that referenced this issue Mar 14, 2019
@lukaseder
Copy link
Member

Fixed in jOOQ 3.12. Backport scheduled for 3.11.11 (#8419) and 3.10.9 (#8420)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants