We're updating the issue view to help you get more done. 

ClusteredTimestampsRegionImpl: Local Timestamp cache is not updated right after cache.put(key, value)


ClusteredTimestampsRegionImpl keeps a localCache that's not updated right after calling its put method. Calling the get just after the put will not return the value that was just added to the region. I understand that the value will not be available for other nodes of the cluster, but I was expecting that the value would be available, at least, to the cluster node that executed the put method. Is this by design?

1 2 3 region.put("some_key", 1L); Long actual = (Long) region.get("some_key"); // here actual might not be 1L, but the previous value before put was called.

The affected scenario:
I have 2 cluster nodes, but I'm accessing only 1 of them.
For the same transaction and "hibernate session", if I do the following:

  • Execute a query for entity A (that will be cached locally local-query)

  • Persist a new instance of entity A

  • Flush the entity manager/session

  • Execute the very same query again

  • Then I'll get old results. The persisted entity A is not returned, but it should be returned.

If I add a sleep of 100ms after the flush, the query will return the correct results. While debugging I realized that ClusteredTimestampsRegionImpl doesn't update its local cache right away during put and it will only be updated after nodeModified is called, the local cache is updated.

All these operations are executed in just one cluster node.

The infinispan configuration:

1 2 3 4 5 6 7 8 9 10 11 12 <local-cache name="entity"> <transaction mode="NON_XA" auto-commit="false" complete-timeout="600000" transaction-manager-lookup="com.our.custom.TransactionManagerLookup"/> <eviction strategy="NONE"/> </local-cache> <local-cache name="local-query"> <transaction mode="NONE"/> <eviction strategy="NONE"/> </local-cache> <local-cache name="timestamps"> <transaction mode="NONE"/> <eviction strategy="NONE"/> </local-cache>

The partial code for the test case:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 @Test public void localQueryShouldBeInvalidatedAfterFlush() { // Given Query query = entityManager.createQuery("select e from MyEntity e"); query.setHint(QueryHints.HINT_CACHEABLE, Boolean.TRUE); List firstResults = query.getResultList(); MyEntity newEntity = new MyEntity(); newEntity.setName("abc"); entityManager.persist(newEntity); entityManager.flush(); // When List finalResults = query.getResultList(); // Then assertEquals(firstResults.size() + 1, finalResults.size()); }


infinispan-embedded-7.2.5.Final.jar hibernate-infinispan-4.3.11.Final.jar infinispan-embedded-8.2.6.Final.jar hibernate-infinispan-5.2.9.Final.jar



Radim Vansa




Fix versions

Affects versions