<div dir="ltr"><div>That doesn&#39;t sound right, we don&#39;t keep any lock for the duration of the replication. In non-tx mode, we have to do a RPC to the primary owner before we acquire any key. So there&#39;s nothing stopping the PFER from writing its value after a regular (sync) put when the put was initiated after the PFER.</div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 22, 2013 at 2:49 PM, William Burns <span dir="ltr">&lt;<a href="mailto:mudokonman@gmail.com" target="_blank">mudokonman@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I wonder if we are over analyzing this.  It seems the main issue is<br>
that the replication is done asynchronously.  Infinispan has many ways<br>
to be make something asynchronous.  In my opinion we just chose the<br>
wrong way.  Wouldn&#39;t it be easier to just change the PFER to instead<br>
of passing along the FORCE_ASYNCHRONOUS flag we instead just have the<br>
operation performed asynchronous using putIfAbsentAsync ?  This way<br>
the lock is held during the duration of the replication and should be<br>
consistent with other operations.  Also the user can regain control<br>
back faster as it doesn&#39;t even have to process the local interceptor<br>
chain.  We could also change the putForExternalRead method declaration<br>
to also return a NotifiableFuture&lt;Void&gt; or something so they know when<br>
the operation is completed (if they want).<br>
<br>
 - Will<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, Nov 21, 2013 at 9:54 AM, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Nov 21, 2013 at 12:35 PM, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com">galder@redhat.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Nov 18, 2013, at 12:42 PM, Dan Berindei &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Mon, Nov 18, 2013 at 9:43 AM, Galder Zamarreño &lt;<a href="mailto:galder@redhat.com">galder@redhat.com</a>&gt;<br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; On Nov 14, 2013, at 1:20 PM, Pedro Ruivo &lt;<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &gt; Hi,<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; Simple question: shouldn&#39;t PFER ensure some consistency?<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; I know that PFER is asynchronous but (IMO) it can create<br>
&gt;&gt; &gt; &gt; inconsistencies<br>
&gt;&gt; &gt; &gt; in the data. the primary owner replicates the PFER follow by a PUT<br>
&gt;&gt; &gt; &gt; (PFER<br>
&gt;&gt; &gt; &gt; is sent async log the lock is released immediately) for the same key,<br>
&gt;&gt; &gt; &gt; we<br>
&gt;&gt; &gt; &gt; have no way to be sure if the PFER is delivered after or before in all<br>
&gt;&gt; &gt; &gt; the backup owners.<br>
&gt;&gt; &gt; &gt;<br>
&gt;&gt; &gt; &gt; comments?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Assuming that PFER and PUT happen in the same thread, we&#39;re normally<br>
&gt;&gt; &gt; relying on the JGroups sequence of events to send the first, wait no<br>
&gt;&gt; &gt; response, and then send the second put. That should guarantee order in which<br>
&gt;&gt; &gt; puts are received in the other nodes, but after that yeah, there&#39;s a risk<br>
&gt;&gt; &gt; that it could happen. PFER and PUT for a given key normally happen in the<br>
&gt;&gt; &gt; same thread in cache heavy use cases such as Hibernate 2LC, but there&#39;s no<br>
&gt;&gt; &gt; guarantee.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I don&#39;t think that&#39;s correct. If the cache is synchronous, the PUT will<br>
&gt;&gt; &gt; be sent as an OOB message, and as such it can be delivered on the target<br>
&gt;&gt; &gt; before the previous PFER command. That&#39;s regardless of whether the PFER<br>
&gt;&gt; &gt; command was sent as a regular or as an OOB message.<br>
&gt;&gt;<br>
&gt;&gt; ^ Hmmmm, that&#39;s definitely risky. I think we should make PFER local only.<br>
&gt;&gt;<br>
&gt;&gt; The fact that PFER is asynchronous is nice to have. IOW, if you read a<br>
&gt;&gt; value from a database and you want to store it in the cache for later read,<br>
&gt;&gt; the fact that it&#39;s replicated asynchronously is just so that other nodes can<br>
&gt;&gt; take advantage of the value being in the cache. Since it&#39;s asynchronous some<br>
&gt;&gt; nodes could fail to apply, but that&#39;s fine since you can go to the database<br>
&gt;&gt; and re-retrieve it from there. So, making PFER local only would be the<br>
&gt;&gt; degenerate case, where all nodes fail to apply except the local node, which<br>
&gt;&gt; is fine. This is better than having the reordering above.<br>
&gt;&gt;<br>
&gt;&gt; In a chat I had with Dan, he pointed out that having PFER local only would<br>
&gt;&gt; be problematic for DIST mode w/ L1 enabled, since the local write would not<br>
&gt;&gt; invalidate other nodes, but this is fine because PFER only really makes<br>
&gt;&gt; sense for situations where the Infinispan is used as a cache. So, if the<br>
&gt;&gt; data is in the DB, you might as well go there (1 network trip), as opposed<br>
&gt;&gt; to askign the other nodes for data and the database in the worst case (2<br>
&gt;&gt; network trips).<br>
&gt;&gt;<br>
&gt;&gt; PFER is really designed for replication or invalidation use cases, which<br>
&gt;&gt; are precisely the ones configured for Hibernate 2LC.<br>
&gt;&gt;<br>
&gt;&gt; Thoughts?<br>
&gt;&gt;<br>
&gt;<br>
&gt; +1 to make PFER local-only in replicated caches, but I now think we should<br>
&gt; go all the way and disallow PFER completely in dist caches.<br>
&gt;<br>
&gt; I still think having L1 enabled would be a problem, because a regular put()<br>
&gt; won&#39;t invalidate the entry on all the nodes that did a PFER for that key<br>
&gt; (there are no requestors, and even if we assume that we do a remote get<br>
&gt; before the PFER we&#39;d still have race conditions).<br>
&gt;<br>
&gt; With L1 disabled, we have the problem that you mentioned: we&#39;re trying to<br>
&gt; read the value from the proper owners, but we never write it to the proper<br>
&gt; owners, so the hit ratio will be pretty bad. Using the SKIP_REMOTE_LOOKUP<br>
&gt; flag on reads, we&#39;ll avoid the extra RPC in Infinispan, but that will make<br>
&gt; the hit ratio even worse. E.g. in a 4-nodes cluster with numOwners=2, the<br>
&gt; hit ratio will never go above 50%.<br>
&gt;<br>
&gt; I don&#39;t think anyone would use a cache knowing that its hit ratio can never<br>
&gt; get above 50%, so we should just save ourselves some effort and stop<br>
&gt; supporting PFER in DIST mode.<br>
&gt;<br>
&gt; Cheers<br>
&gt; Dan<br>
&gt;<br>
&gt;<br>
</div></div><div class="HOEnZb"><div class="h5">&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>
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>