Derby
  1. Derby
  2. DERBY-5425

Updateable holdable ResultSet terminates early after 65638 updates

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.8.3.0, 10.9.2.2, 10.10.1.1
    • Component/s: JDBC
    • Environment:
    • Urgency:
      Normal
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Seen in production, Wrong query result

      Description

      After at least 65638 updates to an indexed column have been done via an updateable holdable resultset and the transaction is committed ResultSet.next() returns false even if more rows exist to be returned.

      The following program should output "Total: 100000" but instead outputs "Total: 65638".

      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      import java.sql.Statement;

      public class DerbyBug {
      public static void main(String[] args) throws ClassNotFoundException, SQLException {
      Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
      Connection conn = DriverManager.getConnection("jdbc:derby:TestDB;create=true");

      conn.setAutoCommit(false);

      Statement createStmt = conn.createStatement();
      createStmt.executeUpdate("CREATE TABLE test (a INT)");
      createStmt.executeUpdate("CREATE INDEX idxa ON test(a)");
      createStmt.close();

      PreparedStatement insertStmt = conn.prepareStatement("INSERT INTO test(a) VALUES ");

      for (int i = 0; i < 100000; ++i)

      { insertStmt.setInt(1, i); insertStmt.executeUpdate(); }

      insertStmt.close();

      conn.commit();

      Statement selectStmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
      ResultSet rs = selectStmt.executeQuery("SELECT a FROM test FOR UPDATE");

      int count = 0;
      while (rs.next())

      { rs.updateInt(1, count); rs.updateRow(); count++; conn.commit(); }

      rs.close();
      selectStmt.close();
      conn.commit();
      conn.close();

      System.out.println("Total: " + count);

      try

      { DriverManager.getConnection("jdbc:derby:;shutdown=true"); }

      catch (SQLException e) {
      if (!e.getSQLState().equals("XJ015"))

      { throw e; }

      }
      }
      }

      1. holdable-row-holders.diff.txt
        3 kB
        Knut Anders Hatlen
      2. DerbyBug.java
        2 kB
        Andrew Johnson
      3. d5425-1a.diff.txt
        23 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Andrew Johnson created issue -
          Andrew Johnson made changes -
          Field Original Value New Value
          Attachment DerbyBug.java [ 12495275 ]
          Mamta A. Satoor made changes -
          Labels derby_triage10_9
          Urgency Normal [ 10052 ]
          Knut Anders Hatlen made changes -
          Attachment holdable-row-holders.diff.txt [ 12533981 ]
          Knut Anders Hatlen made changes -
          Assignee Knut Anders Hatlen [ knutanders ]
          Knut Anders Hatlen made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Knut Anders Hatlen made changes -
          Attachment d5425-1a.diff.txt [ 12534762 ]
          Knut Anders Hatlen made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 10.10.0.0 [ 12321550 ]
          Resolution Fixed [ 1 ]
          Kathey Marsden made changes -
          Link This issue is required by DERBY-5923 [ DERBY-5923 ]
          Kathey Marsden made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]
          Knut Anders Hatlen made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Issue & fix info Newcomer,Repro attached [ 10423, 10424 ] Repro attached [ 10424 ]
          Fix Version/s 10.8.2.3 [ 12318540 ]
          Fix Version/s 10.9.1.1 [ 12321551 ]
          Resolution Fixed [ 1 ]
          Kathey Marsden made changes -
          Fix Version/s 10.8.3.0 [ 12323456 ]
          Fix Version/s 10.8.2.3 [ 12318540 ]
          Kathey Marsden made changes -
          Fix Version/s 10.9.2.0 [ 12323562 ]
          Fix Version/s 10.9.1.1 [ 12321551 ]
          Gavin made changes -
          Workflow jira [ 12633802 ] Default workflow, editable Closed status [ 12801956 ]

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development