1 2 3 Previous Next 33 Replies Latest reply on Jul 30, 2008 12:16 PM by ruthbd Go to original post
      • 15. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

         

        "jhalliday" wrote:
        The JCA should return the connection to the pool on transaction termination. Having an app call close() on a connection handle does not necessarily put it back in the pool. The track-connection-by-tx setting plays a part too. Such matters are really better off being discussed in the JCA forum.


        Thanks, Jonathan. I can ask more questions in the JCA forum. Just one last thing for you, though - when using the "bridge" - when the BridgeParticipantAT gets a rollback() or commit() - that should terminate that transaction, causing JCA to return the connection to the pool, right?

        • 16. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
          jhalliday

          Assuming its previously been closed by the app, yes. My understanding of JCA behaviour when track-connection-by-tx is set is that it will release a connection back into the pool only when it thinks that both the app and the tx are done with it. If either close() has not been called or the tx is not terminated, the connection is not eligible for reuse.

          • 17. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

             

            "jhalliday" wrote:
            Assuming its previously been closed by the app, yes. My understanding of JCA behaviour when track-connection-by-tx is set is that it will release a connection back into the pool only when it thinks that both the app and the tx are done with it. If either close() has not been called or the tx is not terminated, the connection is not eligible for reuse.


            OK, from what I've traced in the app, Spring is definitely releasing the connection (actually, since Hibernate is in play, it seems to acquire/release for nearly every SQL statement .. that may need tuning!).

            The JCA trace logging does indicate that track-connection-by-tx is set:

            2008-07-30 07:22:07,421 TRACE [org.jboss.resource.connectionmanager.TxConnectionManager] getManagedConnection trackByTx=true tx=TransactionImple < jca-subordinate, BasicAction: a413888:a09:48905bb7:6f status: ActionStatus.RUNNING >


            Something else is up, though, but I can't find any fault with the bridge. And while this thread started because of issues I saw when the Tx status was ABORT_ONLY ... the connections aren't being released by JCA even when the Tx is successfully committed (actually, prepare() returns READONLY, so no commit() happens).

            • 18. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
              jhalliday

              Hmm. It may be worth forcing 2PC just in case the JCA is doing the release in commit and failing to deal with the 1PC optimization. Failing that, throw together a test case that reproduces the problem and send it my way, I'll take a look when I get time.

              • 19. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                 

                "jhalliday" wrote:
                Hmm. It may be worth forcing 2PC just in case the JCA is doing the release in commit and failing to deal with the 1PC optimization. Failing that, throw together a test case that reproduces the problem and send it my way, I'll take a look when I get time.


                To force 2PC, just don't return READONLY?

                • 20. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
                  jhalliday

                  That should do it, yes.

                  • 21. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                    Alright, here's a new twist. Forcing 2PC (for some reason, I had to modify BridgeParticipantAT to only return Prepared, despite changing my annotation attributes, somehow READONLY was still being set).

                    On commit(), I get an XAException. In particular, the Tx cannot be found.

                     TransactionImple tx = TxImporter.getImportedTransaction(xid);
                    
                     if (tx == null)
                     throw new XAException(XAException.XAER_INVAL);
                    


                    Is it possible that there's a classloader visibility problem? Depending on where the xid is tracked?

                    Here's the log output ...

                    10:14:34,256 INFO [STDOUT] 10:14:34,256 TRACE [ewsng/InboundBridge] stop(< 131075, 25, 64, 1-a413888:410:4890830a:31
                    10:14:37,334 INFO [STDOUT] 10:14:37,334 TRACE [ewsng/BridgeParticipantAT] prepare(Xid=< 131075, 25, 64, 1-a413888:410:4890830a:31
                    10:14:37,334 INFO [STDOUT] 10:14:37,334 DEBUG [ewsng/BridgeParticipantAT] prepare on Xid=< 131075, 25, 64, 1-a413888:410:4890830a:31 returning Prepared
                    10:14:38,381 INFO [STDOUT] 10:14:38,381 TRACE [ewsng/BridgeParticipantAT] commit(Xid=< 131075, 25, 64, 1-a413888:410:4890830a:31
                    10:14:40,365 INFO [STDOUT] 10:14:40,365 DEBUG [ewsng/BridgeParticipantAT] commit on Xid=< 131075, 25, 64, 1-a413888:410:4890830a:31 failed
                    javax.transaction.xa.XAException
                     at com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple.commit(XATerminatorImple.java:82)
                     at org.jboss.txbridge.BridgeParticipantAT.commit(BridgeParticipantAT.java:98)
                     at com.arjuna.wst.messaging.engines.ParticipantEngine.executeCommit(ParticipantEngine.java:414)
                     at com.arjuna.wst.messaging.engines.ParticipantEngine.commit(ParticipantEngine.java:137)
                     at com.arjuna.wst.messaging.ParticipantProcessorImpl.commit(ParticipantProcessorImpl.java:95)
                     at com.arjuna.webservices.wsat.handlers.ParticipantCommitHandler$1.executeTask(ParticipantCommitHandler.java:64)
                     at com.arjuna.services.framework.task.TaskWorker.run(TaskWorker.java:65)
                     at java.lang.Thread.run(Thread.java:595)
                    


                    We're using the jbossxts.sar and haven't seen any obvious classloader issues since using it ... but if TxImporter.getImportedTransaction(xid) is looking in a different place than where the JCA/JTA TransactionManager is putting the xid when its setup from within our application ... then it would lead to this type of situation, right?

                    • 22. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                      Looks like TxImporter is static, but that doesn't guarantee anything if JBoss has multiple classloaders in play. I'll see if I can make heads or tails of if two instances of this class are being loaded.

                      • 23. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
                        jhalliday

                        OK, I think maybe we are talking at cross purposes here. Forcing 2PC by not returning readonly should be done from the JTA subtransaction, not the BridgeParticipant. If the subtransaction returns readonly from prepare, it also throws away the tx at that point, which is why it can't subsequently be committed. See XATerminatorImple's prepare method. If you've hacked the bridge participant to rewrite an XA readonly from the terminator into a Prepared() response you've caused yourself a problem...

                        • 24. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                           

                          "jhalliday" wrote:
                          OK, I think maybe we are talking at cross purposes here. Forcing 2PC by not returning readonly should be done from the JTA subtransaction, not the BridgeParticipant. If the subtransaction returns readonly from prepare, it also throws away the tx at that point, which is why it can't subsequently be committed. See XATerminatorImple's prepare method. If you've hacked the bridge participant to rewrite an XA readonly from the terminator into a Prepared() response you've caused yourself a problem...


                          Ah, crap. That makes sense, though ... commits had been working fine. OK. Damn ... now I have to figure out why that subtransaction is being marked read-only when I explicitly am saying that it is NOT. Guess I'll set a breakpoint a setReadOnly() and see what's callin' it.

                          Thanks Jonathan.

                          • 25. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
                            jhalliday

                            You can setReadOnly() on a tx???

                            • 26. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                              I'm paraphrasing here .. ;-) Somewhere, there's something akin to a setReadOnly() and I'm guessing its set from somewhere within the Spring or Hibernate code ...

                              • 27. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
                                jhalliday

                                Well if the only XAResource in the transaction is one for a db connection and you only ever do SELECTS on it, it will return readonly. It's not so much a case of that being set explicitly, as you not doing anything that would cause it to be unset. Do an UPDATE on the db, or enlist a dummy XAResource whose prepare impl returns XA_OK.

                                • 28. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS

                                  Ah, OK. I didn't know that the XAResource would do that ... wouldn't there be a way to override that? What if every time you do a SELECT a trigger on the DB fires to insert or update a row? Wouldn't that need to be committed as part of the Tx that encapsulated the SELECT? Probably DB/trigger dependent, but I'm just curious ;-)

                                  • 29. Re: No active JTA Tx?? Spring + JTA Tx rollback on JBossTS
                                    jhalliday

                                    Last time I checked you could not write triggers on SELECTs, with the exception of some dbs that have query audit logging frameworks, which you don't want to be transactional anyhow. Even assuming you could, I'd presume the db would be smart enough to know it had modified some data within the tx and to return the right thing. Basically the XAResource implementation is part of the db driver and can be trusted to have the smarts to know what it's talking about. For example, if you issue an INSERT that fails for e.g. constraint violation, it may still consider the tx to be readonly. It will go by the internal state in the db engine. Looking at the SQL used is just a simple rule of thumb to help guess how it will behave.