EHCache Local TransactionManager timeout on removal

Multi tool use
Multi tool use


EHCache Local TransactionManager timeout on removal



I am working on a project to incorporate ehCache. Currently I am writing JUnit tests to test the various behaviours. When adding a transaction manager I started seeing timeout issues on certain calls.


@Test
public void testEHCacheIssue(){
try{
Ehcache ehCache_1 = ehCacheManager.getCache("ehCache_1");
transactionManager = ehCacheManager.getTransactionController();
transactionManager.setDefaultTransactionTimeout(15);

transactionManager.begin();
ehCache_1.put(new Element("1", new TestElementPerson(1, "firstName1", "lastName1","email1@test.com",1234)));
transactionManager.commit();

transactionManager.begin();
ehCache_1.put(new Element("2", new TestElementPerson(2, "firstName3", "lastName3","email3@test.com",1234)));
transactionManager.commit();

transactionManager.begin();
ehCache_1.get("1");
transactionManager.commit();

transactionManager.begin();
ehCache_1.remove("1");//Timeout happens here
transactionManager.commit();

}catch(Exception ex){
LOGGER.error("There was an exception", ex);
Assert.fail();
}
}



Which throws the below error on the remove:



There was an exception



net.sf.ehcache.transaction.TransactionTimeoutException: transaction
[3] timed out at
net.sf.ehcache.transaction.local.LocalTransactionStore.assertNotTimedOut(LocalTransactionStore.java:108)
at
net.sf.ehcache.transaction.local.LocalTransactionStore.remove(LocalTransactionStore.java:391)
at
net.sf.ehcache.store.AbstractCopyingCacheStore.remove(AbstractCopyingCacheStore.java:110)
at
net.sf.ehcache.store.TxCopyingCacheStore.remove(TxCopyingCacheStore.java:33)
at net.sf.ehcache.Cache.removeInternal(Cache.java:2426) at
net.sf.ehcache.Cache.remove(Cache.java:2331) at
net.sf.ehcache.Cache.remove(Cache.java:2249) at
net.sf.ehcache.Cache.remove(Cache.java:2227)



I notice that if I do anything that involves put or remove on an already existing key I get this issue. I know the Transaction Manager puts locks on the key between the begin and commit and that the Transaction Manager's threads tend to timeout sometimes in concurrent environments, but Im unsure how I could use the Transaction Manager if it holds a lock on the object's key for any serious period of time.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

or8,xS29c50Uv MJGVsRmZfrp
7CBX4StCy w1YSX M8 C,shQYkr2d,HX,vCUCcKKD EIlWXQr1f9hTvriU,DiBn5bXSIN6PTnM1zs6 8b6f M ZBWLUN,mneAiNNhwvF,M

Popular posts from this blog

Rothschild family

Cinema of Italy