Repository navigation
Fix DatabaseReplicated to respect interserver_http_host config - #88378
alexey-milovidov merged 6 commits into
Conversation
| UInt16 port = secure ? global_context->getTCPPortSecure().value_or(DBMS_DEFAULT_SECURE_PORT) : global_context->getTCPPort(); | ||
| return Cluster::Address::toString(getFQDNOrHostName(), port) + ':' + toString(db_uuid); | ||
| return Cluster::Address::toString(host_port.first, port) + ':' + toString(db_uuid); |
There was a problem hiding this comment.
Is it correct that we don't use interserver_http_port here?
There was a problem hiding this comment.
Yes, using TCP port instead of interserver_http_port is correct.
Reason: DatabaseReplicated uses Cluster for distributed DDL execution via TCP, not HTTP replication. When Cluster::Address parses the host_id, it extracts the embedded port from the "host:port:uuid" format.
This PR:
- Uses interserver_http_host for the network interface
- Uses TCP port for query communication (correct behavior)
Compare with StorageReplicatedMergeTree.cpp:9330 which explicitly separates replication_port (HTTP) from queries_port (TCP).
|
@xiaohuanlin, please check why the server didn't start in the tests. |
31381ab to
91e6104
Compare
DatabaseReplicated ignored interserver_http_host when registering replicas in ZooKeeper, always using hostname instead. This prevented node replacements with same IP but different hostname from connecting to existing databases. Now uses getInterserverIOAddress() like StorageReplicatedMergeTree does. Fixes ClickHouse#88361
The test now dynamically configures each node's interserver_http_host with its actual Docker container IP address at runtime, before creating the replicated databases. This ensures nodes register with IP addresses instead of hostnames in ZooKeeper. Previously, removing the interserver_http_host config caused the system to fall back to getFQDNOrHostName(), which returned hostnames.
The test needs to restart ClickHouse instances to apply interserver_http_host configuration changes. This requires stay_alive=True parameter in the instance configuration to allow restart operations during testing.
a8d26f7 to
55614ec
Compare
|
@tavplubix hi! Could you please review this PR as well? |
|
@xiaohuanlin @alexey-milovidov why Also, if someone already has an IP in |
Regarding the use of interserver_http_hostI understand your concern about the naming semantics. However,
Regarding upgrade compatibilityYou're right that this is an important concern. I need to think through the upgrade path more carefully to ensure existing deployments won't face REPLICA_ALREADY_EXISTS errors. Let me work on a proper migration strategy and get back to you. |
|
@xiaohuanlin is the comment above LLM-generated?
Yes, but this is about HTTP interserver interface, which is being used by ReplicatedMergeTree for data replication. DatabaseReplicated needs to create a cluster for Distributed tables like https://clickhouse.com/docs/operations/server-configuration-parameters/settings#remote_servers. They don't use HTTP to reach other nodes, they use native protocol and connect to Also, why But you're right that |
1. Configuration SemanticsSolution: Introduce This provides semantic clarity while maintaining backward compatibility. 2. Upgrade CompatibilitySolution: Automatic migration based on UUID + port matching. Logic: Parse both old and new host_id. If UUID and port match → same instance → auto-update ZooKeeper. Otherwise → reject. All scenarios:
Why safe: UUID is unique per database instance. Matching UUID + port guarantees same server. @tavplubix Let me know if this makes sense or if you'd prefer a different approach. |
|
LGTM |
DatabaseReplicated ignored interserver_http_host when registering replicas in ZooKeeper, always using hostname instead. This prevented node replacements with same IP but different hostname from connecting to existing databases.
Now uses getInterserverIOAddress() like StorageReplicatedMergeTree does.
Fixes #88361
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed DatabaseReplicated to respect
interserver_http_hostconfiguration.