Hi guys,
We have a stand alone Java application that uses Hibernate. Lately during some tests I have started seeing threads getting stuck doing calls to QueryPlanCache. Basically what happens is that one thread reaches the Commons Collections method ReferenceMap.purge(), and goes into what looks like an infinite loop. The CPU gets pegged at 100%. All the other threads in the app in turn are blocked waiting for the purge operation to finish, which never happens. A thread dump is attached at the end of the post.
I've not been able to consistently replicate this. My tests usually run for a couple of hours and sometime during the run the app gets stuck, but it doesn't seem to be caused by a specific event. The application uses a lot of memory, ~2 GB, so it might have something to do with garbage collection or the virtual machine. I doubt it's an actual problem with Hibernate or even a bug in Commons collections.
Has anybody seen something like this? Are there any workarounds or anything else I should look out for? Any ideas or thoughts are appreciated. Thanks!
/ Per
Hibernate version:
3.1
Commons collections 3.1
Sun JDK 1.5.0_07
Mapping documents:
<?xml version='1.0' ?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<!-- db connection -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@(DESCRIPTION=...</property>
<property name="hibernate.connection.username">...</property>
<property name="hibernate.connection.password">...</property>
<!-- connection pooling -->
<property name="hibernate.c3p0.max_size">7</property>
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.timeout">1800</property>
<!-- can idle 1800 secs before being deleted -->
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">600</property>
<!-- test idle connection very 600 secs -->
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.validate">false</property>
<!-- see idle_test_period -->
<!-- other db settings -->
<property name="hibernate.show_sql">false</property>
<property name="max_fetch_depth">4</property>
<property name="hibernate.jdbc.batch_size">10</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- cache configuration -->
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.cache.use_minimal_puts">false</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
...
</session-factory>
</hibernate-configuration>
Thread dump:
"T-1" prio=1 tid=0x088eade8 nid=0x6d91 runnable [0x3d0fe000..0x3d0ff030]
at org.apache.commons.collections.ReferenceMap.purge(ReferenceMap.java:461)
at org.apache.commons.collections.ReferenceMap.purge(ReferenceMap.java:447)
at org.apache.commons.collections.ReferenceMap.get(ReferenceMap.java:517)
at org.hibernate.util.SimpleMRUCache.get(SimpleMRUCache.java:24)
- locked <0x471ef518> (a org.hibernate.util.SimpleMRUCache)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:65)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
"T-2" prio=1 tid=0x085ce820 nid=0x6d92 waiting for monitor entry [0x3d07d000..0x3d07e0b0]
at org.hibernate.util.SimpleMRUCache.get(SimpleMRUCache.java:24)
- waiting to lock <0x471ef518> (a org.hibernate.util.SimpleMRUCache)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:65)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
Name and version of the database you are using:
Oracle 10G
|