Git Product home page Git Product logo

Comments (12)

xetorthio avatar xetorthio commented on August 27, 2024

Are you using a connection pool? I mean, are you using JedisPool?

from jedis.

jiminoc avatar jiminoc commented on August 27, 2024

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.

xetorthio avatar xetorthio commented on August 27, 2024

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.

jiminoc avatar jiminoc commented on August 27, 2024

thanks,
so something like this?
static {
GenericObjectPool.Config config = new GenericObjectPool.Config();
config.testOnBorrow = true;
jedisPool = new JedisPool(new GenericObjectPool.Config(), "cache01");
}

from jedis.

xetorthio avatar xetorthio commented on August 27, 2024

yes! exactly!!!
let me know if it worked!

from jedis.

jiminoc avatar jiminoc commented on August 27, 2024

will do, testing now... thanks for the quick response :)

from jedis.

jiminoc avatar jiminoc commented on August 27, 2024

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.

xetorthio avatar xetorthio commented on August 27, 2024

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.

xetorthio avatar xetorthio commented on August 27, 2024

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.

deepakpol avatar deepakpol commented on August 27, 2024

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.

HeartSaVioR avatar HeartSaVioR commented on August 27, 2024

@deepakpol Could you please post an new issue? Please describe Jedis version and Spring data redis version, too. :)

from jedis.

deepakpol avatar deepakpol commented on August 27, 2024

@HeartSaVioR thanks for the reply, Created a new issue #918

from jedis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.