Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

[Feature request] CLI should support automatic reconnection when connection is lost during interactive session

Ouverte
#17,179 1 commentaire 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é
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
java
Domaine
cli, databases

Piste de recherche

Commencez dans iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java, en particulier avec receiveCommands() et processCommand, puis lisez IoTDBConnection.reconnect() et IoTDBStatement.callWithRetryAndReconnect() dans iotdb-client/jdbc. C’est terminé lorsque les échecs liés à la connexion font l’objet de nouvelles tentatives avec un nombre limité de tentatives de reconnexion, qu’une récupération réussie relance la commande avec un retour d’information et qu’une récupération échouée se termine clairement.

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

Description

Search before asking
  • I searched in the issues and found nothing similar.
Motivation

I am always frustrated when the IoTDB CLI exits as soon as the connection to the server is lost (e.g. server restart, network blip, or idle timeout). I have to reconnect manually, re-enter connection parameters, and lose my session context.

Other IoTDB clients already support reconnection: the Session API (Java), JDBC (via callWithRetryAndReconnect in IoTDBStatement), and the C++/Python clients all retry and reconnect on connection failure. The CLI is the only major client that does not—it holds a single connection for the entire interactive session and exits on any connection-related error. Adding automatic reconnection to the CLI would align its behaviour with the rest of the client stack and improve the experience for long-lived interactive sessions (e.g. over SSH or after server restarts).

Solution

Proposed behaviour

  1. Detect connection loss
    When a command fails with a connection-related error (e.g. SQLException caused by connection refused, timeout, or closed connection), do not exit immediately.

  2. Attempt reconnection
    Try to establish a new connection using the same parameters (host, port, user, password, and options) that were used at login. Reuse the same logic as the initial connection (e.g. DriverManager.getConnection with the same URL and properties).

  3. Retry the command
    After a successful reconnection, retry the same user command (the current line/statement that failed) with the new connection, with a bounded number of retries (e.g. 3) and optional backoff.

  4. User feedback
    On successful reconnection, print a short message such as: "Connection lost. Reconnected. Retrying command." and continue the interactive loop with the new connection.

  5. Failure handling
    If reconnection fails after all retries, exit with a clear error message, e.g. "Could not reconnect after N attempts. Please check that the server is running and try again."

Relevant code

  • iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java:

    • receiveCommands() opens one connection and runs a while (true) loop; any SQLException is caught at the top level and the process exits (lines 215–217).
    • Change: catch connection-related failures inside the loop (or around processCommand), attempt reconnection, then retry the command or continue with the new connection.
  • iotdb-client/jdbc:

    • IoTDBConnection.reconnect() and IoTDBStatement.callWithRetryAndReconnect() can be used as reference for retry/reconnect behaviour.

Optional

  • Make retry count and interval configurable (e.g. CLI options or environment variables) for consistency with Session/JDBC.
Alternatives
  1. No retry, only reconnect
    On connection loss, attempt reconnection and, on success, continue the session without retrying the failed command (user re-enters it). Simpler to implement but less convenient than retrying the last command.

  2. Prompt user
    On connection loss, prompt: "Connection lost. Reconnect? (y/n)". If yes, reconnect and optionally retry the command. Gives control but adds friction for automated or scripted use.

  3. Leave as-is
    Keep current behaviour (exit on connection loss). This preserves simplicity but leaves the CLI as the only client without reconnection support and worsens UX for long sessions and unstable networks.

Are you willing to submit a PR?
  • I'm willing to submit a PR!
Langage dominant
Java
Étoiles
6.4k
Forks
1.2k
Merge moyen
1 j 17 h
PR mergées (30 j)
152

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 apache/iotdb

Toutes les issues de apache/iotdb

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.