-->
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.  [ 1 post ] 
Author Message
 Post subject: using multiple transactions in multiple sessions per thread
PostPosted: Thu Jun 01, 2006 12:22 pm 
Newbie

Joined: Thu Jun 01, 2006 10:25 am
Posts: 1
Location: Hessen/Germany
Hibernate version: 2.1

Name and version of the database you are using: MSSQL wit jtds drivers and JDBC transactions


Hi,

I want to use multiple sessions generated from the same database and session factory to implement a application locking table.

The locking table is used to block parts of my application from concurrent modification. It follows a quite simple approach: Fill the object key (primary key) of the object you want to lock into a database table.

To make the lock row visible to other applications (multiple servlets are accessing this database, all are using hibernate and all are using the same system-wide db-pool) it is required to have it created and removed in a seperate transaction.

I tried this using a standalone application that created two sessions and used the hibernate provided c3p0 pool. This worked as expected, no deadlocks.

Session A opens transaction accesses an instance of Object X.
Session B opens transaction and writes keyOf(X) to LockTable, this will fail if this key is already present (unique index). Session B commits transaction.

Session A works on X and persists X, transaction commits

Session B opens transaction removes keyOf(X) from LockTable

When doing this in my tomcat 5.5.9 container, where dbcp is used, Session B will hang in a deadlock when trying to write the lock. No exceptions are thrown. This seems to be a lock at the database level and I tried to debug the hibernate code just to find, that it seems that both sessions used the same connection object. Could this be the reason for this?

Did anyone else experience similar behaviour? I am currently also evaluating writing a locking service, that will be completely independent from applications requesting locks, but I do not know if this will kill my performance and it adds a single point of failure in the system.

Hoping for ideas,


Thomas

_________________
--
"No, you don't!", Jack Bauer to Nina in "24"


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

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.