<div class="gmail_quote">On Tue, Oct 2, 2012 at 6:29 PM, 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">
<div class="im"><br>
<br>
On 10/2/12 1:43 PM, Dan Berindei wrote:<br>
<br>
&gt;&gt;&gt; test threads are stuck in JGroupsTransport.waitForChannelToConnect so it<br>
&gt;&gt;&gt; looks like a JGroups thing.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; JGroupsTransport.waitForChannelToConnect() is Infinispan code, not<br>
&gt;&gt; JGroups code. IMO unneeded code, too, as I don&#39;t understand why we&#39;re<br>
&gt;&gt; waiting on a latch until we get a view after calling JChannel.connect().<br>
&gt;&gt; When JChannel.connect() returns, you&#39;re guaranteed to have a view<br>
&gt;&gt; installed, so this code can (should !) be removed, as it makes things<br>
&gt;&gt; unnecessarily complex (and error prone ?).<br>
&gt;&gt;<br>
&gt;<br>
&gt; True, it&#39;s Infinispan code - my code, actually ;)<br>
<br>
<br>
</div>ouch :-)<br>
<div class="im"><br>
<br>
&gt; The reason behind the latch was probably to avoid concurrent updates of the<br>
&gt; members list from the main thread and from the JGroups thread that calls viewAccepted().<br>
<br>
<br>
</div>The members should be updated in viewAccepted(). When you connect a<br>
channel, then viewAccepted() will be called *before* JChannel.connect()<br>
returns, so the main thread won&#39;t have a chance of accessing members<br>
before that.<br>
<div class="im"><br></div></blockquote><div><br>Ok, if viewAccepted() is guaranteed to be called before connect() returns then you&#39;re right, the latch is superfluous. We only need to call viewAccepted() ourselves if the channel was injected (which we already do).<br>
<br>In this particular case, however, we don&#39;t get a viewAccepted() call or an exception from connect(), so I&#39;m not sure it would have been better (easier to debug) without the latch. <br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">
<br>
&gt; I agree it&#39;s probably unnecessary, as we already use synchronization in our viewAccepted() implementation, but I don&#39;t see why it shouldn&#39;t work.<br>
<br>
</div>It&#39;s (unnecessarily) complex code that could be simplified; I&#39;m not<br>
suggesting it&#39;s incorrect. More complexity == more bugs.<br>
<div class="im"><br></div></blockquote><div><br>True. I just wasn&#39;t sure whether viewAccepted() is guaranteed to be called during connect(), so I added a &quot;safety net&quot;.<br><br>I know there was a NPE in JGroupsTransport that I thought at the time was caused by a missing viewAccepted() call, but I can&#39;t find the stack trace any more so I&#39;m not sure if that was really the case.<br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
<br>
&gt; We have attached the JGroupsTransport as a membership listener to the<br>
&gt; MessageDispatcher (CommandAwareRpcDispatcher, actually) and we have<br>
&gt; attached the MessageDispatcher as a channel listener to the channel before<br>
&gt; calling connect(), so JGroups should call viewAccepted() for the initial<br>
&gt; view just as it does for every view.<br>
<br>
<br>
</div>You mean MembershipListener ? Yes, if you create the channel, then the<br>
MessageDispatcher, then connect(), then you&#39;ll get the viewAccepted()<br>
callback *before* JChannel.connect() returns.<br>
<br>
Unless you deliver the view in a separate thread, but I don&#39;t think you<br>
do this, right ?<br>
<br></blockquote><div><br>I&#39;m interested here strictly in the viewAccepted() callback in JGroupsTransport - I don&#39;t care how our other components that listen for our JGroups view events get their notifications, they usually all their version of viewAccepted() on startup.<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Which version is the stacktrace below with ? 3.0.x ? Taking a look now...<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br>3.2.0.Alpha2<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">

<br>
&gt; I just got the same test to hang on my machine, and I found this exception<br>
&gt; in the log:<br>
&gt;<br>
&gt; 12:26:25,098 DEBUG (CacheStarter-Cache4:nbst) [GMS]<br>
&gt; exception=java.lang.IllegalStateException: channel is not connected,<br>
&gt; retrying<br>
&gt; java.lang.IllegalStateException: channel is not connected<br>
&gt;      at<br>
&gt; org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.down(MessageDispatcher.java:621)<br>
&gt;      at<br>
&gt; org.jgroups.blocks.RequestCorrelator.handleRequest(RequestCorrelator.java:535)<br>
&gt;      at<br>
&gt; org.jgroups.blocks.RequestCorrelator.receiveMessage(RequestCorrelator.java:390)<br>
&gt;      at<br>
&gt; org.jgroups.blocks.RequestCorrelator.receive(RequestCorrelator.java:248)<br>
&gt;      at<br>
&gt; org.jgroups.blocks.MessageDispatcher$ProtocolAdapter.up(MessageDispatcher.java:604)<br>
&gt;      at org.jgroups.JChannel.up(JChannel.java:715)<br>
&gt;      at org.jgroups.stack.ProtocolStack.up(ProtocolStack.java:1020)<br>
&gt;      at org.jgroups.protocols.FRAG2.up(FRAG2.java:181)<br>
&gt;      at org.jgroups.protocols.FC.up(FC.java:479)<br>
&gt;      at org.jgroups.protocols.pbcast.GMS.up(GMS.java:896)<br>
&gt;      at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:244)<br>
&gt;      at org.jgroups.protocols.UNICAST2.up(UNICAST2.java:432)<br>
&gt;      at org.jgroups.protocols.pbcast.NAKACK2.handleMessage(NAKACK2.java:722)<br>
&gt;      at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:570)<br>
&gt;      at<br>
&gt; org.jgroups.protocols.pbcast.NAKACK2.flushBecomeServerQueue(NAKACK2.java:841)<br>
&gt;      at org.jgroups.protocols.pbcast.NAKACK2.down(NAKACK2.java:490)<br>
&gt;      at org.jgroups.protocols.UNICAST2.down(UNICAST2.java:523)<br>
&gt;      at org.jgroups.protocols.pbcast.STABLE.down(STABLE.java:307)<br>
&gt;      at org.jgroups.protocols.pbcast.GMS.installView(GMS.java:637)<br>
&gt;      at<br>
&gt; org.jgroups.protocols.pbcast.ClientGmsImpl.installView(ClientGmsImpl.java:248)<br>
&gt;      at<br>
&gt; org.jgroups.protocols.pbcast.ClientGmsImpl.joinInternal(ClientGmsImpl.java:182)<br>
&gt;      at<br>
&gt; org.jgroups.protocols.pbcast.ClientGmsImpl.join(ClientGmsImpl.java:37)<br>
&gt;      at org.jgroups.protocols.pbcast.GMS.down(GMS.java:938)<br>
&gt;      at org.jgroups.protocols.FC.down(FC.java:435)<br>
&gt;      at org.jgroups.protocols.FRAG2.down(FRAG2.java:147)<br>
&gt;      at org.jgroups.stack.ProtocolStack.down(ProtocolStack.java:1025)<br>
&gt;      at org.jgroups.JChannel.down(JChannel.java:729)<br>
&gt;      at org.jgroups.JChannel.connect(JChannel.java:291)<br>
&gt;      at org.jgroups.JChannel.connect(JChannel.java:262)<br>
&gt;      at<br>
&gt; org.infinispan.remoting.transport.jgroups.JGroupsTransport.startJGroupsChannelIfNeeded(JGroupsTransport.java:206)<br>
&gt;      at<br>
&gt; org.infinispan.remoting.transport.jgroups.JGroupsTransport.start(JGroupsTransport.java:197)<br>
&gt;      at sun.reflect.GeneratedMethodAccessor113.invoke(Unknown Source)<br>
&gt;      at<br>
&gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>
&gt;      at java.lang.reflect.Method.invoke(Method.java:601)<br>
&gt;      at<br>
&gt; org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:236)<br>
&gt;      at<br>
&gt; org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:900)<br>
&gt;      at<br>
&gt; org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:650)<br>
&gt;      at<br>
&gt; org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:639)<br>
&gt;      at<br>
&gt; org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:542)<br>
&gt;      at<br>
&gt; org.infinispan.factories.GlobalComponentRegistry.start(GlobalComponentRegistry.java:218)<br>
&gt;      at<br>
&gt; org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:680)<br>
&gt;      at<br>
&gt; org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:652)<br>
&gt;      at<br>
&gt; org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:548)<br>
&gt;      at<br>
&gt; org.infinispan.statetransfer.JoiningNode.getCache(JoiningNode.java:54)<br>
&gt;      at<br>
&gt; org.infinispan.statetransfer.StateTransferFunctionalTest$2.run(StateTransferFunctionalTest.java:234)<br>
&gt;      at java.lang.Thread.run(Thread.java:722)<br>
<br>
<br>
</div></div><div class="HOEnZb"><div class="h5">--<br>
Bela Ban, JGroups lead (<a href="http://www.jgroups.org" target="_blank">http://www.jgroups.org</a>)<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>