簡體   English   中英

使用事務控制器的Ehcache事務超時

[英]Ehcache transaction timeout using transaction controller

ehcache.xml中

<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="ehcache.xsd" maxBytesLocalHeap="800M">

        <diskStore path="java.io.tmpdir"/>
        <defaultCache eternal="true" overflowToOffHeap="false" overflowToDisk="false" transactionalMode="local"/>

    </ehcache>

我正在使用TransactionController進行事務管理。

 final boolean isLocalTransactionContext = mTransactionManager.getCurrentTransactionContext() == null;
        try {
            if (isLocalTransactionContext) {
                mTransactionManager.begin(10);
            }

Element cacheElement = mCache.get(Key);
return cacheElement;
} finally {
            if (isLocalTransactionContext) {
                mTransactionManager.commit();
            }
        }

當我在緩存中尋找的“鍵”對象在那里不可用時,它會超時。 理想情況下,它應該只返回“ null”,但會超時。 同樣,這並非總是可再現的錯誤。

et.sf.ehcache.transaction.TransactionTimeoutException: transaction [41] timed out
     net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:108)
     net.sf.ehcache.transaction.local.LocalTransactionStore.get(LocalTransactionStore.java:349)
     net.sf.ehcache.store.AbstractCopyingCacheStore.get(AbstractCopyingCacheStore.java:95)
     net.sf.ehcache.store.TxCopyingCacheStore.get(TxCopyingCacheStore.java:33)
     net.sf.ehcache.Cache.get(Cache.java:1723)
     net.sf.ehcache.Cache.get(Cache.java:1696)

這可能是問題所在。 提前致謝。

因為您說的是這種情況並非總是可重復的,所以我假設您不時地且僅在配置的事務超時(示例中為10秒)到期后才收到此異常。

這可能是並且很可能是完全正常的:如果並發事務正在修改您嘗試獲取的元素,則當前事務將被阻塞,直到另一個事務提交或回滾為止。 根據並發事務花費的時間,或者如果您有許多事務都爭用同一個鍵,則很有可能其中之一最終會超時。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM