Derby
  1. Derby
  2. DERBY-4607

HeapScan test commits wrong connection

    Details

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

      Description

      The SELECT query in HeapScan is initialized like this:

      select = openDefaultConnection().prepareStatement("SELECT * FROM "+tableName);

      The test cases commit the transaction like this:

      getConnection().commit();

      openDefaultConnection() opens and returns a new connection to the default database, whereas getConnection() returns a cached default connection, so the two connections are not the same, and the transaction that's being committed is not the executing transaction.

      1. commit.diff
        2 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        Committed revision 931255.

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

        Attached is a patch that makes setUp() initialize the select statement with the helper method BaseJDBCTestCase.prepareStatement() in HeapScan and its sub-class CoveredIdxScan. The helper method uses the getConnection() method to obtain the connection, so now the calls to getConnection().commit() commit on the correct connection. Using the helper method also removes the need to close the statement explicitly in tearDown(). Also, getConnection().commit() was simplified to commit() (helper in BaseJDBCTestCase) which does the same thing.

        The patch doesn't appear change the results of the tests in any noticeable way. This is as expected, since there shouldn't be much work required on commit for read-only transactions with read committed isolation level (no log records to flush, and all locks should have been released prior to commit).

        Show
        Knut Anders Hatlen added a comment - Attached is a patch that makes setUp() initialize the select statement with the helper method BaseJDBCTestCase.prepareStatement() in HeapScan and its sub-class CoveredIdxScan. The helper method uses the getConnection() method to obtain the connection, so now the calls to getConnection().commit() commit on the correct connection. Using the helper method also removes the need to close the statement explicitly in tearDown(). Also, getConnection().commit() was simplified to commit() (helper in BaseJDBCTestCase) which does the same thing. The patch doesn't appear change the results of the tests in any noticeable way. This is as expected, since there shouldn't be much work required on commit for read-only transactions with read committed isolation level (no log records to flush, and all locks should have been released prior to commit).
        Hide
        Knut Anders Hatlen added a comment -

        I plan to post a fix for this issue, but I'll wait until the fix for DERBY-4608 has been committed in order to prevent conflicts (that fix also touches the HeapScan test).

        Show
        Knut Anders Hatlen added a comment - I plan to post a fix for this issue, but I'll wait until the fix for DERBY-4608 has been committed in order to prevent conflicts (that fix also touches the HeapScan test).

          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