[
https://issues.apache.org/jira/browse/ZOOKEEPER-2447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15354417#comment-15354417
]
Edward Ribeiro commented on ZOOKEEPER-2447:
-------------------------------------------
Hi [~vishk], a couple of comments below.
{code}
if (taddr.isReachable(3000) {
tmpList.add(new InetSocketAddress(taddr, address.getPort()));
}
{code}
What could be a reasonable value? I mean, 3 or 4 seconds can be nice for a LAN
but cannot be enough to a cloud environment, I guess. In other words, I think
this value should be configurable.
Also, looking at InetAddress API docs, it looks like
{{InetAddress#isReachable}} we see this:
{quote}
Best effort is made by the implementation to try to reach the host, but
firewalls and server configuration may block requests resulting in a
unreachable status while some specific ports may be accessible. A typical
implementation will use ICMP ECHO REQUESTs if the privilege can be obtained,
otherwise it will try to establish a TCP connection on port 7 (Echo) of the
destination host.
{quote}
That is, {{isReachable}} implementation is platform dependent and can be very
brittle even when all machines are on the same network. A quick Google search
for "Inetaddress + isreachable + problems" shows that sometimes it can return
false even when the machine is accessible via ping (see "firewalls and server
configuration may block requests resulting in a unreachable status while some
specific ports may be accessible" above).
wdyt?
> Zookeeper adds good delay when one of the quorum host is not reachable
> -----------------------------------------------------------------------
>
> Key: ZOOKEEPER-2447
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2447
> Project: ZooKeeper
> Issue Type: Bug
> Affects Versions: 3.4.6, 3.5.0
> Reporter: Vishal Khandelwal
> Assignee: Vishal Khandelwal
> Fix For: 3.5.3, 3.6.0
>
> Attachments: ZOOKEEPER-2447.3.5.patch, withfix.txt, withoutFix.txt
>
>
> StaticHostProvider --> resolveAndShuffle method adds all of the address which
> are valid in the quorum to the list, shuffles them and sends back to client
> connection class. If after shuffling if first node appear to be the one which
> is not reachable, Clientcnx.SendThread.run will keep on connecting to the
> failure till a timeout and the moves to a different node. This adds up random
> delay in zookeeper connection in case a host is down. Rather we could check
> if host is reachable in StaticHostProvider and ignore isReachable is false.
> Same as we do for UnknownHostException Exception.
> This can tested using following test code by providing a valid host which is
> not reachable. for quick test comment Collections.shuffle(tmpList,
> sourceOfRandomness); in StaticHostProvider.resolveAndShuffle
> {code}
> @Test
> public void test() throws Exception {
> EventsWatcher watcher = new EventsWatcher();
> QuorumUtil qu = new QuorumUtil(1);
> qu.startAll();
>
> ZooKeeper zk =
> new ZooKeeper("<hostnamet:2181," + qu.getConnString(), 180 * 1000,
> watcher);
>
> watcher.waitForConnected(CONNECTION_TIMEOUT * 5);
> Assert.assertTrue("connection Established", watcher.isConnected());
> zk.close();
> }
> {code}
> Following fix can be added to StaticHostProvider.resolveAndShuffle
> {code}
> if(taddr.isReachable(4000 // can be some value)) {
> tmpList.add(new InetSocketAddress(taddr,
> address.getPort()));
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)