Uploaded image for project: 'Hibernate ORM'
  1. HHH-10772

RuntimeException during releaseStatements causes JDBC connection not to be closed

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.1.0
    • Fix Version/s: 5.1.0, 5.2.0
    • Component/s: hibernate-core
    • Labels:
      None

      Description

      We have seen exceptions in production related to some misconfiguration of our Infinispan / JGroups clustering. Another story. What happened was an SQLException is thrown when Hibernate tried to release a ResultSet, this resulted in a RuntimeException (as the SQLException is rethrown as an UndeclaredThrowableException) and misses the connection.close() which leaves hanging connections and eventually connection starvation.

      What do you think about putting the connection.close() in JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:190) into a finally block?

      Here is the exception stacktrace that we are seeing that is causing this issue:

      java.lang.reflect.UndeclaredThrowableException
              at com.sun.proxy.$Proxy39.hashCode(Unknown Source)
              at java.util.HashMap.hash(HashMap.java:338)
              at java.util.HashMap.get(HashMap.java:556)
              at org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl.release(ResourceRegistryStandardImpl.java:76)
              at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.releaseStatements(AbstractBatchImpl.java:157)
              at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.release(AbstractBatchImpl.java:195)
              at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:190)
              at org.hibernate.internal.SessionImpl.close(SessionImpl.java:424)
              at com.xk72.hibernate.session.internal.AbstractHibernateSessionInvocationHandler.doClose(AbstractHibernateSessionInvocationHandler.java:230)
              at com.xk72.hibernate.session.internal.AbstractHibernateSessionInvocationHandler.actuallyClose(AbstractHibernateSessionInvocationHandler.java:218)
              at com.xk72.hibernate.session.internal.AbstractHibernateSessionInvocationHandler.invoke(AbstractHibernateSessionInvocationHandler.java:72)
              at com.sun.proxy.$Proxy66.actuallyClose(Unknown Source)
              at com.xk72.hibernate.session.internal.HibernateCurrentSessionProvider.completelyCloseCurrentSession(HibernateCurrentSessionProvider.java:157)
              at com.xk72.hibernate.session.internal.StandardHibernateSessionProvider.completelyCloseCurrentSession(StandardHibernateSessionProvider.java:82)
              at com.cactuslab.supermodel.utils.HibernateUtil.completelyCloseCurrentSession(HibernateUtil.java:65)
              at com.cactuslab.supermodel.web.SupermodelRootActionContext.doRootAction(SupermodelRootActionContext.java:152)
              at com.xk72.webparts.actions.ActionFilter.doFilter(ActionFilter.java:143)
              at com.xk72.webparts.actions.ActionFilter.doFilter(ActionFilter.java:69)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
              at com.cactuslab.supermodel.web.SupermodelFilter.doFilter(SupermodelFilter.java:58)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
              at com.xk72.webparts.csrf.CSRFFilter.doFilter(CSRFFilter.java:93)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
              at com.xk72.webparts.multipart.MultipartHttpFilter.doFilter(MultipartHttpFilter.java:31)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
              at com.xk72.webparts.RequestCharacterEncodingFilter.doFilter(RequestCharacterEncodingFilter.java:30)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
              at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
              at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:190)
              at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
              at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
              at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
              at java.lang.Thread.run(Thread.java:745)
      Caused by: java.sql.SQLException: Statement closed.
              at org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$StatementProxy.invoke(StatementDecoratorInterceptor.java:238)
              ... 47 more
      
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: