Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-4653

Avoid unnecessary round-trip for commit in the client driver

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 10.7.1.1
    • 10.7.1.1
    • JDBC, Network Client
    • None
    • Patch Available
    • Performance

    Description

      The methods Connection.commit() and Connection.rollback() in the client driver cause a round-trip to the server even if the commit/rollback is unnecessary (i.e. there is nothing to commit or roll back).
      Comments suggest (see below) that this can be optimized, such that the commands are flowed to the server only when required. It can be seen that this optimization has been used other places in the client driver. Never the less, it must be checked that this optimization doesn't have side-effects.

      This issue came up in connection with connection pooling, where a pool implementation always issued a rollback to make sure there was no active transaction on the connection handed out.

      From Connection.flowCommit:
      // Per JDBC specification (see javadoc for Connection.commit()):
      // "This method should be used only when auto-commit mode has been disabled."
      // However, some applications do this anyway, it is harmless, so
      // if they ask to commit, we could go ahead and flow a commit.
      // But note that rollback() is less harmless, rollback() shouldn't be used in auto-commit mode.
      // This behavior is subject to further review.

      // if (!this.inUnitOfWork)
      // return;
      // We won't try to be "too smart", if the user requests a commit, we'll flow a commit,
      // regardless of whether or not we're in a unit of work or in auto-commit mode.
      //

      Attachments

        1. DERBY-4653-7_withflowcommittest_comment_update_diff_followup.txt
          2 kB
          Lily Wei
        2. DERBY-4653-7_withflowcommittest_comment_update_diff.txt
          6 kB
          Kristian Waagan
        3. DERBY-4653-7_withflowcommittest_comment_update_diff.txt
          6 kB
          Katherine Marsden
        4. DERBY-4653-7_withflowcommittest.diff
          6 kB
          Lily Wei
        5. ReproTransInProgressAttempt.java
          3 kB
          Lily Wei
        6. DERBY-4653-6_withflowcommitrollback.diff
          9 kB
          Lily Wei
        7. DERBY-4653-5_withflowcommitrollback.diff
          8 kB
          Lily Wei
        8. DERBY-4653-4_withcommitrollbacktest.diff
          7 kB
          Lily Wei
        9. SaveRoundClientDS.java
          4 kB
          Lily Wei
        10. DERBY-4653-3_withrollback.diff
          3 kB
          Lily Wei
        11. _sds_0
          95 kB
          Lily Wei
        12. SaveRoundClientDS.java
          4 kB
          Lily Wei
        13. DERBY-4653-2.diff
          2 kB
          Lily Wei
        14. DERBY-4653-1.diff
          0.9 kB
          Lily Wei

        Issue Links

          Activity

            People

              lilywei Lily Wei
              kristwaa Kristian Waagan
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: