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
Avoid extra reroutes of delayed shards in RoutingService #12532
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,13 @@ | |
|
||
package org.elasticsearch.cluster.allocation; | ||
|
||
import org.apache.lucene.util.LuceneTestCase; | ||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; | ||
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; | ||
import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteResponse; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.routing.RoutingService; | ||
import org.elasticsearch.cluster.routing.ShardRouting; | ||
import org.elasticsearch.cluster.routing.ShardRoutingState; | ||
import org.elasticsearch.cluster.routing.allocation.RerouteExplanation; | ||
|
@@ -33,15 +35,19 @@ | |
import org.elasticsearch.cluster.routing.allocation.decider.Decision; | ||
import org.elasticsearch.cluster.routing.allocation.decider.DisableAllocationDecider; | ||
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider; | ||
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; | ||
import org.elasticsearch.common.Priority; | ||
import org.elasticsearch.common.io.FileSystemUtils; | ||
import org.elasticsearch.common.logging.ESLogger; | ||
import org.elasticsearch.common.logging.Loggers; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.env.NodeEnvironment; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.test.ElasticsearchIntegrationTest; | ||
import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; | ||
import org.elasticsearch.test.InternalTestCluster; | ||
import org.elasticsearch.test.junit.annotations.TestLogging; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
|
@@ -162,6 +168,45 @@ public void rerouteWithAllocateLocalGateway_enableAllocationSettings() throws Ex | |
rerouteWithAllocateLocalGateway(commonSettings); | ||
} | ||
|
||
/** | ||
* Test that we don't miss any reroutes when concurrent_recoveries | ||
* is set very low and there are a large number of unassigned shards. | ||
*/ | ||
@Test | ||
@LuceneTestCase.Slow | ||
public void testDelayWithALargeAmountOfShards() throws Exception { | ||
Settings commonSettings = settingsBuilder() | ||
.put("gateway.type", "local") | ||
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_CONCURRENT_RECOVERIES, 1) | ||
.build(); | ||
logger.info("--> starting 4 nodes"); | ||
String node_1 = internalCluster().startNode(commonSettings); | ||
internalCluster().startNode(commonSettings); | ||
internalCluster().startNode(commonSettings); | ||
internalCluster().startNode(commonSettings); | ||
|
||
assertThat(cluster().size(), equalTo(4)); | ||
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForNodes("4").execute().actionGet(); | ||
assertThat(healthResponse.isTimedOut(), equalTo(false)); | ||
|
||
logger.info("--> create indices"); | ||
for (int i = 0; i < 25; i++) { | ||
client().admin().indices().prepareCreate("test" + i) | ||
.setSettings(settingsBuilder() | ||
.put("index.number_of_shards", 5).put("index.number_of_replicas", 1) | ||
.put("index.unassigned.node_left.delayed_timeout", randomIntBetween(250, 1000) + "ms")) | ||
.execute().actionGet(); | ||
} | ||
|
||
ensureGreen(TimeValue.timeValueMinutes(1)); | ||
|
||
logger.info("--> stopping node1"); | ||
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(node_1)); | ||
|
||
// This might run slowly on older hardware | ||
ensureGreen(TimeValue.timeValueMinutes(2)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yikes! Is that really 2 minutes of 1 cpu running 100%? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of our CI nodes are reeeeeaaaalllly slow, and since this creates 25 indices with 10 total shards each, I just wanted to make sure it doesn't time out. I do not expect it to take 2 minutes regardless (it's much faster for me). Another reason this test in annotated with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we configure the delayed allocation to not be the default ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I already randomize it between 4 and 15 seconds (since it should find the lowest delay setting), but I can lower it even more. |
||
} | ||
|
||
private void rerouteWithAllocateLocalGateway(Settings commonSettings) throws Exception { | ||
logger.info("--> starting 2 nodes"); | ||
String node_1 = internalCluster().startNode(commonSettings); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want to rest here as well:
registeredNextDelaySetting = Long.MAX_VALUE;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good idea, otherwise it assumes one was running.