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)
- Integrate JUnit reporter in the CI, dorny/reporter
- Check tests that force Redis failover, maybe separate them
- Add pre-commit linting to the repo
- Check tests that are commented out
- Speed up slow tests, or separate them out in their own jobs
- Run parallel jobs
- Ensure local development can run tests easily
- Make tests idempotent
- redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream. - issue with jedis 5.1.0 HOT 4
- jedis subscription not listening to thread interrupted signal HOT 3
- Add support for CLUSTER LINKS command HOT 1
- Add support for HSCAN [NOVALUES]
- Add command filter for CLIENT KILL to support maximum age via [MAXAGE] option
- Support XREAD, XREADGROUP reading from last message of stream
- Supporting redis unstable commands
- [question]Does jedis support jdk21? HOT 2
- How to use RedisTimeSeriesCommands with jedis HOT 1
- Pipelined transaction-handling: watch + get & multi + set
- [Suggested change] Log a warning when `ConnectionFactory.validateObject` determines the connection is no longer connected and/or the ping fails HOT 1
- Reduce the log level of validateObject to WARN HOT 6
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.