-
-
Notifications
You must be signed in to change notification settings - Fork 101
[4.2] Validate transaction and roll back them in case of error #2928
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
Conversation
* Rename variable "rollback" to "markedForRollback" * Change formattation
yrodiere
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Feel free to merge, but I have a few comments below -- especially about the behavior of beginTransaction...
| assertThrown( IllegalStateException.class, getMutinySessionFactory() | ||
| .withTransaction( s -> s | ||
| .persist( beneath ) | ||
| .call( s::flush ) | ||
| // Close the connection before committing | ||
| .call( s::close ) | ||
| ) | ||
| ) | ||
| .invoke( e -> assertThat( e ) | ||
| .hasMessageContaining( "HR000090" ) | ||
| .hasMessageContaining( "closing the connection" ) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you assert that there is no active connection after this? Since that was the main problem :)
...reactive-core/src/test/java/org/hibernate/reactive/NoLiveTransactionValidationErrorTest.java
Show resolved
Hide resolved
hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/SqlClientConnection.java
Outdated
Show resolved
Hide resolved
hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/SqlClientConnection.java
Outdated
Show resolved
Hide resolved
hibernate-reactive-core/src/main/java/org/hibernate/reactive/pool/impl/SqlClientConnection.java
Outdated
Show resolved
Hide resolved
968dc36 to
234f0cd
Compare
There should not be any open transaction in progress when closing a connection. The risk is to leave open connections pending and exhaust the pool. Now, if the close operation detects an open transaction, it will roll back it and throw a validation error before closing the connection.
234f0cd to
ebd9ea5
Compare
Fix #2926
There are two places where we check if a transaction is already open:
SqlConnection#beginTransaction()andSqlConnection#close()The open transaction will be roll backed in both cases.
I wasn't sure how to recreate the Quarkus use case using only Hibernate Reactive, but I tested it locally and this solution fixes the problem.