Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In persistent mode lost Keys. #233

Closed
hsnamed opened this issue Oct 7, 2020 · 2 comments
Closed

In persistent mode lost Keys. #233

hsnamed opened this issue Oct 7, 2020 · 2 comments
Assignees
Labels

Comments

@hsnamed
Copy link

hsnamed commented Oct 7, 2020

Steps to reproduce:

@Test
    public void lostkeysTest() throws Exception{
        File storagetmp = new File("./tmp.dat");
        if(storagetmp.exists()) storagetmp.delete();
        storagetmp.deleteOnExit();

        LongValue valueSample = Values.newHeapInstance(LongValue.class);
        ChronicleMap<byte[], LongValue> mmap = ChronicleMap
                .of(byte[].class, LongValue.class)
                .entries(10)
                .actualSegments(1)
                .constantValueSizeBySample(valueSample)
                .constantKeySizeBySample(new byte[36])
                .removeReturnsNull(false)
                .createPersistedTo(storagetmp);

        valueSample.setValue(1);
        var lostKey = "12b5633bad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001";

        var h1add = Hex.decodeHex("591e91f809d716912ca1d4a9295e70c3e78bab077683f79350f101da6458807300000000");
        mmap.put(h1add, valueSample);

        var bLostKey = Hex.decodeHex(lostKey);
        mmap.put(bLostKey, valueSample);

        var v1 = mmap.remove(h1add);
        Assert.assertEquals(1L, v1.getValue());

        var h3add = Hex.decodeHex("6f80ca7441710cf0942cf99e3e8aa59d38d73b124730306afeb1aec8f08fd76b00000000");
        mmap.put(h3add, valueSample);
        //here we lost key
        var lostKeyVal = mmap.get(bLostKey);
        Assert.assertEquals(1L, lostKeyVal.getValue());

        var v2 = mmap.remove(bLostKey);
        Assert.assertEquals(1L, v2.getValue());
}

map stat :

09:02:36.892 [Test worker] DEBUG ChMapTest - Map  segments: 1, size: 2
09:02:36.893 [Test worker] DEBUG ChMapTest -   segment[0] - 2 entries
09:02:36.894 [Test worker] DEBUG ChMapTest - 	 266d63a1ad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001, 36 bytes -> LongValue{ value=1 }, 8 bytes
09:02:36.894 [Test worker] DEBUG ChMapTest - 	 6f80ca7441710cf0942cf99e3e8aa59d38d73b124730306afeb1aec8f08fd76b00000000, 36 bytes -> LongValue{ value=1 }, 8 bytes

As we see strange key : <266d63a1>ad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001
its like <12b5633b>ad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001 except 4 bytes

Problem arise when map used in persisted mode createPersistedTo

Compiled with JDK 15 , Runtime JDK 11

compile group: 'net.openhft', name: 'chronicle-map', version: '3.20.61'
@hsnamed hsnamed changed the title In persistent mode key inaccessible (first 4 bytes of key changed) , after other key placed in the same segment. In persistent mode lost Keys. Oct 9, 2020
@minborg
Copy link
Contributor

minborg commented Jan 3, 2022

I have added a reproducing test. Once it passes on all platforms, this issue will be closed automatically..

@minborg minborg self-assigned this Jan 3, 2022
@minborg minborg added the bug label Jan 3, 2022
minborg added a commit that referenced this issue Jan 4, 2022
@hft-team-city
Copy link
Contributor

Released in Chronicle-Map-3.22ea6, BOM-2.22ea86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants