Hi,
We've been experiencing stale cache issues when using HazelcastLocalCacheRegionFactory (Hazelcast 2.6.3, Hibernate 3.6.10.Final) in our project, specifically involving the query cache for sure.
What appears to be happening is that when a Hibernate update of any kind (insert, update, delete) is performed on one node, the cached timestamp for that table is updated on that node itself, but never gets propagated to any other node. The effect being that updates are seen on the node that performed the update, but all other nodes continue to see stale cached data.
For reference, we are setting the following properties:
hibernate.cache.use_second_level_cache=true
hibernate.cache.use_query_cache=true
hibernate.cache.use_minimal_puts=true
hibernate.generate_statistics=false
hibernate.cache.use_structured_entries=false
The one particular Entity that I have been testing with is annotated as such:
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
I mentioned that we are using Hazelcast 2.6.3 but I have also tested (same problem) with 2.6.4 and 2.6.5-SNAPSHOT.
One thing I did notice in the code is that com.hazelcast.hibernate.local.LocalRegionCache only sends an invalidation message when the update() method is called. When put() is called, the value is updated in the local cache ONLY. On a whim, I updated put() to invoke update() (exactly as it is done in com.hazelcast.hibernate.distributed.IMapRegionCache) and my stale cache issue seems to be fixed.
So am I doing something wrong, or is this a bug?
Attached is a patch made against the maintenance-2.x branch.
Thanks!
John