Skip to content

Commit 590e658

Browse files
committed
GH-5148 better detection of non-empty b-tree
1 parent 2e075d5 commit 590e658

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree

core/sail/nativerdf/src/main/java/org/eclipse/rdf4j/sail/nativerdf/btree/BTree.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.rdf4j.common.io.ByteArrayUtil;
2626
import org.eclipse.rdf4j.common.io.NioFile;
2727
import org.eclipse.rdf4j.sail.SailException;
28+
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
2829
import org.slf4j.Logger;
2930
import org.slf4j.LoggerFactory;
3031

@@ -292,9 +293,10 @@ public BTree(File dataDir, String filenamePrefix, int blockSize, int valueSize,
292293
this.valueSize = buf.getInt();
293294
this.rootNodeID = buf.getInt();
294295

295-
if (rootNodeID == 0) {
296-
if (nioFile.size() >= 1024) {
297-
throw new IllegalStateException("Root node ID is 0 but file is not empty");
296+
if (rootNodeID == 0 && NativeStore.SOFT_FAIL_ON_CORRUPT_DATA_AND_REPAIR_INDEXES) {
297+
if (nioFile.size() > blockSize) {
298+
throw new SailException("Root node ID is 0 but file is not empty. Btree may be corrupt. File: "
299+
+ file.getAbsolutePath());
298300
}
299301
}
300302

0 commit comments

Comments
 (0)