Fix ping node procedure may fail when another node leaves the cluster - Fixes
@@ -726,7 +726,7 @@ class ServerImpl extends TcpDiscoveryImpl {
return F.t(getLocalNodeId(), clientPingRes);
}
- GridPingFutureAdapter<IgniteBiTuple<UUID, Boolean>> fut = new GridPingFutureAdapter<>();
+ GridPingFutureAdapter<IgniteBiTuple<UUID, Boolean>> fut = new GridPingFutureAdapter<>(nodeId);
GridPingFutureAdapter<IgniteBiTuple<UUID, Boolean>> oldFut = pingMap.putIfAbsent(addr, fut);
@@ -848,11 +848,13 @@ class ServerImpl extends TcpDiscoveryImpl {
for (InetSocketAddress addr : spi.getNodeAddresses(node)) {
GridPingFutureAdapter fut = pingMap.get(addr);
- if (fut != null && fut.sock != null)
+ if (fut != null && fut.sock != null) {
+ if (fut.nodeId == null || fut.nodeId.equals(node.id()))
// Reference to the socket is not set to null. No need to assign it to a local variable.
U.closeQuiet(fut.sock);
}
}
+ }
/** {@inheritDoc} */
@Override public void disconnect() throws IgniteSpiException {
@@ -7537,9 +7539,19 @@ class ServerImpl extends TcpDiscoveryImpl {
*
*/
private static class GridPingFutureAdapter<R> extends GridFutureAdapter<R> {
+ /** ID of node ping request is sent to. */
+ private final UUID nodeId;
+
/** Socket. */
private volatile Socket sock;
+ /**
+ * @param nodeId ID of node ping request is sent to.
+ */
+ GridPingFutureAdapter(@Nullable UUID nodeId) {
+ this.nodeId = nodeId;
+ }
+
/**
* Returns socket associated with this ping future.
*
