Hello,
I am new to MapDB and I have experienced one problem, when I try to open a db.
The stacktrace is
Exception in thread "main" java.io.IOError: java.io.IOException: storage has invalid header
at org.mapdb.StoreDirect.checkHeaders(StoreDirect.java:212)
at org.mapdb.StoreDirect.<init>(StoreDirect.java:197)
at org.mapdb.DBMaker.extendStoreDirect(DBMaker.java:800)
at org.mapdb.DBMaker.makeEngine(DBMaker.java:663)
at org.mapdb.DBMaker.make(DBMaker.java:631)
at kg.wikipedia.TestMapDB.getDB(TestMapDB.java:34)
at kg.wikipedia.TestMapDB.test1(TestMapDB.java:68)
at kg.wikipedia.TestMapDB.main(TestMapDB.java:107)
Caused by: java.io.IOException: storage has invalid header
... 8 more
The version of MapDB is 0.9.4.
I have transactions disabled, and I close the db before shutdown of the JVM by calling db.close().
This is how I get a db instance
public DB getDB(File dbPath, boolean readonly) {
DBMaker<?> dbMaker = DBMaker.newFileDB(dbPath);
dbMaker = dbMaker.transactionDisable();
dbMaker = dbMaker.closeOnJvmShutdown();
if (readonly) {
// NOTE: i don't need transactions, disabling should improve speed
// db = DBMaker.newFileDB(dbPath).transactionDisable()
// .closeOnJvmShutdown().readOnly().make();
dbMaker = dbMaker.readOnly();
}
db = dbMaker.make();
return db;
}
If I enable transactions, I dont see the problem.
Best regards
Reinhard