Derby
  1. Derby
  2. DERBY-5524

Speed up clean-up after StatementJdbc30Test.xtestMaxOpenStatementsWithQueryTimeout

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 10.9.1.0
    • Fix Version/s: 10.9.1.0
    • Component/s: Test
    • Labels:
      None

      Description

      StatementJdbc30Test.xtestMaxOpenStatementsWithQueryTimeout takes close to four minutes in my environment. It turns out it spends most of the time in tearDown() closing statements.

      The test case opens a lot of statements (more than 16000) on the same connection and keeps them open until the test has completed, to verify that it is possible to have that many open statements on a single connection when a query timeout has been specified. The test case runs with auto-commit enabled, and every call to Statement.close() in tearDown() therefore results in an implicit commit. When committing a transaction, the engine needs to go through the list of activations in that transaction. Since there's one activation per open statement, that list is pretty long. Although it gets shorter for each statement that is closed, it takes a while to get through all the statements (~16000^2/2 activations need to be checked before all statements are closed...).

      This can easily be fixed by disabling auto-commit for the test case. Since no (implicit) commit happens during the test case itself, this doesn't change the semantics of the test case. It will speed up the closing of the statements in tearDown() because it will no longer run 16000 implicit commits and traverse the long list of activations 16000 times.

      1. d5524.diff
        0.9 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Hide
          Knut Anders Hatlen added a comment -

          Committed revision 1213248.

          Show
          Knut Anders Hatlen added a comment - Committed revision 1213248.
          Hide
          Knut Anders Hatlen added a comment -

          Attaching the patch d5524.diff which disables auto-commit for xtestMaxOpenStatementsWithQueryTimeout. The time to run the test case is reduced from 230 sec to 30 sec in my environment when the patch is applied.

          Show
          Knut Anders Hatlen added a comment - Attaching the patch d5524.diff which disables auto-commit for xtestMaxOpenStatementsWithQueryTimeout. The time to run the test case is reduced from 230 sec to 30 sec in my environment when the patch is applied.

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development