`JedisConnectionFactory.start()` leaks the pool when `preparePool()` fails
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
- #3484 di @night-crawlr — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start in JedisConnectionFactory.start() and compare its failure path with the resource cleanup in stop(). The issue provides a reproducer using minIdle(1) and an unreachable Redis server; use it to check that a failed start releases the pool and leaves the factory retryable. An open linked pull request (#3484) already addresses this work.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Affected: 3.4.2 onwards (since #3072), including 4.0.x, 4.1.x and main. On 4.1+ the pool leak needs the legacy client path (setUseUnifiedJedis(false), the deprecated JedisPoolConfig constructors, or a Jedis version without RedisClient).
start() sets the state to STARTING, creates the pool, then calls pool.preparePool(). With minIdle > 0 and a Redis that is down or stalling, preparePool() throws and start() rethrows it as PoolException. After that:
- the state stays
STARTING.stop()only acts onSTARTED, so neitherstop()nordestroy()closes the pool (destroy()only setsDESTROYED); - a second
start()silently does nothing andgetConnection()fails, so the factory can never be used or retried; - the
poolfield is private, so the caller cannot close it either; - in a Spring container, a bean whose
afterPropertiesSet()threw is never destroyed, so the only place the pool can be released is insidestart()itself.
The abandoned GenericObjectPool stays registered in JMX (enabled by default), which keeps it reachable, and its evictor keeps running (JedisPoolConfig sets a 30 s interval). While Redis is down, every eviction run tries to create the missing idle connections and fails; once Redis is reachable again, every orphaned pool keeps reopening about minIdle connections (idle ones are evicted after 60 s and recreated) for the life of the JVM. With sentinels configured and the master unreachable, the same happens to the JedisSentinelPool, whose MasterListener threads also keep running.
An application that builds a new factory after a failure (for example one factory per Redis server, created on demand) leaks one pool per failed attempt, so an outage of a few minutes can leave enough orphaned pools behind to keep the server at maxclients after it has recovered.
The "cannot be retried" part is not limited to the legacy path: if creating the unified client throws (for example a cluster that is unreachable at startup), the factory also stays in STARTING.
Reproducer:
JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMinIdle(1);
JedisConnectionFactory factory = new JedisConnectionFactory(
new RedisStandaloneConfiguration("127.0.0.1", 6390), // nothing listening
JedisClientConfiguration.builder().usePooling().poolConfig(poolConfig).build());
factory.setUseUnifiedJedis(false); // 4.1+ only
factory.afterPropertiesSet(); // PoolException: Could not prepare the pool
factory.destroy(); // sets DESTROYED, releases nothing
// org.apache.commons.pool2:type=GenericObjectPool,* is still registered, and the
// commons-pool-evictor thread keeps trying to create minIdle connections every 30 s.
Expected: a start() that fails releases what it created and returns the factory to a state from which start() can be retried.
(Not covered here: if no sentinel answers, the JedisSentinelPool constructor itself throws after its pool was registered, so that pool never reaches Spring Data.)
I'm happy to send a PR: run the body of start() in a try/catch, dispose the created resources the same way stop() does, restore the previous state and rethrow.
- Lingua principale
- Java
- Stelle
- 1.9k
- Fork
- 1.3k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di spring-projects/spring-data-redis
-
RENAME on cluster connections drops the source key's TTL when keys are in different slotsForse già presa @mp911de l’ha presa 9 giorni fa. Apertatype: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
spring-projects/spring-data-redis#3476 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 5 giorni
-
PathIndexResolver iterates byte[] element-by-element, causing O(n) overheadForse già presa @mp911de l’ha presa 12 giorni fa. Apertatype: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
spring-projects/spring-data-redis#3460 · 1 assegnatario ·
I maintainer di solito rispondono entro 5 giorni
-
status: waiting-for-triage
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
spring-projects/spring-data-redis#3485 ·
I maintainer di solito rispondono entro 5 giorni
-
Release 4.0.9 (2025.1.9)Apertatype: task
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
spring-projects/spring-data-redis#3479 ·
I maintainer di solito rispondono entro 5 giorni
-
Release 4.1.3 (2026.0.3)Apertatype: task
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
spring-projects/spring-data-redis#3478 ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di spring-projects/spring-data-redis
Issue simili
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
authorjapps/zerocode#808 ·
-
upgrade to checkstyle 14.4.0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
checkstyle/sonar-checkstyle#625 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
quarkusio/quarkus-agent-mcp#302 ·
I maintainer di solito rispondono entro 2 giorni
-
build
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
MetricsHub/metricshub-community#1472 ·
I maintainer di solito rispondono entro 1 giorno