Comments (8)
This usually happens when you share Jedis instances among different threads.
Please make sure you are not doing that. If you need to do that, use JedisPool.
from jedis.
Thanks for the reply, I do use the pool.
For each service method invocation:
public void savePost(Post post) {
Jedis conn = getPool().getResource();
try {
....
} finally {
if (conn != null) {
getPool().returnResource(conn);
}
}
}
The getPool method:
private JedisPool getPool() {
if (pool == null) {
pool = new JedisPool(server, port);
pool.init();
}
return pool;
}
I'm not using Spring for services, but a JSF bean with Application scope.
I am using hot deploy in Tomcat (from Netbeans IDE) and at around the moment of the exception there were some redeploys before / after, since I was changing behavior of the request beans.
But the pool behavior is there from the beginning, I read about it in the wiki and applied it :)
from jedis.
Great! Can you write a small test that reproduces this? Maybe a connection is not used for some time and redis is closing it? I have the feeling it might be that. But a tests that reproduces this would be great!
from jedis.
I also experience a similar error (Jedis 1.3.1) but it doesn't seem to be deterministic so it's hard to write tests that demonstrates it. I get: "redis.clients.jedis.JedisException: Unknown reply: P" and "redis.clients.jedis.JedisException: Unknown reply: ^@".
E.g.
redis.clients.jedis.JedisException: Unknown reply: P
at redis.clients.jedis.Protocol.process(Protocol.java:65)
at redis.clients.jedis.Protocol.read(Protocol.java:116)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:131)
at redis.clients.jedis.Jedis.hexists(Jedis.java:787)
I'm also using the JedisPool to get a Jedis instance before each invocation.
from jedis.
This happens because Redis by default closes idle connections after 300 seconds and the pool is not checking connections in the ready queue.
You should use Jedis 1.5.0 RC2 which uses the apache pool instead and you can tell that pool to test on borrow, which will ensure that the connection is up and running.
from jedis.
Thanks for your reply. Would you recommend using 1.5.0 RC2 in a business critical system or would you rather advice me to wait until the final 1.5.0 release?
from jedis.
It is in maven central already.
Final 1.5.0 will be released Friday. There won't be many changes. Lots of the big changes were pushed to 1.6.0, so I would say you can go ahead and use it. Or you can wait until Friday for the final 1.5.0. :)
from jedis.
This issue has been handled before using testOnBorrow
So I'm closing this since there is a solution. You'll find information on this in:
https://github.com/xetorthio/jedis/wiki
under "Using Jedis in a multithreaded environment"
from jedis.
Related Issues (20)
- Is renewSlotCache necessary when received MOVED HOT 3
- Using Chinese query plus summarize syntax, the characters are garbled:�
- client side cache is not invalidated upon key deletion from the same client HOT 1
- unable to connect to Google Memorystore HOT 4
- Could not get a resource from the pool HOT 7
- Jedis4 cannot close SentinelListener connection completely in a JedisSentineled mode when executing method close ,caused connection leak
- redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
- redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool at redis.clients.jedis.util.Pool.getResource(Pool.java:42) ~[jedis-5.1.2.jar:?] at redis.clients.jedis.JedisPool.getResource(JedisPool.java:378) ~[jedis-5.1.2.jar:?] HOT 2
- JedisPooled ## Could not get a resource from the pool HOT 5
- redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream. HOT 4
- Resource leak: JedisPooled does not return connection to the pool on socket exception HOT 1
- Jedis connect failed when using dns resolver in jedis 5.1.2 HOT 5
- Pipeline is invalid HOT 2
- Performance issue version 5.1.3
- Empty lua table returns EmptyMap since 5.0.1
- redis.clients.jedis.exceptions.JedisConnectionException: Failed to connect to any host resolved for DNS name. HOT 1
- Failed to connect to any host resolved for DNS name. HOT 1
- Java 21 and Virtual Threads: Timeout waiting for idle object HOT 2
- Refresh connections when getting JedisMovedDataException during using pipeline HOT 1
- Does jedis support valkey connections ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jedis.