client-v2 retries an insert with the same query id after NoHttpResponseException, causing QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start in Client.java at Client.lambda$insert$3, Client.insert, and runAsyncOperation, then trace HttpAPIClientHelper.executeRequest around retry handling. Reproduce the NoHttpResponseException path with the stated async-insert settings; done means a delivered insert can be retried without reusing an in-flight query ID or turning the transient fault into code 216.
索引モデルが issue の本文から書いたものです。
説明
Description
Client.insert reuses requestSettings.getQueryId() across every retry attempt. After NoHttpResponseException (retried by default via ClientFaultCause.NoHttpResponse) the first request may already have reached the server and still be executing. The second attempt is then rejected with Code: 216 QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING, which is not retryable, so a transient transport fault becomes a hard failure.
https://github.com/ClickHouse/clickhouse-java/pull/1721 introduced the retry and noted that "not every request may be retried safely". This is that case.
Steps to reproduce
client.insert(table, data, format, settings)with default retry settings through a proxy or load balancer.- The proxy closes the keep-alive connection after forwarding the request, while the server is still executing the insert (
async_insert=1, wait_for_async_insert=1makes the window at least the busy timeout). - The client gets
NoHttpResponseException, logsRetrying., and resends with the same query id. The server answers 216.
Error Log or Exception StackTrace
WARN Retrying. (com.clickhouse.client.api.Client)
org.apache.hc.core5.http.NoHttpResponseException: <host>:8443 failed to respond
at org.apache.hc.core5.http.impl.io.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:333)
...
at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:453)
at com.clickhouse.client.api.Client.lambda$insert$3(Client.java:1474)
at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2012)
at com.clickhouse.client.api.Client.insert(Client.java:1518)
com.clickhouse.client.api.ServerException: Code: 216. DB::Exception: Query with id = b266240e-d406-4874-ba3b-cd1b0bd969f8 is already running. (QUERY_WITH_SAME_ID_IS_ALREADY_RUNNING) (version 26.4.1.2359 (official build))
at com.clickhouse.client.api.internal.HttpAPIClientHelper.readError(HttpAPIClientHelper.java:403)
at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:467)
at com.clickhouse.client.api.Client.lambda$insert$3(Client.java:1474)
at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2012)
at com.clickhouse.client.api.Client.insert(Client.java:1518)
at com.clickhouse.client.api.Client.insert(Client.java:1408)
Expected Behaviour
A retry after a fault where the first request may have been delivered does not collide with its own earlier attempt. Either the retry uses a fresh query id, or the client does not retry once the request body has been sent.
Configuration
Client Configuration
Defaults: retry=3, retryOnFailures = [NoHttpResponse, ConnectTimeout, ConnectionRequestTimeout, ServerRetryable]. Caller sets queryId and insert_deduplication_token per insert (clickhouse-kafka-connect v1.6.0).
Environment
- Cloud
- Client version: client-v2 0.9.5 (insert loop unchanged on 0.9.6, 0.10.0 and
main) - Language version: Java 21.0.10
- OS: Linux
ClickHouse Server
- ClickHouse Server version: 26.4.1 and 26.6.1
- Non-default settings:
async_insert=1, wait_for_async_insert=1, async_insert_busy_timeout_ms=200
Related: https://github.com/ClickHouse/clickhouse-java/issues/1529 (same code, different cause). Downstream: https://github.com/ClickHouse/clickhouse-kafka-connect/issues/847.
- 主要言語
- Java
- スター
- 1.6k
- フォーク
- 649
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 39
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ClickHouse/clickhouse-java のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/clickhouse-java#3349 ·
メンテナーはふだん 1 日以内に返信
-
bug jdbc-v2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
ClickHouse/clickhouse-java#3347 ·
メンテナーはふだん 1 日以内に返信
-
bug jdbc-v2
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ClickHouse/clickhouse-java#3326 ·
メンテナーはふだん 1 日以内に返信
-
[client-v2] Enum8/Enum16 insert accepts a non-member integer and uses Enum.ordinal(), silently storing values that are not enum members対応中かも @jaya232 が 6 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-java#3304 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug jdbc-v2
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ClickHouse/clickhouse-java#3214 ·
メンテナーはふだん 1 日以内に返信
ClickHouse/clickhouse-java の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug:unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
UniversalMediaServer/UniversalMediaServer#6473 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
StarRocks/starrocks#83246 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 2 日以内に返信