To simplify various unrelated issues I am pasting a snippet from 
org.h2.mvstore.Page.java(line 666, coincidence?:) -- 
https://github.com/h2database/h2database/blob/master/h2/src/main/org/h2/mvstore/Page.java

"...
       if (check != (short) checkTest) {
        log.warn("Potentially corrupted chunk: @"+(start + pageLength)+" 
Expected: "+check+" vs "+checkTest +" Page length: "+pageLength);
        
        /*
            throw DataUtils.newIllegalStateException(
                    DataUtils.ERROR_FILE_CORRUPT,
                    "File corrupted in chunk {0}, expected check value {1}, 
got {2}",
                    chunkId, checkTest, check);
                    */
        }

..."
The page is written in a sequence of writes: pageLength(offset=0),page 
data(offset+4),check(offset+4+pageLength) 
The consistency check is rather simple not to incur any significant 
overhead (I guess). 

I commented out throw error part and let program run. I didn't encounter 
problems bypassing the error. And no, it doesn't go away on 
s.compactMoveChunks().
Potentially, one can overwrite the "check" int to avoid seeing this error 
all the time. 
Granted, this is not a good solution but I couldn't find other tools to 
simply recover one MVStore file that contained one record. Maybe I missed 
it.
Needless to say, this error prevented the whole application startup. It was 
rather annoying. I guess in my case, the "check" int was not written before 
the power cord was pulled (machined decided to rebooted)
But this error demonstrates a fragile nature of the write process.

So what would be a more robust solution than ignoring this error (smile)? A 
page post restore area where a copy of the old page is kept until check is 
written.
The page copy should be kept for a while. But that would probably dictate 
store format changes and incur a performance penalty. Again maybe I am 
missing something.

Post restore area should be configurable and created with allocated space 
for multiple pages with various (but fixed) sizes. 
Somehow, we need to overcome this with a more reliable hardware and a 
backups.

Vadim


On Thursday, March 3, 2016 at 10:12:41 AM UTC-5, Matt Hicks wrote:
>
> I have a 9gig database file that was open when my Linux machine crashed 
> and rebooted and now I get the following when I try to load the database:
>
> [error] Caused by: java.lang.IllegalStateException: File corrupted in 
> chunk 1550574, expected page length 4..1024, got 1852517937 [1.4.191/6]
> [error] at 
> org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:773)
> [error] at org.h2.mvstore.Page.read(Page.java:649)
> [error] at org.h2.mvstore.Page.read(Page.java:195)
> [error] at org.h2.mvstore.MVStore.readPage(MVStore.java:1939)
> [error] at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
> [error] at org.h2.mvstore.Page.getChildPage(Page.java:217)
> [error] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:468)
> [error] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:469)
> [error] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:469)
> [error] at org.h2.mvstore.MVMap.get(MVMap.java:450)
> [error] at org.h2.mvstore.MVStore.getChunkIfFound(MVStore.java:954)
> [error] at org.h2.mvstore.MVStore.getChunk(MVStore.java:931)
> [error] at org.h2.mvstore.MVStore.readPage(MVStore.java:1930)
> [error] at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
>
> I have run `Recover` but it also crashes with this:
>
> [info] 2016.03.03 08:54:40:629 [main] ERROR t.n.c.NaboCloud$.main:38 - 
> java.lang.IllegalStateException: File corrupted in chunk 1550574, expected 
> page length 4..1024, got 1852517937 [1.4.191/6]
> [info] at 
> org.h2.mvstore.DataUtils.newIllegalStateException(DataUtils.java:773)
> [info] at org.h2.mvstore.Page.read(Page.java:649)
> [info] at org.h2.mvstore.Page.read(Page.java:195)
> [info] at org.h2.mvstore.MVStore.readPage(MVStore.java:1939)
> [info] at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
> [info] at org.h2.mvstore.Page.getChildPage(Page.java:217)
> [info] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:468)
> [info] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:469)
> [info] at org.h2.mvstore.MVMap.binarySearch(MVMap.java:469)
> [info] at org.h2.mvstore.MVMap.get(MVMap.java:450)
> [info] at org.h2.mvstore.MVStore.getChunkIfFound(MVStore.java:954)
> [info] at org.h2.mvstore.MVStore.getChunk(MVStore.java:931)
> [info] at org.h2.mvstore.MVStore.readPage(MVStore.java:1930)
> [info] at org.h2.mvstore.MVMap.readPage(MVMap.java:736)
> [info] at org.h2.mvstore.Page.getChildPage(Page.java:217)
>
> Is there anything I can do to recover the data?  I've been using H2 in 
> production systems because it's faster than other SQL databases, but if 
> it's this easy to corrupt and lose data then I'm going to have to re-think 
> that.
>
> Any insights would be greatly appreciated.
>
> Thanks,
>
> Matt Hicks
> OUTR Technologies, LLC
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to