|
42 | 42 | import org.opensearch.cluster.ClusterStateTaskConfig;
|
43 | 43 | import org.opensearch.cluster.ClusterStateUpdateTask;
|
44 | 44 | import org.opensearch.cluster.LocalClusterUpdateTask;
|
| 45 | +import org.opensearch.cluster.NodeConnectionsService; |
45 | 46 | import org.opensearch.cluster.block.ClusterBlocks;
|
46 | 47 | import org.opensearch.cluster.coordination.ClusterFormationFailureHelper.ClusterFormationState;
|
47 | 48 | import org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion;
|
@@ -187,6 +188,7 @@ public class Coordinator extends AbstractLifecycleComponent implements Discovery
|
187 | 188 | private final NodeHealthService nodeHealthService;
|
188 | 189 | private final PersistedStateRegistry persistedStateRegistry;
|
189 | 190 | private final RemoteStoreNodeService remoteStoreNodeService;
|
| 191 | + private NodeConnectionsService nodeConnectionsService; |
190 | 192 |
|
191 | 193 | /**
|
192 | 194 | * @param nodeName The name of the node, used to name the {@link java.util.concurrent.ExecutorService} of the {@link SeedHostsResolver}.
|
@@ -418,7 +420,11 @@ PublishWithJoinResponse handlePublishRequest(PublishRequest publishRequest) {
|
418 | 420 |
|
419 | 421 | synchronized (mutex) {
|
420 | 422 | final DiscoveryNode sourceNode = publishRequest.getAcceptedState().nodes().getClusterManagerNode();
|
421 |
| - logger.trace("handlePublishRequest: handling [{}] from [{}]", publishRequest, sourceNode); |
| 423 | + logger.debug( |
| 424 | + "handlePublishRequest: handling version [{}] from [{}]", |
| 425 | + publishRequest.getAcceptedState().getVersion(), |
| 426 | + sourceNode |
| 427 | + ); |
422 | 428 |
|
423 | 429 | if (sourceNode.equals(getLocalNode()) && mode != Mode.LEADER) {
|
424 | 430 | // Rare case in which we stood down as leader between starting this publication and receiving it ourselves. The publication
|
@@ -630,7 +636,6 @@ private void handleJoinRequest(JoinRequest joinRequest, JoinHelper.JoinCallback
|
630 | 636 |
|
631 | 637 | transportService.connectToNode(joinRequest.getSourceNode(), ActionListener.wrap(ignore -> {
|
632 | 638 | final ClusterState stateForJoinValidation = getStateForClusterManagerService();
|
633 |
| - |
634 | 639 | if (stateForJoinValidation.nodes().isLocalNodeElectedClusterManager()) {
|
635 | 640 | onJoinValidators.forEach(a -> a.accept(joinRequest.getSourceNode(), stateForJoinValidation));
|
636 | 641 | if (stateForJoinValidation.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) == false) {
|
@@ -814,6 +819,10 @@ public void onFailure(String source, Exception e) {
|
814 | 819 | public ClusterTasksResult<LocalClusterUpdateTask> execute(ClusterState currentState) {
|
815 | 820 | if (currentState.nodes().isLocalNodeElectedClusterManager() == false) {
|
816 | 821 | allocationService.cleanCaches();
|
| 822 | + // This set only needs to be maintained on active cluster-manager |
| 823 | + // This is cleaned up to avoid stale entries which would block future reconnections |
| 824 | + logger.trace("Removing all pending disconnections as part of cluster-manager cleanup"); |
| 825 | + nodeConnectionsService.clearPendingDisconnections(); |
817 | 826 | }
|
818 | 827 | return unchanged();
|
819 | 828 | }
|
@@ -914,11 +923,18 @@ public DiscoveryStats stats() {
|
914 | 923 | @Override
|
915 | 924 | public void startInitialJoin() {
|
916 | 925 | synchronized (mutex) {
|
| 926 | + logger.trace("Starting initial join, becoming candidate"); |
917 | 927 | becomeCandidate("startInitialJoin");
|
918 | 928 | }
|
919 | 929 | clusterBootstrapService.scheduleUnconfiguredBootstrap();
|
920 | 930 | }
|
921 | 931 |
|
| 932 | + @Override |
| 933 | + public void setNodeConnectionsService(NodeConnectionsService nodeConnectionsService) { |
| 934 | + assert this.nodeConnectionsService == null : "nodeConnectionsService is already set"; |
| 935 | + this.nodeConnectionsService = nodeConnectionsService; |
| 936 | + } |
| 937 | + |
922 | 938 | @Override
|
923 | 939 | protected void doStop() {
|
924 | 940 | configuredHostsResolver.stop();
|
@@ -1356,6 +1372,9 @@ assert getLocalNode().equals(clusterState.getNodes().get(getLocalNode().getId())
|
1356 | 1372 | currentPublication = Optional.of(publication);
|
1357 | 1373 |
|
1358 | 1374 | final DiscoveryNodes publishNodes = publishRequest.getAcceptedState().nodes();
|
| 1375 | + // marking pending disconnects before publish |
| 1376 | + // if a nodes tries to send a joinRequest while it is pending disconnect, it should fail |
| 1377 | + nodeConnectionsService.setPendingDisconnections(new HashSet<>(clusterChangedEvent.nodesDelta().removedNodes())); |
1359 | 1378 | leaderChecker.setCurrentNodes(publishNodes);
|
1360 | 1379 | followersChecker.setCurrentNodes(publishNodes);
|
1361 | 1380 | lagDetector.setTrackedNodes(publishNodes);
|
|
0 commit comments