Skip to content
Advertisement

Infinispan : locking in remote transactional cache

We try to use infinispan as a remote cache with a read lock. The clients are making a read with a “put” in order to acquire a lock on the key, like described infinispan documentation in the section pessimistic transactional cache “When cache.put(k1,v1) returns, k1 is locked and no other transaction running anywhere in the cluster can write to it. Reading k1 is still possible. The lock on k1 is released when the transaction completes (commits or rollbacks). so the scenario :

JavaScript

the remote cache is configured as transactional with pessimistic locking :

JavaScript

and the clients are accessing the remoteCacheManager as HOTROD client with the configuration:

JavaScript

Despite that the clients could “read with put” one value simultaneously, Concurent clients are not getting the exception when putting the value when reading it, but only later by commiting the transction. Is that the expected bahavior ?

Advertisement

Answer

Yes, it is.

As described in the docs (Hot Rod Transaction) the transaction running on the client has optimistic semantics. The locks will be acquired only during commit.

The pessimistic locking transactions are only valid in embedded mode.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement