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

enableTransactionSupport cause Redis Pool connections leak [DATAREDIS-823] #1395

Closed
spring-projects-issues opened this issue May 3, 2018 · 3 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@spring-projects-issues
Copy link

GaoChao opened DATAREDIS-823 and commented

If set enableTransactionSupport=true and use RedisCache (Not use @Transactional Because 

we use @Cacheable)

RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setEnableTransactionSupport(true);

RedisCacheManager redisCacheManager = new RedisCacheManager(template);

When call org.springframework.data.redis.core.RedisConnectionUtils#releaseConnection

isConnectionTransactional return true TransactionSynchronizationManager.isCurrentTransactionReadOnly() return false,so both unbindConnection and conn.close() are not executed.

if (isConnectionTransactional(conn, factory)  
      && TransactionSynchronizationManager.isCurrentTransactionReadOnly()) {
   unbindConnection(factory);
} else if (!isConnectionTransactional(conn, factory)) {
   if (log.isDebugEnabled()) {
      log.debug("Closing Redis Connection");
   }
   conn.close();
}

The result is the connection is not released.

 


Affects: 1.8.11 (Ingalls SR11)

Attachments:

1 votes, 1 watchers

@spring-projects-issues
Copy link
Author

Christoph Strobl commented

thanks for reporting.
Can you provide a bit insight why you use the tx feature on the template instead of the one available via RedisCacheManager#setTransactionAware?

@spring-projects-issues
Copy link
Author

GaoChao commented

In the attachment project

When set spring.redis.transaction.enable=true in /src/test/resources/application.yml,the test may fail.(Somtimes it is passed.Ithink the reason is that the server reuse the same thread for diffrent request and the redis connection is binded to thread)

When set spring.redis.transaction.enable=false the test is passed

@spring-projects-issues spring-projects-issues added status: waiting-for-feedback We need additional information before we can continue in: cache RedisCache and CacheManager type: bug A general bug in: jedis Jedis driver labels Dec 30, 2020
@mp911de mp911de added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Dec 30, 2020
@mp911de mp911de assigned mp911de and unassigned christophstrobl Jan 11, 2021
@mp911de mp911de added status: duplicate A duplicate of another issue and removed in: cache RedisCache and CacheManager in: jedis Jedis driver status: feedback-provided Feedback has been provided type: bug A general bug labels Jan 11, 2021
@mp911de
Copy link
Member

mp911de commented Jan 11, 2021

That issue was addressed with #573 in version 2.5.0 M1. Marking it as duplicate.

@mp911de mp911de closed this as completed Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants