Skip to content

Extend default probe connect/handshake timeouts #68059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/reference/modules/discovery/discovery-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ Defaults to `1s`.
`discovery.probe.connect_timeout`::
(<<static-cluster-setting,Static>>)
Sets how long to wait when attempting to connect to each address. Defaults to
`3s`.
`30s`.

`discovery.probe.handshake_timeout`::
(<<static-cluster-setting,Static>>)
Sets how long to wait when attempting to identify the remote node via a
handshake. Defaults to `1s`.
handshake. Defaults to `30s`.

`discovery.request_peers_timeout`::
(<<static-cluster-setting,Static>>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ public class HandshakingTransportAddressConnector implements TransportAddressCon
// connection timeout for probes
public static final Setting<TimeValue> PROBE_CONNECT_TIMEOUT_SETTING =
Setting.timeSetting("discovery.probe.connect_timeout",
TimeValue.timeValueMillis(3000), TimeValue.timeValueMillis(1), Setting.Property.NodeScope);
TimeValue.timeValueSeconds(30), TimeValue.timeValueMillis(1), Setting.Property.NodeScope);
// handshake timeout for probes
public static final Setting<TimeValue> PROBE_HANDSHAKE_TIMEOUT_SETTING =
Setting.timeSetting("discovery.probe.handshake_timeout",
TimeValue.timeValueMillis(1000), TimeValue.timeValueMillis(1), Setting.Property.NodeScope);
TimeValue.timeValueSeconds(30), TimeValue.timeValueMillis(1), Setting.Property.NodeScope);

private final TransportService transportService;
private final TimeValue probeConnectTimeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.MockLogAppender;
import org.elasticsearch.test.junit.annotations.TestLogging;
Expand All @@ -53,6 +54,7 @@
import static java.util.Collections.emptyMap;
import static java.util.Collections.emptySet;
import static org.elasticsearch.cluster.ClusterName.CLUSTER_NAME_SETTING;
import static org.elasticsearch.discovery.HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING;
import static org.elasticsearch.discovery.HandshakingTransportAddressConnector.PROBE_HANDSHAKE_TIMEOUT_SETTING;
import static org.elasticsearch.node.Node.NODE_NAME_SETTING;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -79,6 +81,7 @@ public void startServices() {
final Settings settings = Settings.builder()
.put(NODE_NAME_SETTING.getKey(), "node")
.put(CLUSTER_NAME_SETTING.getKey(), "local-cluster")
.put(PROBE_HANDSHAKE_TIMEOUT_SETTING.getKey(), "1s") // shorter than default for the sake of test speed
.build();
threadPool = new TestThreadPool("node", settings);

Expand Down Expand Up @@ -211,6 +214,11 @@ public void testDoesNotConnectToDifferentCluster() throws InterruptedException {
failureListener.assertFailure();
}

public void testTimeoutDefaults() {
assertThat(PROBE_HANDSHAKE_TIMEOUT_SETTING.get(Settings.EMPTY), equalTo(TimeValue.timeValueSeconds(30)));
assertThat(PROBE_CONNECT_TIMEOUT_SETTING.get(Settings.EMPTY), equalTo(TimeValue.timeValueSeconds(30)));
}

public void testHandshakeTimesOut() throws InterruptedException {
remoteNode = new DiscoveryNode("remote-node", buildNewFakeTransportAddress(), Version.CURRENT);
discoveryAddress = getDiscoveryAddress();
Expand All @@ -219,15 +227,14 @@ public void testHandshakeTimesOut() throws InterruptedException {

FailureListener failureListener = new FailureListener();
handshakingTransportAddressConnector.connectToRemoteMasterNode(discoveryAddress, failureListener);
Thread.sleep(PROBE_HANDSHAKE_TIMEOUT_SETTING.get(Settings.EMPTY).millis());
failureListener.assertFailure();
}

private TransportAddress getDiscoveryAddress() {
return randomBoolean() ? remoteNode.getAddress() : buildNewFakeTransportAddress();
}

private class FailureListener implements ActionListener<DiscoveryNode> {
private static class FailureListener implements ActionListener<DiscoveryNode> {
final CountDownLatch completionLatch = new CountDownLatch(1);

@Override
Expand All @@ -241,7 +248,7 @@ public void onFailure(Exception e) {
}

void assertFailure() throws InterruptedException {
assertTrue(completionLatch.await(30, TimeUnit.SECONDS));
assertTrue(completionLatch.await(15, TimeUnit.SECONDS));
}
}
}