apla / node-clickhouse

Yandex ClickHouse driver for nodejs
MIT License
216 stars 50 forks source link

ON CLUSTER syntax makes the query execution hang #27

Open databrecht opened 5 years ago

databrecht commented 5 years ago

I've set up multiple 'replicas' and 'shards' with docker compose. If you use the clickhouse 'ON CLUSTER' syntax, clickhouse sends back a simple text (not json) which contains the information about the replicas. The library expects JSON but does not handle this gracefully. The result is that the response will never come since no 'end' or 'error' is send.

What clickhouse sends back: clickhouse-shard1-replica1 9000 0 3 0 clickhouse-shard2-replica1 9000 0 2 0 clickhouse-shard2-replica2 9000 0 1 0 clickhouse-shard1-replica2 9000 0 0 0

In order to send an end an just make it work (without providing results) I assume you need to add a stream.push(null) in clickhouse.js at line 160. I don't know how you want to tackle something like that though.

apla commented 5 years ago

I don't have a cluster, so you can provide response from cluster or (even better) make PR.