Skip to content

Conversation

@DavideD
Copy link
Member

@DavideD DavideD commented Dec 18, 2025

Fix #2926

There are two places where we check if a transaction is already open: SqlConnection#beginTransaction() and SqlConnection#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.

* Rename variable "rollback" to "markedForRollback"
* Change formattation
@DavideD DavideD added this to the 4.2.1.Final milestone Dec 18, 2025
@DavideD DavideD requested a review from yrodiere December 18, 2025 18:57
@DavideD DavideD added bug Something isn't working 4.2 ORM 7.2 and Vert.x 5.0 quarkus The issue links an issue in Quarkus labels Dec 18, 2025
Copy link
Member

@yrodiere yrodiere left a 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...

Comment on lines +110 to +135
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" )
)
Copy link
Member

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 :)

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.
@DavideD DavideD merged commit 58354ea into hibernate:main Dec 19, 2025
22 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.2 ORM 7.2 and Vert.x 5.0 bug Something isn't working quarkus The issue links an issue in Quarkus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Roll back live transaction when closing the connection

2 participants