I was trying to run this simple MVStore test, essentially trying to see if
the multiple read-only versions worked.
I noticed that if the commit() statements are not called after an
incrementVersion(), then close() throws an unknown version exception. See
highlighted sections below in the code. What am I doing wrong?
*Exception:
*
Exception in thread "main" java.lang.IllegalArgumentException: Unknown
version 2 [1.3.174/0]
at
org.h2.mvstore.DataUtils.newIllegalArgumentException(DataUtils.java:672)
at org.h2.mvstore.DataUtils.checkArgument(DataUtils.java:659)
at org.h2.mvstore.MVStore.rollbackTo(MVStore.java:1749)
at org.h2.mvstore.MVStore.close(MVStore.java:678)
at test.MvTest1.main(MvTest1.java:54)
*Code:
*
public class MvTest1 {
public static void main(String[] args) {
MVStore s = new MVStore.Builder().
backgroundExceptionHandler(
new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread,
Throwable throwable) {
throwable.printStackTrace();
}
}).
cacheSize(10).
compressData().
encryptionKey("007".toCharArray()).
fileStore(new OffHeapStore()).
pageSplitSize(6 * 1024).
readOnly().
writeBufferSize(8).
writeDelay(100).
open();
//Put some items.
MVMap<String, String> names = s.openMap("names");
for (int i = 0; i < 10000; i++) {
names.put(System.nanoTime() + "_" + i,
Long.toString(names.sizeAsLong()));
}
System.out.println("Map count: " + names.size() + " version: " +
names.getVersion());
//Take a snapshot.
MVMap<String, String> namesOld =
names.openVersion(names.getVersion());
//Bump up the version.
s.incrementVersion();
// Either both this commit and the one below MUST be called OR
NEITHER!
// s.commit();
//Put some more items.
for (int i = 20000; i < 25000; i++) {
names.put(System.nanoTime() + "_" + i,
Long.toString(names.sizeAsLong()));
}
System.out.println("Map count: " + names.size() + " version: " +
names.getVersion());
System.out
.println("Old map count: " + namesOld.size() + " version: "
+ namesOld.getVersion());
//s.commit();
s.close();
}
}
Regards,
Ashwin.
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/groups/opt_out.