4 Replies Latest reply on Dec 14, 2001 3:40 PM by Joel Cordonnier

    Deadlock with Oracle and Jboss 2.2.1

    Jose R. Diaz Newbie

      Hi,

      We have a Stateless bean with JBoss 2.2.1. This EJB makes deletes
      and updates of several rows, inserts and selects in a table, and selects
      in other three tables.
      That table is only accessed from that EJB. This EJB is called 5 or 6
      times/second. This table usually contains about 200 or 250 rows.
      Our problem is that Oracle is detecting deadlocks. If we access that
      table only from that EJB, isn´t it supposed to be serialized every
      transaction? Why is Oracle detecting a deadlock?
      We have configured the EJB as a container managed transaction. Would
      it be better to be a Bean managed transaction and to make the commits
      and rollback on our own explicitly?

      Thanks

      Jose R. Díaz

        • 1. Re: Deadlock with Oracle and Jboss 2.2.1
          Fusayuki Minamoto Apprentice

          Since I am also a WebLogic + Oracle user and had deadlocks with them, I'm interested in this issue.

          I can't believe default isolation level is serializable.
          Could you tell us yourtransaction attributes (all Required?) in ejb-jar.xml and pool configuration in jboss.jcml?

          And one more question. How did you detect the deadlock: SQLException, JBoss console or else?

          Miki

          • 2. Re: Deadlock with Oracle and Jboss 2.2.1
            Jose R. Diaz Newbie

            Hi,

            we have detected the deadlock in several ways: trace files in Oracle, and SQLException(ORA-00060).

            My EJB(1) is with transaction REQUIRED, it calls another three EJBs(they only performs reads) with MANDATORY transaction.

            If I make an Entity Bean for the table I can update from the EJB(1), would the performance go down? Now this EJB is called ~5 times/second, but probably it will raise to ~15 times/second in a few months.

            Thanks

            Jose R. Díaz

            • 3. Re: Deadlock with Oracle and Jboss 2.2.1
              Fusayuki Minamoto Apprentice

              >My EJB(1) is with transaction REQUIRED, it calls another three EJBs(they only performs reads) with MANDATORY transaction.

              The session transaction seems to be too long. In the transaction, it is involved with operatons to cause row lovel locks, such as insert, update and delete.

              If a sesion transaction conflicts other transactions caused by row locks, you may get the ORA-00060. They say we can avoid deadlocks by resource ordering. So review your code of session bean and find access pattern that causes deadlocks. This is my first advice, but I know this is difficult for complicated case as yours.

              My second advice is to redesign the transaction demarcation of your beans. This is an easier one.
              To make the updating transaction shorter, for example, you have some options to change the transaction attributes:

              1) Session: 'Required'
              Entity: 'RequiredNew'
              2) Session: 'NotSupported'
              Entity: 'Required'

              It depends on your requirement which is best option for you.

              >If I make an Entity Bean for the table I can update from the EJB(1), would the performance go down? Now this EJB is called ~5 times/second, but probably it will raise to ~15 times/second in a few months.

              If you access the bean in a transaction, it doesn't cost so much because the entity object is cached in the ejb server. If you follow my advice, however, the transactions of entity beans become shorter and ejbStore() is called at end of each transaction. Thus I say that again - it depends on the design of transactions.

              BMP is another option as you wrote in first message. My favorite combination is BMP + CMT. I usually make a session bean with 'Supports' or 'NotSupported' to list value objects from entities not to use finder methods.

              I'd like to hear JBoss expert's ideas.
              Correct me if my advice is inadequate.

              Miki

              • 4. Re: Deadlock with Oracle and Jboss 2.2.1
                Joel Cordonnier Newbie

                Hi !

                I have a similar problem with my BMP. It's seems that there is some problem woth Oracle XA transaction.

                I use the Xdoclet tags @ejb:transaction type="RequiresNew" for some methods of the bean remote interface, and after some times, the pool hang and I see the charges when the connection pool is closed !?

                Any idea ?
                /Joel