I have 1 suggestion/doubt - why is incrementVersion() even exposed? Is it 
meant to be a checkpoint for uncommitted transactions? It's confusing.

Why would I not use commit() instead to bump up the version? Because it has 
to flush the store which might be slower than just increment?

Can multiple threads access store concurrently? Can multiple threads access 
diff versions of a map concurrently?

Thanks.



On Friday, October 25, 2013 4:51:19 AM UTC-7, Thomas Mueller wrote:
>
> Hi,
>
> Thanks a lot for reporting! This is a very good test case. I can reproduce 
> the problem now, I will try to fix it in the next days. The problem isn't 
> really the number of entries in the map, the problem is that the background 
> thread stores the transient (uncommitted) changes to avoid out of memory, 
> and closing will try to revert that (and this is what fails for some 
> reason).
>
> Regards,
> Thomas
>
>
> On Fri, Oct 25, 2013 at 7:33 AM, Ashwin Jayaprakash <
> [email protected] <javascript:>> wrote:
>
>> 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] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/h2-database.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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.

Reply via email to