]
Adrian Brock closed JBAS-5040.
------------------------------
Resolution: Rejected
What you describe is a self deadlock and can never work regardless of transaction
timeout.
Locking is by transaction not thread.
ejb1 (lock entity - tx1) -> RequiresNew/UserTransaction -> ejb2 (try to lock entity
- tx2) -> deadlock
tx2 cannot lock the entity because tx1 holds the lock.
tx1 cannot release the lock because it won't complete until tx2 completes.
Please use the forums to ask for help before raising bug reports.
We used to check for self deadlocks but that introduced spurious reports of deadlock
when mulitple clients use remote user tranasctions but share the same pooled
server threads during their requests.
Locked entities won't be released correctly after transaction
timeout
---------------------------------------------------------------------
Key: JBAS-5040
URL:
http://jira.jboss.com/jira/browse/JBAS-5040
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Transaction Manager
Affects Versions: JBossAS-4.2.2.GA
Reporter: Christian Michels
Assigned To: Adrian Brock
When locking an entity in a (outer) user transaction and trying to lock the same entitity
in a inner transaction (with a smaller txTimeout), the entity will not be released, if the
inner transaction timed out.
The entity won't be released until the outer transaction timed out.
With JBoss 4.0.4, the inner transaction rollback will be resolved after a short while:
18:56:14,237 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257,
GlobalId=PCTR694/17, BranchQual=, localId=17] timed out. status=STATUS_ACTIVE
18:56:17,237 ERROR [BeanLock] Thread[RMI TCP Connection(2)-172.22.6.85,5,RMI Runtime]Saw
rolled back tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=PCTR694/17, BranchQual=,
localId=17] waiting for txLock
18:56:17,237 ERROR [LogInterceptor] TransactionRolledbackException in method: public
abstract void kam.jbosstest.transactionlocking.LockedEntityEJBRemote.loadIntoTransaction()
throws java.rmi.RemoteException, causedBy:
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
...
e.g.
EntityLockingEJBHome entityLockingHome = (EntityLockingEJBHome)
ctx.lookup("EntityLockingEJB");
kam.jbosstest.transactionlocking.EntityLockingEJBRemote entityLockingRemote =
entityLockingHome.create();
LockedEntityEJBHome lockedEntityHome =
(LockedEntityEJBHome) ctx.lookup("LockedEntityEJB");
LockedEntityEJBRemote entity = null;
try {
entity = lockedEntityHome.findByPrimaryKey(1);
} catch (FinderException e) {
throw new Exception(e);
}
UserTransaction ut = (UserTransaction) ctx.lookup("UserTransaction");
ut.setTransactionTimeout(10);
System.out.println("Starting transaction (timeout=10s)...");
Date start = new Date(System.currentTimeMillis());
ut.begin();
System.out.println("Date:" + start);
System.out.println("...locking entity in client context...");
entity.loadIntoTransaction();
try{
System.out.println("...trying to lock the same entity in a new transaction with 2s
txTimeout...");
entityLockingRemote.lockResource(1, 2);
}catch(Exception e){
e.printStackTrace();
}
Date end = new Date(System.currentTimeMillis());
System.out.println("Application was locked for: " + (end.getTime() -
start.getTime()) + "ms instead of about 2s");
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: