永久模式下的编年史地图将丢失密钥

问题描述

复制步骤:

@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());
}

地图统计信息:

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,8 bytes

我们看到的是奇怪的密钥: ad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001 类似于 ad1f9c167d523ad1aa1947b2732a865bf5414eab2f9e5ae5d5c191ba00000001,除了4个字节

在持久模式下使用地图时出现问题 createPersistedTo

在JDK 15/11上测试

compile group: 'net.openhft',name: 'chronicle-map',version: '3.20.61'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)