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

Tracing wrapper implementation causes Jedis resource being destroyed when returning to pool. #37

Merged
merged 1 commit into from
Jun 3, 2019

Conversation

kasinskim
Copy link
Contributor

Problem Description

Tracing wrapper implementation causes Jedis resource being destroyed when returning to pool.
When Jedis resource is destroyed socket associated with its client gets closed.
So, whenever you get instance from JedisPool, you get it in disconnected state - it is reconnecting any time you execute some action on it.

Consider test case scenario available in this PR:

 @Test
 public void shouldReturnResourceToThePoolOnCloseAndStayConnected() {
    //given
    JedisPool pool = new TracingJedisPool(new TracingConfiguration.Builder(mockTracer).build());
    Jedis resource = pool.getResource();
    assertTrue(resource.isConnected());

     //when
    resource.close();

     //then
    assertTrue(resource.isConnected());
  }

Expected behavior

Jedis resource returned to pool should keep connection open for at least BaseGenericObjectPool#getMinEvictableIdleTimeMillis (by default 60 seconds)

Changes introduced

  • TracingJedisWrapper extends Jedis resource & decorates all its methods with tracing spans
  • TracingJedis extends TracingJedisWrapper - so its public interface does not change
  • Covering changes with test cases for both Jedis/Jedis3 implementations

…when returning to pool.

Jedis resource returned to pool should keep connection open for at least BaseGenericObjectPool#getMinEvictableIdleTimeMillis.
Introducing test cases covering the this issue.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 177

  • 35 of 2904 (1.21%) changed or added relevant lines in 5 files are covered.
  • 36 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.7%) to 4.631%

Changes Missing Coverage Covered Lines Changed/Added Lines %
opentracing-redis-jedis/src/main/java/io/opentracing/contrib/redis/jedis/TracingJedis.java 1 19 5.26%
opentracing-redis-jedis3/src/main/java/io/opentracing/contrib/redis/jedis3/TracingJedis.java 1 19 5.26%
opentracing-redis-jedis/src/main/java/redis/clients/jedis/TracingJedisWrapper.java 29 2862 1.01%
Files with Coverage Reduction New Missed Lines %
opentracing-redis-jedis/src/main/java/io/opentracing/contrib/redis/jedis/TracingJedis.java 18 5.26%
opentracing-redis-jedis3/src/main/java/io/opentracing/contrib/redis/jedis3/TracingJedis.java 18 5.26%
Totals Coverage Status
Change from base Build 176: 0.7%
Covered Lines: 1018
Relevant Lines: 21984

💛 - Coveralls

@malafeev malafeev merged commit d2ee42c into opentracing-contrib:master Jun 3, 2019
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

Successfully merging this pull request may close these issues.

3 participants