-->
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.  [ 5 posts ] 
Author Message
 Post subject: SQLServer temp_db table locking due to Hibernate transaction
PostPosted: Fri Jul 01, 2005 2:29 pm 
Newbie

Joined: Fri Jul 01, 2005 12:51 pm
Posts: 1
Hibernate version:
2.1.8

Mapping documents:
This is a big application, and there are 22 of them. The problem isn't particular to any operation on any particular data object, so omitting them for brevity's sake.

Code between sessionFactory.openSession() and session.close():
Here's a brief example method (using the ThreadLocal HibernateUtil class)
Code:
public List getAllAuthors() throws FacadeException
{
    try
    {
        Session session = HibernateUtil.currentSession();

        Query allAuthorsQuery = session.createQuery("from AllAuthor as aa where aa.uni != '' order by aa.lastName asc");

        return allAuthorsQuery.list();
    }
    catch (HibernateException e)
    {
        log.warn(e);

        try
        {
            HibernateUtil.closeSession();
        }
        catch (HibernateException e2)
        {
            log.warn("Caught exception trying to close session.", e2);
        }

        throw new FacadeException(e);
    }
}


Full stack trace of any exception that occurs:
N/A

Name and version of the database you are using:
MS SQL Server, jtds-0.9.1.jar

problem description:

Our problem isn't with the functionality of Hibernate, it's that Hibernate, according to the DBA we're working with (our access to the db itself is limited), is creating locks in the table temp_db that remain for at least an hour and that interfere with her administration of the db. Apparently, according to her description, it seems that these locks are related to PreparedStatements somehow. We've attempted to address the solution by changing from DBCP to C3P0 and configuring it to not pool prepared statements:

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">30</property>
<property name="hibernate.c3p0.timeout">100</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.validate">false</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.cache.use_query_cache">false</property>
<property name="hibernate.c3p0.max_statements">0</property>

We weren't initally having the trouble with the production version of the database, but it has arisen after a few months of the application being in production. We've heard no reports of any similar problems from the DBA of our ordinary database, which is DB2/Solaris. Any insight anyone could offer as far as resources that Hibernate may secure during normal operation that may create locks that prevent other operations on the database would be helpful.
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 11:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
are you *certain* that the sessions are getting closed?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 11:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Also, where are your transactions being controlled? I don't see any such code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 18, 2005 12:18 pm 
Newbie

Joined: Mon Jul 18, 2005 12:13 pm
Posts: 1
Provided you are closing the sessions as Steve suggested, try updating the jtds driver to v1.1. I have seen this behavior with jtds v1.0.3 and prior, but seems to be "fixed" in 1.1, although no listed bug appears to be directly related to the issue.

-C


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 11:18 am 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
cped wrote:
Provided you are closing the sessions as Steve suggested, try updating the jtds driver to v1.1. I have seen this behavior with jtds v1.0.3 and prior, but seems to be "fixed" in 1.1, although no listed bug appears to be directly related to the issue.


Updating jTDS to the latest version will fix the problem. tempdb is used by earlier versions because prepared statements were by default creating temporary stored procedures to "prepare" the query. jTDS 1.1 uses sp_prepare and sp_execute by default (you can still switch to 3 other modes, read the jTDS FAQ for more detailed information); this doesn't use tempdb and isn't affected by transaction rollbacks.

Alin,
The jTDS Project.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.