-
Bug
-
Resolution: Done
-
Major
-
5.1.3.FINAL
-
None
The javadoc says: "Only goes through if the key specified does not exist..."
But, two consecutive calls for putForExternalRead result in the second one acting on the cache.
1st call:
1444 TRACE [org.infinispan.interceptors.InvocationContextInterceptor] (main:replSync) Invoked with command PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1} and InvocationContext [SingleKeyNonTxInvocationContext{flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ]}] 1444 TRACE [org.infinispan.statetransfer.StateTransferLockImpl] (main:replSync) Acquired shared state transfer shared lock, total holders: 1 1444 TRACE [org.infinispan.container.EntryFactoryImpl] (main:replSync) Exists in context? null 1444 TRACE [org.infinispan.container.EntryFactoryImpl] (main:replSync) Retrieved from container null 1444 TRACE [org.infinispan.container.EntryFactoryImpl] (main:replSync) Creating new entry. 1446 TRACE [org.infinispan.interceptors.CallInterceptor] (main:replSync) Executing command: PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1}. 1447 TRACE [org.infinispan.remoting.rpc.RpcManagerImpl] (main:replSync) NodeA-26945 broadcasting call PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1} to recipient list null ... 1452 TRACE [org.infinispan.container.entries.ReadCommittedEntry] (main:replSync) Updating entry (key=k removed=false valid=true changed=true created=true value=v] 1453 TRACE [org.infinispan.interceptors.EntryWrappingInterceptor] (main:replSync) Committed entry ReadCommittedEntry(1436ae83){key=k, value=v, oldValue=null, isCreated=false, isChanged=false, isRemoved=false, isValid=true}
2nd call:
1453 TRACE [org.infinispan.interceptors.InvocationContextInterceptor] (main:replSync) Invoked with command PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1} and InvocationContext [SingleKeyNonTxInvocationContext{flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ]}] 1453 TRACE [org.infinispan.remoting.InboundInvocationHandlerImpl] (Incoming-1,ISPN,NodeB-23417:) Calling perform() on SingleRpcCommand{cacheName='replSync', command=PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=false, lifespanMillis=-1, maxIdleTimeMillis=-1}} 1453 TRACE [org.infinispan.container.EntryFactoryImpl] (main:replSync) Exists in context? null 1453 TRACE [org.infinispan.container.EntryFactoryImpl] (main:replSync) Retrieved from container ImmortalCacheEntry{key=k, value=ImmortalCacheValue {value=v}} 1454 TRACE [org.infinispan.interceptors.CallInterceptor] (main:replSync) Executing command: PutKeyValueCommand{key=k, value=v, flags=[ZERO_LOCK_ACQUISITION_TIMEOUT, FORCE_ASYNCHRONOUS, FAIL_SILENTLY, PUT_FOR_EXTERNAL_READ], putIfAbsent=true, lifespanMillis=-1, maxIdleTimeMillis=-1}. 1454 TRACE [org.infinispan.container.entries.ReadCommittedEntry] (main:replSync) Updating entry (key=k removed=false valid=true changed=true created=false value=v] 1454 TRACE [org.infinispan.interceptors.EntryWrappingInterceptor] (main:replSync) Committed entry ReadCommittedEntry(7f2ea1dd){key=k, value=v, oldValue=null, isCreated=false, isChanged=false, isRemoved=false, isValid=true}
Why is updating an entry if if the value is already present? It shouldn't do that.
Even further, in the case of putForExternalRead() the previous value is not needed since we don't return it, so it should not even retrieve it from the container. Just checking if it's present should be enough. This is in contrast to a normal putIfAbsent() call.
- relates to
-
ISPN-1986 Make putForExternalRead return a boolean instead of void
- Resolved