Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-5040

Locked entities won't be released correctly after transaction timeout

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • JBossAS-4.2.2.GA
    • None

    Description

      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");

      Attachments

        Activity

          People

            adrian.brock Adrian Brock (Inactive)
            cmichels_jira Christian Michels (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: