Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finally return resource jedis to pool #1895

Closed
birdfe76 opened this issue Nov 20, 2018 · 8 comments
Closed

finally return resource jedis to pool #1895

birdfe76 opened this issue Nov 20, 2018 · 8 comments

Comments

@birdfe76
Copy link

birdfe76 commented Nov 20, 2018

Expected behavior

As blow my code.

static JedisPool jedisPool;
public Jedis getResource(){
return jedisPool.getResource();
}
public void returnJedisResource(Jedis resource){
  try{ 
        resource.close();
   }catch(Exception e){
   }finally{
      if( resource.isConnected() ){
             resource.close();
      }
   }
}

First of all, We closed once. but, sometime did not work. only appeared exception.
So we added code 'finally......' We want to return resource to pool surely.

Actual behavior

It doesn't work.
It made more exception. (message: Object has already been returned to this pool or is invalid)
We want to return resource to pool surely.
Can I check resource state whether the resource return to pool instead of 'resource.isConnected()' ?

Jedis version: jedis 2.7.3

Java version: 1.6

How about change jar file to jedis 2.9.0.jar ?
Is it working safety for returning resouce to pool ?

@gkorland
Copy link
Contributor

Can you please attach the full Exception stack trace?

@sazzad16
Copy link
Collaborator

@birdfe76 I suppose your situation is one of the ideal reason for #1775. It's merged but not released yet. Hope your issue will be resolved after a new release.

@birdfe76
Copy link
Author

birdfe76 commented Nov 22, 2018

@sazzad16 Actually I doubted that. JAVA is procedure oriented language.
So When 'finally...' code will be worked after first 'close'. Am I right ?
Anyway I'll see your comment link. Thank you so much your advise.

@birdfe76 birdfe76 reopened this Nov 22, 2018
@birdfe76
Copy link
Author

@gkorland
Caused by: redis.clients.jedis.exceptions.JedisException: Could not return the resource to the pool
at redis.clients.util.Pool.returnResourceObject(Pool.java:66)
at redis.clients.jedis.JedisPool.returnResource(JedisPool.java:124)
... 127 more
Caused by: java.lang.IllegalStateException: Object has already been returned to this pool or is invalid
at org.apache.commons.pool2.impl.GenericObjectPool.returnObject(GenericObjectPool.java:551)
at redis.clients.util.Pool.returnResourceObject(Pool.java:64)
... 128 more

@birdfe76
Copy link
Author

I tried to jedis-3.0.0-m1.jar. but, same result. Exception appeared again as above.

@gkorland
Copy link
Contributor

@birdfe76 can you please check the following snapshot?

 <repositories>
    <repository>
      <id>snapshots-repo</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>


  <dependencies>
    <dependency>
      <groupId>redis.clients</groupId>
      <artifactId>jedis</artifactId>
      <version>3.0.1-20181217.192606-2</version>
    </dependency>
  </dependencies>

It might be related to this issue #1910

@sazzad16
Copy link
Collaborator

@gkorland I don't think so. #1910 is entirely about JedisSentinelPool. @birdfe76 is using only JedisPool.

@birdfe76
Copy link
Author

@gkorland I don't think so. #1910 is entirely about JedisSentinelPool. @birdfe76 is using only JedisPool.

yeap. We don't use JedisSentinelPool and we just gave up that issue.
We've cleaned that code which is 'finally closed'.
Anyway thanks u guys interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants