EHC ❯ Search on transactin cache does look at objects created in thesame transaction
-
Bug
-
Status: Resolved
-
2 Major
-
Resolution: As Designed
-
ehcache-core
-
-
ljacomet
-
Reporter: 01epa
-
January 20, 2015
-
0
-
Watchers: 2
-
February 09, 2015
-
February 09, 2015
Attachments
Description
During testing an Ehcache we found that search does not work on transaction cache correctly. We used the following configs: CacheConfiguration cacheConfiguration = new CacheConfiguration(cacheName, 0).eternal(true).statistics(true).maxEntriesLocalHeap(10000).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU); if (useTransaction) { cacheConfiguration.transactionalMode(CacheConfiguration.TransactionalMode.XA); } Searchable searchable = new Searchable(); cacheConfiguration.addSearchable(searchable); CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration = new CacheConfiguration.CacheEventListenerFactoryConfiguration(); factoryConfiguration.setProperties(“nccachelistener=com.netcracker.platform.core.ncdo.plugin.impl.CacheContextListener”); factoryConfiguration.setClass(“com.netcracker.platform.cache.listener.NCEhCacheEventListenerFactory”); cacheConfiguration.addCacheEventListenerFactory(factoryConfiguration); final CopyStrategyConfiguration copyStrategyConfiguration = new CopyStrategyConfiguration(); copyStrategyConfiguration.setClass(“com.netcracker.platform.core.ncdo.persistence.cache.impl.NCDOReadWriteCopyStrategy”); cacheConfiguration.addCopyStrategy(copyStrategyConfiguration); Ehcache cache = new Cache(cacheConfiguration); cacheManager.addCache(cache); EhCacheCache cacheCache = new EhCacheCache(cache);
The probkem happend when we added some objects to cache and wanted to search them in cache but as we found the search does not return any of these objects.
Debug showed that search did not look at objects which we added during current transaction even if it is not complieted. The probkem is in TransactionalIterator.
I attached a patch which we have tested and which worked fine.
In the newest versions we observed the same behaviour, so it would be great to have fix in these versions also.
Search in Ehcache should not be considered transactional. It always looks at the state prior to the transaction. There are no plans to change this.