2 Replies Latest reply on Apr 25, 2012 12:15 AM by eugendueck

    Overly optimistic concurrency in Infinispan REST server?

    eugendueck

      I wanted to check out ways to access Infinispan from .net, and the REST server looks like a (the?) way to go. I want to ensure integrity of my data by means of optimistic concurrency,

      and the resolved "support optimistic locking with ETags and If-Match in rest server" JIRA (https://issues.jboss.org/browse/ISPN-1084) seemed to provide that.

       

      Looking at the sources

      https://github.com/infinispan/infinispan/blob/master/server/rest/src/main/scala/org/infinispan/rest/Server.scala

      however, it seems the "optimistic currency control" is not atomic. The sequence in e.g. a PUT request goes like this:

      1. request.evaluatePreconditions
      2. cache.put (if preconditions met)

       

      Which is not in a lock (that would make it pessimistic, anyway), in other words, a race condition.

       

      I'm not a scala user, but as ConcurrentMap's methods (replace, putIfAbsent, ...) - that I checked on http://docs.jboss.org/infinispan/5.0/apidocs/org/infinispan/Cache.html Infinispan seems to be using - are not referenced anywhere in the sources, I guess I'm out of luck...

       

      Am I missing anything?