Unexpected code path with 1.0.79 - how to avoid data loss?

20 views
Skip to first unread message

hendrik

unread,
Apr 16, 2009, 9:27:20 AM4/16/09
to H2 Database
Hi,

a customer of mine had some random crash which left the h2 1.0.79
database corrupted.
Recovery works, but a lot of data is missing.
When opening _without_ recovery turned on, I get this trace entry:

java.lang.RuntimeException: Unexpected code path
at org.h2.message.Message.getInternalError(Message.java:179)
at org.h2.message.Message.getInternalError(Message.java:280)
at org.h2.store.DiskFile.init(DiskFile.java:407)
at org.h2.engine.Database.open(Database.java:539)
at org.h2.engine.Database.<init>(Database.java:212)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:125)
at org.h2.engine.Engine.getSession(Engine.java:108)
at org.h2.engine.Session.createSession(Session.java:242)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:115)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:88)
at org.h2.Driver.connect(Driver.java:57)
at org.h2.server.web.WebServer.getConnection(WebServer.java:625)
at org.h2.server.web.WebThread$1LoginTask.run(WebThread.java:1165)
at java.lang.Thread.run(Thread.java:613)

I guess the data is simply gone.

No, this isn't the first time an h2 1.0.79 database got corrupted due
to program crashes.
What I am wondering is, how can I better avoid data loss (except for
backing it up, of course)?
Would upgrading to the latest h2 1.1 be beneficial at all?
In other words, is this is problem that has been fixed already?

Thanks,

-hendrik

PS: If you want to take a look at the corrupted database, it's at
http://www.beatunes.com/download/corrupt_h2_1_0_79.zip

Chris Schanck

unread,
Apr 16, 2009, 6:58:22 PM4/16/09
to h2-da...@googlegroups.com
I can't answer your question, but I got rid of the Unexpectred Code Path error by not using LOG=2.  FWIW.
--
C. Schanck

Thomas Mueller

unread,
Apr 18, 2009, 5:22:28 AM4/18/09
to h2-da...@googlegroups.com
Hi,

> Would upgrading to the latest h2 1.1 be beneficial at all?
> In other words, is this is problem that has been fixed already?

Yes, an important problem was fixed. See
http://www.h2database.com/html/changelog.html :

Version 1.1.108 (2009-02-28)
"When the shutdown hook closed the database, the last log file was
deleted too early. This could cause uncommitted changes to be
persisted."

Later I found out this problem can also cause data corruption. I will
update the change log entry.

Regards,
Thomas

beaTunes Support

unread,
Apr 19, 2009, 5:07:26 AM4/19/09
to h2-da...@googlegroups.com
On Apr 18, 2009, at 5:22 , Thomas Mueller wrote:

>
>> Would upgrading to the latest h2 1.1 be beneficial at all?
>>

> Yes, an important problem was fixed. See
> http://www.h2database.com/html/changelog.html :
>
> Version 1.1.108 (2009-02-28)
> "When the shutdown hook closed the database, the last log file was
> deleted too early. This could cause uncommitted changes to be
> persisted."

But I guess there is nothing new in there, that guards better against
system crashes, power outage and the like, right?

Thanks,

-hendrik

Thomas Mueller

unread,
Apr 19, 2009, 4:13:01 PM4/19/09
to h2-da...@googlegroups.com
Hi,

> But I guess there is nothing new in there, that guards better against
> system crashes, power outage and the like, right?

I tested power outage (using a christmas light timer and an old
computer). It did cause corrupted databases (not only H2, also Apache
Derby and HSQLDB; I didn't test others so far).

I'm working on a new storage mechanism (I call it 'page store') that
should better protect against such problems. I did have to read a lot
about how file systems work, and how they solve such problems
(problems like: data was written to the wrong location). However it
will take a few more month until the 'page store' is ready to use.

Regards,
Thomas

beaTunes Support

unread,
Apr 19, 2009, 4:49:56 PM4/19/09
to h2-da...@googlegroups.com

Thanks, Thomas, I am certainly not expecting magic - I was just
wondering what the status is.
Looking forward to an even better h2!

-hendrik

Reply all
Reply to author
Forward
0 new messages