You can clone with
HTTPS or Subversion.
Intermittently our webservice is failing against jedis call with following error:
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
Caused by: java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed
We're noticing this on read and r+w(master) pool
Config pool settings:
#public static final byte WHEN_EXHAUSTED_GROW = 2;
#public static final byte WHEN_EXHAUSTED_BLOCK = 1;
Hey just wanted to add some more thoughts on this since we're still consistently seeing this error..
I've increase connection pool WhenExhaustedAction=2 (WHEN_EXHAUSTED_GROW), and also increased to 5000 maxActive, even though it shouldn't affect by that parm, but still continue to see this error.
As per GenericPoolConfig, NoElementException is caused when WhenExhaustedAction=BLOCK..http://commons.apache.org/pool/api-1.6/org/apache/commons/pool/impl/GenericObjectPool.html#borrowObject%28%29
I'm wondering if whenExhaustedAction is really getting set. Any thoughts, comments very much appreciated.
I think there is a problem when the pool want to create new resources. Because the message is: "Could not create a validated object". It tries to grow, but can't.
Is there any connection problem that you are aware of when creating the resources?
You're right. The real problem was thread unsafe code jedis = jedisPool.getResource(); stored as instance variable of Dropwizard resource class. To adress this issue we moved getResource() deeper into the core: now we use jedis as local variable at the method level. Everything work as expected.
jedis = jedisPool.getResource();
I'm getting this exact same issue. a-b can you expand on your comment?
I believe I'm using Jedis in the same way -- I have a public class that keeps the JedisPool as a static variable, and only when I need to issue a redis command do I request a resource, and then return it immediately. Is this what you mean by using "jedis as a local variable at the method level" ?
I got the similar issue. In my scenario that is because of new JedisPool/3 timeout (default is 2000) so change to JedisPool/4 (with timeout) to solve the problem. I need a longer timeout because of several complex queries. BTW, my getResource() inside method by default.
the psudo processes are:
3. Jedis.ping() --> timeout
4. JedisPool$JedisFactory.validateObject() --> failed because obj NOT instanceof Jedis inside JedisPool.validateObject(final Object obj)
5. java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed
hope this helps