Tons of exceptions with H2 1.3.166

114 views
Skip to first unread message

Stuart Goldberg

unread,
Feb 1, 2016, 12:18:37 PM2/1/16
to H2 Database
Our software got tons of H2 exceptions. It all started with the following

### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: IO Exception: "java.io.IOException: Stream Closed"; "/d1/data/fixflyerWeb/daytona.h2.db" [90031-166]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
	at org.h2.message.DbException.get(DbException.java:158)
	at org.h2.message.DbException.convertIOException(DbException.java:315)
	at org.h2.store.FileStore.write(FileStore.java:330)
	at org.h2.store.PageStore.writePage(PageStore.java:1323)
	at org.h2.store.PageStreamData.write(PageStreamData.java:105)
	at org.h2.store.PageOutputStream.storePage(PageOutputStream.java:146)
	at org.h2.store.PageOutputStream.write(PageOutputStream.java:129)
	at org.h2.store.PageLog.write(PageLog.java:533)
	at org.h2.store.PageLog.commit(PageLog.java:553)
	at org.h2.store.PageStore.commit(PageStore.java:1430)
	at org.h2.engine.Database.commit(Database.java:1767)
	at org.h2.engine.Session.commit(Session.java:450)
	at org.h2.command.Command.stop(Command.java:144)

Then we get seemingly endless exceptions traces that start with the following:

org.springframework.dao.CannotAcquireLockException: 
### Error updating database.  Cause: org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "ALERT"; SQL statement:

Things never seem to recover. We suspect that in the environment where this occurred that the H2 database file was located on a NAS and there may have been some network stability issues.

My question is if there was a network glitch during a database operation, can the code leave one or more tables locked such that subsequent accesses to those tables would lead to an endless series of CannotAcquireLockExceptions?

Would a newer version of H2 fix this? 

Stuart Goldberg

unread,
Feb 1, 2016, 2:45:10 PM2/1/16
to H2 Database
BTW, I just wanted to add that our software works most of the time. It's just that we recently experienced the above scenario at a client of ours and in our internal ticketing system we have a record of having seen this once before. Trying to understand what's going on and if this is a bug and if so, if it's been fixed.

Noel Grandin

unread,
Feb 2, 2016, 6:19:56 AM2/2/16
to h2-da...@googlegroups.com

Sounds like H2 hit some kind of corruption and closed the DB file.

That should be another exception earlier in the file before the "stream closed" one that indicates the root cause.

Stuart Goldberg

unread,
Feb 2, 2016, 3:44:39 PM2/2/16
to H2 Database
I saw a similar response (possible from you) to another post that had complained of something similar. So I dutifully looked for an early exception except that there were none.

The real question I have is whether H2 has a bug where locks are left locked from an aborted insert (or some other operation) such that one could get repeated exceptions complaining the it can't get a lock on a table.

Noel Grandin

unread,
Feb 3, 2016, 3:59:39 AM2/3/16
to h2-da...@googlegroups.com

You're running a fairly old version, and we've fixed a few corruption bugs since then, so it's possible you're hitting
one of those, but your stacktrace doesn't ring any bells for me.

Noel Grandin

unread,
Feb 3, 2016, 8:04:41 AM2/3/16
to h2-da...@googlegroups.com
you don't by any chance have some other code that might be calling "interrupt()" on the thread writing to the H2
database file?

That might conceivably cause such a problem.

Stuart Goldberg

unread,
Feb 3, 2016, 9:29:18 AM2/3/16
to H2 Database
To my knowledge there is no such code. But if interrupt() might cause such a problem, it would seem to me that some other unforeseen exception might also cause that kind of problem.

Noel Grandin

unread,
Feb 3, 2016, 2:11:59 PM2/3/16
to H2 Database
One thing to ask - did you check the h2 trace log or just your own log? Sometimes errors will show up there first.
--
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.

Stuart Goldberg

unread,
Feb 8, 2016, 10:34:13 AM2/8/16
to H2 Database
I only checked my own log. This problem is not, for all intents and purposes, reproducible. We've seen it a few times over the years. So I cannot retry this with H2 trace logging on.

Later today I will try to post my analysis of the H2 code stack that I think could explain what I am seeing. I'd appreciate your feedback on it.

Stuart Goldberg

unread,
Feb 8, 2016, 12:47:12 PM2/8/16
to H2 Database
My analysis of the H2 code stack was inconclusive.

Bottom line should I upgrade to the latest 1.3.X or give 1.4.X a chance? Should the fact that 1.4.X is marked Beta give me pause?

Noel Grandin

unread,
Feb 8, 2016, 11:56:14 PM2/8/16
to h2-da...@googlegroups.com
You can run 1.4.x with the original storage engine by adding
MV_STORE=FALSE to your DB URL.
Reply all
Reply to author
Forward
0 new messages