2 Replies Latest reply on Jul 9, 2004 10:49 PM by Adrian Brock

    Getting Unrecognized transaction..

    Dayasakti Kartika Newbie

      Hi,
      I have a application deployed under these configurations:
      -OS=Gentoo Linux Kernel 2.4.25
      -JVM=Blackdown1.4.1
      -JBoss-3.2.3
      -RDBMS=Firebird-1.5.0 (Classic Server)
      -JDBC=FirebirdSQL-1.5.0-RC2 (deployed as a JCA adapter. Pooling is set to discard idle connections after 15 minutes)

      Sometimes I would get this kind of exception while closing a Jdbc connection:


      2004-05-05 10:31:15,966 WARN [org.jboss.tm.TransactionImpl] XAException: tx=TransactionI
      mpl:XidImpl [FormatId=257, GlobalId=appserver01//11103, BranchQual=] errorCode=XAER_NOTA
      org.firebirdsql.jca.FBXAException: Unrecognized transaction at org.firebirdsql.jca.FBManagedConnection.internalEnd(FBManagedConnection.java:437)
      at org.firebirdsql.jca.FBManagedConnection.end(FBManagedConnection.java:409)
      at org.jboss.tm.TransactionImpl.endResource(TransactionImpl.java:1205)
      at org.jboss.tm.TransactionImpl.delistResource(TransactionImpl.java:543)
      at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventList
      ener.delist(TxConnectionManager.java:505)
      at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventList
      ener.connectionClosed(TxConnectionManager.java:554)
      at org.firebirdsql.jca.FBManagedConnection$2.notify(FBManagedConnection.java:1176
      )
      at org.firebirdsql.jca.FBManagedConnection.notify(FBManagedConnection.java:1157)
      at org.firebirdsql.jca.FBManagedConnection.close(FBManagedConnection.java:846)
      at org.firebirdsql.jdbc.AbstractConnection.close(AbstractConnection.java:437)


      It's kind of difficult to reproduce this problem.
      But everytime this exception occurs, 1 additional physical connection doesn't get discarded, even after overnight (when no one is even using the application). I can see this by running pstree on the linux console. (One managedConnection is associated with one process).

      Then I decide to download the jboss-3.2.3 source code, open TxConnectionManager.java and observe line 554 where the connectionClosed method calls delist()

       if (isManagedConnectionFree())
       {
       //log.trace("called unregisterAssociation, delisting");
       //no more handles
       delist();
       //log.trace("called unregisterAssociation, returning");
       returnManagedConnection(this, false);
       }
       //log.trace("called unregisterAssociation");
       }
       catch (ResourceException re)
       {
       log.error("ResourceException while closing connection handle!", re);
       } // end of try-catch
      


      Now my question:

      If an exception occured (like the one i have) while delist() is called, then the returnManagedConnection(this,false) won't be called. Does this mean that the managedConnection will never be returned to the pool thus causing some sort of a leak ?

      If so would it be safe to do this:
       if (isManagedConnectionFree())
       {
       //log.trace("called unregisterAssociation, delisting");
       //no more handles
       try{
       delist();
       }catch(ResourceException re){
       //log.trace("called unregisterAssociation, return and KILL");
       returnManagedConnection(this, true);
       //rethrow
       throw re;
       }
       //log.trace("called unregisterAssociation, return ");
       returnManagedConnection(this,false);
       }
       //log.trace("called unregisterAssociation");
       }
       catch (ResourceException re)
       {
       log.error("ResourceException while closing connection handle!", re);
       } // end of try-catch
      
      


      Thanks for any comments and answers.