javablocked-threads

Java Stack Dump - waiting to lock


We use a java 1.4 on our JSP web app and from time to time our web app comes to a complete halt. When users try to access the home page they get page cannot be found.

When this occurs we run a stack dump and using samurai I can see several blocked threads with the same message

at java.util.Collections$SynchronizedMap.get(Collections.java:1942)      
- waiting to lock <0x23e40898> (a 
java.util.Collections$SynchronizedMap)      at 
org.hibernate.tuple.EntityModeToTuplizerMapping.getTuplizerOrNull(EntityModeToTuplizerMapping.java:53)      at 
org.hibernate.tuple.EntityModeToTuplizerMapping.getTuplizer(EntityModeToTuplizerMapping.java:66)      at 
org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)      at 
org.hibernate.type.ComponentType.toLoggableString(ComponentType.java:379)      at 
org.hibernate.pretty.MessageHelper.infoString(MessageHelper.java:89)      at 
org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1355)      at 
org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308)      at org.hibernate.loader.Loader.getRow(Loader.java:1206) 
     at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)      at 
org.hibernate.loader.Loader.doQuery(Loader.java:701)      at 
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)      at 
org.hibernate.loader.Loader.doList(Loader.java:2220)      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104) 
     at org.hibernate.loader.Loader.list(Loader.java:2099)      at 
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)      at 
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)      at 
org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)      at 
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)      at 
org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)      at
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)      at 
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)      at
org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)

How can I identify what is holding this thread up. Is there any tool i can use to identify this?

Thanks


Hi Mprivat, Thanks a lot. I will take this to our architect too see if we can have this upgrade done. Since this is taking only happening every once and a while, it will take some time to see if this was the cause. I will feedback in a few months time as only time could tel. thanks a lot


Solution

  • Prepending to my previous answer based on additional research:

    Sounds like you are using a Hibernate version older than 3.2.6 (where they addressed this defect). Defect ID: HHH-2645

    http://lists.jboss.org/pipermail/hibernate-issues/2008-February/009043.html


    Normally, you should be able to match the "waiting to lock <0x23e40898>" messages with a "setting lock <0x23e40898>" message (spelling may wary). Do a complete stack dump (you can use jstack by the way, it's standard with the JDK), and search for your lock ID. You'll see a bunch of waits, but also the thread that sets it.