influxdata / influxdata/influxdb-java
InfluxDB Client prevents application from exiting when batch mode is enabled
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 1.2k
- フォーク
- 469
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hi Team,
When an influxdb-java client is created and batch is enabled, it prevents the application from exiting normally due to the use of a default non-daemon thread pool. This prevents the application from shutting down in the event that the main thread exits/ crashes. Adding a shutdown hook would not help with closing the client as the JVM will only run shutdown hooks after all non-daemon thread exits. A small example would be running the following:
public class App {
public static void main(String[] args) {
InfluxDB influxDB = InfluxDBFactory.connect("http://localhost:8086");
influxDB.enableBatch();
Runtime.getRuntime().addShutdownHook(new Thread(influxDB::close));
System.out.println(influxDB.ping());
}
}
Currently, the workaround is to explicitly specify a daemon thread factory:
influxDB.enableBatch(
BatchOptions.DEFAULTS
.threadFactory(runnable -> {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
})
);
But I was wondering if it would be a better user experience to have this be the default behaviour so that the main application is allowed to exit normally. The rationale is that a common use case for influxdb-java is to write application metrics and usually one would not expect a metrics library to affect the main application (e.g. cause it to not exit properly).
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
enableBatch エントリーポイントとレポートに示されている BatchOptions.DEFAULTS 設定から開始し、提供された App 例を使ってライフサイクルを再現します。デフォルトのスレッドファクトリがどのように作成されるかを追跡し、バッチモードが有効な場合にバッチ動作を維持したままアプリケーションが正常に終了できることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100