Bug 990587 - [HHH-7959] Hibernate/Infinispan 2nd Level Caches set to transaction-mode=NONE stop functioning after an explicit eviction
[HHH-7959] Hibernate/Infinispan 2nd Level Caches set to transaction-mode=NONE...
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
6.0.1
Unspecified Unspecified
unspecified Severity high
: ER1
: EAP 6.2.0
Assigned To: Brett Meyer
Zbyněk Roubalík
Russell Dickenson
:
Depends On:
Blocks: 990594 eap62-upgrade-hibernate425
  Show dependency treegraph
 
Reported: 2013-07-31 09:41 EDT by csams
Modified: 2015-09-01 00:00 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
An Infinispan second-level cache configured with `transaction-mode=NONE` would be invalidated when programmatically forcing an eviction. This invalid state would result in performance degradation, and TRACE level log messages of `Could not invalidate region: null`. This issue was caused by unhandled null values related to attempting to use a TransactionManager in a non-transactional configuration, resulting in NullPointerExceptions. This issue has been fixed in this release of JBoss EAP 6 so that proper null checks now allow the eviction and valid state to occur. As a result, programmatically forcing an eviction on an Infinispan second-level cache configured with `transaction-mode=NONE` will no longer trigger an invalid state and associated performance degradation.
Story Points: ---
Clone Of:
: 990594 (view as bug list)
Environment:
Last Closed: 2013-12-15 11:12:47 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description csams 2013-07-31 09:41:47 EDT
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:
Comment 1 Brett Meyer 2013-08-20 11:19:55 EDT
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.
Comment 2 Zbyněk Roubalík 2013-09-23 07:21:11 EDT
EAP 6.2.0.ER1

Note You need to log in before you can comment on or make changes to this bug.