Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Pooled clients leak a connection per call: pipelines and transactions taken from UnifiedJedis are never closed

オープン 初心者向け
#333 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@ali-jawad がすでに取り組んでいます。

2026年10月23日 から。

  • #334 @ali-jawad による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
77/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

バッチおよび定期的なエンキュー操作について AbstractClient.java の該当メソッドを読み、次に worker の失敗処理について AbstractWorker.java を読んでください。パイプラインとトランザクションがどのように取得され、閉じられるかを確認し、上限のあるプールの maxTotal を超える回数の呼び出しを行う回帰テストを追加してください。これらの呼び出しによってプールが枯渇せず、接続がプールに返却されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Version: jesque 3.0.0 with its jedis 7.2.1. The code is unchanged on master (e4d551d, jedis 8.0.0).

What happens

These calls each take a connection from the client's UnifiedJedis pool and never return it:

  • ClientPoolImpl.batchEnqueue(...), through a pipeline;
  • ClientPoolImpl.recurringEnqueue(...) and ClientPoolImpl.removeRecurringEnqueue(...), through a transaction;
  • WorkerPoolImpl failure handling, through a transaction, when the FailQueueStrategy returns getFailQueueMaxItems(...) > 0.

With a bounded pool, the call after maxTotal such calls fails:

redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
Caused by: java.util.NoSuchElementException: Timeout waiting for idle object, maxWaitDuration=PT1S
	at redis.clients.jedis.util.Pool.getResource(Pool.java:42)
	...
	at redis.clients.jedis.UnifiedJedis.pipelined(UnifiedJedis.java:6001)
	at redis.clients.jedis.RedisClient.pipelined(RedisClient.java:167)
	at net.greghaines.jesque.client.AbstractClient.doBatchEnqueue(AbstractClient.java:210)

That trace is from master (jedis 8.0.0). In the worker, the exception is caught and logged at WARN, so failures silently stop being recorded. With the default pool config (unbounded, non-blocking), nothing throws. Instead, every call leaves one more connection open on Redis: 50 batch enqueues took CLIENT LIST from 2 to 51 connections.

Why

UnifiedJedis.pipelined() and UnifiedJedis.multi() create the pipeline or transaction on a connection taken from the pool, with closeConnection = true, and only their close() returns it:

https://github.com/redis/jedis/blob/26bbb8e33af4efe569d8b7d1126329e257f79e0b/src/main/java/redis/clients/jedis/UnifiedJedis.java#L5129-L5137
https://github.com/redis/jedis/blob/26bbb8e33af4efe569d8b7d1126329e257f79e0b/src/main/java/redis/clients/jedis/UnifiedJedis.java#L5150-L5158

Jesque calls sync() or exec(), but never close():

In 2.3.0 these calls ran inside PoolUtils.doWorkInPool, which returns the Jedis to the pool, so the leak is new in 3.0.0:

https://github.com/gresrun/jesque/blob/5fbb197fda8319f47f679da4d68c38c1542a9db2/src/main/java/net/greghaines/jesque/client/ClientPoolImpl.java

The non-pooled ClientImpl and WorkerImpl aren't affected: closing a pipeline or transaction of a plain Jedis leaves its connection open.

How to reproduce

  1. Create a pooled client with maxTotal = 3, blockWhenExhausted = true and maxWait = 1s: a JedisPooled on jedis 7.x, or PoolUtils.createJedisPool(config, poolConfig) on master.
  2. Pass it to a ClientPoolImpl.
  3. Call client.batchEnqueue("q", List.of(job)) four times.
  4. The 4th call fails as above, although nothing else uses the pool.

Fix

Close the pipelines and transactions with try-with-resources. AbstractPipeline and AbstractTransaction implement Closeable without a checked exception. I'll open a PR with the fix and regression tests that run more calls than a bounded pool's maxTotal.

Workaround

Subclass ClientPoolImpl, override doBatchEnqueue (and the recurring methods, if you use them), and close the pipeline or transaction there.

主要言語
Java
スター
629
フォーク
132
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

gresrun/jesque のほかの issue

gresrun/jesque の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。