--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/0f3d164f-c4e4-45b1-9637-250765cbac0dn%40googlegroups.com.
Hmm, I don't think so, at least we're not the ones closing the connection. All connections and transactions in this stack trace are container managed and the delete method just deletes an entity. It doesn't touch the connection.
Good point. Is this a problem that only occurs under (multiple
requests on multiple threads) load? I think the error means that
the database connection was already returned to the database
connection pool which implies that the connection was already
previously closed.
What else could it be? Should I log or debug something?
Sure, logging can help give context as to what might be going
on. Take a look at
https://docs.wildfly.org/30/Developer_Guide.html#troubleshooting
for enabling TRACE logging for org.jboss.as.jpa (and setting TRACE
for console-handler). Every Persistence/JPA call will be logged
including some of the transaction interaction. Mostly, you will
be interested in the org.jboss.as.jpa log output that precedes the
unexpected "java.lang.IllegalStateException: IJ000152: Trying to
return an unknown connection" and I think understanding why the
database connection was already closed.
Scott
--On Monday, February 26, 2024 at 5:00:44 PM UTC+1 Scott Marlow wrote:
I think your application is calling flush after the database connection has already been closed:
deployment.redacted.ear.redacted-ejb.jar//at.redacted.redacted.service.OneServiceBean.delete(OneServiceBean.java:369)
On Fri, Feb 23, 2024 at 4:20 AM M K <mko...@gmail.com> wrote:
Hi,
we have migrated our application from WildFly 10 to WildFly 30, Hibernate 5 to Hibernate 6.4 and Java 8 to Java 17 over the last year. We're seeing the following INFO message quite often in our server.logs:
INFO [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (default task-10) IJ000311: Throwable from unregister connection: java.lang.IllegalStateException: IJ000152: Trying to return an unknown connection: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@6ca4f174
I have attached the full stack trace.
Does anyone know what it is about, if it is a reason to worry, what our best course of action is?
Thank you very much in advance!Greetings,Manuel K.
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/0f3d164f-c4e4-45b1-9637-250765cbac0dn%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/27b0393d-7120-40ba-84dc-499f0e5cf445n%40googlegroups.com.
I enabled JPA and Hibernate logging, but I'm none the wiser:
2024-02-27 12:05:19,927 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (default task-1) Executing flush
2024-02-27 12:05:19,927 TRACE [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl] (default task-1) Starting after statement execution processing [AFTER_STATEMENT]
2024-02-27 12:05:19,927 TRACE [org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor] (default task-1) LogicalConnection#afterStatement
2024-02-27 12:05:19,927 DEBUG [org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl] (default task-1) Initiating JDBC connection release from afterStatement
2024-02-27 12:05:19,927 TRACE [org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl] (default task-1) Releasing JDBC resources
2024-02-27 12:05:19,927 DEBUG [org.hibernate.orm.jdbc.batch] (default task-1) PreparedStatementDetails did not contain PreparedStatement on #releaseStatements : update [...]
2024-02-27 12:05:19,927 TRACE [org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl] (default task-1) Starting after statement execution processing [AFTER_STATEMENT]
2024-02-27 12:05:19,927 TRACE [org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor] (default task-1) LogicalConnection#afterStatement
2024-02-27 12:05:19,927 DEBUG [org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl] (default task-1) Initiating JDBC connection release from afterStatement
2024-02-27 12:05:19,927 INFO [org.jboss.jca.core.connectionmanager.listener.TxConnectionListener] (default task-1) IJ000311: Throwable from unregister connection: java.lang.IllegalStateException: IJ000152: Trying to return an unknown connection: org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@42bcc16b
2024-02-27 12:05:19,929 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (default task-1) Post flush
2024-02-27 12:05:19,929 TRACE [org.jboss.as.jpa] (default task-1) flush took 74ms
2024-02-27 12:05:19,929 DEBUG [org.jboss.as.jpa] (default task-1) default task-1:transaction scoped EntityManager [redacted.ear/redacted-ejb.jar#redacted]: reuse entity manager session already in tx Local transaction (delegate=TransactionImple < ac, BasicAction: 0:ffffac1b7001:1f5a4bce:65ddc110:db1 status: ActionStatus.RUNNING >, owner=Local transaction context for provider JBoss JTA transaction provider)
2024-02-27 12:05:19,929 TRACE [org.hibernate.event.internal.AbstractFlushingEventListener] (default task-1) Flushing session
2024-02-27 12:05:19,929 DEBUG [org.hibernate.event.internal.AbstractFlushingEventListener] (default task-1) Processing flush-time cascades
Do you see anything? It's using the same EntityManager and Transaction before the exception and after the exception.
I also debugged the IronJacamar CachedConnectionManagerImpl class, and when the exception occurs a different connection is found in the map, so the connection to be unregistered is not removed and the exception is logged. I couldn't figure out how this happens, there are just too many calls.
Does the "redacted" persistence unit definition
(in persistence.xml) have any persistence unit hints specified
that could impact connection release behavior?
You can also enable TRACE logging for org.jboss.jca which should show more information.
Scott
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/7d2c0f19-a93f-420f-a22a-e0127dbb3affn%40googlegroups.com.
Thank you for your reply!
No, we don't have anything related to connections in our persistence.xml.
I already enabled the TRACE logging for org.jboss.jca after wring my reply, but did not gain any new insights. Here is the output:
I wonder if Hibernate ORM is using the JTA transaction. Does the
persistence.xml specify transaction-type="RESOURCE_LOCAL" or
transaction-type="JTA"?
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/f940801c-e536-43f0-aba8-1e0055c86da6n%40googlegroups.com.
It's not specified at all, that probably means JTA. I have attached our persistence.xml so you can check if there's anything suspect.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/58c84486-9da3-4544-83a4-752d894e67e7n%40googlegroups.com.
It's not specified at all, that probably means JTA. I have attached our persistence.xml so you can check if there's anything suspect.
I don't see anything the in the persistence.xml that seems
related.
I looked again at the first exception call stack that you attached which I'm pasting part of here because I think we should explore why flush was called:
"
INFO
[org.jboss.jca.core.connectionmanager.listener.TxConnectionListener]
(default task-10) IJ000311: Throwable from unregister connection:
java.lang.IllegalStateException: IJ000152: Trying to return an
unknown connection:
org.jboss.jca.adapters.jdbc.jdk8.WrappedConnectionJDK8@6ca4f174
at
org.jboss.iro...@3.0.4.Final//org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManagerImpl.unregisterConnection(CachedConnectionManagerImpl.java:408)
at
org.jboss.iro...@3.0.4.Final//org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.connectionClosed(TxConnectionListener.java:645)
at
org.jboss.ironjac...@3.0.4.Final//org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.returnHandle(BaseWrapperManagedConnection.java:629)
at
org.jboss.ironjac...@3.0.4.Final//org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:574)
at
org.jboss.ironjac...@3.0.4.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.returnConnection(WrappedConnection.java:307)
at
org.jboss.ironjac...@3.0.4.Final//org.jboss.jca.adapters.jdbc.WrappedConnection.close(WrappedConnection.java:265)
at
org.hi...@6.4.1.Final//org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:127)
at
org.hi...@6.4.1.Final//org.hibernate.internal.NonContextualJdbcConnectionAccess.releaseConnection(NonContextualJdbcConnectionAccess.java:64)
at
org.hi...@6.4.1.Final//org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:224)
at
org.hi...@6.4.1.Final//org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.afterStatement(LogicalConnectionManagedImpl.java:156)
at
org.hi...@6.4.1.Final//org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.afterStatementExecution(JdbcCoordinatorImpl.java:280)
at
org.hi...@6.4.1.Final//org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.flushEnding(JdbcCoordinatorImpl.java:147)
at
org.hi...@6.4.1.Final//org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:367)
at
org.hi...@6.4.1.Final//org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:41)
at
org.hi...@6.4.1.Final//org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at
org.hi...@6.4.1.Final//org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1423)
at
org.hi...@6.4.1.Final//org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1409)
at
org.jbos...@30.0.1.Final//org.jboss.as.jpa.container.AbstractEntityManager.flush(AbstractEntityManager.java:445)
at
deployment.redacted.ear.redacted-ejb.jar//at.redacted.redacted.service.OneServiceBean.delete(OneServiceBean.java:369)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
"
You mentioned that the OneServiceBean.delete() is deleting
something. I'm not concerned about the delete as much as whether
you can confirm that line 369 in OneServiceBean.java is indeed
calling EntityManager.flush() as the exception call stack shows.
I think the flush call should work but I am concerned that there could be a bug that leads to the database connection being closed too early. Could you try again with the latest WildFly that includes Hibernate ORM 6.4.4.Final in case you are hitting a bug that has already been fixed. Download link would be https://github.com/wildfly/wildfly/releases/download/31.0.1.Final/wildfly-31.0.1.Final.zip
I tried recreating the failure locally with a modified WildFly
unit test that calls persist + flush a few times but could not.
https://github.com/scottmarlow/wildfly/tree/recreate_flush_connectionalreadyclosed
contains my attempt to recreate with "mvn install
-Dtest=org.jboss.as.test.integration.jpa.basic.entitymanagerfactorytest.EntityManagerFactoryTestCase".
Please let me know if the later WildFly release helps so I can delete my test branch and others know the issue was resolved.
If the problem recreates with WildFly 31.0.1.Final, we will need
to create a tracking https://issues.redhat.com/browse/WFLY issue
for this problem.
Scott
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/58c84486-9da3-4544-83a4-752d894e67e7n%40googlegroups.com.
Thank you Scott!
> I'm not concerned about the delete as much as whether you can confirm that line 369 in OneServiceBean.java is indeed calling EntityManager.flush() as the exception call stack shows.
Yes, I can confirm that EntityManager.flush() is being called explicitly.
> Could you try again with the latest WildFly that includes Hibernate ORM 6.4.4.Final in case you are hitting a bug that has already been fixed.
We are already using Hibernate ORM 6.4.4.Final with our WildFly 30.0.1.Final. Do you still think it makes sense to test it with WildFly 31.0.1.Final? It would take some time to get our application running on it.
Did you see the configuration attribute I found: https://docs.wildfly.org/30/wildscribe/subsystem/jca/cached-connection-manager/cached-connection-manager/index.html#attr-ignore-unknown-connectionsDo you know why it exists?
It would suppress the log message, but of course getting to the root of the problem seems more sensible.
+100
Can you want to start a https://issues.redhat.com/browse/WFLY
issue for this failure? There should be a forum link field that
could be set to this forum discussion (https://groups.google.com/d/msgid/wildfly/f2e42c23-3444-4412-ba57-74803ed64446n%40googlegroups.com).
Please do respond with the WFLY issue link here.
Thank you,
Scott
Thank you!GreetingsManuel
If the problem recreates with WildFly 31.0.1.Final?, we will need to create a tracking https://issues.redhat.com/browse/WFLY issue for this problem.
Scott
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/f2e42c23-3444-4412-ba57-74803ed64446n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/7ceff33f-f44a-41f8-97a6-c12d4c83c3a0n%40googlegroups.com.