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

未关闭 适合新手
#3,469 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1-3 小时
新手友好度
86/100
Issue 类型
文档
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
documentation

调研方向

编辑 docs/clickhouse-docs/client.mdx 中迁移表的四个单元格和 AUTO_SESSION 注释,使用 issue 中列出的 Client.Builder 方法。先阅读 V2 配置表和链接的 Sessions API 文档。更新各行,注明受支持的 setter,并修订注释;当迁移指南不再暗示 client-v2 不支持 session 时,即告完成。

由索引模型根据 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 小时
30 天内合并 PR
36

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ClickHouse/clickhouse-java 的其他 Issue

查看 ClickHouse/clickhouse-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。