Comments (12)
Are you using a connection pool? I mean, are you using JedisPool?
from jedis.
yes I'm using this that I pasted in the bug report:
jedisPool = new JedisPool(new GenericObjectPool.Config(), "cache01");
I'm using that in my main thread as a public static object. Then in my threads I use the code I pasted in pasteBin.
from jedis.
Ok. So the problem is that Redis by default closes connections after 300 seconds. The connection pool doesn't check idle connections, so your application might receive a broken connection and because of that throw the error you get.
The way to avoid that is setting in the connection pool testOnBorrow=true, that will make sure that all the connections you get are open and ready to receive commands.
from jedis.
thanks,
so something like this?
static {
GenericObjectPool.Config config = new GenericObjectPool.Config();
config.testOnBorrow = true;
jedisPool = new JedisPool(new GenericObjectPool.Config(), "cache01");
}
from jedis.
yes! exactly!!!
let me know if it worked!
from jedis.
will do, testing now... thanks for the quick response :)
from jedis.
unfortunately the problem still happens, just had it happen again. Any other ideas? Have you seen that error before?
I have 250 threads running that pull the jedis resource from the pool if that helps
from jedis.
Oh wait... you are not giving JedisPool the Config you are creating.
Try to do this:
static {
GenericObjectPool.Config config = new GenericObjectPool.Config();
config.testOnBorrow = true;
jedisPool = new JedisPool(config, "cache01");
}
from jedis.
I am closing this as I never get a response from you, so I am assuming it worked! :)
thanks for reporting this and if you still have an error just let me know!
from jedis.
Hi,
I am getting into this issue while using Jedis with spring data redis integration. I am setting the configuration to use pool, testOnBorrow as well as testOnReturn true.
I am using Jedis pool, and have verified that spring ensures the resources are returned to the pool, by calling returnResource() and returnBrokenResource in case of exceptions. Still facing this issue. I have a heavily multi-threaded environment.
Error stack -
Thread 1:
[ERROR] [03/01/2015 07:05:32.044] [events-system-akka.actor.default-dispatcher-2281] [akka://events-system/user/$YN/$b/$b/$b] java.lang.Long cannot be cast to java.util.List
java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List
at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:230)
at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:236)
at redis.clients.jedis.BinaryJedis.zscan(BinaryJedis.java:3608)
at org.springframework.data.redis.connection.jedis.JedisConnection$3.doScan(JedisConnection.java:2998)
at org.springframework.data.redis.core.KeyBoundCursor.doScan(KeyBoundCursor.java:39)
at org.springframework.data.redis.core.ScanCursor.scan(ScanCursor.java:85)
at org.springframework.data.redis.core.ScanCursor.hasNext(ScanCursor.java:168)
at org.springframework.data.redis.core.ConvertingCursor.hasNext(ConvertingCursor.java:56)
...
application specific stack trace
...
Thread 2:
[ERROR] [03/01/2015 07:03:07.295] [events-system-akka.actor.default-dispatcher-2273] [akka://events-system/user/$VN/$b/$b/$b] Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long
org.springframework.data.redis.RedisSystemException: Unknown redis exception; nested exception is java.lang.ClassCastException: [B cannot be cast to java.lang.Long
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.getFallback(FallbackExceptionTranslationStrategy.java:48)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:38)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:195)
at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2321)
at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:283)
at org.springframework.data.redis.core.DefaultZSetOperations$19.doInRedis(DefaultZSetOperations.java:280)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:85)
at org.springframework.data.redis.core.DefaultZSetOperations.remove(DefaultZSetOperations.java:280)
...
application specific stack trace
...
Caused by: java.lang.ClassCastException: [B cannot be cast to java.lang.Long
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:210)
at redis.clients.jedis.BinaryJedis.zrem(BinaryJedis.java:1624)
at org.springframework.data.redis.connection.jedis.JedisConnection.zRem(JedisConnection.java:2319)
... 21 more
from jedis.
@deepakpol Could you please post an new issue? Please describe Jedis version and Spring data redis version, too. :)
from jedis.
@HeartSaVioR thanks for the reply, Created a new issue #918
from jedis.
Related Issues (20)
- redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream when init JedisCluster using java test container HOT 1
- Sometimes observing high latency when using JedisCluster with large number of threads. HOT 2
- 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
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.