<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 27, 2013 at 11:13 AM, Bela Ban <span dir="ltr">&lt;<a href="mailto:bban@redhat.com" target="_blank">bban@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">OK, here&#39;s what happens:<br>
<br>
- A&#39;s receiver table forB is at #6, this means that next message from B<br>
must be #7<br>
- A receives B#8 (regular message from B)<br>
- A adds B#8 to B&#39;s receiver table, but doesn&#39;t deliver it (not OOB,and<br>
not #7)<br>
- A receives OOB message B#7 from B<br>
- The OOB thread delivers B#7 immediately<br>
- Infinispan blocks on B#7<br>
- Unless another message from B is received, B#8 will *not* get<br>
delivered: as you can see in the codebelow, the OOB thread would check<br>
*after* delivering B#7 if there are more messages to be delivered, but<br>
because it is blocked by Infinispan, it cannot deliver B#8.<br>
<br>
This is one of the rare cases where an OOB thread gets to deliver<br>
regular messages.<br>
<br>
The root cause is that Infinispan blocks on an OOB message; but OOB<br>
messages should never block! This is another reason why an Infinispan<br>
application thread pool makes a lot of sense !<br>
<br></blockquote><div><br></div><div>I wonder who first added sync mode and locking in JBossCache ;)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<br>
     // An OOB message is passed up immediately. Later, when remove() is<br>
called, we discard it. This affects ordering !<br>
         // <a href="http://jira.jboss.com/jira/browse/JGRP-377" target="_blank">http://jira.jboss.com/jira/browse/JGRP-377</a><br>
         if(msg.isFlagSet(Message.OOB) &amp;&amp; added) {<br>
             try {<br>
                 up_prot.up(evt);<br>
             }<br>
             catch(Throwable t) {<br>
                 log.error(&quot;couldn&#39;t deliver OOB message &quot; + msg, t);<br>
             }<br>
         }<br>
<br>
         //The OOB thread never gets here as it is blocked in<br>
up_prot.up()by Infinispan.<br>
<br>
         final AtomicBoolean processing=win.getProcessing();<br>
         if(!processing.compareAndSet(false, true))<br>
             return true;<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 2/26/13 7:35 PM, Pedro Ruivo wrote:<br>
&gt; On 02/26/2013 04:31 PM, Bela Ban wrote:<br>
&gt;&gt; On 2/26/13 5:14 PM, Pedro Ruivo wrote:<br>
&gt;&gt;&gt; So, in this case, the regular message will block until the OOB<br>
&gt;&gt;&gt; message is delivered.<br>
&gt;&gt;<br>
&gt;&gt; No, the regular message should get delivered as soon as the OOB message<br>
&gt;&gt; has been *received* (not *delivered*). Unless there are previous regular<br>
&gt;&gt; messages from the same sender which are delivered in the same thread,<br>
&gt;&gt; and one of them is blocked in application code...<br>
&gt; In attachment is part of the log. I only know that the response is<br>
&gt; disappearing between UNICAST2 and the ISPN unmarshaller.<br>
&gt;<br>
&gt; could you please take a look?<br>
&gt;<br>
&gt; the response is being sent and received and I don&#39;t understand why<br>
&gt; ISPN is not receive it<br>
&gt;<br>
&gt; Thanks<br>
&gt; Pedro<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; however, the OOB message is being block in the application<br>
&gt;&gt;&gt; until the regular message is delivered. And there is no way to pick the<br>
&gt;&gt;&gt; regular message from the window list while the OOB is blocked, right?<br>
&gt;&gt;&gt; (assuming no more incoming messages)<br>
&gt;&gt; This actually should happen, as they&#39;re delivered by different threads !<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt; so, if everybody agrees, if I move the OOB message to another thread,<br>
&gt;&gt;&gt; everything should work fine...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 02/26/2013 03:50 PM, Bela Ban wrote:<br>
&gt;&gt;&gt;&gt; On 2/26/13 4:15 PM, Dan Berindei wrote:<br>
&gt;&gt;&gt;&gt;&gt; On Tue, Feb 26, 2013 at 12:57 PM, Pedro Ruivo &lt;<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a><br>
&gt;&gt;&gt;&gt;&gt; &lt;mailto:<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a>&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       hi,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       I found the blocking problem with the state transfer this<br>
&gt;&gt;&gt;&gt;&gt; morning.<br>
&gt;&gt;&gt;&gt;&gt;       It happens because of the reordering of a regular and OOB<br>
&gt;&gt;&gt;&gt;&gt; message.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       Below, is a simplification of what is happening for two nodes<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       A: total order broadcasts rebalance_start<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       B: (incoming thread) delivers rebalance_start<br>
&gt;&gt;&gt;&gt;&gt;       B: has no segments to request so the rebalance is done<br>
&gt;&gt;&gt;&gt;&gt;       B: sends async request with rebalance_confirm (unicast #x)<br>
&gt;&gt;&gt;&gt;&gt;       B: sends the rebalance_start response (unicast #x+1) (the<br>
&gt;&gt;&gt;&gt;&gt; response<br>
&gt;&gt;&gt;&gt;&gt;       is a regular message)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       A: receives rebalance_start response (unicast #x+1)<br>
&gt;&gt;&gt;&gt;&gt;       A: in UNICAST2, it detects the message is out-of-order and<br>
&gt;&gt;&gt;&gt;&gt; blocks<br>
&gt;&gt;&gt;&gt;&gt;       the response in the sender window (i.e. the message #x is<br>
&gt;&gt;&gt;&gt;&gt; missing)<br>
&gt;&gt;&gt;&gt;&gt;       A: receives the rebalance_confirm (unicast #x)<br>
&gt;&gt;&gt;&gt;&gt;       A: delivers rebalance_confirm. Infinispan blocks this command<br>
&gt;&gt;&gt;&gt;&gt;       until all the rebalance_start responses are received ==&gt; this<br>
&gt;&gt;&gt;&gt;&gt;       originates a deadlock! (because the response is blocked in<br>
&gt;&gt;&gt;&gt;&gt; unicast<br>
&gt;&gt;&gt;&gt;&gt;       layer)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       Question: can the request&#39;s response message be sent always as<br>
&gt;&gt;&gt;&gt;&gt;       OOB? (I think the answer should be no...)<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; We could, if Bela adds the send(Message) method to the Response<br>
&gt;&gt;&gt;&gt;&gt; interface...<br>
&gt;&gt;&gt;&gt; I created a JIRA yesterday: <a href="https://issues.jboss.org/browse/JGRP-1602" target="_blank">https://issues.jboss.org/browse/JGRP-1602</a>.<br>
&gt;&gt;&gt;&gt; I&#39;m wondering though if you *really* need it, as making all responses<br>
&gt;&gt;&gt;&gt; OOB is a bad idea IMO, see below...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; and personally I think it would be better to make all responses OOB<br>
&gt;&gt;&gt;&gt;&gt; (as in JGroups 3.2.x). I don&#39;t have any data to back this up,<br>
&gt;&gt;&gt;&gt;&gt; though...<br>
&gt;&gt;&gt;&gt; Intuitively, I think indiscriminatingly marking all responses as OOB<br>
&gt;&gt;&gt;&gt; is bad, especially in the light of the async invocation API which will<br>
&gt;&gt;&gt;&gt; make all messages non-blocking, at least in the OOB or reg thread<br>
&gt;&gt;&gt;&gt; pools.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; The code in 3.3 *does* actually copy the flags of the request into the<br>
&gt;&gt;&gt;&gt; response, so if the request is async (OOB), so will the response be.<br>
&gt;&gt;&gt;&gt; For async RPCs (regular messages), you&#39;re not getting any response<br>
&gt;&gt;&gt;&gt; anyway, so no worries here...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       My suggestion: when I deliver a rebalance_confirm command<br>
&gt;&gt;&gt;&gt;&gt; (that it<br>
&gt;&gt;&gt;&gt;&gt;       is send async), can I move it to a thread in<br>
&gt;&gt;&gt;&gt;&gt;       async_thread_pool_executor?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I have WIP fix for <a href="https://issues.jboss.org/browse/ISPN-2825" target="_blank">https://issues.jboss.org/browse/ISPN-2825</a>, which<br>
&gt;&gt;&gt;&gt;&gt; should stop blocking the REBALANCE_CONFIRM commands on the<br>
&gt;&gt;&gt;&gt;&gt; coordinator: <a href="https://github.com/danberindei/infinispan/tree/t_2825_m" target="_blank">https://github.com/danberindei/infinispan/tree/t_2825_m</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I haven&#39;t issued a PR yet because I&#39;m still getting a failure in<br>
&gt;&gt;&gt;&gt;&gt; ClusterTopologyManagerTest, I think because of a JGroups issue (RSVP<br>
&gt;&gt;&gt;&gt;&gt; not receiving an ACK from itself). I&#39;ll let you know when I find<br>
&gt;&gt;&gt;&gt;&gt; out...<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Yes, please do that. I saw in London that you could reproduce it in<br>
&gt;&gt;&gt;&gt; your test, so it should be simple to find the root cause.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;       Weird thing: last night I tried more than 5x time in a row with<br>
&gt;&gt;&gt;&gt;&gt;       UNICAST3 and it never blocks. can this meaning a problem with<br>
&gt;&gt;&gt;&gt;&gt;       UNICAST3 or I had just lucky?<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Even though the REBALANCE_CONFIRM command is sent async, the message<br>
&gt;&gt;&gt;&gt;&gt; is still OOB. I think UNICAST/2/3 should not block any regular<br>
&gt;&gt;&gt;&gt;&gt; message waiting for the processing of an OOB message, as long as that<br>
&gt;&gt;&gt;&gt;&gt; message was received, so maybe the problem is in UNICAST2?<br>
&gt;&gt;&gt;&gt; If the OOB thread added the OOB message, then it will simply pass it<br>
&gt;&gt;&gt;&gt; up. However, the regular thread needs to wait for gaps in the receiver<br>
&gt;&gt;&gt;&gt; table to fill, as it doesn&#39;t know what type of message will be<br>
&gt;&gt;&gt;&gt; received (could be regular).<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; As soon as the OOB message has been added to the table, the regular<br>
&gt;&gt;&gt;&gt; message will get delivered<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&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;<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>
</div></div><div class="im HOEnZb">--<br>
Bela Ban, JGroups lead (<a href="http://www.jgroups.org" target="_blank">http://www.jgroups.org</a>)<br>
<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<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>