Repository navigation
Add replica_host configuration for DatabaseReplicated - #90117
xiaohuanlin wants to merge 47 commits into
Conversation
|
@tavplubix Please take a look if you get a chance |
|
Workflow [PR], commit [71a79e6] Summary: ❌
|
f56f354 to
3f60b22
Compare
|
All integration tests for replica_host are passing across different configurations (asan, binary, tsan, arm). The feature works as expected. Non-related Failures:
|
5121c8e to
7270f83
Compare
Adds a new top-level config option `replica_host` that specifies the hostname other replicas should use to reach this server. This is useful when the FQDN returned by `getFQDNOrHostName()` or `interserver_http_host` does not match the hostname used for inter-replica communication (e.g. in containerized or NATed environments). Fallback chain in `getHostID`: 1. `replica_host` (if configured) 2. `interserver_http_host` (existing behavior) Closes ClickHouse#89915
9daac39 to
2f0edb1
Compare
a848a94 to
3c31bce
Compare
Documents the new `replica_host` setting for `DatabaseReplicated`, including its purpose, fallback chain (replica_host → interserver_io_host), and an example XML configuration.
Cluster::Address::toString uses escapeForFileName(host) + ':' + port, producing a literal colon as separator. The test was incorrectly using '%3A' (URL-encoded colon) in the stale host_id, which caused parseHostID to fail parsing the host:port segment and left uuid_in_keeper as Nil, triggering REPLICA_ALREADY_EXISTS instead of the expected ZK update.
… documentation Use the correct user-facing configuration key `interserver_http_host` instead of the internal field name `interserver_io_host` in the docs for `replica_host`.
…ost-config # Conflicts: # programs/server/Server.cpp
The fresh CI run after merging `master` flags `import time` as unused (`F401`) in `tests/integration/test_replicated_database_replica_host/test.py`. The import was never used; remove it so the `ruff` style check passes. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=90117&sha=4be55b1e39f7a598ebe15bc6ace29396e25288a9&name_0=PR&name_1=Style%20check Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ker` `replica_host` replaces the interserver IO host in the host IDs that a `Replicated` database publishes in its automatically generated cluster, but `DDLWorker::markReplicasActive` preclaimed only the interserver IO host IDs. So the first `ON CLUSTER` query after startup could see the `replica_host` replica as inactive with the `*_only_active` output modes. Preclaim `replica_host` with `tcp_port` and `tcp_port_secure` too, and add an `ON CLUSTER` regression on a mixed `replica_host` / hostname cluster. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🕵 Merged the latest |
…ost-config Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Databases/DatabaseReplicated.cpp
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=90117&sha=126e3b5d644bda266f8f249c77caac53e1574fd1&name_0=PR&name_1=Stress%20test%20%28amd_debug%29 ( The other failure, |
|
This is the abort that my open #122045 fixes, so I am not opening a separate PR. I ran the query from
The #122045 is green on |
…d_ddl.host_name` is set With `<distributed_ddl><host_name>` configured, `DDLTask::findCurrentHostID` matched host IDs only by that name. The cluster of a `Replicated` database lists the server under `replica_host`, so `ON CLUSTER <replicated_db>` skipped the local task. Accept `replica_host` (in the bracketed form for IPv6 literals, as published to the cluster) too, and add a regression test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Pushed 3a03561. It has two changes:
@groeneai, thanks for linking #122045 for the The red jobs at 7b5fd79 do not touch this PR's code:
Both of those should clear on the new run, which is based on current |
…_name` is set With an explicit `distributed_ddl.host_name`, `DDLTask::findCurrentHostID` accepts `replica_host` by name without resolving it, but `DDLWorker::markReplicasActive` still required DNS resolution to a local address, so a non-resolving `replica_host` was never marked active and `*_only_active` modes treated the running replica as inactive. Apply the same explicit self-name rule there, and extend the explicit-host integration test to check the `active` node ownership and use `throw_only_active`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion of a foreign active replica The new test keeps a replica active on node1 and tries `CREATE DATABASE` on node3 with the same database UUID, Keeper path, shard and replica name but a different advertised host. It asserts `REPLICA_ALREADY_EXISTS` and that the stored `host_id` and the `/active` owner in Keeper remain node1's. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged the latest |
The automatically generated cluster of a `Replicated` database lists a bare IPv6 advertised host in the bracketed form, so distributed DDL is queued for `[<ipv6>]:<port>`. `DDLWorker::markReplicasActive` normalized only `replica_host`, so with a bare IPv6 `interserver_http_host` and no `replica_host`, the first `ON CLUSTER` query could see the running replica as offline. Claim the bracketed form of the advertised host in both cases, and share the normalization through `HostID::bracketIPv6Host`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| if (config_host_name) | ||
| { | ||
| if (config_host_name != host.host_name) | ||
| if (config_host_name != host.host_name && advertised_replica_host != host.host_name) |
There was a problem hiding this comment.
[Major] Normalize the explicit DDL self-name as well as the advertised name
The IPv6 normalization in fetchClusterTopology also applies when replica_host is unset, but this comparison still uses the unnormalized distributed_ddl.host_name. For example, configure both interserver_http_host and distributed_ddl.host_name as ::1, with no replica_host. The generated database cluster now publishes [::1]:9000, and markReplicasActive correctly claims that bracketed ID. However, findCurrentHostID compares "::1" and the empty advertised_replica_host against "[::1]", rejects the entry, and never reaches DNS-based matching. The worker skips the task, so CREATE TABLE default.t ON CLUSTER <db> ... times out without creating the local table despite the replica being marked active.
Please apply a consistent IPv6 representation to both sides of the name-based self comparisons, including the explicit configured name. Extend the fallback IPv6 regression with the matching bare IPv6 distributed_ddl.host_name and an actual ON CLUSTER operation; checking /active and system.clusters alone misses this dispatch failure.
There was a problem hiding this comment.
🕵 Fixed in 71a79e6. DDLTask::findCurrentHostID now brings distributed_ddl.host_name, replica_host and the entry host to the bracketed form before comparing them, so host_name = ::1 matches the entry host [::1]. The by-name rule in DDLWorker::markReplicasActive uses the same form.
test_ipv6_interserver_host_marked_active now also runs CREATE TABLE ... ON CLUSTER <db> with throw_only_active and checks that the table exists, once without distributed_ddl.host_name and once with it set to ::1.
I could not run the test locally: the changed translation units compile, but the final link of clickhouse was repeatedly terminated by the memory watchdog on the build machine. So the test is verified only by CI on this commit.
# Conflicts: # src/Interpreters/DDLTask.h
…CurrentHostID` The cluster of a `Replicated` database lists a bare IPv6 literal in brackets, also when `replica_host` is unset and the interserver IO host is advertised. With an explicit `distributed_ddl.host_name`, `DDLTask::findCurrentHostID` compares names instead of resolving them, and it compared the configured name as is: `host_name` = `::1` did not match the entry host `[::1]`, so the worker skipped the task and `ON CLUSTER` on the cluster of the database timed out, although the replica was marked active. Bring `host_name`, `replica_host` and the entry host to the bracketed form before comparing, and do the same for the by-name rule in `DDLWorker::markReplicasActive`. Extend `test_ipv6_interserver_host_marked_active` with an actual `ON CLUSTER` query, run both without and with a bare IPv6 `distributed_ddl.host_name`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Pushed 71a79e6. It has two changes:
The changed translation units compile, but I could not link The only red job at 45374fc was |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add
replica_hostconfiguration parameter for DatabaseReplicated to specify advertised hostname for replica communication, independent from server bind address. Resolves #88378Documentation entry for user-facing changes
Details
Currently, DatabaseReplicated uses
interserver_http_hostor the system hostname, which may not be routable from other replicas.This PR adds a new
replica_hostconfiguration parameter that allows administrators to explicitly specify the advertised hostname for DatabaseReplicated communication.Resolves #88378
Changes
New Configuration Parameter:
replica_hostconfig.xmlinterserver_http_hostand system hostnameFallback Chain:
Automatic Migration:
replica_host), automatically updates ZooKeeper if UUID and TCP port matchImplementation:
Context::getReplicaHost(),setReplicaHost(),hasReplicaHost()DatabaseReplicated::getHostID()to use fallback chainparseHostID()helper for UUID and port validationreplica_hostfrom config on startupConfiguration Example
public.example.com 0.0.0.0 9000Backward Compatibility
Fully backward compatible:
interserver_http_hostcontinues to workWorkflow [PR]
Sync PR [sync-upstream/pr/90117]