开发者

Ehcache cannot overflow data to disk in XA Mode (NotSerializableException)

I'm experimenting XA transactions with Ehcache. Currently I'm using Spring transaction management and Bitronix as transaction manager.

I create, configure and fill up a cache using the method below:

@Transactional
public void createCache() {
    this.cacheConfiguration = new CacheConfiguration("MyCache", 5000).diskPersistent(false).eternal(false)
            .diskExpiryThreadIntervalSeconds(1).maxElementsInMemory(70).transactionalMode(TransactionalMode.XA);
    final Configuration config = new Configuration();
    config.setDefaultCacheConfiguration(this.cacheConfiguration);
    final DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
    diskStoreConfiguration.setPath("cache");
    config.addDiskStore(diskStoreConfiguration);
    this.cacheManager = new CacheManager(config);
    this.cacheConfiguration.name("primaryCache");
    this.cache = new Cache(this.cacheConfiguration);
    this.cacheManager.addCache(this.cache);

    for (int i = 0; i < 100; i++) {
        final Integer value = Integer.valueOf(i);
        this.cache.put(new Element(value, value));
    }
}

Everything is working fine and Ehcache works as expected by evicted elements over the count of 70.

Now if I change diskPersistent from false to true, it does not work as soon as Ehcache attempt to copy some element to the disk storage with the following exception:

[primaryCache.data] ERROR n.s.e.s.c.f.DiskStorageFactory btm-gtrid=737072696E672D62746D0000012F9296448C00000000 - Disk Write of 0 fai开发者_如何学JAVAled (it will be evicted instead): 
java.io.NotSerializableException: net.sf.ehcache.transaction.ReadCommittedSoftLockImpl

This is expected as switching Ehcache to transactional mode makes it replace the original values of Integertype by a SoftLock:

[main] DEBUG n.s.e.t.local.LocalTransactionStore ehcache-txid=0, btm-gtrid=737072696E672D62746D0000012F9296448C00000000 - put: cache [primaryCache] key [0] was not in, soft lock inserted

To be complete, this also happens when using the Atomikos transaction manager and works flawlessly when not using XA mode.

The question is: is there a way to mix XA transactions and disk overflow ?


Everything should work as you expect them to but you've just found a bug which completely prevents the Open Source disk persistent store from working with any transactional mode.

Please report the problem in the Ehcache JIRA (https://jira.terracotta.org/jira/browse/EHC) and we'll fix it as soon as we can.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜