Error: Unpexpected code path

288 views
Skip to first unread message

Silvio

unread,
Aug 22, 2018, 5:00:02 AM8/22/18
to H2 Database
Hello all,

We have an application that uses multiple H2 databases. In our production environments we use h2-1.4.196 and that has been working fine for months now. In a test environment a have upgraded to version h2-1.4.197 and now some parts of our applications fail with "Unexpected code path" errors. The tables (and thus SQL the queries) are generated from meta-data that is extracted from certain user definitions that determine which columns are present and what their types are. So neither the tables nor the queries are fixed.

I am pretty sure I have seen this error occur on both PageStore and MVStore databases but my most current failures are on a MVStore database. Note that these have all been created with 196.

Has something changed that might cause this error to be triggered? It sounds like an internal server error to me.

For now we will just stay on 196 but since we like to keep up with new and improved versions I would like to resolve this ASAP.

Kind regards,

Silvio

Noel Grandin

unread,
Aug 22, 2018, 5:30:09 AM8/22/18
to h2-da...@googlegroups.com

Stacktrace?

Evgenij Ryazanov

unread,
Aug 22, 2018, 7:49:59 AM8/22/18
to H2 Database
For information:

The only one reliable way to upgrade from 1.4.196 to a more recent version is to run SCRIPT TO 'filename.sql' in this version, then create a new empty database in a new version and finally run RUNSCRIPT FROM 'filename.sql'.

Script tool from 1.4.196 and RunScript from 1.4.197 can be also used, result will be the same:
http://h2database.com/html/tutorial.html#upgrade_backup_restore

Not all old databases are affected. The common source of problems is ALTER TABLE command that was used in 1.4.196 or in an older version.


Your problem, however, may be unrelated.

Silvio

unread,
Aug 22, 2018, 9:02:19 AM8/22/18
to H2 Database
I added a stack trace from a similar failure. This is in a PageStore database.

Relevant part of stack trace:

org.h2.jdbc.JdbcSQLException: General error: "java.lang.RuntimeException: Unexpected code path" [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.message.DbException.toSQLException(DbException.java:280)
at org.h2.message.TraceObject.logAndConvert(TraceObject.java:357)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:158)
        .....
 
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.Command.stop(Command.java:157)
at org.h2.command.CommandContainer.stop(CommandContainer.java:122)
at org.h2.command.Command.executeUpdate(Command.java:296)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:199)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:153)
        .......

and

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.Command.stop(Command.java:157)
at org.h2.command.CommandContainer.stop(CommandContainer.java:122)
at org.h2.command.Command.executeUpdate(Command.java:296)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:199)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:153)


Silvio

unread,
Aug 22, 2018, 9:21:06 AM8/22/18
to H2 Database
Thanks for the response.

Our system supports exporting (and subsequently importing) a "subsystem" including its database in either raw or SQL formats. So I did this and that does resolve the issue. But I must add that importing a subsystem that was exported in SQL format automatically results in a MVStore database. So by doing this I silently converted the PageStore database to a MVStore one.

HOWEVER: our production environments consist of tens to hundreds of subsystems (users create these from the application by copying template definitions) with databases ranging from a couple of MBs totens of GBs. That means it is not practically feasible to do conversions across all databases. That is why backward compatibility is extremely important to us. H2 automagically recognizes and correctly handles old PageStore databases while allowing us to use MVStore databases for all new definitions (we converted most templates to MVStore).

Swapping out the H2 versions is now no longer possible if it requires converting. That will take hours at least. We can not do it lazily since we need to provide sub-second responsiveness.

Can this be narrowed down to a more specific subset like affected column types or so? Anything that makes a conversion batch more manageable?

Kind regards,

Silvio

Silvio

unread,
Aug 22, 2018, 9:25:38 AM8/22/18
to H2 Database
I would like to add that most of the applications is working fine and the databases can be accessed for the most part. Only specific application functions (in this case removing records from a couple of tables) is affected.

Jesse Docken

unread,
Aug 24, 2018, 12:43:03 AM8/24/18
to h2-da...@googlegroups.com
Hey Silvio,

We noticed this with our own software stack and I managed to track down the cause.  It's currently fixed in the master branch but isn't in a released version of H2 yet.

Jesse

On Wed, Aug 22, 2018 at 8:25 AM Silvio <sbie...@jambo-software.com> wrote:
I would like to add that most of the applications is working fine and the databases can be accessed for the most part. Only specific application functions (in this case removing records from a couple of tables) is affected.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Silvio

unread,
Aug 28, 2018, 10:37:58 AM8/28/18
to H2 Database
Thank you for this. that will solve my problem with the next release. I will just have to skip 197.

Reply all
Reply to author
Forward
0 new messages