Skip to content

Commit

Permalink
GH-5148 better detection of non-empty b-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
hmottestad committed Oct 28, 2024
1 parent 2e075d5 commit 590e658
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.rdf4j.common.io.ByteArrayUtil;
import org.eclipse.rdf4j.common.io.NioFile;
import org.eclipse.rdf4j.sail.SailException;
import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

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

Expand Down

0 comments on commit 590e658

Please sign in to comment.