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

New ManagedConnection locking does not play nicely with transaction interleaving

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • JBossAS-5.0.0.CR2
    • JBossAS-5.0.0.CR1, JBossAS-4.2.3.GA
    • JCA service
    • None
    • Workaround Exists
    • Hide

      You can workaround this issue by turning off transaction interleaving in jms-ds.xml
      (or whether you've defined your jms connector deployment)

      <track-connection-by-tx/>

      Show
      You can workaround this issue by turning off transaction interleaving in jms-ds.xml (or whether you've defined your jms connector deployment) <track-connection-by-tx/>

    Description

      The new locking in the jms resource adapter to avoid race conditions between the asynch rollback
      and the normal usage is not playing nicely with transaction interleaving.

      When we are using transaction interleaving, there is no such race condition because the "normal usage"
      has already been suspended and the managed connection (for normal usage) given to another transaction.

      In fact, the new locking in this case could cause over contention because besides the lock being irrelevant,
      it could actually cause the real current usage of the managed connection to block.

      The problem has actually first show up as incorrect release of the lock:

      java.lang.IllegalMonitorStateException
      at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:125)
      at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1137)
      at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:431)
      at org.jboss.resource.adapter.jms.JmsManagedConnection.unlock(JmsManagedConnection.java:401)
      at org.jboss.resource.adapter.jms.JmsXAResource.commit(JmsXAResource.java:102)
      at org.jboss.resource.connectionmanager.xa.JcaXAResourceWrapper.commit(JcaXAResourceWrapper.java:53)
      at com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord.topLevelCommit(XAResourceRecord.java:502)
      at com.arjuna.ats.arjuna.coordinator.BasicAction.doCommit(BasicAction.java:3107)
      at com.arjuna.ats.arjuna.coordinator.BasicAction.doCommit(BasicAction.java:3022)
      at com.arjuna.ats.arjuna.coordinator.BasicAction.phase2Commit(BasicAction.java:2126)
      at com.arjuna.ats.arjuna.coordinator.BasicAction.End(BasicAction.java:1819)
      at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:88)
      at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)

      but this is really a symptom of taking the lock unnecessarily/wrongly in the first place
      when somebody else should really own it.

      The fix would be to spot that we are transaction interleaving by keeping track of the "active" xid in
      JmsXAResource wrapper and only doing the locking in the 2PC callbacks if we are the active xid.

      The active xid is defined as the one on which start() has been invoked but not end().

      For completeness, the same fix is also required in the jdbc xa resource adapter,
      but none of the current commercial xa datasources actually support transaction interleaving
      so it is not really an issue there.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: