Repository navigation
fix(Keeper): Add fallback to IPv4 for Raft listener if IPv6 fails - #85400
jskong1124 wants to merge 1 commit into
Conversation
antonio2368
left a comment
There was a problem hiding this comment.
Why don't you just set keeper_server.enable_ipv6 to false?
|
Workflow [PR], commit [8277d30] Summary: ❌
|
There was a problem hiding this comment.
| asio_listener = asio_service->create_rpc_listener("0.0.0.0", state_manager->getPort(), logger); | |
| asio_listener = asio_service->create_rpc_listener(state_manager->getPort(), logger, /*_enable_ipv6=*/false); |
|
Hi @antonio2368, thanks for the review and the great suggestion! You're right, that setting would have solved my issue. I wasn't aware of <enable_ipv6> until I dug deep into the source code. My initial approach was debugging from the error log (Address family not supported...), which didn't point to a specific config, so I thought a code-level fix would be the most robust solution for users who might run into the same problem. I agree your suggested change to the code is much cleaner. I'll apply it right now. Thanks! |
There was a problem hiding this comment.
nit:
The throw Exception part can be added directly after the LOG_WARNING part, instead of judging if (!asio_listener) twice.
There was a problem hiding this comment.
Good point, thanks! I've pushed the change.
|
Hi @superdiaodiao and @antonio2368, |
|
Hi @superdiaodiao and @antonio2368, It seems the CI is now failing the new_tests_check. I need to add a test case to verify this fix. I've read the integration test guide (tests/integration/README.md), but I'm still not confident about how to properly set up an IPv4 only Docker environment for the test. Could you please point me to a good example test file that I could use as a template, or provide some guidance on how to best approach this? Any help would be greatly appreciated. |
|
Hi @superdiaodiao and @antonio2368 I've added a new integration test, test_keeper_ipv4_fallback, to address the new_tests_check failure. Thanks for your help! |
| asio_listener = asio_service->create_rpc_listener(state_manager->getPort(), logger, /*_enable_ipv6=*/false); | ||
|
|
||
| if (!asio_listener) |
There was a problem hiding this comment.
please replace tabs with spaces
There was a problem hiding this comment.
what are these added files?
| where IPv6 is disabled via kernel sysctls. This confirms that the | ||
| IPv4 fallback logic for the Raft listener is working correctly. | ||
| """ | ||
| assert keeper_node.query("ruok") == "imok\n" |
There was a problem hiding this comment.
how does this test what the comments says?
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
ClickHouse Keeper no longer crashes on startup on systems where IPv6 is disabled at the kernel level (e.g., RHEL with ipv6.disable=1). It now attempts to fall back to an IPv4 listener if the initial IPv6 listener fails.
Documentation entry for user-facing changes
Hi there! This PR aims to fix a crash that makes it difficult to run ClickHouse Keeper in some common enterprise environments.
On systems where IPv6 is disabled at the kernel level (like hardened RHEL 8 with ipv6.disable=1), ClickHouse Keeper currently fails to start. The logs show an Address family not supported by protocol error because Keeper tries to create an IPv6 Raft listener by default, and doesn't attempt to fall back to IPv4 when this fails.
This can be tricky to debug, and the only workaround is to use the <interserver_listen_host> setting, which isn't widely known.
I've added a simple fallback to make the startup process more robust.
The code will now first try to create the listener with its default behavior. If that fails (for instance, on an IPv4-only system), it will log a warning and automatically try again with an IPv4-only listener (0.0.0.0). The server only terminates if both attempts fail.
This change should allow Keeper to work smoothly out-of-the-box for more users, especially in environments where IPv6 is not available, without needing any special configuration.
Thank you for considering this contribution
The error log before this fix typically shows: