Corrupted DB - strange content in the db file

100 views
Skip to first unread message

Peter

unread,
Jan 8, 2013, 4:16:47 PM1/8/13
to h2-da...@googlegroups.com
Hi everyone,

I got a corrupted DB file and the expected error "File corrupted while reading record: "wrong checksum". Possible solution: use the recovery tool [90030-163]". H2 Version is 1.3.163.

After having a look at the 32MB h2.db file (plaintext), I found strange content - the file was full with java class file content, bytecode, some license agreements etc. After a quick research I fount out, that SOME of the jar-files of the application were appended to the db file. The application is an eclipse rcp based app using hibernate for persistence with H2. The application includes its own copy of the JRE and for example the whole content of the rt.jar was byte-wise copied into the db file.

I know that this might have nothing to do with H2Database. But I have really no clue how this could happen, so could it be that H2 is messing something up after all? Or especially in combination with hibernate or something? No other file got affected than the h2 db file.

By the way, this is the second time I encountered this strange behavior. First time was half a year ago on a very different system (but same application). That time, I ignored the strange error, but now i am a bit concerned. The file could easily be fixed by removing the strange content which left the original 500KB db and as far as I know, there was no data loss (but I cannot be totally sure about that - it's not my data).

I am also very happy, if somebody got a hint what else could make such strange things.

Greetings and thanks a lot in advance,
Peter

Ryan How

unread,
Jan 8, 2013, 10:12:34 PM1/8/13
to h2-da...@googlegroups.com
That is really strange!. I've been using H2 for quite a few years and
never had a corrupted DB. What environment are you running on? And what
connection string are you using? JVM version?

And do you know when it happened?. Was the application running and
crashed?. Or it was fine, then shutdown and on startup it was corrupted?

Ryan
> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/CBzzAbYo4McJ.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.


Peter

unread,
Jan 10, 2013, 11:49:48 AM1/10/13
to h2-da...@googlegroups.com
Dear Ryan,

the application is bundled with a copy of the 32bit JRE Version 1.6.0_37.
The connection is made with the following javax.sql.datasource bean exported through spring-dm osgi mechanism:

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
p:driverClassName="org.h2.Driver" p:url="jdbc:h2:${h2db.path}/${h2db.dbname};IGNORECASE=TRUE"
p:username="${h2db.admin}" p:password="${h2db.pass}" init-method="createDataSource"
destroy-method="close" />

The bean is then used in a different osgi bundle as datasource for a hibernate session factory.

<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="configLocation" value="hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
</bean>

Right now, I can't tell which windows version was used. Neither do I know how it happened. I'm trying to get these informations - but that's a bit difficult because the software is used in production and I get the error reports forwarded from a client who distributes the software to endusers. So I have no direct contact to the real users of the application.

Greetings
Onno

Noel Grandin

unread,
Jan 10, 2013, 12:17:02 PM1/10/13
to h2-da...@googlegroups.com

That smells like filesystem corruption.
The jar's appeared in the DB file because they were nearby on the disk.
There is nothing much you can do about dodgy hardware, and if you have enough customers, sooner or later you are going to run across it.

Onno

unread,
Jan 10, 2013, 12:23:15 PM1/10/13
to h2-da...@googlegroups.com
Dear Noel,
that was my first thought too when it happened for the first time. But I'm wondering how chances are for the same behavior on a different system (different customer)? Especially because the same file (h2 database file) was the only affected file again. Any thoughts on that?

Noel Grandin

unread,
Jan 10, 2013, 12:50:57 PM1/10/13
to h2-da...@googlegroups.com
Yeah, the corruption you are most likely to see is corruption from the most frequently used application, which is probably your application, the one that uses H2.

Of course, this kind of filesystem corruption is sometimes caused by dodgy third party software like anti-virus tools that try and intercept file system writes.
Reply all
Reply to author
Forward
0 new messages