[Feature request] CLI should support automatic reconnection when connection is lost during interactive session
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
iotdb-client/cli/src/main/java/org/apache/iotdb/cli/Cli.java から始め、特に receiveCommands() と processCommand を確認してから、iotdb-client/jdbc 配下の IoTDBConnection.reconnect() と IoTDBStatement.callWithRetryAndReconnect() を読んでください。接続関連の失敗が回数を制限した再接続試行によってリトライされ、正常に復旧した場合はフィードバックを伴ってコマンドが再試行され、復旧に失敗した場合は明確に終了すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
-
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. -
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). -
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. -
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. -
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 awhile (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()andIoTDBStatement.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
-
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. -
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. -
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!
- 主要言語
- Java
- スター
- 6.4k
- フォーク
- 1.2k
- 平均マージ
- 1日 17時間
- マージ済み PR(30日)
- 152
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
apache/iotdb のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apache/iotdb#18655 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports successオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column nameオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OpenAPITools/openapi-generator#25014 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
AloisSeckar/demos-java#380 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
openhab/openhab-core#5847 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
appsmithorg/appsmith#42297 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100