Hello,
I am using Infinispan as second level Hibernate cache in EAP 6.1. I'm working on single node.
It seems that the cache is set up and being used properly. I have noticed that in case of heavy load there occured some lock timeouts on keys of cached entities.
And really, if I switched the infinispan log to TRACE, I've found that the lock is being acquired:
Code:
15:30:51,330 TRACE [org.infinispan.util.concurrent.locks.LockManagerImpl] (Thread-12 (HornetQ-client-global-threads-972879781)) Attempting to lock com.productcatalog.ParameterMappingE
lement#-3 with acquisition timeout of 10000 millis
15:30:51,330 TRACE [org.infinispan.util.concurrent.locks.containers.ReentrantPerEntryLockContainer] (Thread-12 (HornetQ-client-global-threads-972879781)) Creating and acquiring new lock instance fo
r key com.productcatalog.ParameterMappingElement#-3
15:30:51,330 TRACE [org.infinispan.util.concurrent.locks.LockManagerImpl] (Thread-12 (HornetQ-client-global-threads-972879781)) Successfully acquired lock com.productcatalog.Parameter
MappingElement#-3!
15:30:51,330 TRACE [org.infinispan.util.concurrent.locks.LockManagerImpl] (Thread-12 (HornetQ-client-global-threads-972879781)) Attempting to unlock com.productcatalog.ParameterMappin
gElement#-3
15:30:51,331 TRACE [org.infinispan.util.concurrent.locks.containers.ReentrantPerEntryLockContainer] (Thread-12 (HornetQ-client-global-threads-972879781)) Unlocking lock instance for key com.productcatalog.ParameterMappingElement#-3
The application never changes cached data so I've configured the ConcurrencyStrategy to @Cache(usage=CacheConcurrencyStrategy.READ_ONLY).
It is strange for me that there are some locks, I thought that in case the it is used in READ_ONLY mode then nothing must be locked as there is no risk that concurrent threads will affect the cache values.
my persistence.xml looks like this:
Code:
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.hbm2ddl.auto" value="validate" />
<!-- <property name="hibernate.show_sql" value="true" /> -->
<!-- <property name="hibernate.format_sql" value="true" /> -->
<!--<property name="hibernate.transaction.flush_before_completion" value="true" /> -->
<property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory"/>
<property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate"/>
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true" />
</properties>
and the excerpt from standalone.xml is as follows:
Code:
<cache-container name="hibernate" default-cache="local-query" module="org.jboss.as.jpa.hibernate:4">
<local-cache name="entity">
<locking isolation="READ_COMMITTED" striping="false" concurrency-level="2000"/>
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000" lifespan="600000"/>
</local-cache>
<local-cache name="local-query">
<locking isolation="READ_COMMITTED" striping="false" concurrency-level="2000"/>
<transaction mode="NONE"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000" lifespan="600000"/>
</local-cache>
<local-cache name="timestamps">
<locking isolation="READ_COMMITTED" striping="false" concurrency-level="2000"/>
<transaction mode="NONE"/>
<eviction strategy="NONE"/>
<expiration lifespan="600000"/>
</local-cache>
</cache-container>
Could anybody tell me why entities are locked when cache is in READ_ONLY mode?
Many thanks.
Martin