6 Replies Latest reply on Oct 25, 2001 10:49 PM by oravecz

    two phase commit?

    ceyhun_ozgun

      Hi all,

      I want to implement two phase commit with JBoss.
      Is this possible?
      Or what is required to do?
      Is only jdbc-driver issue or JBoss-oriented issue?
      Is Jboss supports it?

        • 1. Re: two phase commit?
          davidjencks

          The jboss transaction manager and both XADataSourceLoader and ConnectionFactoryLoader with the XA ConnectionManager support xa 2pc. Finding a driver that supports it properly without writing it yourself is another story. What resource managers are you using, what driver(s), specifically, are you trying to use, and which version of jboss are you using?

          • 2. Re: two phase commit?
            ceyhun_ozgun


            Hi,

            I am using JBoss 2.2.2
            I am Using jConnect JDBC driver for Sybase DB.
            I have succeeded in achieveing 2pc with different Sybase DB datasource defined on same JBoss server,
            but when I have deployed 2 different JBoss servers
            2 of them does not included in transaction together and 2pc was not worked.

            I have posted a message to ejb forum but nobody responded it.
            It's subject is 'transaction with external ejb-ref does not rolled back'

            Any idea?

            thanx

            • 3. Re: two phase commit?
              davidjencks

              This is really xa distributed transactions rather than 2pc. You need to upgrade to 2.4 and use the Tyrex distributed transaction manager. There is either a howto in the manual or you may need to search the dev archives for advice. The default jboss transaction manager does not handle distributed transactions, just 2pc for several resource managers all accessed from the same jboss instance.

              Normally distributed transactions are notoriously slow. You might consider trying to break your work up into multiple steps each of which can be executed in a transaction on one jboss instance, where one effect of the transaction is to send a (transacted) jms message to the server handling the next step, which does its work in a separate transaction, starting by fetching the jms message.

              • 4. Re: two phase commit?
                oravecz

                > I have succeeded in achieveing 2pc with different
                > Sybase DB datasource defined on same JBoss server,
                > but when I have deployed 2 different JBoss servers
                > 2 of them does not included in transaction together
                > and 2pc was not worked.

                How was this accomplished. We have two datasources (both Sybase) attempting to update within the same transaction, but our second connection is stalling because of the lock held by the first connection.

                -jim (Sybase also)

                • 5. Re: two phase commit?
                  davidjencks

                  Does the sybase driver really support 2pc, have an XADataSource, etc etc? If not, you are not really getting 2pc: jboss is pretending, but you are actually executing 2 independent transactions.

                  Even if you do have a true xa capable driver, it is not necessarily possible to access the same data through 2 different connection pools. (It might be...) If the XAResources from the 2 connections agree they are the same resource manager, the jboss transaction manager ought to give them both the same xid: Sybase should then recognize them as parts of the same transaction. If for some reason the XAResources cannot recognize themselves as being for the same resource manager, then Sybase would have to support tightly coupled distributed transaction branches (which basically means it has to analyse the xids and determine that they are both part of the same global transaction, rather than simply going by the xid's identity.) This is less likely than Sybase supporting 2pc.

                  Why do you need to access the same data through connections from 2 datasources in the same transaction?

                  • 6. Re: two phase commit?
                    oravecz

                    > Does the sybase driver really support 2pc, have an
                    > XADataSource, etc etc? If not, you are not really
                    > getting 2pc: jboss is pretending, but you are
                    > actually executing 2 independent transactions.

                    Yes, it really does: com.sybase.jdbc2.jdbc.SybXADataSource.

                    > Even if you do have a true xa capable driver, it is
                    > not necessarily possible to access the same data
                    > through 2 different connection pools. (It might
                    > be...)

                    I agree with you. Two separate connections from 2 different pools hopefully cannot obtain a write lock on the same data. But, IIUC, this should be possible in a 2PC situation, since the manager should be telling these two connections that "you are the same transaction", no?

                    > If the XAResources from the 2 connections
                    > agree they are the same resource manager, the jboss
                    > transaction manager ought to give them both the same
                    > xid: Sybase should then recognize them as parts of
                    > the same transaction.

                    I think we are struggling with a setup issue. We do not know how to specify the Xid.

                    > Why do you need to access the same data through
                    > connections from 2 datasources in the same
                    > transaction?

                    It's not exactly the same data. One connection is writing to table A, the other to table B. There is a db constraint between these two tables. We are implementing a cascading delete scenario (in code, not using triggers), and the two tables are in separate databases.

                    Thanks for the help so far, David. What we really need to see are examples. How do you set the Interbase drivers up for 2PC, or Oracle, or whatever. We have absolutely no direction from Sybase on how to set this up.

                    -jim