You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "amaliujia (via GitHub)" <gi...@apache.org> on 2026/10/14 02:57:21 UTC
[PR] RATIS-2744. Bind gRPC and Netty servers to the IPv4 wildcard when no host is configured [ratis]
amaliujia opened a new pull request, #1637:
URL: https://github.com/apache/ratis/pull/1637
## What changes were proposed in this pull request?
When no host is configured, the gRPC and Netty servers build their bind address with new InetSocketAddress(port), which resolves to the IPv6 wildcard ::. On machines without IPv6 support, such as the GitHub Actions Ubuntu runners, the native epoll transport can't bind to that address, so the server fails to start.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2744
Discovered from the github job: https://github.com/apache/ratis/actions/runs/36123180483/job/108033212253?pr=1614 with the following tracestack:
```
Caused by: org.apache.ratis.util.ExitUtils$ExitException: Failed to start Grpc server
at org.apache.ratis.util.ExitUtils.terminate(ExitUtils.java:141)
at org.apache.ratis.util.ExitUtils.terminate(ExitUtils.java:151)
at org.apache.ratis.grpc.server.GrpcServicesImpl.startImpl(GrpcServicesImpl.java:393)
at org.apache.ratis.util.LifeCycle.startAndTransition(LifeCycle.java:280)
at org.apache.ratis.server.RaftServerRpcWithProxy.start(RaftServerRpcWithProxy.java:72)
at org.apache.ratis.server.impl.RaftServerProxy.startImpl(RaftServerProxy.java:416)
at org.apache.ratis.util.LifeCycle.startAndTransition(LifeCycle.java:280)
at org.apache.ratis.server.impl.RaftServerProxy.start(RaftServerProxy.java:409)
at org.apache.ratis.server.impl.MiniRaftCluster.startServers(MiniRaftCluster.java:466)
at org.apache.ratis.server.impl.MiniRaftCluster.start(MiniRaftCluster.java:340)
at org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:144)
at org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:124)
at org.apache.ratis.datastream.DataStreamCommandE2ETestCases.testStreamCommand(DataStreamCommandE2ETestCases.java:66)
... 3 more
Caused by: java.io.IOException: Failed to bind to address ::/[0:0:0:0:0:0:0:0]:15002
at org.apache.ratis.thirdparty.io.grpc.netty.NettyServer.start(NettyServer.java:347)
at org.apache.ratis.thirdparty.io.grpc.internal.ServerImpl.start(ServerImpl.java:187)
at org.apache.ratis.thirdparty.io.grpc.internal.ServerImpl.start(ServerImpl.java:94)
at org.apache.ratis.grpc.server.GrpcServicesImpl.startImpl(GrpcServicesImpl.java:391)
... 13 more
Caused by: org.apache.ratis.thirdparty.io.netty.channel.unix.Errors$NativeIoException: bind(..) failed with error(-97): Address family not supported by protocol
```
## How was this patch tested?
Existing test
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Bind gRPC and Netty servers to the IPv4 wildcard when no host is configured [ratis]
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #1637:
URL: https://github.com/apache/ratis/pull/1637#discussion_r4277617668
##########
ratis-common/src/main/java/org/apache/ratis/util/NetUtils.java:
##########
@@ -166,6 +166,19 @@ static String address2String(InetSocketAddress address) {
String LOCALHOST = "localhost";
+ /** IPv4 wildcard for binding a server to all local interfaces. */
+ String WILDCARD_ADDRESS = "0.0.0.0";
+
+ /**
+ * Creates a socket address for binding a server.
+ * When {@code host} is null or empty, uses {@link #WILDCARD_ADDRESS} instead of
+ * {@code new InetSocketAddress(port)}, which may resolve to an IPv6 wildcard.
+ */
+ static InetSocketAddress createBindSocketAddress(String host, int port) {
+ return host == null || host.isEmpty() ?
+ createSocketAddrForHost(WILDCARD_ADDRESS, port) : createSocketAddrForHost(host, port);
Review Comment:
@amaliujia , some questions/comments:
-
- Could we use JVM option `-Djava.net.preferIPv4Stack=true` ?
- Some systems may support IPv6 only. Then, this may not work.
- I suggest to try-catch the binding methods such as ServerBuilder.forPort(port). When it fails, fall back to IPv4 wildcard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Add `-Djava.net.preferIPv4Stack=true` to root pom file for tests [ratis]
Posted by "amaliujia (via GitHub)" <gi...@apache.org>.
amaliujia commented on PR #1637:
URL: https://github.com/apache/ratis/pull/1637#issuecomment-6307118362
@adoroszlai thanks for the insights. I see the full picture better now that the issue bind with the upgrade otherwise only merge this PR targets nothing (yet). I will close this PR for now. We shall continue thinking how to upgrade in its own JIRA.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Bind gRPC and Netty servers to the IPv4 wildcard when no host is configured [ratis]
Posted by "amaliujia (via GitHub)" <gi...@apache.org>.
amaliujia commented on PR #1637:
URL: https://github.com/apache/ratis/pull/1637#issuecomment-6160553897
We could make this for test only though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Add `-Djava.net.preferIPv4Stack=true` to root pom file for tests [ratis]
Posted by "amaliujia (via GitHub)" <gi...@apache.org>.
amaliujia closed pull request #1637: RATIS-2744. Add `-Djava.net.preferIPv4Stack=true` to root pom file for tests
URL: https://github.com/apache/ratis/pull/1637
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Add `-Djava.net.preferIPv4Stack=true` to root pom file for tests [ratis]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #1637:
URL: https://github.com/apache/ratis/pull/1637#issuecomment-6234599497
Thanks @amaliujia for working on this.
The problem appears only in #1614, which bumps `maven-apache-parent`, which in turn bumps `maven-surefire-plugin` to 3.6.0. Adding `preferIPv4Stack` fixes the IP problem, but a different, Mockito-related error appears in several tests (but fewer than the IP issue), see below. We need this patch only if upgrading surefire, but this in itself is not enough in that case.
Therefore I propose the following:
- introduce this workaround (or preferably fix the root cause) only when upgrading surefire (via parent POM), otherwise it is a no-op change
- defer upgrade of parent POM until we can fix all 3 problems (2 test issues + Rat java version compatibility)
Of course should these 2 problems turn out to be Surefire bugs, we can upgrade as soon as they are fixed in Surefire.
Mockito error:
```
[ERROR] Tests run: 16, Failures: 0, Errors: 16, Skipped: 0, Time elapsed: 0.728 s <<< FAILURE! -- in org.apache.ratis.grpc.server.TestGrpcLogAppenderCallbacks
[ERROR] org.apache.ratis.grpc.server.TestGrpcLogAppenderCallbacks.testTimeout -- Time elapsed: 0.016 s <<< ERROR!
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:84)
at jdk.proxy2/jdk.proxy2.$Proxy21.isTypeMockable(Unknown Source)
at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:78)
at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:267)
at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:234)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:86)
at org.mockito.Mockito.mock(Mockito.java:2037)
at org.mockito.Mockito.mock(Mockito.java:1952)
at org.apache.ratis.grpc.server.TestGrpcLogAppenderCallbacks.<init>(TestGrpcLogAppenderCallbacks.java:84)
...
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@1fde4f40
at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:56)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:65)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:50)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:27)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:22)
at org.mockito.internal.MockitoCore.<clinit>(MockitoCore.java:73)
at org.mockito.Mockito.<clinit>(Mockito.java:1669)
... 6 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)
at org.mockito.internal.configuration.plugins.PluginInitializer.loadImpl(PluginInitializer.java:51)
... 12 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Add `-Djava.net.preferIPv4Stack=true` to root pom file for tests [ratis]
Posted by "amaliujia (via GitHub)" <gi...@apache.org>.
amaliujia commented on code in PR #1637:
URL: https://github.com/apache/ratis/pull/1637#discussion_r4280768216
##########
ratis-common/src/main/java/org/apache/ratis/util/NetUtils.java:
##########
@@ -166,6 +166,19 @@ static String address2String(InetSocketAddress address) {
String LOCALHOST = "localhost";
+ /** IPv4 wildcard for binding a server to all local interfaces. */
+ String WILDCARD_ADDRESS = "0.0.0.0";
+
+ /**
+ * Creates a socket address for binding a server.
+ * When {@code host} is null or empty, uses {@link #WILDCARD_ADDRESS} instead of
+ * {@code new InetSocketAddress(port)}, which may resolve to an IPv6 wildcard.
+ */
+ static InetSocketAddress createBindSocketAddress(String host, int port) {
+ return host == null || host.isEmpty() ?
+ createSocketAddrForHost(WILDCARD_ADDRESS, port) : createSocketAddrForHost(host, port);
Review Comment:
Sure. try `-Djava.net.preferIPv4Stack=true` first.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] RATIS-2744. Bind gRPC and Netty servers to the IPv4 wildcard when no host is configured [ratis]
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #1637:
URL: https://github.com/apache/ratis/pull/1637#discussion_r4277617668
##########
ratis-common/src/main/java/org/apache/ratis/util/NetUtils.java:
##########
@@ -166,6 +166,19 @@ static String address2String(InetSocketAddress address) {
String LOCALHOST = "localhost";
+ /** IPv4 wildcard for binding a server to all local interfaces. */
+ String WILDCARD_ADDRESS = "0.0.0.0";
+
+ /**
+ * Creates a socket address for binding a server.
+ * When {@code host} is null or empty, uses {@link #WILDCARD_ADDRESS} instead of
+ * {@code new InetSocketAddress(port)}, which may resolve to an IPv6 wildcard.
+ */
+ static InetSocketAddress createBindSocketAddress(String host, int port) {
+ return host == null || host.isEmpty() ?
+ createSocketAddrForHost(WILDCARD_ADDRESS, port) : createSocketAddrForHost(host, port);
Review Comment:
@amaliujia , some questions/comments:
- Could we use JVM option `-Djava.net.preferIPv4Stack=true` ?
- Some systems may support IPv6 only. Then, this may not work.
- I suggest to try-catch the binding methods such as ServerBuilder.forPort(port). When it fails, fall back to IPv4 wildcard.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org