-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Getting deadlock error on brand new session. Why?
PostPosted: Wed May 10, 2006 12:20 pm 
Newbie

Joined: Thu Mar 16, 2006 1:12 pm
Posts: 10
All,

I have an application that creates a new session and attempts to achieve a pessimistic lock one a SINGLE item in the DB. Sometimes when I do this, I get the following exception:


Code:
2006-05-10 00:00:16,051 [http-0.0.0.0-20080-105] ERROR exception:org.hibernate.exception.GenericJDBCException: could not load an entity: [com.real.mediaengine.admin.data.HManager#47850]
        at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
        at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
        at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
        at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
        at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
        at org.hibernate.event.def.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:272)
        at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:90)
        at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
        at org.hibernate.impl.SessionImpl.load(SessionImpl.java:872)
        at org.hibernate.impl.SessionImpl.load(SessionImpl.java:867)
        at com.real.mediaengine.admin.ejb.commandHandlers.GetManagerUpdatesHandler.handleTaskAssignmentWork(GetManagerUpdatesHandler.java:154)
        at com.real.mediaengine.admin.ejb.commandHandlers.GetManagerUpdatesHandler.perform(GetManagerUpdatesHandler.java:79)
        at com.real.mediaengine.admin.ejb.commandHandlers.AdminCommandHandler.performCommand(AdminCommandHandler.java:52)
        at com.real.mediaengine.admin.ejb.MediaEngineAdminBeanImpl.performManagerAction(MediaEngineAdminBeanImpl.java:369)
        at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source)
Caused by: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource
        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
        at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
        at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
        at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)
        at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
        at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
        at org.hibernate.loader.Loader.doQuery(Loader.java:662)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
        ... 72 more


Please notice, in particular, the last few lines:
Code:
Caused by: java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource

        at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
        at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
        at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
        at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
        at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880)
        at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850)
        at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
        at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1669)
        at org.hibernate.loader.Loader.doQuery(Loader.java:662)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
        ... 72 more



This happens when I execute the following lines of code (this doesn't happen all the time - it happens rarely - but it happens - the exception is being thrown on the call to session.load():

Code:
Session session = HibernateUtil.getSession();
Transaction transaction = session.beginTransaction();
HManager manager = (HManager)session.load(HManager.class, managerId, LockMode.UPGRADE);



Here is my HibernateUtil class (very short):

Code:
package com.goober.mediaengine.admin.common;

import org.hibernate.*;
import org.hibernate.cfg.*;

public class HibernateUtil {

   private static final SessionFactory sessionFactory;
   
    static {
        try {
            Configuration cfg = new Configuration();
            sessionFactory = cfg.configure().buildSessionFactory();
            // SessionFactory is now in JNDI, see hibernate.cfg.xml
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            ex.printStackTrace(System.out);
            throw new ExceptionInInitializerError(ex);
        }
    }

   public static Session getSession() throws HibernateException {
      return sessionFactory.openSession();
   }
}


Basically, I'm creating a new session, and trying to obtain a pessimistic lock on a particular item. I know there are other threads out there that are trying to get a pessimistic lock on the same item - but since my session has no locks (yet), I don't see how I could possibly (even theoretically) get deadlock...

I am using hibernate 3.1.2 with an oracle database on the backend. I'm running under JBoss and using stateless session beans.

Is it possible that the session object that I "create" is being recycled by hibernate and not being "cleaned up" properly?

Any light you can shed would be extremely helpful.

Thanks,

-john


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 10, 2006 3:47 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
The ORACLE database detects the dedlock, therefore you need to find out what exactly caused that, then you will be able to trace it back to Hibernate or other parts of your system.

I suspect that Hibernate is not guilty.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.