Project

General

Profile

Bug #3961

"Unexpected code path" failure when using H2 in MVCC mode

Added by Greg Shah over 5 years ago. Updated over 4 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:

Related issues

Related to Database - Bug #4422: h2.sortNullsHigh in page-store mode New 11/22/2019

History

#1 Updated by Greg Shah over 5 years ago

When using H2 as a database, the following failure has been seen:

Caused by: org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: Unexpected code path"; SQL statement:
COMMIT [50000-197]
        at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
        at org.h2.message.DbException.get(DbException.java:168)
        at org.h2.message.DbException.convert(DbException.java:307)
        at org.h2.command.Command.executeUpdate(Command.java:274)
        at org.h2.jdbc.JdbcConnection.commit(JdbcConnection.java:497)
        at com.mchange.v2.c3p0.impl.NewProxyConnection.commit(NewProxyConnection.java:981)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112)
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:178)
        at com.goldencode.p2j.persist.Persistence$Context.commit(Persistence.java:5263)
        at com.goldencode.p2j.persist.Persistence.commit(Persistence.java:4052)
        at com.goldencode.p2j.persist.Persistence.commit(Persistence.java:3705)
        at com.goldencode.p2j.persist.BufferManager$DBTxWrapper.commit(BufferManager.java:2583)
        at com.goldencode.p2j.util.TransactionManager$WorkArea.notifyMasterCommit(TransactionManager.java:6495)
        at com.goldencode.p2j.util.TransactionManager$WorkArea.access$4800(TransactionManager.java:5999)
        at com.goldencode.p2j.util.TransactionManager.processCommit(TransactionManager.java:5459)
        at com.goldencode.p2j.util.TransactionManager.popScope(TransactionManager.java:2105)
        at com.goldencode.p2j.util.BlockManager.doBlockWorker(BlockManager.java:8981)
        at com.goldencode.p2j.util.BlockManager.doBlock(BlockManager.java:1111)
... converted customer code ...
Caused by: java.lang.RuntimeException: Unexpected code path
        at org.h2.message.DbException.throwInternalError(DbException.java:254)
        at org.h2.message.DbException.throwInternalError(DbException.java:267)
        at org.h2.engine.Session.unlockAll(Session.java:985)
        at org.h2.engine.Session.endTransaction(Session.java:760)
        at org.h2.engine.Session.commit(Session.java:708)
        at org.h2.command.dml.TransactionCommand.update(TransactionCommand.java:46)
        at org.h2.command.CommandContainer.update(CommandContainer.java:102)
        at org.h2.command.Command.executeUpdate(Command.java:261)
        at org.h2.jdbc.JdbcConnection.commit(JdbcConnection.java:497)
        at com.mchange.v2.c3p0.impl.NewProxyConnection.commit(NewProxyConnection.java:981)
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doCommit(JdbcTransaction.java:112)
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:178)
        at com.goldencode.p2j.persist.Persistence$Context.commit(Persistence.java:5263)
        at com.goldencode.p2j.persist.Persistence.commit(Persistence.java:4052)
        at com.goldencode.p2j.persist.Persistence.commit(Persistence.java:3705)
        at com.goldencode.p2j.persist.BufferManager$DBTxWrapper.commit(BufferManager.java:2583)
        at com.goldencode.p2j.util.TransactionManager$WorkArea.notifyMasterCommit(TransactionManager.java:6495)
        at com.goldencode.p2j.util.TransactionManager$WorkArea.access$4800(TransactionManager.java:5999)
        at com.goldencode.p2j.util.TransactionManager.processCommit(TransactionManager.java:5459)
        at com.goldencode.p2j.util.TransactionManager.popScope(TransactionManager.java:2105)
        at com.goldencode.p2j.util.BlockManager.doBlockWorker(BlockManager.java:8981)
        at com.goldencode.p2j.util.BlockManager.doBlock(BlockManager.java:1111)
... converted customer code ...

From Eric:

I took a look inside the H2 source to see what might cause this.

The exception is thrown during cleanup processing after a transaction commit, if there is something left in the undo log (maintained to enable rollback) which presumably has not been committed. The transaction commit walks through all the accumulated entries in the undo log, committing and removing each one, then clears the log (which already should be empty at that point) for good measure. After this, it cleans up the transaction and asserts that the undo log is indeed empty. If it is not, it throws this error, representing an unexpected internal state.

As the individual undo log entries are committed in a loop, they are removed, and the undo log must be empty for this loop to end. If the loop exits abnormally, there is no catch statement between the loop and the call to Session.endTransaction that we see in the stack trace, so I'm really not sure how we would get into this state. I suspect this is a bug in H2.

From Ovidiu:

I investigated a bit this issue. It seems to be related to H2's MVCC. More details here: https://github.com/h2database/h2database/issues/1200.

This issue is only seen in H2, not in PostgreSQL.

#2 Updated by Constantin Asofiei over 4 years ago

  • Related to Bug #4422: h2.sortNullsHigh in page-store mode added

#3 Updated by Eric Faulhaber over 4 years ago

Please refresh my memory on this issue. Is there a production use case where this is a problem?

We do not support H2 as a primary database in production; however, we do use it for development/testing and internally (in production) for various purposes: temp-tables, dirty share, metadata tables. But for those internal purposes, we always use the page store engine, so I don't expect the problem is related to those uses. So, this must only be happening when we are using H2 as a primary database, for development/testing? The stack trace above suggests that use case.

Please post the (anonymized) JDBC URL associated with this problem.

#4 Updated by Constantin Asofiei over 4 years ago

Eric Faulhaber wrote:

Please refresh my memory on this issue. Is there a production use case where this is a problem?

Stanislav mentioned this in #3940-43.

Please post the (anonymized) JDBC URL associated with this problem.

Eugenie was using H2 for 'poc testing', see #4121-411

Also available in: Atom PDF