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

SYSCS_UTIL.SYSCS_COMPRESS_TABLE causes concurrent transactions to fail

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 10.6.2.1, 10.8.1.2
    • None
    • SQL
    • None
    • Repro attached
    • Seen in production

    Description

      Our application is set to run a set of nightly maintenance tasks which include SYSCS_UTIL.SYSCS_COMPRESS_TABLE. From our logs it appears that occasionally selects will fail while the database is being compressed with the following error: "ERROR XSCH1: Container 1,408 not found." A full stack trace is included below.

      Attached is a standalone test case which will reproduce the problem within a couple of seconds. It will create two threads, one which will repeatedly compress TABLE1 while the second thread tries to read from the table. The documentation states that SYSCS_COMPRESS_TABLE will acquire an exclusive lock on the table which suggests it any simultaneous requests should block until the compress has completed.

      A workaround is to switch to SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE which does not seem to have the problem.

      Sample output from test case
      ---------------------------------------
      Thread-3: Selecting...
      Thread-2: Compressing...
      Thread-3: Selecting...
      Thread-3: Selecting...
      Thread-2: Compressing...
      Thread-3: Selecting...
      Thread-3: Selecting...
      Thread-3: Selecting...
      Thread-2: Compressing...
      Thread-3: Selecting...
      Thread-2: Compressing...
      java.sql.SQLException: Container 2,480 not found.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeQuery(Unknown Source)
      at BashOnCompressTables$SelectRunnable.select(BashOnCompressTables.java:67)
      at BashOnCompressTables$SelectRunnable.run(BashOnCompressTables.java:48)
      at java.lang.Thread.run(Unknown Source)
      Caused by: java.sql.SQLException: Container 2,480 not found.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
      ... 12 more
      Caused by: ERROR XSCH1: Container 2,480 not found.
      at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
      at org.apache.derby.impl.store.access.heap.Heap.openScan(Unknown Source)
      at org.apache.derby.impl.store.access.RAMTransaction.openScan(Unknown Source)
      at org.apache.derby.impl.store.access.RAMTransaction.openCompiledScan(Unknown Source)
      at org.apache.derby.impl.sql.execute.BulkTableScanResultSet.openScanController(Unknown Source)
      at org.apache.derby.impl.sql.execute.TableScanResultSet.openCore(Unknown Source)
      at org.apache.derby.impl.sql.execute.BulkTableScanResultSet.openCore(Unknown Source)
      at org.apache.derby.impl.sql.execute.BasicNoPutResultSetImpl.open(Unknown Source)
      at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
      at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
      ... 6 more

      Attachments

        1. CompressTableTestCase.java
          2 kB
          Brett Mason

        Issue Links

          Activity

            People

              Unassigned Unassigned
              b.mason@adinstruments.com Brett Mason
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: