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

Warning JDBC resources leaked when executing StoredProcedureQuery #13273

Closed
paschm opened this issue Nov 13, 2020 · 6 comments
Closed

Warning JDBC resources leaked when executing StoredProcedureQuery #13273

paschm opened this issue Nov 13, 2020 · 6 comments
Assignees
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working

Comments

@paschm
Copy link

paschm commented Nov 13, 2020

Describe the bug
For legacy reasons we are using stored procedures in a Oracle DB. We are calling this procedures over an JPA EntityManager ( EntityManager#createStoredProcedureQuery(String) and StoredProcedureQuery#execute() ). This leads to follow warnings

2020-11-13 10:30:39,440 WARN  [io.agr.pool] (executor-thread-1) Datasource '<default>': Closing open connection prior to commit
2020-11-13 10:30:39,441 WARN  [io.agr.pool] (executor-thread-1) Datasource '<default>': JDBC resources leaked: 0 ResultSet(s) and 1 Statement(s)

As it seems upon execution a CallableStatement gets prepared and tracked in io.agroal.pool.wrapper.ConnectionWrapper.prepareCall(String) . However upon commit of the transaction this CallableStatment isn't closed and therefore doesn't get untracked. When the connection is closed, this results in an open tracked statement in ConnectionWrapper#closeTrackedStatements(), which results in the appropriate JdbcResourcesLeakReport and the warnings. A real resource leak imho doesn't exist, as this CallableStatment is closed in this method.

Expected behavior
When executing a StoredProcedureQuery the prepared CallableStatement gets closed upon commit of the transaction.

Actual behavior
The CallableStatement doesn't get closed upon commit of the transaction, which leads to an open tracked statement when closing the connection.

To Reproduce

Maven project to reproduce:
code-with-quarkus.zip

Script for stored procedure:
procedure.zip

Steps to reproduce the behavior:

  1. Create procedure in Oracle DB
  2. Modify user, pass and url in application.yml
  3. mvn test

Environment (please complete the following information):

  • Quarkus version: 1.9.2.Final
  • Oracle Database 11g Enterprise Edition Release 11.2.0.4.0
@paschm paschm added the kind/bug Something isn't working label Nov 13, 2020
@ghost ghost added the triage/needs-triage label Nov 13, 2020
@gsmet
Copy link
Member

gsmet commented Nov 13, 2020

/cc @barreiro @Sanne

@gsmet gsmet added area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE and removed triage/needs-triage labels Nov 13, 2020
@Sanne
Copy link
Member

Sanne commented Nov 13, 2020

Interesting. In my experience, Agroal is typically right - we're probably leaking a callable in ORM.

@Sanne
Copy link
Member

Sanne commented Nov 13, 2020

@paschm
Copy link
Author

paschm commented Dec 7, 2020

This even seems to be an issue in the spec

jakartaee/persistence#162

The workaround

Unwrapping and calling getOutputs().release() work as a workaround.

works. The tracked statement is released, before the connection is closed and the leakage warning disappears.

WARN [io.agr.pool] (executor-thread-1) Datasource '<default>': Closing open connection prior to commit

still persists.

@yrodiere
Copy link
Member

yrodiere commented Jan 8, 2021

I believe this would be solved by #7242 if we were to set PhysicalConnectionHandlingMode to DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION by default. See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/HHH-14326 .

There are, however, other aspects to this change, so I'll let the discussion continue on #7242.

@yrodiere yrodiere self-assigned this Jan 14, 2021
yrodiere added a commit to yrodiere/quarkus that referenced this issue Jan 14, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Jan 14, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Jan 21, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Feb 5, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Feb 10, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Feb 22, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Feb 22, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
yrodiere added a commit to yrodiere/quarkus that referenced this issue Feb 22, 2021
Signed-off-by: Yoann Rodière <yoann@hibernate.org>
@yrodiere
Copy link
Member

Fixed in #14305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM area/persistence OBSOLETE, DO NOT USE kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants