<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 12, 2013 at 1:32 PM, Galder Zamarreño <span dir="ltr">&lt;<a href="mailto:galder@redhat.com" target="_blank">galder@redhat.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Mar 8, 2013, at 1:50 PM, Sanne Grinovero &lt;<a href="mailto:sanne@infinispan.org">sanne@infinispan.org</a>&gt; wrote:<br>
<br>
&gt; Hi Galder,<br>
&gt; I think using conditional operations is very useful even with<br>
&gt; optimistic locking: the single conditional operation might not make<br>
&gt; sense, but a transaction might include more operations and some of<br>
&gt; these operations might depend on the result of the conditional<br>
&gt; operation.<br>
&gt;<br>
&gt; I&#39;d expect the conditional operation to only return the value based on<br>
&gt; current state (a prediction), and the transaction would fail if this<br>
&gt; value is no longer valid at commit time. So no locks need to be taken<br>
&gt; during the evaluation.<br>
<br>
</div>^ That&#39;s indeed what&#39;s happening, but as you can see, it confuses users (Jim, are you there?)…<br>
<br>
And I can see why they get confused. The conditional operations, such as replace, are rooted in enabling CAS-like operation, and an attempt to replace a value in a collection without having to synchronize or use locks…<br>


<br>
You can do what you say above with put/get operations. It will create more boiler plate code for sure, but the expectations of what the code does might be easier to understand for users.<br>
<br>
So, on one side, conditional operations can help reduce the code-size (by doing multiple operations in one go), but users expect them to behave in a way which does not really happen when you use transactions + OL.<br>
<br>
I&#39;m in two minds on this…<br>
<br></blockquote><div><br></div><div>I remember having a discussion about conditional operations with optimistic locking a long time ago (Edinburgh?) and concluding that they should be allowed to &quot;lie&quot; - pretend that they did the put/replace/remove and check again on prepare if the condition still holds (with write skew check enabled).<br>

<br>I think the other option on the table was treat conditional operations as &quot;non-transactional&quot; - if putIfAbsent(k, v) returned true, then v would be stored in the cache even if the current transaction was rolled back.<br>

<br></div><div>I don&#39;t remember if we considered acquiring locks for conditional operations even with optimistic locking at the time or not. It would be a bit of a hack, but it would make a lot more sense than the current behaviour with the default configuration (optimistic locking with write skew check disabled, which makes conditional operations pretty much useless).<br>

</div><div><br></div><div>Off-topic: is it just me, or is it a little odd that the locking mode is configured via TransactionConfigurationBuilder and the isolation level/write skew check are configured via LockingConfigurationBuilder?<br>

<br></div><div>Cheers<br></div><div>Dan<br><br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cheers,<br>
<div class="HOEnZb"><div class="h5"><br>
&gt;<br>
&gt; Sanne<br>
&gt;<br>
&gt; On 6 March 2013 14:45, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com">galder@redhat.com</a>&gt; wrote:<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; Re: <a href="https://issues.jboss.org/browse/ISPN-2891" target="_blank">https://issues.jboss.org/browse/ISPN-2891</a><br>
&gt;&gt;<br>
&gt;&gt; Not sure what previous Infinispan version the AS instance Immutant guys used (5.1?), but seems like they&#39;re having more issues with the clojure test linked in the JIRA.<br>
&gt;&gt;<br>
&gt;&gt; Again, we&#39;re talking about issues with replace(), but in a single node environment. They seem to have issues with PL and OL, but let&#39;s focus on OL for which there are logs attached.<br>
&gt;&gt;<br>
&gt;&gt; Do conditional operations make any sense at all with OL? For example, can the return of replace() be taken a truthful in a transaction with OL?<br>
&gt;&gt;<br>
&gt;&gt; As shown in the bad.log, this is not possible because lock acquisition and write skew checks are only done when the transaction is committed. So, what&#39;s the point of the conditional operations with OL? Their returns provide no guarantees whatsoever.<br>


&gt;&gt;<br>
&gt;&gt; If this is known thing, I&#39;m not aware of any docu on the topic.<br>
&gt;&gt;<br>
&gt;&gt; Thoughts?<br>
&gt;&gt;<br>
&gt;&gt; Cheers,<br>
&gt;&gt; --<br>
&gt;&gt; Galder Zamarreño<br>
&gt;&gt; <a href="mailto:galder@redhat.com">galder@redhat.com</a><br>
&gt;&gt; <a href="http://twitter.com/galderz" target="_blank">twitter.com/galderz</a><br>
&gt;&gt;<br>
&gt;&gt; Project Lead, Escalante<br>
&gt;&gt; <a href="http://escalante.io" target="_blank">http://escalante.io</a><br>
&gt;&gt;<br>
&gt;&gt; Engineer, Infinispan<br>
&gt;&gt; <a href="http://infinispan.org" target="_blank">http://infinispan.org</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
<br>
<br>
--<br>
Galder Zamarreño<br>
<a href="mailto:galder@redhat.com">galder@redhat.com</a><br>
<a href="http://twitter.com/galderz" target="_blank">twitter.com/galderz</a><br>
<br>
Project Lead, Escalante<br>
<a href="http://escalante.io" target="_blank">http://escalante.io</a><br>
<br>
Engineer, Infinispan<br>
<a href="http://infinispan.org" target="_blank">http://infinispan.org</a><br>
<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br></div></div>