DarkWanderer / ClickHouse.Client

.NET client for ClickHouse
MIT License
315 stars 62 forks source link

insert .. select from query with Kafka engine breaks down the server. #446

Closed kayanme closed 6 months ago

kayanme commented 6 months ago

I've put an issue in Clickhouse github, but I think it should be replicated here.

In short (more words there)

Given the DB scheme

create table default.insertlocal  (num UInt32) Engine=Null();

create table default.insertlocal2 as   default.insertlocal Engine=Memory();
create or replace table KafkaSend  as  default.insertlocal ENGINE = Kafka ('kafka:29092', 'topic', 'clickhouse') SETTINGS kafka_format = 'JSONEachRow';

create materialized view  default.KafkaLink to default.KafkaSend as select * from default.insertlocal;

insert into insertlocal2 select arrayJoin(range(100));

This query goes fine from the server, but crashes from Clickhouse Client insert into default.insertlocal select * from default.insertlocal2

Version of CC is 7.1.1

DarkWanderer commented 6 months ago

Hi. This is interesting.

Am I understanding correctly that this query specifically causes the crash?

insert into  default.insertlocal select * from default.insertlocal2

If so, I am not quite sure how it the client implementation can affect it as the query will just be pushed as plaintext HTTP POST request body, there's no binary serialization involved

This query goes fine from the server, but crashes from Clickhouse Client

Does this mean that this query works when executed from builtin clickhouise-client CLI?

kayanme commented 6 months ago

Am I understanding correctly that this query specifically causes the crash?

Yes.

Does this mean that this query works when executed from builtin clickhouise-client CLI?

And yes.

Actually I can't understand that too. We can also do a query without an intermediate table, just inserting some raw values from cli or from library - yet cli is ok, client is not.

I had some theories about connection properties (tried all - no effect), async inserts and other asynchronicity (looks like the CH reserve some space in part for the data, but insert tht part before it has been actually filled) - something that could be at http connection and absent in binary, which cli uses. Actually I didn't try the other clients. But I did try the earlier version of CH (23.8). Seemed ok.

DarkWanderer commented 6 months ago

I will close this for now as this seems to be a serverside issue