I'm using h2-1.3.155 in embedded mode with Spring/Hibernate in a Java/Swing 
client app running on WinXP SP3 with the startup params : 
IFEXISTS=TRUE;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=5.  I have several corrupted 
databases on different tablets where I am either no longer able to query 
against some or all of the database and sometimes cannot access it at all. 
Looking at the one with partial access, the trace file initially contains 
the following error:

08-20 04:37:48 database: close
org.h2.message.DbException: IO Exception: "java.io.EOFException"; 
"C:\journal\H2DB\HNDLDATA.h2.db" [90031-155]
at org.h2.message.DbException.get(DbException.java:156)
at org.h2.message.DbException.convertIOException(DbException.java:313)
at org.h2.store.FileStore.readFully(FileStore.java:287)
at org.h2.store.PageStore.readPage(PageStore.java:1247)
at org.h2.store.PageStore.getPage(PageStore.java:701)
at org.h2.store.PageStreamTrunk$Iterator.next(PageStreamTrunk.java:247)
at org.h2.store.PageLog.free(PageLog.java:210)
at org.h2.store.PageStore.compact(PageStore.java:583)
at org.h2.engine.Database.closeOpenFilesAndUnlock(Database.java:1125)
at org.h2.engine.Database.close(Database.java:1076)
at org.h2.engine.DatabaseCloser.run(DatabaseCloser.java:80)
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: 
"java.io.EOFException"; "C:\journal\H2DB\HNDLDATA.h2.db" [90031-155]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
... 11 more
Caused by: java.io.EOFException
at java.io.RandomAccessFile.readFully(Unknown Source)
at org.h2.store.FileStore.readFully(FileStore.java:285)
... 8 more

>From this point forward in time, most basic queries in the H2 Console fail 
against the schema tables fail in one of two ways as seen below:

SELECT * FROM JESIG;
General error: "java.lang.NullPointerException"; SQL statement:
SELECT * FROM JESIG 
[50000-155]<http://localhost:8082/query.do?jsessionid=cf9954cdf90d52fab5595e508649a250#>HY000/50000
 
(Help) <http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c50000>
org.h2.jdbc.JdbcSQLException: General error: 
"java.lang.NullPointerException"; SQL statement:
SELECT * FROM JESIG [50000-155] 
    at 
org.h2.message.DbException.getJdbcSQLException(DbException.java:327<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=327&build=155>)
 

    at 
org.h2.message.DbException.get(DbException.java:156<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=156&build=155>)
 

    at 
org.h2.message.DbException.convert(DbException.java:279<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=279&build=155>)
 

    at 
org.h2.command.Command.executeQuery(Command.java:185<http://h2database.com/html/source.html?file=org/h2/command/Command.java&line=185&build=155>)
 

    at 
org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:173<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcStatement.java&line=173&build=155>)
 

    at 
org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcStatement.java&line=152&build=155>)
 

    at 
org.h2.server.web.WebApp.getResult(WebApp.java:1304<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1304&build=155>)
 

    at 
org.h2.server.web.WebApp.query(WebApp.java:994<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=994&build=155>)
 

    at 
org.h2.server.web.WebApp$1.next(WebApp.java:957<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=957&build=155>)
 

    at 
org.h2.server.web.WebApp$1.next(WebApp.java:960<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=960&build=155>)
 

    at 
org.h2.server.web.WebThread.process(WebThread.java:166<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=166&build=155>)
 

    at 
org.h2.server.web.WebThread.run(WebThread.java:93<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=93&build=155>)
 

    at java.lang.Thread.run(Thread.java:595) 
Caused by: java.lang.NullPointerException 
    at 
org.h2.index.PageDataLeaf.getNextPage(PageDataLeaf.java:391<http://h2database.com/html/source.html?file=org/h2/index/PageDataLeaf.java&line=391&build=155>)
 

    at 
org.h2.index.PageDataCursor.nextRow(PageDataCursor.java:90<http://h2database.com/html/source.html?file=org/h2/index/PageDataCursor.java&line=90&build=155>)
 

    at 
org.h2.index.PageDataCursor.next(PageDataCursor.java:49<http://h2database.com/html/source.html?file=org/h2/index/PageDataCursor.java&line=49&build=155>)
 

    at 
org.h2.index.IndexCursor.next(IndexCursor.java:235<http://h2database.com/html/source.html?file=org/h2/index/IndexCursor.java&line=235&build=155>)
 

    at 
org.h2.table.TableFilter.next(TableFilter.java:352<http://h2database.com/html/source.html?file=org/h2/table/TableFilter.java&line=352&build=155>)
 

    at 
org.h2.command.dml.Select.queryFlat(Select.java:512<http://h2database.com/html/source.html?file=org/h2/command/dml/Select.java&line=512&build=155>)
 

    at 
org.h2.command.dml.Select.queryWithoutCache(Select.java:617<http://h2database.com/html/source.html?file=org/h2/command/dml/Select.java&line=617&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:290<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=290&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:260<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=260&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:37<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=37&build=155>)
 

    at 
org.h2.command.CommandContainer.query(CommandContainer.java:80<http://h2database.com/html/source.html?file=org/h2/command/CommandContainer.java&line=80&build=155>)
 

    at 
org.h2.command.Command.executeQuery(Command.java:181<http://h2database.com/html/source.html?file=org/h2/command/Command.java&line=181&build=155>)
 

    ... 9 more 

or

SELECT * FROM USER_SESSION;
General error: "java.lang.ArrayIndexOutOfBoundsException: -1"; SQL 
statement:
SELECT * FROM USER_SESSION 
[50000-155]<http://localhost:8082/query.do?jsessionid=cf9954cdf90d52fab5595e508649a250#>HY000/50000
 
(Help) <http://h2database.com/javadoc/org/h2/constant/ErrorCode.html#c50000>
org.h2.jdbc.JdbcSQLException: General error: 
"java.lang.ArrayIndexOutOfBoundsException: -1"; SQL statement:
SELECT * FROM USER_SESSION [50000-155] 
    at 
org.h2.message.DbException.getJdbcSQLException(DbException.java:327<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=327&build=155>)
 

    at 
org.h2.message.DbException.get(DbException.java:156<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=156&build=155>)
 

    at 
org.h2.message.DbException.convert(DbException.java:279<http://h2database.com/html/source.html?file=org/h2/message/DbException.java&line=279&build=155>)
 

    at 
org.h2.command.Command.executeQuery(Command.java:185<http://h2database.com/html/source.html?file=org/h2/command/Command.java&line=185&build=155>)
 

    at 
org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:173<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcStatement.java&line=173&build=155>)
 

    at 
org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152<http://h2database.com/html/source.html?file=org/h2/jdbc/JdbcStatement.java&line=152&build=155>)
 

    at 
org.h2.server.web.WebApp.getResult(WebApp.java:1304<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=1304&build=155>)
 

    at 
org.h2.server.web.WebApp.query(WebApp.java:994<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=994&build=155>)
 

    at 
org.h2.server.web.WebApp$1.next(WebApp.java:957<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=957&build=155>)
 

    at 
org.h2.server.web.WebApp$1.next(WebApp.java:960<http://h2database.com/html/source.html?file=org/h2/server/web/WebApp.java&line=960&build=155>)
 

    at 
org.h2.server.web.WebThread.process(WebThread.java:166<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=166&build=155>)
 

    at 
org.h2.server.web.WebThread.run(WebThread.java:93<http://h2database.com/html/source.html?file=org/h2/server/web/WebThread.java&line=93&build=155>)
 

    at java.lang.Thread.run(Thread.java:595) 
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1 
    at 
org.h2.index.PageDataLeaf.getNextPage(PageDataLeaf.java:391<http://h2database.com/html/source.html?file=org/h2/index/PageDataLeaf.java&line=391&build=155>)
 

    at 
org.h2.index.PageDataCursor.nextRow(PageDataCursor.java:90<http://h2database.com/html/source.html?file=org/h2/index/PageDataCursor.java&line=90&build=155>)
 

    at 
org.h2.index.PageDataCursor.next(PageDataCursor.java:49<http://h2database.com/html/source.html?file=org/h2/index/PageDataCursor.java&line=49&build=155>)
 

    at 
org.h2.index.IndexCursor.next(IndexCursor.java:235<http://h2database.com/html/source.html?file=org/h2/index/IndexCursor.java&line=235&build=155>)
 

    at 
org.h2.table.TableFilter.next(TableFilter.java:352<http://h2database.com/html/source.html?file=org/h2/table/TableFilter.java&line=352&build=155>)
 

    at 
org.h2.command.dml.Select.queryFlat(Select.java:512<http://h2database.com/html/source.html?file=org/h2/command/dml/Select.java&line=512&build=155>)
 

    at 
org.h2.command.dml.Select.queryWithoutCache(Select.java:617<http://h2database.com/html/source.html?file=org/h2/command/dml/Select.java&line=617&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:290<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=290&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:260<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=260&build=155>)
 

    at 
org.h2.command.dml.Query.query(Query.java:37<http://h2database.com/html/source.html?file=org/h2/command/dml/Query.java&line=37&build=155>)
 

    at 
org.h2.command.CommandContainer.query(CommandContainer.java:80<http://h2database.com/html/source.html?file=org/h2/command/CommandContainer.java&line=80&build=155>)
 

    at 
org.h2.command.Command.executeQuery(Command.java:181<http://h2database.com/html/source.html?file=org/h2/command/Command.java&line=181&build=155>)
 

    ... 9 more 


As you would expect, views against these tables fail in the same way. These 
two exceptions are also repeated in the trace file.  Running the Recovery 
tool, it appears to generate the SQL to recreate all objects, however it 
only seems to reclaim < 5% of the data and the recovery file is full of 
messages like this:

-- page 20: data node parent: 0 table: 18 entries: 295 *rowCount: 5058*
-- ERROR [20] child[0]: 63 parent: 0
-- ERROR [20] child[1]: 64 parent: 0
...
...
-- ERROR [20] child[291]: 1335 parent: 0
-- ERROR [20] child[292]: 1340 parent: 0
-- page 21: data overflow (last) 

and this:

-- page 1294: data node parent: 17 table: 20 entries: 203 *rowCount: -1*
-- ERROR [1294] child[0]: 974 parent: 0
-- ERROR [1294] child[1]: 981 parent: 0

I could use some expert assistance in determine if there's any hope of 
recovering the rest of the data. 

As for the cause of the corruption, logging data points to the running of a 
bat file to move (and subsequently replace) the db using the local 
Scheduled Task Manager while it was in use that is likely the culprit. This 
has since been disabled to say the least.

I appreciate any help in trying to recover the data.
Thanks

-- 
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/-/zlg4uZJM4-cJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to