Skip to content

HIVE-28781: Hive shouldn't disable IPv6 stack. - #5753

Merged
difin merged 1 commit into
apache:masterfrom
difin:hive_should_not_disable_ipv6
May 27, 2025
Merged

HIVE-28781: Hive shouldn't disable IPv6 stack.#5753
difin merged 1 commit into
apache:masterfrom
difin:hive_should_not_disable_ipv6

Conversation

@difin

@difin difin commented Apr 8, 2025

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Hive used to disable IPv6 by setting this config in some services and in maven surefire plugin (for tests): java.net.preferIPv4Stack=true. When this config is true, IPv6 is completely disabled. This should be changed to false to support dual stack, IPv4 and IPv6.

Why are the changes needed?

To add support for IPv6 in Hive.

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

Hive pre-commit tests.

<property>
<name>templeton.controller.mr.child.opts</name>
<value> -Xmx64m -Djava.net.preferIPv4Stack=true</value>
<value> -Xmx64m -Djava.net.preferIPv4Stack=false</value>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is needs? I think the preferred IP version would be the 4. Ipv6 need to support, but it is optional. Majority of our population would use ipv4 as a default. 6 would only need on huge networks. I would not change the default behavior. Or does this change? Temporary ask a change request. But If you could explain why it is necessary I'm ok :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I saw in the web, if this flag is set to true then we disable IPv6. But does it enable it when set to false?
https://stackoverflow.com/questions/9882357/how-to-set-java-net-preferipv4stack-true-at-runtime

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The java.net.preferIPv4Stack variable name is misleading, in my opinion.
It controls if IPv6 stack is enabled or disabled.
When true, IPv6 stack is completely disabled and a java component that starts with this config won't work in IPv6-only environment.
When false, both IPv4 and IPv6 stacks are available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no argument what is the default? I guess without argument it should be available for Ipv4 and Ipv6? Does it need for java explicitly say it is enabled or disabled?

@difin difin Apr 8, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is false starting from Java 8.
Correct, there is no need to set it if we want the default behavior.
Fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from me :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayushtkn could you please also check?

@difin
difin force-pushed the hive_should_not_disable_ipv6 branch from a89c19e to ba9585a Compare April 9, 2025 22:49
@sonarqubecloud

Copy link
Copy Markdown

@difin
difin requested a review from ayushtkn April 10, 2025 20:27
Comment thread testutils/hadoop

# Disable ipv6 as it can cause issues
# TODO: change to -Djava.net.preferIPv4Stack=false after Hadoop adds support for IPv6
HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assume libraries provided by Hadoop can handle IPv6?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Hadoop presently doesn't support IPv6

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this PR assumes the environment where Hive is deployed without YARN or HDFS. Just to clarify, I still wonder if shared or client libraries used in Hive, such as hadoop-common or File System API, correctly work with IPv6. Is the answer probably yes?

@difin difin Apr 23, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hadoop currently doesn't support IPv6, and I haven't found info about any hadoop libraries to support IPv6.
However, the default behavior on dual stack IPv4/IPv6 hosts is to prefer IPv4 addresses when available.
Currently, Hive can't work on IPv6-only hosts, but on dual-stack hosts it should work properly and prefer to bind to IPv4 addresses.

This is from Java Networking doc:

IPv4 / IPv6
java.net.preferIPv4Stack (default: false)
If IPv6 is available on the operating system the underlying native socket will be, by default, an IPv6 socket which lets applications connect to, and accept connections from, both IPv4 and IPv6 hosts. However, in the case an application would rather use IPv4 only sockets, then this property can be set to true. The implication is that it will not be possible for the application to communicate with IPv6 only hosts.

java.net.preferIPv6Addresses (default: false)
When dealing with a host which has both IPv4 and IPv6 addresses, and if IPv6 is available on the operating system, the default behavior is to prefer using IPv4 addresses over IPv6 ones. This is to ensure backward compatibility, for example applications that depend on the representation of an IPv4 address (e.g. 192.168.1.1). This property can be set to true to change that preference and use IPv6 addresses over IPv4 ones where possible.

When java.net.preferIPv4Stack=false and java.net.preferIPv6Addresses=false, both IPv4 and IPv6 are enabled, but Java prefers to use IPv4 addresses unless it can find only IPv6 (if there is only IPv6 address for a DNS name, it will use IPv6, but on properly configured system it won't happen)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that sense, don't we have to overwrite HADOOP_OPTS here or should we configure java.net.preferIPv6Addresses=false here?

@difin
difin marked this pull request as draft April 23, 2025 00:06
@difin
difin marked this pull request as ready for review April 24, 2025 15:49

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@difin AFAIK Djava.net.preferIPv4Stack=true forces Java to use IPv4 over IPv6, even when IPv6 is available.

As of now Hadoop doesn't support IPV6 & moreover we didn't even test Hive fully to see if it works completely f9 with IPV6.

Moreover even if it works f9, don't you think this would be a behaviour change for Hive, like post upgrade suddenly the Hive machines will start preferring IPv6, I believe this would break compat, we should let users decide if they want to go with IPV6 or not. We can just claim from Hive, yes, IPV6 is now supported in Hive & to enable you can remove these flags from the launch scripts or so

@difin

difin commented Apr 29, 2025

Copy link
Copy Markdown
Contributor Author

Hi @ayushtkn ,
If we have java.net.preferIPv4Stack=false and java.net.preferIPv6Addresses=false (which is BTW the default in Java), there won't be behavior change in Hive because it doesn't make IPv6 preferred over IPv4.

  • java.net.preferIPv4Stack=false --> makes both IPv4 and IPv6 available (when true, IPv6 is completely disabled).
  • java.net.preferIPv6Addresses=false --> IPv4 addresses are preferred over IPv6.

The only time Java would prefer to use IPv6 with these settings is when a DNS name has only IPv6 mapping.
If Hive precommit tests pass with this change on a dual-stack machine, would you agree with these changes?

@ayushtkn

Copy link
Copy Markdown
Member

Sounds good then, if the CI is green on Dual stack machine, Then it is good with me

@difin

difin commented May 27, 2025

Copy link
Copy Markdown
Contributor Author

Sounds good then, if the CI is green on Dual stack machine, Then it is good with me

Hi @ayushtkn, I executed all unit tests and q-tests on my local Linux VM, and there were no IPv6-related failures.

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@difin
difin merged commit 0520076 into apache:master May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants