Skip to content

Commit b9ca755

Browse files
authored
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 0b1e118 commit b9ca755

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
@@ -410,7 +410,9 @@ public void onFailure(Exception e) {
410410
synchronized (mutex) {
411411
assert probeConnectionResult.get() == null
412412
: "discoveryNode unexpectedly already set to " + probeConnectionResult.get();
413-
peersByAddress.remove(transportAddress);
413+
if (isActive()) {
414+
peersByAddress.remove(transportAddress);
415+
} // else this Peer has been superseded by a different instance which should be left in place
414416
}
415417
}
416418
});

0 commit comments

Comments
 (0)