[infinispan-issues] [JBoss JIRA] (ISPN-4972) Two concurrent replaceWithVersions may both succeed
Galder Zamarreño (JIRA)
issues at jboss.org
Wed Nov 12 10:24:30 EST 2014
[ https://issues.jboss.org/browse/ISPN-4972?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019456#comment-13019456 ]
Galder Zamarreño commented on ISPN-4972:
----------------------------------------
I’m not sure this is a bug at all. If the values are equal, ReplaceIfUnmodified returning true could be valid. IOW, it’s replaced the value and the value is... the same one :|. To take a CHM as an example:
{code}
ConcurrentMap chm = new ConcurrentHashMap[Integer, String]()
chm.put(1, "v1”)
chm.replace(1, "v1", "v1”) // returns true
{code}
> Two concurrent replaceWithVersions may both succeed
> ---------------------------------------------------
>
> Key: ISPN-4972
> URL: https://issues.jboss.org/browse/ISPN-4972
> Project: Infinispan
> Issue Type: Bug
> Components: Remote Protocols
> Affects Versions: 7.0.0.Final
> Reporter: Radim Vansa
>
> Cache contains entry {{K = V}}. Two concurrent threads, that execute:
> {code}
> long version = cache.getVersioned(K).getVersion();
> boolean succeeded = cache.replaceWithVersion(K, V, version);
> {code}
> Both of these threads can get {{succeeded = true}}.
> Reason:
> When the server receives the operation ReplaceIfUnmodified=replaceWithVersion, it retrieves the entry (key + value + metadata) from the cache and checks that the version stored (in metadata) is the same as the version in the request. If so, it creates conditional ReplaceCommand which contains the value (retrieved atomically with version from the cache) and executes this one. Therefore, as the value is in both requests identical (and is not changed by the replace), two concurrent ReplaceCommands can both succeed, and this value is returned to the HotRod client.
--
This message was sent by Atlassian JIRA
(v6.3.8#6338)
More information about the infinispan-issues
mailing list