Skip to content

Commit

Permalink
Fixed - Connection pinging works incorrectly if new connections were …
Browse files Browse the repository at this point in the history
…created in pool. #4441
  • Loading branch information
Nikita Koksharov committed Aug 23, 2022
1 parent a731958 commit 8b392b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ private void createConnection(boolean checkFreezed, AtomicInteger requests, Clie
createConnection(entry, promise);
promise.whenComplete((conn, e) -> {
if (e == null) {
conn.decUsage();
if (changeUsage()) {
conn.decUsage();
}
if (!initPromise.isDone()) {
entry.addConnection(conn);
} else {
Expand Down Expand Up @@ -280,11 +282,17 @@ private void createConnection(ClientConnectionsEntry entry, CompletableFuture<T>
return;
}

promise.thenApply(c -> c.incUsage());
if (changeUsage()) {
promise.thenApply(c -> c.incUsage());
}
connectedSuccessful(entry, promise, conn);
});
}

protected boolean changeUsage() {
return true;
}

private void connectedSuccessful(ClientConnectionsEntry entry, CompletableFuture<T> promise, T conn) {
if (conn.isActive() && entry.getNodeType() == NodeType.SLAVE) {
entry.resetFirstFail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,8 @@ protected void releaseConnection(ClientConnectionsEntry entry, RedisPubSubConnec
entry.releaseSubscribeConnection(conn);
}

@Override
protected boolean changeUsage() {
return false;
}
}

0 comments on commit 8b392b6

Please sign in to comment.