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

Ouverte Adaptée aux débutants
#3,469 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
1/5
Temps estimé
1-3 heures
Accessibilité débutants
86/100
Type d'issue
Documentation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
documentation

Piste de recherche

Modifiez les quatre cellules du tableau de migration et le commentaire AUTO_SESSION dans docs/clickhouse-docs/client.mdx, en utilisant les méthodes de Client.Builder indiquées dans l’issue. Lisez d’abord le tableau de configuration V2 et la documentation liée de Sessions API. Mettez à jour les lignes pour nommer les setters pris en charge et révisez le commentaire ; la tâche est terminée lorsque le guide de migration ne laisse plus entendre que client-v2 ne prend pas en charge les sessions.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Java
Étoiles
1.6k
Forks
657
Merge moyen
2 j 6 h
PR mergées (30 j)
36

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de ClickHouse/clickhouse-java

Toutes les issues de ClickHouse/clickhouse-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.