[
https://issues.apache.org/jira/browse/HADOOP-20095?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153198#comment-18153198
]
ASF GitHub Bot commented on HADOOP-20095:
-----------------------------------------
pan3793 commented on code in PR #9030:
URL: https://github.com/apache/hadoop/pull/9030#discussion_r4749999931
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetUtils.java:
##########
@@ -619,6 +620,13 @@ public static void connect(Socket socket,
throw new ConnectTimeoutException(ste.getMessage());
} catch (UnresolvedAddressException uae) {
throw new UnknownHostException(endpoint.toString());
+ } catch (UnsupportedAddressTypeException uate) {
+ // Unchecked and message-less, so name the endpoint the socket cannot
use.
+ SocketException se = new SocketException("Cannot connect to " + endpoint
+ + ": address type not supported by this socket. A common cause is an"
+ + " IPv6 address used from a JVM with
java.net.preferIPv4Stack=true.");
+ se.initCause(uate);
+ throw se;
Review Comment:
Non-blocking: the IPv6/`preferIPv4Stack` hint is appended unconditionally,
but the exception also fires for endpoints that are not an `InetSocketAddress`
(the case the new test triggers), where the hint is misleading. Could you guard
the hint with a check that the endpoint is an IPv6 `InetSocketAddress` before
appending it? For example:
```java
} catch (UnsupportedAddressTypeException uate) {
String msg = "Cannot connect to " + endpoint
+ ": address type not supported by this socket";
if (endpoint instanceof InetSocketAddress
&& ((InetSocketAddress) endpoint).getAddress() instanceof
Inet6Address) {
msg += "; IPv6 is not available to this JVM,"
+ " check java.net.preferIPv4Stack and OS IPv6 support";
}
SocketException se = new SocketException(msg);
se.initCause(uate);
throw se;
}
```
> NetUtils.connect should report the endpoint when the socket cannot use its
> address type
> ---------------------------------------------------------------------------------------
>
> Key: HADOOP-20095
> URL: https://issues.apache.org/jira/browse/HADOOP-20095
> Project: Hadoop Common
> Issue Type: Improvement
> Reporter: Siyao Meng
> Priority: Major
> Labels: pull-request-available
>
> On a dual stack cluster where DataNodes register IPv6 addresses, a client JVM
> started with {{-Djava.net.preferIPv4Stack=true}} fails every block read and
> write with a bare unchecked exception that names neither the target nor the
> reason:
> {noformat}
> java.nio.channels.UnsupportedAddressTypeException
> at sun.nio.ch.Net.checkAddress(Net.java:...)
> at sun.nio.ch.SocketChannelImpl.checkRemote(SocketChannelImpl.java:...)
> at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:...)
> at
> org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:...)
> at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:...)
> {noformat}
> {{NetUtils.connect}} already translates {{SocketTimeoutException}} and
> {{UnresolvedAddressException}} into IOExceptions.
> {{UnsupportedAddressTypeException}} is a RuntimeException, so it escapes the
> IOException handling of callers (for example the DFS client retry and dead
> node logic) and gives the user nothing to act on.
> Proposal: catch it in {{NetUtils.connect}} and throw a {{SocketException}}
> that names the endpoint and the likely cause (an IPv6 address used from a JVM
> with {{java.net.preferIPv4Stack=true}}), keeping the original exception as
> the cause.
> Workarounds for affected clients are to drop {{preferIPv4Stack=true}} or set
> {{dfs.client.use.datanode.hostname=true}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]