Closed
Description
Jedis.java
@Override
public void close() {
if (dataSource != null) {
if (client.isBroken()) {
this.dataSource.returnBrokenResource(this);
} else {
this.dataSource.
returnResource(this);
}
this.dataSource = null; // <-- This line
} else {
super.close();
}
}
JedisSentinelPool.java
@Override
public Jedis getResource() {
while (true) {
Jedis jedis = super.getResource();
jedis.setDataSource(this); // <-- This line
// get a reference because it can change concurrently
final HostAndPort master = currentHostMaster;
final HostAndPort connection = new HostAndPort(jedis.getClient().getHost(), jedis.getClient()
.getPort());
if (master.equals(connection)) {
// connected to the correct master
return jedis;
} else {
returnBrokenResource(jedis);
}
}
}
In the case of concurrency
-
Thread A return an object but not run to "this.dataSource = null" yet
-
Thread B borrow an object and set dataSource to this;
-
And Then Thread A run this.dataSource = null;
-
Finally Thread A will never returnResource because dataSource is null
Jedis version:
2.10.0
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Relationships
Development
No branches or pull requests
Activity
gkorland commentedon Dec 23, 2018
See #1911
sazzad16 commentedon Dec 24, 2018
@gkorland Isn't this issue actually related to #1918 ?
Fix #1920 (port #1918)
oliverbestmann commentedon Dec 28, 2018
Sorry, looks like this is still broken in
2.10.1
. We are still leaking connections.kutzi commentedon Jan 7, 2019
Is there any update on this? Should we open a new bug against 2.10.1?
sazzad16 commentedon Jan 7, 2019
I think, it's because of 02f2cc5#diff-df2421269af8d142bf842cb0141f3a95R3639
@gkorland ping
pavel-hp commentedon Jan 15, 2019
@gkorland
We moved from version 2.9.0 to 2.10.1 and we've faced with the same issue.
Leaking connection to Redis.
All our threads have this StackTrace (it waits infinite time)
remove reset after connection was returned to pool
remove reset after connection was returned to pool (#1935)
22 remaining items