Sean Bridges created DERBY-7023: ----------------------------------- Summary: Exception inserting (possibly due to integer overflow) Key: DERBY-7023 URL: https://issues.apache.org/jira/browse/DERBY-7023 Project: Derby Issue Type: Bug Components: SQL Affects Versions: 10.10.1.1 Reporter: Sean Bridges Fix For: 10.15.0.0
We get an exception writing to derby, {code:java} Caused by: java.sql.SQLException: An unexpected exception was thrown at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:101) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:148) at org.apache.derby.impl.jdbc.Util.seeNextException(Util.java:349) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:431) at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(TransactionResourceImpl.java:353) at org.apache.derby.impl.jdbc.EmbedConnection.handleException(EmbedConnection.java:2400) at org.apache.derby.impl.jdbc.ConnectionChild.handleException(ConnectionChild.java:85) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1436) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1724) at org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1379) at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172) ... 1 more Caused by: java.sql.SQLException: An unexpected exception was thrown at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:126) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71) ... 14 more Caused by: java.sql.SQLException: Java exception: ': java.io.IOException'. at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:42) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:126) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:71) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:148) at org.apache.derby.impl.jdbc.Util.javaException(Util.java:370) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:436) at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(TransactionResourceImpl.java:432) ... 11 more Caused by: java.io.IOException at org.apache.derby.iapi.services.io.CompressedNumber.writeInt(CompressedNumber.java:97) at org.apache.derby.impl.store.raw.data.StoredRecordHeader.write(StoredRecordHeader.java:457) at org.apache.derby.impl.store.raw.data.StoredPage.logRow(StoredPage.java:3861) at org.apache.derby.impl.store.raw.data.InsertOperation.writeOptionalDataToBuffer(InsertOperation.java:370) at org.apache.derby.impl.store.raw.data.InsertOperation.<init>(InsertOperation.java:115) at org.apache.derby.impl.store.raw.data.LoggableActions.actionInsert(LoggableActions.java:139) at org.apache.derby.impl.store.raw.data.BasePage.insertNoOverflow(BasePage.java:604) at org.apache.derby.impl.store.raw.data.BasePage.insertAtSlot(BasePage.java:525) at org.apache.derby.impl.store.raw.data.StoredPage.insertAtSlot(StoredPage.java:6833) at org.apache.derby.impl.store.access.btree.BTreeController.doIns(BTreeController.java:938) at org.apache.derby.impl.store.access.btree.BTreeController.insert(BTreeController.java:1372) at org.apache.derby.impl.store.access.btree.index.B2IController.insert(B2IController.java:210) at org.apache.derby.impl.sql.execute.IndexChanger.insertAndCheckDups(IndexChanger.java:440) at org.apache.derby.impl.sql.execute.IndexChanger.doInsert(IndexChanger.java:383) at org.apache.derby.impl.sql.execute.IndexChanger.insert(IndexChanger.java:590) at org.apache.derby.impl.sql.execute.IndexSetChanger.insert(IndexSetChanger.java:268) at org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:453) at org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1057) at org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:518) at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:452) at org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:333) at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1344) ... 7 more{code} I think this is due to an integer overflow. Earlier StoredPage#readPageHeader is called, and nextId is set to -2147481666. Before this line in StoredPage#readPageHeader, {code:java} nextId = lrdi.nextInt();{code} lrdi.position = 16, and lrdi.pageData = (in hex) 007500000001000000017f41de880219800007be0000000000... I can't provide the entire data base, as it is confidential. This occurred with derby 10.10.1.0, but I can reproduce it with 10.14.1.0 We do a lot of writes/deletes to this table, it's quite possible we've hit 2 billion inserts/deletes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)