Skip to content

Commit 54c446d

Browse files
committed
Only remove active peer on connection failure (#79557)
Today if the `PeerFinder` experiences a connection failure then it removes the `Peer` with the corresponding transport address. However the removed `Peer` might be a different instance which is actually fine and holds a connection reference which therefore leaks. With this commit we only remove ourselves from the tracked set of peers. Relates #77295 Closes #79550
1 parent b28a041 commit 54c446d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/main/java/org/elasticsearch/discovery/PeerFinder.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ public void onFailure(Exception e) {
431431
synchronized (mutex) {
432432
assert probeConnectionResult.get() == null
433433
: "discoveryNode unexpectedly already set to " + probeConnectionResult.get();
434-
peersByAddress.remove(transportAddress);
434+
if (isActive()) {
435+
peersByAddress.remove(transportAddress);
436+
} // else this Peer has been superseded by a different instance which should be left in place
435437
}
436438
}
437439
});

0 commit comments

Comments
 (0)