Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix_transport_service…
Browse files Browse the repository at this point in the history
…_on_closed_executor
  • Loading branch information
henningandersen committed May 31, 2024
2 parents 7747639 + 3f23c15 commit d89ecb6
Show file tree
Hide file tree
Showing 39 changed files with 296 additions and 333 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/109240.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 109240
summary: Fix trappy timeout in allocation explain API
area: Allocation
type: bug
issues: []
5 changes: 5 additions & 0 deletions docs/changelog/109241.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 109241
summary: Fix misc trappy allocation API timeouts
area: Allocation
type: bug
issues: []
2 changes: 1 addition & 1 deletion docs/reference/data-streams/tsds-index-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ information, refer to <<dimension-based-routing>>.
`index.mapping.dimension_fields.limit`::
(<<dynamic-index-settings,Dynamic>>, integer)
Maximum number of <<time-series-dimension,time series dimensions>> for the
index. Defaults to `21`.
index. Defaults to `32768`.
// end::dimensions-limit[]
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ teardown:

- do:
allowed_warnings:
- "index template [generic_logs_template] has index patterns [logs-*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [generic_logs_template] will take precedence during new index creation"
- "index template [my-template] has index patterns [data-*] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template] will take precedence during new index creation"
indices.put_index_template:
name: my-template
body:
Expand Down
4 changes: 0 additions & 4 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ tests:
- class: "org.elasticsearch.upgrades.MlTrainedModelsUpgradeIT"
issue: "https://github.com/elastic/elasticsearch/issues/108993"
method: "testTrainedModelInference"
- class: "org.elasticsearch.datastreams.DataStreamsClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/109154"
method: "test {p0=data_stream/200_rollover_failure_store/Lazily roll over a data\
\ stream's failure store after an ingest failure}"
- class: "org.elasticsearch.xpack.security.CoreWithSecurityClientYamlTestSuiteIT"
issue: "https://github.com/elastic/elasticsearch/issues/109188"
method: "test {yaml=search/180_locale_dependent_mapping/Test Index and Search locale\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
]
}
]
},
"params": {
"master_timeout":{
"type":"time",
"description":"Timeout for connection to master node"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
]
}
]
},
"params": {
"master_timeout":{
"type":"time",
"description":"Timeout for connection to master node"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
]
},
"params":{
"master_timeout":{
"type":"time",
"description":"Timeout for connection to master node"
},
"include_yes_decisions":{
"type":"boolean",
"description":"Return 'YES' decisions in explanation (default: false)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,7 @@ public void testUnassignedReplicaDelayedAllocation() throws Exception {
// wait till we have passed any pending shard data fetching
assertEquals(
AllocationDecision.ALLOCATION_DELAYED,
clusterAdmin().prepareAllocationExplain()
.setIndex("idx")
.setShard(0)
.setPrimary(false)
.get()
.getExplanation()
ClusterAllocationExplanationUtils.getClusterAllocationExplanation(client(), "idx", 0, false)
.getShardAllocationDecision()
.getAllocateDecision()
.getAllocationDecision()
Expand Down Expand Up @@ -1076,12 +1071,12 @@ public void testCannotAllocateStaleReplicaExplanation() throws Exception {

// wait until the system has fetched shard data and we know there is no valid shard copy
assertBusy(() -> {
ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex("idx")
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();
ClusterAllocationExplanation explanation = ClusterAllocationExplanationUtils.getClusterAllocationExplanation(
client(),
"idx",
0,
true
);
assertTrue(explanation.getShardAllocationDecision().getAllocateDecision().isDecisionTaken());
assertEquals(
AllocationDecision.NO_VALID_SHARD_COPY,
Expand Down Expand Up @@ -1223,19 +1218,11 @@ private ClusterAllocationExplanation runExplain(boolean primary, boolean include
return runExplain(primary, null, includeYesDecisions, includeDiskInfo);
}

private ClusterAllocationExplanation runExplain(boolean primary, String nodeId, boolean includeYesDecisions, boolean includeDiskInfo)
throws Exception {

ClusterAllocationExplanation explanation = admin().cluster()
.prepareAllocationExplain()
.setIndex("idx")
.setShard(0)
.setPrimary(primary)
.setIncludeYesDecisions(includeYesDecisions)
.setIncludeDiskInfo(includeDiskInfo)
.setCurrentNode(nodeId)
.get()
.getExplanation();
private ClusterAllocationExplanation runExplain(boolean primary, String nodeId, boolean includeYesDecisions, boolean includeDiskInfo) {
final var request = new ClusterAllocationExplainRequest(TEST_REQUEST_TIMEOUT, "idx", 0, primary, nodeId);
request.includeYesDecisions(includeYesDecisions);
request.includeDiskInfo(includeDiskInfo);
final var explanation = safeGet(client().execute(TransportClusterAllocationExplainAction.TYPE, request)).getExplanation();
if (logger.isDebugEnabled()) {
logger.debug("--> explain json output: \n{}", Strings.toString(explanation, true, true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ public void testDesiredBalanceOnMultiNodeCluster() throws Exception {
var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest().waitForStatus(ClusterHealthStatus.GREEN)).get();
assertEquals(RestStatus.OK, clusterHealthResponse.status());

DesiredBalanceResponse desiredBalanceResponse = client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest())
.get();
final var desiredBalanceResponse = safeGet(
client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest(TEST_REQUEST_TIMEOUT))
);

assertEquals(1, desiredBalanceResponse.getRoutingTable().size());
Map<Integer, DesiredBalanceResponse.DesiredShards> shardsMap = desiredBalanceResponse.getRoutingTable().get(index);
Expand Down Expand Up @@ -75,8 +76,9 @@ public void testDesiredBalanceWithUnassignedShards() throws Exception {
var clusterHealthResponse = clusterAdmin().health(new ClusterHealthRequest(index).waitForStatus(ClusterHealthStatus.YELLOW)).get();
assertEquals(RestStatus.OK, clusterHealthResponse.status());

DesiredBalanceResponse desiredBalanceResponse = client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest())
.get();
final var desiredBalanceResponse = safeGet(
client().execute(TransportGetDesiredBalanceAction.TYPE, new DesiredBalanceRequest(TEST_REQUEST_TIMEOUT))
);

assertEquals(1, desiredBalanceResponse.getRoutingTable().size());
Map<Integer, DesiredBalanceResponse.DesiredShards> shardsMap = desiredBalanceResponse.getRoutingTable().get(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
package org.elasticsearch.cluster;

import org.apache.lucene.tests.util.LuceneTestCase;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainRequest;
import org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanationUtils;
import org.elasticsearch.action.admin.cluster.node.shutdown.NodePrevalidateShardPathResponse;
import org.elasticsearch.action.admin.cluster.node.shutdown.PrevalidateShardPathRequest;
import org.elasticsearch.action.admin.cluster.node.shutdown.PrevalidateShardPathResponse;
Expand Down Expand Up @@ -90,13 +89,12 @@ public void testCheckShards() throws Exception {
.filter(s -> node2ShardIds.contains(s.shardId()))
.filter(s -> s.currentNodeId().equals(node2Id))
.toList()) {
var explanation = client().execute(
TransportClusterAllocationExplainAction.TYPE,
new ClusterAllocationExplainRequest().setIndex(node2Shard.getIndexName())
.setCurrentNode(node2Shard.currentNodeId())
.setShard(node2Shard.id())
.setPrimary(node2Shard.primary())
).get();
var explanation = ClusterAllocationExplanationUtils.getClusterAllocationExplanation(
client(),
node2Shard.getIndexName(),
node2Shard.id(),
node2Shard.primary()
);
logger.info(
"Shard: {} is still located on relocation source node: {}. Allocation explanation: {}",
node2Shard.shardId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

package org.elasticsearch.cluster.routing;

import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanation;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanationUtils;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.indices.stats.ShardStats;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.routing.allocation.AllocationDecision;
import org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision;
import org.elasticsearch.cluster.routing.allocation.command.AllocateStalePrimaryAllocationCommand;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexService;
Expand Down Expand Up @@ -199,14 +198,12 @@ private void putFakeCorruptionMarker(IndexSettings indexSettings, ShardId shardI

private void checkNoValidShardCopy(String indexName, ShardId shardId) throws Exception {
assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(shardId.id())
.setPrimary(true)
.get()
.getExplanation();

final ShardAllocationDecision shardAllocationDecision = explanation.getShardAllocationDecision();
final var shardAllocationDecision = ClusterAllocationExplanationUtils.getClusterAllocationExplanation(
client(),
indexName,
shardId.id(),
true
).getShardAllocationDecision();
assertThat(shardAllocationDecision.isDecisionTaken(), equalTo(true));
assertThat(
shardAllocationDecision.getAllocateDecision().getAllocationDecision(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.store.NativeFSLockFactory;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanation;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
Expand All @@ -37,7 +36,6 @@
import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.UnassignedInfo;
import org.elasticsearch.cluster.routing.allocation.AllocationDecision;
import org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision;
import org.elasticsearch.cluster.routing.allocation.command.AllocateStalePrimaryAllocationCommand;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
Expand Down Expand Up @@ -78,6 +76,7 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanationUtils.getClusterAllocationExplanation;
import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
Expand Down Expand Up @@ -173,14 +172,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {

// shard should be failed due to a corrupted index
assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();

final ShardAllocationDecision shardAllocationDecision = explanation.getShardAllocationDecision();
final var shardAllocationDecision = getClusterAllocationExplanation(client(), indexName, 0, true).getShardAllocationDecision();
assertThat(shardAllocationDecision.isDecisionTaken(), equalTo(true));
assertThat(
shardAllocationDecision.getAllocateDecision().getAllocationDecision(),
Expand Down Expand Up @@ -219,14 +211,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {

// there is only _stale_ primary (due to new allocation id)
assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();

final ShardAllocationDecision shardAllocationDecision = explanation.getShardAllocationDecision();
final var shardAllocationDecision = getClusterAllocationExplanation(client(), indexName, 0, true).getShardAllocationDecision();
assertThat(shardAllocationDecision.isDecisionTaken(), equalTo(true));
assertThat(
shardAllocationDecision.getAllocateDecision().getAllocationDecision(),
Expand All @@ -237,13 +222,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, nodeId, true)).get();

assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();

final var explanation = getClusterAllocationExplanation(client(), indexName, 0, true);
assertThat(explanation.getCurrentNode(), notNullValue());
assertThat(explanation.getShardState(), equalTo(ShardRoutingState.STARTED));
});
Expand Down Expand Up @@ -331,13 +310,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {

// all shards should be failed due to a corrupted translog
assertBusy(() -> {
final UnassignedInfo unassignedInfo = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation()
.getUnassignedInfo();
final UnassignedInfo unassignedInfo = getClusterAllocationExplanation(client(), indexName, 0, true).getUnassignedInfo();
assertThat(unassignedInfo.getReason(), equalTo(UnassignedInfo.Reason.ALLOCATION_FAILED));
assertThat(ExceptionsHelper.unwrap(unassignedInfo.getFailure(), TranslogCorruptedException.class), not(nullValue()));
});
Expand Down Expand Up @@ -392,14 +365,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {

// there is only _stale_ primary (due to new allocation id)
assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();

final ShardAllocationDecision shardAllocationDecision = explanation.getShardAllocationDecision();
final var shardAllocationDecision = getClusterAllocationExplanation(client(), indexName, 0, true).getShardAllocationDecision();
assertThat(shardAllocationDecision.isDecisionTaken(), equalTo(true));
assertThat(
shardAllocationDecision.getAllocateDecision().getAllocationDecision(),
Expand All @@ -410,13 +376,7 @@ public Settings onNodeStopped(String nodeName) throws Exception {
clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, primaryNodeId, true)).get();

assertBusy(() -> {
final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain()
.setIndex(indexName)
.setShard(0)
.setPrimary(true)
.get()
.getExplanation();

final var explanation = getClusterAllocationExplanation(client(), indexName, 0, true);
assertThat(explanation.getCurrentNode(), notNullValue());
assertThat(explanation.getShardState(), equalTo(ShardRoutingState.STARTED));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.elasticsearch.index.store;

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplainResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchPhaseExecutionException;
import org.elasticsearch.cluster.routing.UnassignedInfo;
Expand All @@ -32,6 +31,7 @@
import java.util.Arrays;
import java.util.Collection;

import static org.elasticsearch.action.admin.cluster.allocation.ClusterAllocationExplanationUtils.getClusterAllocationExplanation;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.containsString;
Expand Down Expand Up @@ -79,13 +79,9 @@ public void onAllNodesStopped() throws Exception {

assertBusy(() -> {
// assertBusy since the shard starts out unassigned with reason CLUSTER_RECOVERED, then it's assigned, and then it fails.
final ClusterAllocationExplainResponse allocationExplainResponse = clusterAdmin().prepareAllocationExplain()
.setIndex("test")
.setShard(0)
.setPrimary(true)
.get();
final String description = Strings.toString(allocationExplainResponse.getExplanation());
final UnassignedInfo unassignedInfo = allocationExplainResponse.getExplanation().getUnassignedInfo();
final var allocationExplainResponse = getClusterAllocationExplanation(client(), "test", 0, true);
final var description = Strings.toString(allocationExplainResponse);
final var unassignedInfo = allocationExplainResponse.getUnassignedInfo();
assertThat(description, unassignedInfo, not(nullValue()));
assertThat(description, unassignedInfo.getReason(), equalTo(UnassignedInfo.Reason.ALLOCATION_FAILED));
var failure = unassignedInfo.getFailure();
Expand Down
Loading

0 comments on commit d89ecb6

Please sign in to comment.