ClickHouse / clickhouse-java

ClickHouse Java Clients & JDBC Driver
https://clickhouse.com
Apache License 2.0
1.45k stars 535 forks source link

INSERT query fails occasionally due to issue with ClientStatistics tracking. #1839

Closed maxsumrall closed 1 month ago

maxsumrall commented 1 month ago

Describe the bug

INSERT query fails occasionally due to issue with ClientStatistics tracking. This is when using the V2 Client.

This issue happened only a few times while we are executing INSERT for many events in production. It seems (but not with total certianty) to only happen at the start of a long-running process, like when starting up an application for the first time, or if the application was idle for some time.

Steps to reproduce

  1. Execute Client::insert

Expected behaviour

Insert succeeds.

Code example

client.insert("my_table", ImmutableList.of(events), INSERT_SETTINGS);

Error log

Cannot invoke "com.clickhouse.client.api.internal.ClientStatisticsHolder.start(com.clickhouse.client.api.metrics.ClientMetrics)" because "clientStats" is null

and

Cannot invoke "com.clickhouse.client.api.internal.ClientStatisticsHolder.stop(com.clickhouse.client.api.metrics.ClientMetrics)" because the return value of "java.util.Map.get(Object)" is null

Configuration

Environment

ClickHouse server

We only see this on one production instance running 24.6. The other instances are running 24.5 and don't have this issue.

chernser commented 1 month ago

@maxsumrall, thank you for reporting the issue! This is definitely a bug - will fix it.