- Wildfly 39.0.1
- Hibernate 6.6.40
- Infinispan 16.0.5
I’m trying to use the hibernte L2C in a clustered wildfly environment. I have two nodes, behind an apache load balancer, using the standalone-ha configuration that wildfly provides for clustered servers. I’ve stripped my application down to as small as I can, just one Person entity. It’s marked as @Cacheable and my queries all have query.setHint("org.hibernate.cacheable", true)set.
My persistence.xml has cache mode set to ENABLE_SELECTIVE, and hibernate.cache.use_second_level_cache and hibernate.cache.use_query_cache are set to true.
The L2C works great - I can see from the server logs that it makes one actual query per node and then uses the cache instead. Until I mutate an entity. Then, both nodes are invalidated and another query happens when make a reading API call. But it keeps happening - reads don’t use the cache again for what appears to be 60 seconds.
I assume this is unexpected? It’s as if the cache invalidation keeps it invalid, rather than marking it as “needing update”. A subsequent SELECT doesn’t update the cache and mark it as “valid”.
In the log file, it looks like:
2026-08-29 14:07:48,089 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:07:48,089 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:07:48,089 DEBUG [org.hibernate.orm.cache] (default task-2) Returning cached query results
2026-08-29 14:07:49,570 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:07:49,571 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:07:49,571 DEBUG [org.hibernate.orm.cache] (default task-2) Returning cached query results
2026-08-29 14:07:50,335 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:07:50,335 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:07:50,335 DEBUG [org.hibernate.orm.cache] (default task-2) Returning cached query results
# UPDATE ON NODE 2
2026-08-29 14:07:57,364 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:07:57,364 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:07:57,364 DEBUG [org.hibernate.orm.cache] (default task-2) Cached query results were not up-to-date
2026-08-29 14:07:57,365 DEBUG [org.hibernate.orm.cache] (default task-2) Caching query results in region: default-query-results-region; timestamp=1788026877363
2026-08-29 14:08:05,462 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:08:05,462 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:08:05,462 DEBUG [org.hibernate.orm.cache] (default task-2) Cached query results were not up-to-date
2026-08-29 14:08:05,464 DEBUG [org.hibernate.orm.cache] (default task-2) Caching query results in region: default-query-results-region; timestamp=1788026885462
# [...] LOTS OF THESE
2026-08-29 14:08:53,194 DEBUG [org.hibernate.orm.sql.exec] (default task-2) Reading Query result cache data per CacheMode#isGetEnabled [NORMAL]
2026-08-29 14:08:53,194 DEBUG [org.hibernate.orm.cache] (default task-2) Checking cached query results in region: default-query-results-region
2026-08-29 14:08:53,195 DEBUG [org.hibernate.orm.cache] (default task-2) Returning cached query results