[client-v2] Migration guide marks SESSION_ID, SESSION_CHECK and SESSION_TIMEOUT as ✗, but Client.Builder supports them

オープン 初心者向け
#3,469 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
documentation

調査の方向性

docs/clickhouse-docs/client.mdx の移行テーブルの4つのセルと AUTO_SESSION コメントを、issue に記載された Client.Builder メソッドを使って編集します。まず V2 設定テーブルとリンク先の Sessions API ドキュメントを読みます。サポートされている setter を示すように行を更新し、コメントを修正します。移行ガイドが client-v2 はセッションをサポートしていないと示唆しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

client documentation

Description

The V1 → V2 configuration table of the migration guide (docs/clickhouse-docs/client.mdx, tab "Timeouts & Retry", published as Configuration Parameters Match) marks three V1 options as ✗ (no V2 builder method). client-v2 has a method for each of them, released in 0.10.0:

V1 option Table client-v2 on main
ClickHouseClientOption#SESSION_ID ✗ Client.Builder#setSessionId, Client#updateSessionId
ClickHouseClientOption#SESSION_CHECK ✗ Client.Builder#setSessionCheck
ClickHouseClientOption#SESSION_TIMEOUT ✗ Client.Builder#setSessionTimeout

The operation settings (QuerySettings, InsertSettings, CommandSettings) have the same three setters, and all have use(Session).

In the tab "Miscellaneous", ClickHouseDefaults#AUTO_SESSION has the comment "Session support will be reviewed". The ✗ of that row is correct (client-v2 does not make a session by itself), but the comment also says that client-v2 has no sessions. The REPEAT_ON_SESSION_LOCK ✗ is correct.

A V1 user who migrates reads that client-v2 has no sessions. The V2 part of client.mdx has no section about sessions, so the page shows no other information. The feature table in docs/clickhouse-docs/index.mdx says "Sessions ✔" for Client V2, and docs/features.md ("Session handling") describes the API.

Steps to reproduce
  1. Run the program below against a local server.
  2. Each case uses one of the three builder methods. The server result shows that the server applies the parameter.
Error Log or Exception StackTrace
1. setSessionId: CREATE TEMPORARY TABLE t: OK
1. setSessionId: SELECT FROM t: OK
2. setSessionCheck(true), unknown session: Code: 372. DB::Exception: Session 4114d1b9-86de-40df-8d79-d05e408086d0 not found. (SESSION_NOT_FOUND)  (queryId= )
3. setSessionTimeout(1): first query: OK
3. setSessionTimeout(60): first query: OK
3. timeout 1 s: session_check after 5 s: Code: 372. DB::Exception: Session 48b06230-8dfe-4bbe-b7ee-bbac6af8b584 not found. (SESSION_NOT_FOUND)  (queryId= )
3. timeout 60 s: session_check after 5 s: OK
Expected Behaviour

The three rows name the V2 builder methods, and the AUTO_SESSION comment does not say that sessions are not supported. The output above shows that the server applies each parameter that client-v2 sends: the temporary table stays in the session (session_id), an unknown session fails with SESSION_NOT_FOUND (session_check), and the session with session_timeout=1 is gone after 5 s while the one with 60 is not.

The stale cells are at docs/clickhouse-docs/client.mdx:1384-1386 (the three rows) and docs/clickhouse-docs/client.mdx:1482 (the AUTO_SESSION comment). The builder methods are at client-v2/src/main/java/com/clickhouse/client/api/Client.java:1079-1120.

The fix is a change of four table cells; a short Sessions section in the V2 part of client.mdx is optional. Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.

Related: #2892 (open) asks to restructure the same configuration tables.

Code Example
Reproduction program (Java, 39 lines)
import com.clickhouse.client.api.Client;
import com.clickhouse.client.api.query.QueryResponse;
import java.util.UUID;

public class Repro {
    static Client.Builder base() {
        return new Client.Builder().addEndpoint("http://localhost:8123").setUsername("default").setPassword("");
    }

    static void run(Client c, String label, String sql) {
        try (QueryResponse r = c.query(sql).get()) {
            System.out.println(label + ": OK");
        } catch (Exception e) {
            System.out.println(label + ": " + e.getMessage().split("\n")[0]);
        }
    }

    public static void main(String[] args) throws Exception {
        try (Client c = base().setSessionId(UUID.randomUUID().toString()).build()) {
            run(c, "1. setSessionId: CREATE TEMPORARY TABLE t", "CREATE TEMPORARY TABLE t (x UInt8)");
            run(c, "1. setSessionId: SELECT FROM t", "SELECT * FROM t");
        }
        try (Client c = base().setSessionId(UUID.randomUUID().toString()).setSessionCheck(true).build()) {
            run(c, "2. setSessionCheck(true), unknown session", "SELECT 1");
        }
        String s1 = UUID.randomUUID().toString(), s60 = UUID.randomUUID().toString();
        try (Client a = base().setSessionId(s1).setSessionTimeout(1).build();
             Client b = base().setSessionId(s60).setSessionTimeout(60).build()) {
            run(a, "3. setSessionTimeout(1): first query", "SELECT 1");
            run(b, "3. setSessionTimeout(60): first query", "SELECT 1");
        }
        Thread.sleep(5000);
        try (Client a = base().setSessionId(s1).setSessionCheck(true).build();
             Client b = base().setSessionId(s60).setSessionCheck(true).build()) {
            run(a, "3. timeout 1 s: session_check after 5 s", "SELECT 1");
            run(b, "3. timeout 60 s: session_check after 5 s", "SELECT 1");
        }
    }
}
Configuration
Client Configuration
// In the program: Client.Builder with setSessionId, setSessionCheck(true), setSessionTimeout(1) and setSessionTimeout(60).
Environment
  • Cloud
  • Client version: client-v2 main (8480ca001, 0.12.0-rc1-SNAPSHOT)
  • Language version: Java 17.0.21
  • OS: Linux (Docker)
ClickHouse Server
  • ClickHouse Server version: 26.11.4.11
  • ClickHouse Server non-default settings, if any: none
  • CREATE TABLE statements for tables involved: none (the program makes a temporary table)
  • Sample data for all these tables: none

Classification: impact: none · area: Docs & project (migration guide)


Found by automated analysis (Polyglot AI) while working on ClickHouse/clickhouse-cs#785. Verified against a live server.

主要言語
Java
スター
1.6k
フォーク
657
平均マージ
2日 6時間
マージ済み PR(30日)
36

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

ClickHouse/clickhouse-java のほかの issue

ClickHouse/clickhouse-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。