Derby
  1. Derby
  2. DERBY-759

Query with thousands of logical operators and parameters causes StackOverflowError and then ERROR 40XT0: An internal error was identified by RawStore module on next statement

    Details

    • Urgency:
      Normal
    • Bug behavior facts:
      Crash

      Description

      An SQL Statement with thousands of logical operators and parameters causes a StackOverflow Error and then the next statement throws a ERROR 40XT0: An internal error was identified by RawStore module.

      The statement is of the form SELECT * FROM T0 WHERE (si = ? AND si = ? ) OR (si = ? AND si = ? ) ...

      I came across this issue when looking at DERBY-739 and code generation issues for large queries, thus the very silly looking query.

      To reproduce, uncomment this line in the test lang/largeCodeGen.java
      // testLogicalOperators(con, 10000);

      FAILED QUERY: Logical operators with 10000 parameters. java.lang.StackOverflowError
      FAILED QUERY: IN clause with 3300 parameters. ERROR 40XT0: An internal error was identified by RawStore module.
      at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:301)
      at org.apache.derby.impl.store.raw.xact.Xact.setActiveState(Xact.java:1770)
      at org.apache.derby.impl.store.raw.xact.Xact.openContainer(Xact.java:1271)
      at org.apache.derby.impl.store.access.conglomerate.OpenConglomerate.init(OpenConglomerate.java:865)
      at org.apache.derby.impl.store.access.heap.Heap.open(Heap.java:614)
      at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(RAMTransaction.java:478)
      at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(RAMTransaction.java:1315)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(DataDictionaryImpl.java:7251)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.locateSchemaRow(DataDictionaryImpl.java:1470)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(DataDictionaryImpl.java:1380)
      at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1460)
      at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1412)
      at org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(FromBaseTable.java:2370)
      at org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(FromBaseTable.java:2120)
      at org.apache.derby.impl.sql.compile.FromList.bindTables(FromList.java:307)
      at org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(SelectNode.java:434)
      at org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(DMLStatementNode.java:217)
      at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(DMLStatementNode.java:158)
      at org.apache.derby.impl.sql.compile.ReadCursorNode.bind(ReadCursorNode.java:74)
      at org.apache.derby.impl.sql.compile.CursorNode.bind(CursorNode.java:250)
      at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:336)
      at org.apache.deERROR 40XT0: An internal error was identified by RawStore module.
      at org.apache.derby.iapi.error.StandardException.newException(StandardException.java:301)
      at org.apache.derby.impl.store.raw.xact.Xact.setActiveState(Xact.java:1770)
      at org.apache.derby.impl.store.raw.xact.Xact.openContainer(Xact.java:1271)
      at org.apache.derby.impl.store.access.conglomerate.OpenConglomerate.init(OpenConglomerate.java:865)
      at org.apache.derby.impl.store.access.heap.Heap.open(Heap.java:614)
      at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(RAMTransaction.java:478)
      at org.apache.derby.impl.store.access.RAMTransaction.openConglomerate(RAMTransaction.java:1315)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getDescriptorViaIndex(DataDictionaryImpl.java:7251)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.locateSchemaRow(DataDictionaryImpl.java:1470)
      at org.apache.derby.impl.sql.catalog.DataDictionaryImpl.getSchemaDescriptor(DataDictionaryImpl.java:1380)
      at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1460)
      at org.apache.derby.impl.sql.compile.QueryTreeNode.getSchemaDescriptor(QueryTreeNode.java:1412)
      at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:263)
      at org.apache.derby.impl.sql.compile.DDLStatementNode.getTableDescriptor(DDLStatementNode.java:234)
      at org.apache.derby.impl.sql.compile.DropTableNode.bind(DropTableNode.java:114)
      at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:336)
      at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:110)
      at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:704)
      at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:533)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(EmbedStatement.java:158)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.createTestTable(Unknown Source)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.testUnions(Unknown Source)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.main(Unknown Source)
      rby.impl.sql.GenericStatement.prepare(GenericStatement.java:110)
      at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:704)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:118)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(EmbedPreparedStatement20.java:82)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement30.<init>(EmbedPreparedStatement30.java:62)
      at org.apache.derby.jdbc.Driver30.newEmbedPreparedStatement(Driver30.java:92)
      at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:678)
      at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:522)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.checkT0Query(Unknown Source)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.testInClause(Unknown Source)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.testInClause(Unknown Source)
      at org.apache.derbyTesting.functionTests.tests.lang.largeCodeGen.main(Unknown Source)
      Exception in thread "main"

      NOTE:
      I was actually able to connect to the database after the query failed despite the RawStore error so maybe the db is not corrupted but just the transaction state out of whack for the connection. This needs more investigation. I am putting this as SQL for now, even though we don't have a stack trace for the StackOverflow. This is just a guess at component.

      1. run1tst.out
        1.08 MB
        Myrna van Lunteren

        Issue Links

          Activity

          Myrna van Lunteren made changes -
          Attachment run1tst.out [ 12597589 ]
          Myrna van Lunteren made changes -
          Labels derby_triage10_5_2 derby_triage10_11 derby_triage10_5_2
          Gavin made changes -
          Workflow jira [ 12344851 ] Default workflow, editable Closed status [ 12801365 ]
          Kathey Marsden made changes -
          Labels derby_triage10_5_2
          Rick Hillegas made changes -
          Bug behavior facts [Crash]
          Urgency Normal
          A B made changes -
          Link This issue relates to DERBY-1818 [ DERBY-1818 ]
          Kathey Marsden made changes -
          Assignee Kathey Marsden [ kmarsden ]
          Daniel John Debrunner made changes -
          Resolution Duplicate [ 3 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Kathey Marsden made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Kathey Marsden [ kmarsden ]
          Kathey Marsden made changes -
          Field Original Value New Value
          Resolution Duplicate [ 3 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Kathey Marsden created issue -

            People

            • Assignee:
              Unassigned
              Reporter:
              Kathey Marsden
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development