Open flarco opened 2 months ago
@jkaflik any timeframe on this?
@flarco, thanks for reporting this. There is definitely some unexpected behavior here. Could you clarify on:
I am actually not using any of the result since I am making an INSERT.
please?
@alisman initially assigned me to triage. Currently, we don't have the capacity to have a look shortly. Any contributions are welcome.
Limiting the number of rows inserted per transaction helps a lot with lowering the memory usage. So that works as a work-around.
The issue stands, though: if millions of rows are inserted in 1 transaction, the memory leakage crashes the process.
Observed
Hi, I am seeing a big memory usage from the
resultFromStatement
after making aINSERT
query. I believe the leak is happening here: https://github.com/ClickHouse/clickhouse-go/blob/28fd6a4954a5dbf09b7dcc0fcce597beb2dd0b58/lib/column/decimal.go#L238See graph below. This happens when I insert millions of rows with Decimal & Int64 values. The decimal values are made using
github.com/shopspring/decimal
, withdecimal.NewFromString
. I am actually not using any of the result since I am making anINSERT
. Not sure why it's appending from result and taking so much memory.Here is the pprof output:
Expected behaviour
Should not take up much memory after an
INSERT
call.Code example
See https://github.com/slingdata-io/sling-cli/blob/main/core/dbio/database/database_clickhouse.go#L157
Environment
clickhouse-go
version: v2.24.0database/sql
yandex/clickhouse-server:21.3
CREATE TABLE
statements for tables involved: