We're updating the issue view to help you get more done. 

Connection leak with lazy load of references and Agroal

Description

When entityManager.getReference() method is invoked, the transaction interceptor (@Transactional) is executed and the commit is done but at this moment without involving any connection to the database.
After that, when a proxy fires a load event, it opens a connection and performs the query, but the close() method is never invoked causing the connection to remain active in the pool and never be released.

I have based my sample on projects of Hibernate repo. Following the example of hibernate-demo (cdi-jpa-testing) I made a sample project with Hibernate 5.4.2/5.4.3 and Agroal (test).
After running into connection leaks with "Arjuna TransactionalDriver", I tried with "hibernate-agroal" but using a custom AgroalConnectionProvider (enabling transaction integration) with same result.

Environment

  • windows 10

  • java 8 (1.8.0_201)

  • Hibernate 5.4.3 / 5.4.2

  • CDI 2 (Weld 3.1.0)

  • JPA

  • JTA

  • Hibernate-agroal 5.4.2/5.4.3 or Arjuna TransactionalDriver

  • Agroal with Narayana Transaction Integration

Status

Assignee

Unassigned

Reporter

Ariel Carrera

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.4.3
5.4.2

Priority

Major