-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Every try to repair or rollback an Database with the MVStoreTool throws an NullPointerException.
Exception in thread "main" java.lang.NullPointerException: Cannot read field "len" because "newestChunk" is null
at org.h2.mvstore.MVStoreTool.rollback(MVStoreTool.java:676)
...
RootCause is the int headerType = block.get(); in the following Code (h2/src/main/org/h2/mvstore/MVStoreTool.java:637):
public static long rollback(String fileName, long targetVersion, Writer writer)
DataUtils.readFully(file, pos, block);
block.rewind();
int headerType = block.get();
if (headerType == 'H') {
block.rewind();
target.write(block, pos);
pos += blockSize;
continue;the block.get() increments the BufferPosition but the following block.rewind() ist just called in the StoreHeader Block, that in the following code:
Chunk c;
try {
c = Chunk.readChunkHeader(block, pos);
} catch (MVStoreException e) {
pos += blockSize;
continue;
}The parsing of the chunkHeader always starts with missing the first character hunk:1,block:2,len:1,map:6,max:1c0,next:3,pages:2,root:4000004f8c,time:1fc,version:1
The following diff Block fixes the Problem:
diff --git a/h2/src/main/org/h2/mvstore/MVStoreTool.java b/h2/src/main/org/h2/mvstore/MVStoreTool.java
index d29909994..b3f5fc07d 100644
--- a/h2/src/main/org/h2/mvstore/MVStoreTool.java
+++ b/h2/src/main/org/h2/mvstore/MVStoreTool.java
@@ -635,8 +635,8 @@ public static long rollback(String fileName, long targetVersion, Writer writer)
DataUtils.readFully(file, pos, block);
block.rewind();
int headerType = block.get();
+ block.rewind();
if (headerType == 'H') {
- block.rewind();
target.write(block, pos);
pos += blockSize;
continue;
Metadata
Metadata
Assignees
Labels
No labels