Loading ...
Sorry, an error occurred while loading the content.

Multiple transactions over single socket [Fwd: fb: r6346 - in trunk/rdb_2_1/jaybird/src: main/org/firebirdsql/jca test/org/firebirdsql/jca]

Expand Messages
  • Nikolay Samofatov
    Hello, Roman! Attached is the code from Eugene Putilin as applied to RDB 2.1 trunk. We integrated the use of this feature into our framework (ncore) and the
    Message 1 of 2 , Nov 1, 2009
    • 0 Attachment
      Hello, Roman!

      Attached is the code from Eugene Putilin as applied to RDB 2.1 trunk.
      We integrated the use of this feature into our framework (ncore) and the
      code appears to work.
      The presense of subj capability is critical for our deliverable. I guess
      it can be useful for other people as well.

      The code apparently needs a bit of polishing before it can be applied to
      Jaybird HEAD.
      Please let us know what you think.

      Nikolay

      -------- Original Message --------
      Subject: fb: r6346 - in trunk/rdb_2_1/jaybird/src:
      main/org/firebirdsql/jca test/org/firebirdsql/jca
      Date: Mon, 2 Nov 2009 04:08:12 +0300 (MSK)
      From: SVNMailer@...
      To: roman.simakov at red-soft.biz, dmitry.starodubov at red-soft.biz,
      artyom.smirnov at red-soft.biz, pavel.maslov at red-soft.biz,
      nikolay.samofatov at red-soft.biz, roman.kisluhin at red-soft.biz



      Author: skidder
      Date: 2009-11-02 04:08:11 +0300 (Mon, 02 Nov 2009)
      New Revision: 6346

      Added:
      trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBSADataSource.java
      trunk/rdb_2_1/jaybird/src/test/org/firebirdsql/jca/TestFBSADataSource.java
      Modified:
      trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBManagedConnection.java
      Log:
      Add code from Putilin to allow multiple transactions per physical attachment

      Modified: trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBManagedConnection.java
      ===================================================================
      --- trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBManagedConnection.java 2009-11-01 19:02:38 UTC (rev 6345)
      +++ trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBManagedConnection.java 2009-11-02 01:08:11 UTC (rev 6346)
      @@ -62,6 +62,7 @@
      private GDS gds;
      private IscDbHandle dbHandle;
      private GDSHelper gdsHelper;
      + private FBManagedConnection parent;

      private FBConnectionRequestInfo cri;
      private FBTpb tpb;
      @@ -92,6 +93,28 @@
      }
      }

      +
      + private FBManagedConnection(FBManagedConnection mc)
      + {
      + this.parent = mc;
      + this.mcf = mc.mcf;
      + this.gds = mc.gds;
      + this.cri = mc.cri;
      + this.tpb = mc.tpb;
      + this.transactionIsolation = mc.transactionIsolation;
      + this.dbHandle = mc.dbHandle;
      +
      + DatabaseParameterBuffer dpb = this.cri.getDpb();
      +
      + this.gdsHelper = new GDSHelper(this.gds, dpb, (AbstractIscDbHandle)this.dbHandle, this);
      + }
      +
      +
      + public FBManagedConnection forkManagedConnection()
      + {
      + return new FBManagedConnection(parent != null ? parent : this);
      + }
      +
      /**
      * Notify GDS container that error occured, if the <code>ex</code>
      * represents a "fatal" one
      @@ -414,7 +437,7 @@
      private void disassociateConnections() throws ResourceException {

      ResourceException ex = null;
      -
      + ArrayList connectionHandles = new ArrayList (this.connectionHandles);
      for (Iterator i = connectionHandles.iterator(); i.hasNext();) {
      AbstractConnection connection = (AbstractConnection) i.next();

      @@ -428,7 +451,7 @@
      }
      }

      - connectionHandles.clear();
      + this.connectionHandles.clear();

      if (ex != null)
      throw ex;
      @@ -511,6 +534,8 @@
      throw new java.lang.IllegalStateException(
      "Can't destroy managed connection with active transaction");

      + if (parent != null)
      + return;
      try {
      gdsHelper.detachDatabase();
      } catch (GDSException ge) {


      Property changes on: trunk/rdb_2_1/jaybird/src/main/org/firebirdsql/jca/FBSADataSource.java
      ___________________________________________________________________
      Added: svn:mime-type
      + text/plain
      Added: svn:eol-style
      + native


      Property changes on: trunk/rdb_2_1/jaybird/src/test/org/firebirdsql/jca/TestFBSADataSource.java
      ___________________________________________________________________
      Added: svn:mime-type
      + text/plain
      Added: svn:eol-style
      + native



      --
      Nikolay Samofatov, MBA
      Red Soft Corporation
      +7 495 668 3735



      [Non-text portions of this message have been removed]
    • Roman Rokytskyy
      Hi, ... I have talked with Eugene last week and told me that for me would be easier if the driver code is not modified at all. About the patch. From the first
      Message 2 of 2 , Nov 2, 2009
      • 0 Attachment
        Hi,

        > Attached is the code from Eugene Putilin as applied to RDB 2.1 trunk.
        > We integrated the use of this feature into our framework (ncore) and the
        > code appears to work.
        > The presense of subj capability is critical for our deliverable. I guess
        > it can be useful for other people as well.
        >
        > The code apparently needs a bit of polishing before it can be applied to
        > Jaybird HEAD.
        > Please let us know what you think.

        I have talked with Eugene last week and told me that for me would be
        easier if the driver code is not modified at all.

        About the patch. From the first look code should work ok in non-managed
        environment, but I am not ready to answer about the behavior in a
        managed environment - I am not that good in JCA specs to tell if
        everything is ok in Xid matching code and connection association when
        multiple managed connections are forked.

        Now I think there is easier solution:

        - database is attached only in one place - in the constructor of the
        FBManagedConnection class.

        - now, there are only two places where FBManagedConnection is created -
        in a FBManagedConnectionFactory.createManagedConnection and in
        FBManagedConnectionFactory.tryCompleteInLimboTransaction.

        - and finally the FBManagedConnectionFactory is created in:
        - AbstractFBConnectionPoolDataSource.getManagedConnectionFactory()
        - FBXADataSource.createMcf(...)
        - FBSimpleDataSource (constructor)
        - FBDriver.connect(...) (two methods)

        but in all cases the code depends on FBConnectionProperties contents.

        So, I would:

        - create a possibility to pass the database handle into
        FBManagedConnection constructor.

        - create new property that would tell driver to share the attachment
        (best way is to add a getter into FirebirdConnectionProperties
        interface, that would also tell which places in the code are affected).

        - modify the FBManagedConnectionFactory.start() method to check that
        property and do an eager attachment.

        In this case the code will work the same as of now, only that attachment
        will be shared among Connection objects. Any connection that you will
        get in a managed and non-managed environment should work correctly as
        well, you also would not need to call your custom
        forkManagedConnection() method - you simply get the connection from a
        DataSource or from DriverManager. Also, if you subclass appropriate data
        source and driver classes, you could create a "parallel" version of the
        code without modifying the code in the Firebird's trunk. For me this
        looks like a better solution.

        Roman
      Your message has been successfully submitted and would be delivered to recipients shortly.