josefmezera / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

[MVStore] Data Loss #462

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
H2 Version: svn trunk

Test:
==========================================
package my.test.mvstore.bugs;

import org.h2.mvstore.MVMap;
import org.h2.mvstore.MVStore;
import org.h2.store.fs.FileUtils;
import org.junit.Assert;
import org.junit.Test;

public class TestMVStoreDataLoss {
    static MVStore getMVStore(String fileName) {
        MVStore.Builder builder = new MVStore.Builder();
        builder.writeDelay(0).fileName(fileName);

        MVStore store = builder.open();
        store.setPageSize(512);

        return store;
    }

    @Test
    public void testDataLoss() throws Exception {
        String fileName = "E:/H2/baseDir/testDataLoss";
        FileUtils.deleteRecursive(fileName, true);

        MVStore store = getMVStore(fileName);

        MVMap<Integer, String> map = store.openMap("MVMapTest");

        map.put(1, "1");
        map.put(2, "2");
        map.put(3, "3");

        Assert.assertEquals(3, map.size()); //ok

        store.commit();
        store.close();

        store = getMVStore(fileName);
        map = store.openMap("MVMapTest");

        Assert.assertEquals(3, map.size()); //failed
    }
}

P.S. When H2 team submit the code, the h2 unit tests do not need to run it?

Original issue reported on code.google.com by zhh200...@gmail.com on 12 May 2013 at 4:29

GoogleCodeExporter commented 9 years ago
If i set the writeDelay to a value other than 0, the test can be passed,
Or explicitly call the method "store.store()", the test can be passed too。

My question is: Whenever explicitly call the method "store.store()" is 
necessary?

Original comment by zhh200...@gmail.com on 13 May 2013 at 1:03

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for the test case!

This is now fixed (not yet committed), test case TestMVStore.testWriteDelay().

> My question is: Whenever explicitly call the method "store.store()" is 
necessary?

No, as documented.

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 14 May 2013 at 7:38

GoogleCodeExporter commented 9 years ago
Fixed in version 1.3.172.

Original comment by thomas.t...@gmail.com on 25 May 2013 at 1:49