Wildfly 26 Hibernate 5.3.x Infinispan 13.0.x Cache Refresh Issue

159 views
Skip to first unread message

Sayantan Ganguly

unread,
May 13, 2024, 1:06:54 PM5/13/24
to WildFly
Hello All,

I am new to Inifinispan(l2c) and facing a strange issue of Infinispan Cache not updating the latest data from DB(postgres or derby).  The data retrieved for <MAPPED_ENTITY> has a mapping to the <ENTITY>, though it is actually deleted from the data base.

In JBOSS the infinispan-config.xml was used, which is now migrated to the standalone configuration file and mapped to the hibernate.properties. 

I am able to see the Named Cache entities in the infinispan subsystem but I am not sure the new cache configurations actually are mapped to the entities or whether they matter in case of this issue?

They were added using hibernate.cache.infinispan.cfg, hibernate.cache.infinispan.eviction.max_entries,  properties - does they need to be updated for Wildfly?

How can I debug the issue? - I have enabled the infinispan logs and can see the some logs but unfortunately not able to decipher much from them.

2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#284, 1715594016840)
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#284, 1715594016840)
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] Region invalidated at -9223372036854775808, this transaction started at 1715594016840
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] Region invalidated at -9223372036854775808, this transaction started at 1715594016840
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#284, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#284, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<ENTITY>#<ENTITY>#284, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.841 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<ENTITY>#<ENTITY>#284, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#373, 1715594016840)
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#373, 1715594016840)
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] Region invalidated at -9223372036854775808, this transaction started at 1715594016840
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] Region invalidated at -9223372036854775808, this transaction started at 1715594016840
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#373, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<ENTITY>#<ENTITY>#373, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<ENTITY>#<ENTITY>#373, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<ENTITY>#<ENTITY>#373, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] registerPendingPut(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840) registered using putIfAbsent: { PendingPuts=[R@Session#649787962], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}
2024-05-13 03:53:36.842 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] registerPendingPut(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840) registered using putIfAbsent: { PendingPuts=[R@Session#649787962], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840)
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840)
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] acquirePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, 1715594016840) ended with { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false}, valid: true
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.commons.access.PutFromLoadValidator] releasePutFromLoadLock(<MAPPED_ENTITY>#<MAPPED_ENTITY>#377, { PendingPuts=[], Invalidators=[], LastInvalidationEnd=<none>, Removed=false})
2024-05-13 03:53:36.848 TRACE [org.infinispan.hibernate.cache.v53.impl.Sync] 0 tasks done, 0 tasks not done yet
20

Is there any example of Wildfly Infinispan Configuration with custom named cache?

Thanks,
Sayantan

Sayantan Ganguly

unread,
May 13, 2024, 9:57:47 PM5/13/24
to WildFly
Any pointers would be much appreciated!!

--
You received this message because you are subscribed to a topic in the Google Groups "WildFly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wildfly/ZzMRmrTlSMk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/24e6cf15-4dac-4a35-90aa-2cbdf8e4d3a5n%40googlegroups.com.

Paul Ferraro

unread,
May 20, 2024, 6:09:54 PM5/20/24
to WildFly
Are you using hibernate directly or via JPA?  Can you attach your hibernate session-factory configuration?

Sayantan Ganguly

unread,
May 21, 2024, 12:02:59 AM5/21/24
to Paul Ferraro, WildFly
We are using hibernate directly and don't use JPA. This is our hibernate.properties file used for session-factory configuration. 

hibernate.properties

hibernate.current_session_context_class=jta
hibernate.transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.connection.autocommit=false
#
# read committed
hibernate.connection.isolation=2
#

#Cache settings

hibernate.cache.region.factory_class=org.infinispan.hibernate.cache.v53.InfinispanRegionFactory
hibernate.cache.use_second_level_cache=true

hibernate.cache.infinispan.statistics=true
hibernate.cache.infinispan.shared=false
hibernate.cache.use_query_cache=true
hibernate.cache.use_minimal_puts=true

#
# batch sizes
# size of prefetch batches
hibernate.default_batch_fetch_size=64

# size of jdbc fetch. setting this large will cause high memory use on oracle.
hibernate.jdbc.fetch_size=100

# number of statements in jdbc batch
hibernate.jdbc.batch_size=100

# depth of outer join fetches
hibernate.max_fetch_depth=4

# Stats off by default for production
hibernate.generate_statistics=false

# order updates by PK to reduce likelihood of deadlocks
hibernate.order_updates=true
# order inserts for batching
hibernate.order_inserts=true

hibernate.show_sql=false
hibernate.format_sql=false
hibernate.use_sql_comments=false

# we do our own validation
javax.persistence.validation.mode=none

Some additional information:

The infinispan cache properties are set using set property during hibernate session-factory configuration phase for example :

java.util.setProperty(hibernate.cache.infinispan.<ENTITY_NAME_WITH_PACKAGE>.eviction.max_entries, 1000) &
java.util.setProperty(hibernate.cache.infinispan.<ENTITY_NAME_WITH_PACKAGE>.cfg, test)

I had also created the cache configuration (config) in Wildfly model as below:

standalone.xml

<local-cache name="test" statistics-enabled="false">
      <locking acquire-timeout="60000" concurrency-level="16" isolation="READ_COMMITTED" striping="false"/>
      <heap-memory size="10000"/>
      <expiration max-idle="3600000"/>
</local-cache>

Thanks,
Sayantan



You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/7ace92b0-4577-4557-8560-40fbf3f70d76n%40googlegroups.com.

Paul Ferraro

unread,
May 21, 2024, 4:40:48 PM5/21/24
to WildFly
Remove your "hibernate.cache.region.factory_class" property - this implementation is not supported within WildFly.
See https://docs.wildfly.org/26.1/Developer_Guide.html#using-the-infinispan-second-level-cache

Sayantan Ganguly

unread,
May 22, 2024, 12:36:38 AM5/22/24
to WildFly
I tried this configuration but same results.

This issue is happening in tests where a few db operations are happening in quick succession.

Though these are not good options and will impact the performance, I observed that if I make the db operation to wait for a minute plus it works, or if I evict all the cache regions explicitly (SessionFactory.getSessionFactory().getCache().evictAllRegions();) it also works.

My concern is this issue may be observed in production as well and can have functional impact - Is this a issue with Infinispan? 

Thanks,
Sayantan

Reply all
Reply to author
Forward
0 new messages