Description of problem: The caches in the 'infinispan' subsystem configured with <transaction mode="NONE"/> (which results in no transaction used by 2LC) get stuck in state= CLEARING when you perform a programmatic evict() on them to clear the caches. (Using e.g. em.getEntityManagerFactory().getCache().evictAll() or the evict* from the Cache gotten from the SessionFactory) The problem seem to lie within the class 'org.hibernate.cache.infinispan.impl.BaseRegion, where the 'checkValid' method fails to clear the cache (and set back the state to VALID). The reason it fails is because it calls: cacheAdapter.withinTx(), which in turn tries to get the TransactionManager from the cache (which seems to be null for these non-transactional caches), and then NPEs on the tm.begin(); The NPE is caught and logs out (TRACE in org.hibernate.cache.infinispan.impl.BaseRegion) "Could not invalidate region: null", and never set the state in VALID. So from thereon the caches are in an Invalid state and are not used anymore by Infinispan, thus leading to much performance degradation. Version-Release number of selected component (if applicable): EAP 6.0.1 / Hibernate 4.1.3 How reproducible: Always Steps to Reproduce: 0. Set org.hibernate.cache logging category to TRACE. 1. Execute a cacheable query with cacheable entities. 2. Execute all of the evict* methods: HibernateEntityManagerFactory hEmf = (HibernateEntityManagerFactory)em.getEntityManagerFactory(); Cache cache = hEmf.getSessionFactory().getCache(); cache.evictEntityRegions(); cache.evictCollectionRegions(); cache.evictDefaultQueryRegion(); cache.evictQueryRegions(); 3. Execute the query again. Actual results: See "Could not invalidate region: null" at TRACE level in the logs, and the query cache stops working. Expected results: No trace level message Additional info:
Fix pushed to http://git.app.eng.bos.redhat.com/?p=hibernate/hibernate-core.git;a=shortlog;h=refs/heads/eap61-cp-updates, but EAP 6.2.0 should have a Hibernate upgrade anyway.
EAP 6.2.0.ER1