crobox / clickhouse-scala-client

Clickhouse Scala Client with Reactive Streams support
GNU Lesser General Public License v3.0
112 stars 25 forks source link

Unable to use 'cluster-aware' connection type with cluster #126

Closed yahor-ivanou closed 2 years ago

yahor-ivanou commented 3 years ago

I am trying to use Crobox Clickhouse Client along with Clickhouse cluster configuration(2 shards with 2 replicas). When Clickhouse Client is starting, I am getting the error saying that Clickhouse Client is not able to connect to the host 127.0.0.1. After looking into the source code of ClusterConnectionFlow it turned out that client is sending the following query to some Clickhouse replica: SELECT host_address FROM system.clusters WHERE cluster='$cluster' which in fact returns the following result: 127.0.0.1 10.244.106.15 10.244.5.26 10.244.3.2

The fact that 127.0.0.1 is returned is expected behaviour of CH cluster according to the answers from CH team from yandex: the replica has loopback address as host_address for itself.

How should I use crobox client for cluster setup then?

erdebee commented 3 years ago

I think you properly identified a bug. You can statically define the hosts using "multi host" setup.

Pull requests for a fix would also be accepted.

lwolters commented 2 years ago

Hi,

Sorry for the late reply. I'll look into this this week. But to me, having a cluster with 3 production nodes and 1 localhost doesn't seem right. That said, I'll look into it.

sjoerdmulder commented 2 years ago

I would agree with @lwolters the fact that CH returns 127.0.0.1 is an incorrect configuration somewhere in the CH cluster, maybe remote_servers or listen_host are not configured correctly. The crobox client cannot do much about this since well it's a client.