Infinispan invalidation cache invalidates on new key

488 Views Asked by At

We have a two active/active node Wildfly 19 cluster configuration with infinispan (v 9.4.18) invalidation cache.

<invalidation-cache name="opencell-tenant-cache">
    <transaction locking="OPTIMISTIC" mode="NONE"/>
</invalidation-cache>

According to the infinispan documentation, when a cached value change on node1, a InvalidateCommand is send from node 1 to node2, invalidating/removing a key entry from a node2 cache.

What I noticed is that InvalidateCommand is send even on a new key put.

In our application if key is not found in cache, a value will be loaded from a DB and put in a cache. And as both servers are active, I get the following never ending scenario:

Request to Node 1 > Key not found on Node1 cache > Value is loaded from DB and put to Node1 cache > key invalidated on Node2
Request to Node 2 > Key not found on Node2 cache > Value is loaded from DB and put to Node2 cache > key invalidated on Node 1
Request to Node 1 > Key not found on Node1 cache > Value is loaded from DB and put to Node1 cache > key invalidated on Node 2
and so on.

With this scenario, I am invalidating cache constantly, even though data is never changed. I would expect that no invalidation command is send on new key put.

Otherwise what is a practical use of invalidation cache, if same key put after receiving invalidation command will trigger an invalidation again.

Thanks

1

There are 1 best solutions below

4
pruivo On

I would expect that no invalidation command is send on new key put. And what is a new put?

Request to Node 2 > Key not found on Node2 cache <- in your example, Node 2 does not have the key locally; so it is a new put.

Node 2 can fetch the key from Node 2 if you configure a ClusterLoader. See Invalidation Cache Mode Documentation.

If invalidation does not fit your data access, take a look at the other cache modes (like replicated/distributed).