mailru / go-clickhouse

Golang SQL database driver for Yandex ClickHouse
MIT License
422 stars 89 forks source link

Facing "use of closed network connection." #166

Open shubham19may opened 1 year ago

shubham19may commented 1 year ago

Hello Go-Clickhouse team,

Facing following error :

database: xx
table: xxxxxxx
statement: INSERT INTO ....
objects count: 10000
values of 1st object: {...}
}, cause: doRequest: transport failed to send a request to ClickHouse: write tcp [instance-ip]-> [ck-load-balancer-ip]: use of closed network connection. Process will be killed

I have Clickhouse hosted in EKS (kubernetes) and i am inserting data from other kubernetes pod. Clickhouse is exposed to other pods by load balancer.

Few more information points :

  1. I am inserting 10000 rows in one go, average row size is quite big (200 columns).
  2. Its taking 3-4 seconds averagely to do one insert. (This includes flattening of record 2 sec, actual insert 1.5-2 sec)
  3. Everything is running on AWS EKS
  4. Using go-clickhouse version v1.8.0
  5. Error happens randomly. No specific pattern noticed, sometimes it happens after 2 mins, sometime after 30 mins.
  6. My program works by inserting data in batches of 10000. inserting millions of rows in few hours
phil-schreiber commented 1 year ago

@shubham19may Hey, I'm facing similar issue and was wondering whether you ever resolved this thing?

shubham19may commented 1 year ago

Hey @phil-schreiber we sorted this issue out by moving to https://github.com/ClickHouse/clickhouse-go as this is more stable.

DoubleDi commented 1 year ago

Hi! Are you yousing any balancers in the middle?

phil-schreiber commented 1 year ago

@DoubleDi Hey! No, in this particular case we're not using any LBs. We are comitting to clickhouse in parallel with one opened sqlx.DB. I avoid commits at exact same time, which lead to EOF errors, but still we're seeing these closed connection errors randomly.

phil-schreiber commented 1 year ago

I was wondering whether hard-coding the max idle conns to 1 (https://github.com/mailru/go-clickhouse/blob/master/conn.go#L80) could be the culprit in my specific usecase. Generally an sql.DB is supposed to be used by goroutines in parallel.