Heap space error and H2 database corruption
For our multithreaded application that uses H2 database, we saw the following error in our logs immediately following a heap space error:
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space ........ org.h2.jdbc.JdbcSQLException: File corrupted while reading record: "[17806] stream data key:1922 pos:11 remaining:0". Possible solution: use the recovery tool; SQL statement: update keys set taken=false where taken=true [90030-155] at org.h2.message.DbException.getJdbcSQLException(DbException.java: 327) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.get(DbException.java:144) at org.h2.index.PageDataIndex.getPage(PageDataIndex.java:230) at org.h2.index.PageDataNode.getNextPage(PageDataNode.java:226) at org.h2.index.PageDataLeaf.getNextPage(PageDataLeaf.java:391) at org.h2.index.PageDataCursor.nextRow(PageDataCursor.java:90) at org.h2.index.PageDataCursor.next(PageDataCursor.java:49) 开发者_StackOverflow社区 at org.h2.index.IndexCursor.next(IndexCursor.java:235) at org.h2.table.TableFilter.next(TableFilter.java:352) at org.h2.command.dml.Update.update(Update.java:89) at org.h2.command.CommandContainer.update(CommandContainer.java:71) at org.h2.command.Command.executeUpdate(Command.java:212) at org.h2.jdbc.JdbcStatement.executeUpdateInternal(JdbcStatement.java: 125) at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:110) ... 6 more
Is this a known issue with H2 ?
Also when I tried to recover data using the Recover Tool from the corrupt database, I was only able to recover 10% of it. The original DB size was 1.6 GB while the recovered database size was only 81 MB. I exported all the data from the corrupt database to a .sql file using the Recover Tool and then recreated database out of it by running this script against an H2 database. Is there something else that I am missing?
That means that your database was corrupted. As to exactly why it was corrupted, that is harder to say.
The Recover tool will do the best it can, but when the DB is badly corrupted, there is not always much it can do.
Documentation for the Recovery tool is here: http://h2database.com/html/advanced.html#using_recover_tool
精彩评论