-
-
Notifications
You must be signed in to change notification settings - Fork 98
Description
We are opening an existing database as follows:
MVStoreModule storeModule = MVStoreModule.withConfig()
.filePath(databaseLocation).readOnly(readOnly).build();
NitriteBuilder builder = Nitrite.builder().loadModule(storeModule);
return builder.openOrCreate(VALUE_PROPERTY_SOURCE_USER, password);
after this, we call
nitriteDatabase.getCollection(COLLECTION_ELEMENTS)
closing the nitriteDatabase then leads to an exception
org.dizitart.no2.exceptions.NitriteIOException: Error occurred while committing the database
at org.dizitart.no2.NitriteDatabase.commit(NitriteDatabase.java:204) ~[nitrite-4.2.0.jar:?]
at org.dizitart.no2.NitriteDatabase.close(NitriteDatabase.java:177) ~[nitrite-4.2.0.jar:?]
...
...
Caused by: org.h2.mvstore.MVStoreException: This store is read-only [2.2.224/2]
at org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:996) ~[h2-mvstore-2.2.224.jar:2.2.224]
at org.h2.mvstore.MVStore.store(MVStore.java:804) ~[h2-mvstore-2.2.224.jar:2.2.224]
at org.h2.mvstore.MVStore.commit(MVStore.java:778) ~[h2-mvstore-2.2.224.jar:2.2.224]
at org.h2.mvstore.MVStore.commit(MVStore.java:770) ~[h2-mvstore-2.2.224.jar:2.2.224]
at org.dizitart.no2.mvstore.NitriteMVStore.commit(NitriteMVStore.java:73) ~[nitrite-mvstore-adapter-4.2.0.jar:?]
at org.dizitart.no2.NitriteDatabase.commit(NitriteDatabase.java:202) ~[nitrite-4.2.0.jar:?]
... 13 more
What I found was that the following code:
System.err.println(nitriteDatabase.hasUnsavedChanges());
nitriteDatabase.getCollection(COLLECTION_ELEMENTS);
System.err.println(nitriteDatabase.hasUnsavedChanges());
returns first false then true.
Note that the collection in this example already exists in the database. I.e. nitriteDatabase.hasCollection(COLLECTION_ELEMENTS) returns true before the abovementioned code.