Repository navigation
fix(Keeper): Add fallback to IPv4 for Raft listener if IPv6 fails - #85901
Conversation
|
Workflow [PR], commit [bf70532] Summary: ❌
|
There was a problem hiding this comment.
First of all, thanks for your contribution and for pursuing the work in a following PR. Much appreciated 🫂
The idea and the C++ code looks fine.
I have comments regarding the test, though:
- The test finishes successfully with current build from master without your changes, so it doesn't seem to be a good check for your changes
- We're skipping the test in case we're not root, but at that point we've already tried to run commands that require root privileges. Shouldn't we skip all the tests of the module and even the module fixture if we don't have root access?
- Since you're disabling IPv6 system-wise, you may affect other tests. If you want to make sure this tests runs sequentially, you need to add it to the list in parallel_skip.yaml
Let me also ping @antonio2368 for some extra eyes, since he already reviewed the original PR
There was a problem hiding this comment.
In case the sysctl cannot be executed we fail on this fixture, but on the other hand we skip the test if we are not root.
There was a problem hiding this comment.
If anything happens here that throws, we're never enabling IPv6 again. We should make a more resilient solution to ensure if we disable IPv6, it's always enabled back after the tests, no matter what.
103fa0d to
bf70532
Compare
|
Hi @pamarcos There's a key difference in how Keeper behaves depending on how IPv6 is disabled: "Soft" Disable (via sysctl): "Hard" Disable (via ipv6.disable=1 kernel param): Unfortunately, replicating the "hard" disable in CI seems impossible. I've confirmed my patch works in a manual test with the kernel param, but I can't create an automated test that fails on master and passes with my fix. If you have any ideas for how to test this scenario in CI, I'd be grateful for your advice. Thanks again for your help and patience! (P.S. English isn't my first language, so my apologies for any awkward phrasing.) |
|
Thanks for the taking care of this! I've fixed a conflict in the private fork so we'll have to wait for the
Yeah, even if it's possible disabling IPv6 for a new docker instance that runs only that test, it seems a little overkill. No need to apologize for the delay or for not not being a native English-speaker! As you can guess, most of us aren't but we still manage to communicate succesfully :) I've reworded slightly the CHANGELOG description from "no longer crashes on startup" to "no longer fails to start" because it was not a real crash, was it? |
|
Hi @pamarcos And yes, you are absolutely right about the changelog entry. "fails to start" is much more accurate since it wasn't a crash in the strict sense. Thanks for catching that and making the correction. |
|
Merged, thanks a lot for your contribution 🫂 |
…ntegration job The module runs `sysctl -w net.ipv6.conf.all.disable_ipv6=1`, starts its cluster, and writes `=0` in `finally`. pytest runs as root in the integration job container, so this flips IPv6 in the job container's network namespace, where the nested dockerd's bridges and every pytest process live. Disabling IPv6 flushes every IPv6 address in that namespace. The restore brings back only what the kernel generates (`::1`, link-local addresses), not dockerd's static `fd00::1/8` on `docker0` (`fixed-cidr-v6: fd00::/8`), and it also enables IPv6 on the container's uplink, which Docker had disabled. For the rest of the job the namespace has no global IPv6 source address except the gateways of the compose bridges themselves. The gateway of a new compose network (`2001:3984:3989::1` for test_grpc_protocol) is added with duplicate address detection, so it is tentative for 1-2 s. A TCP connect to the container's IPv6 address issued in that window has to pick another source: before the toggle that is `fd00::1` and the connection completes as soon as DAD ends; after the toggle it is a link-local address of another interface (or `::1`), the container's reply to it cannot be delivered over the bridge, and the SYN is retransmitted from the same source until the 10 s `channel_ready_future` budget of `test_ipv6_select_one` runs out. Only the targeted check is affected: it moves test_grpc_protocol (a fixed-address module) to the sequential phase, after every parallel module, so the toggle always precedes it, and the release arm_binary server is ready within the DAD window. The regular shards run test_grpc_protocol before the keeper module. CIDB, 30 days, rows of test_ipv6_select_one: arm targeted, keeper module in the same job 3 FAIL / 14 OK arm targeted, keeper module not in the job 0 FAIL / 553 OK amd sanitizer targeted, keeper module in the job 0 FAIL / 50 OK regular arm shards (grpc runs before keeper) 0 FAIL / 7500 OK Reproduced in private network namespaces modelled on the job container: a 10 s connect started while the gateway is tentative completes in ~2 s with source `fd00::1` before the toggle (3/3) and times out with a `fe80::` source after it (3/3). The module does not test what it claims. `[::]` still binds with `disable_ipv6=1`, so NuRaft's IPv6 acceptor never fails and the IPv4 fallback in `KeeperServer::launchRaftServer` is never reached; that needs `socket(AF_INET6)` itself to fail, as with the `ipv6.disable=1` boot parameter, which a CI container cannot emulate (the author of ClickHouse#85901 said so, and its Bugfix validation failed on master). The Keeper containers get fresh network namespaces that do not inherit the toggle, and `keeper_ipv6_enabled.xml` is a user config of `node1`, which runs no Keeper. The module was kept sequential until 511c5a1 made it parallel. Drop its line from RAW_TEST_DURATIONS and from the durations sample, as in 95af852. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
ClickHouse Keeper no longer fails to start 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 is a follow-up to PR #85400.
The last one was closed after I struggled with the integration test and accidentally deleted the branch. I've since set up the full local test environment and added a proper test to validate this fix.
Problem:
Keeper fails to start on hosts with kernel-level IPv6 disabled (e.g., ipv6.disable=1 on RHEL 8). It throws a generic Address family not supported by protocol error in the log.
While the documentation suggests setting <keeper_server.enable_ipv6>false</keeper_server.enable_ipv6>, the actual error message doesn't hint at this, making the issue difficult to debug.
Fix:
Same C++ change as before. It adds a simple fallback: if the default listener (with IPv6) fails, it logs a warning and automatically retries with an IPv4-only listener. This lets Keeper start on IPv4-only systems without requiring users to debug the issue and manually change the configuration.
Test (test_keeper_ipv4_fallback/test.py):
Thanks!
(P.S. English isn't my first language, so my apologies for any awkward phrasing.)