|
|
Hibernernate 3.2 with Spring 2.0 deadlock
When starting our application using new Spring 2.0 tomcat hangs while initializing the application (Thread dump follows). However, this does not happen all the time, but overall, performance with newer versions of hibernate (beyond 3.0.5) seems to be very unstable, resources aren't freed and idle connections aren't reused under some cisrcumstances. Maybe one reason for this is that we use jrockit.
The thread dump of the deadlock:
quot;Main Threadquot; id=1 idx=0x2 tid=4095 prio=5 alive, in native, waiting -- Waiting for notification on: com/mchange/v2/resourcepool/BasicResourcePool@0x9ccc698[fat lock] at jrockit/vm/Threads.waitForSignal(J)Z(Native Method) at java/lang/Object.wait(J)V(Native Method) at com/mchange/v2/resourcepool/BasicResourcePool.awaitAvailable(J)V(BasicResource Pool.java:998) at com/mchange/v2/resourcepool/BasicResourcePool.checkoutResource(J)Ljava/lang/Object;(BasicResourcePool.java:293) ^-- Lock released while waiting: com/mchange/v2/resourcepool/BasicResourcePool@0x9ccc698[fat lock]
at com/mchange/v2/c3p0/impl/C3P0PooledConnectionPool.checkoutPooledConnection( )Ljavax/sql/PooledConnection;(C3P0PooledConnectionPool.java:34 8) at com/mchange/v2/c3p0/PoolBackedDataSource.getConnection()Ljava/sql/Connection;(PoolBackedDataSource.java:120) at com/mchange/v2/c3p0/ComboPooledDataSource.getConnection()Ljava/sql/Connection;(ComboPooledDataSource.java:601) at org//orm/hibernate3/LocalDataSourceConnectionProvider.getConnection()L java/sql/Connection;(LocalDataSourceConnectionProvider.java :81) at
First check the c3p0 forum and see if there are any issues with jrockit. What strategy are you using for closing connections? Hibernate 3.1 changed the default connection release strategy (hib_docs/v3...tion-optional). - table 3.7.
Originally Posted by Costin LeauFirst check the c3p0 forum and see if there are any issues with jrockit. What strategy are you using for closing connections? Hibernate 3.1 changed the default connection release strategy (hib_docs/v3...tion-optional). - table 3.7.
We are pretty sure that it has anything to do with the release of connections.
We are using OpenSessionInViewFilter configured in the web.xml:Code:
lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt;
lt;web-app id=quot;WebApp_IDquot; version=quot;2.4quot; xmlns=quot;xml/ns/j2eequot; xmlns:xsi=quot;2001/XMLSchema-instancequot; xsi:schemaLocation=quot;xml/ns/j2ee xml/ns/j2ee/web-app_2_4.xsdquot;gt;
lt;servletgt;
lt;servlet-namegt;pageDispatcherlt;/servlet-namegt;
lt;servlet-classgt;org..web.servlet.DispatcherServletlt;/servlet-classgt;
lt;init-paramgt;
lt;param-namegt;debuglt;/param-namegt;
lt;param-valuegt;0lt;/param-valuegt;
lt;/init-paramgt;
lt;init-paramgt;
lt;param-namegt;listingslt;/param-namegt;
lt;param-valuegt;falselt;/param-valuegt;
lt;/init-paramgt;
lt;load-on-startupgt;1lt;/load-on-startupgt;
lt;/servletgt;
lt;servlet-mappinggt;
lt;servlet-namegt;pageDispatcherlt;/servlet-namegt;
lt;ucl-patterngt;*.htmllt;/ucl-patterngt;
lt;/servlet-mappinggt;
lt;servlet-mappinggt;
lt;servlet-namegt;pageDispatcherlt;/servlet-namegt;
lt;ucl-patterngt;*.phplt;/ucl-patterngt;
lt;/servlet-mappinggt;
lt;listenergt;
lt;listener-classgt;org..web.context.ContextLoaderListenerlt;/listener-classgt;
lt;/listenergt;
lt;filtergt;
lt;filter-namegt;OpenSessionInViewFilterlt;/filter-namegt;
lt;filter-classgt;org..orm.hibernate3.support.OpenSessionInViewFilterlt;/filter-classgt;
lt;init-paramgt;
lt;param-namegt;singleSessionlt;/param-namegt;
lt;param-valuegt;truelt;/param-valuegt;
lt;/init-paramgt;
lt;/filtergt;
lt;filter-mappinggt;
lt;filter-namegt;OpenSessionInViewFilterlt;/filter-namegt;
lt;servlet-namegt;pageDispatcherlt;/servlet-namegt;
lt;/filter-mappinggt;
lt;error-pagegt;
lt;exception-typegt;java.lang.Exceptionlt;/exception-typegt;
lt;locationgt;/error.htmllt;/locationgt;
lt;/error-pagegt;
lt;error-pagegt;
lt;error-codegt;404lt;/error-codegt;
lt;locationgt;/error.htmllt;/locationgt;
lt;/error-pagegt;
lt;/web-appgt;
We are pretty sure that it has anything to do with the release of connections.
Then play around with the different connection releasing types - for example use after_transaction. See the LocalSessionFactoryBean javadoc for more information.
Originally Posted by Costin LeauThen play around with the different connection releasing types - for example use after_transaction. See the LocalSessionFactoryBean javadoc for more information.
Thx a lot for your help, we will do this.
Ok we figured out what happened:
We used an index.jsp to forward to our main page if anybody typed in the ucl without a file name. The effect was, that the OpenSessionInViewFilter wasn't executed, therefore the connections wheren't bound to the thread and wheren't closed.
With hibernate 3.0 this wasn't a big problem, since this did not happen pretty often and somehow the connections where closed sometimes.
But hibernate 3.1 held the connections indefenitely, which blocked our data base.
This is just for the record and a warning to everybody:
DO NOT USE JAVA FORWARDS WITH OpenSessionInViewFilter!
Thx for the help! |
|