Skip to content

Commit dbb0685

Browse files
Merge remote-tracking branch 'elastic/main' into all-in-one-query-change
2 parents 056704d + 95c9b4b commit dbb0685

File tree

71 files changed

+2127
-1820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2127
-1820
lines changed

docs/changelog/120807.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/changelog/121240.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 121240
2+
summary: Implement runtime skip_unavailable=true
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/121256.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 121256
2+
summary: Run `TransportEnrichStatsAction` on local node
3+
area: Ingest Node
4+
type: enhancement
5+
issues: []

muted-tests.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ tests:
122122
- class: org.elasticsearch.test.rest.yaml.CcsCommonYamlTestSuiteIT
123123
method: test {p0=search.highlight/50_synthetic_source/text multi unified from vectors}
124124
issue: https://github.com/elastic/elasticsearch/issues/117815
125-
- class: org.elasticsearch.xpack.esql.plugin.ClusterRequestTests
126-
method: testFallbackIndicesOptions
127-
issue: https://github.com/elastic/elasticsearch/issues/117937
128125
- class: org.elasticsearch.xpack.ml.integration.RegressionIT
129126
method: testTwoJobsWithSameRandomizeSeedUseSameTrainingSet
130127
issue: https://github.com/elastic/elasticsearch/issues/117805
131-
- class: org.elasticsearch.xpack.esql.action.EsqlActionTaskIT
132-
method: testCancelRequestWhenFailingFetchingPages
133-
issue: https://github.com/elastic/elasticsearch/issues/118193
134128
- class: org.elasticsearch.packaging.test.ArchiveTests
135129
method: test44AutoConfigurationNotTriggeredOnNotWriteableConfDir
136130
issue: https://github.com/elastic/elasticsearch/issues/118208
@@ -215,8 +209,6 @@ tests:
215209
- class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncEnrichStopIT
216210
method: testEnrichAfterStop
217211
issue: https://github.com/elastic/elasticsearch/issues/120757
218-
- class: org.elasticsearch.search.fieldcaps.FieldCapabilitiesIT
219-
issue: https://github.com/elastic/elasticsearch/issues/120772
220212
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
221213
method: test {p0=ml/3rd_party_deployment/Test start deployment fails while model download in progress}
222214
issue: https://github.com/elastic/elasticsearch/issues/120810
@@ -437,6 +429,18 @@ tests:
437429
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryUnavailableRemotesIT
438430
method: testRemoteOnlyCCSAgainstDisconnectedRemoteWithSkipUnavailableTrue
439431
issue: https://github.com/elastic/elasticsearch/issues/121578
432+
- class: org.elasticsearch.xpack.esql.action.CrossClustersCancellationIT
433+
method: testTasks
434+
issue: https://github.com/elastic/elasticsearch/issues/121626
435+
- class: org.elasticsearch.xpack.esql.action.CrossClustersCancellationIT
436+
method: testCloseSkipUnavailable
437+
issue: https://github.com/elastic/elasticsearch/issues/121627
438+
- class: org.elasticsearch.xpack.esql.action.CrossClustersCancellationIT
439+
method: testCancel
440+
issue: https://github.com/elastic/elasticsearch/issues/121632
441+
- class: org.elasticsearch.xpack.esql.action.CrossClustersCancellationIT
442+
method: testCancelSkipUnavailable
443+
issue: https://github.com/elastic/elasticsearch/issues/121631
440444

441445
# Examples:
442446
#

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SourceModeRollingUpgradeIT.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919
import java.util.Map;
2020

21-
import static org.hamcrest.Matchers.containsString;
2221
import static org.hamcrest.Matchers.equalTo;
2322

2423
public class SourceModeRollingUpgradeIT extends AbstractRollingUpgradeTestCase {
@@ -83,20 +82,10 @@ public void testConfigureStoredSourceWhenIndexIsCreatedLegacy() throws IOExcepti
8382
private void assertDeprecationWarningForTemplate(String templateName) throws IOException {
8483
var request = new Request("GET", "/_migration/deprecations");
8584
var response = entityAsMap(client().performRequest(request));
86-
if (response.containsKey("templates")) {
87-
// Check the newer version of the deprecation API that contains the templates section
88-
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
89-
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
90-
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
91-
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
92-
} else {
93-
// Bwc version with 8.18 until https://github.com/elastic/elasticsearch/pull/120505/ gets backported, clean up after backport
94-
var nodeSettings = (Map<?, ?>) ((List<?>) response.get("node_settings")).getFirst();
95-
assertThat(nodeSettings.get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
96-
assertThat(
97-
(String) nodeSettings.get("details"),
98-
containsString(SourceFieldMapper.DEPRECATION_WARNING + " Affected component templates: [" + templateName + "]")
99-
);
100-
}
85+
assertThat(response.containsKey("templates"), equalTo(true));
86+
Map<?, ?> issuesByTemplate = (Map<?, ?>) response.get("templates");
87+
assertThat(issuesByTemplate.containsKey(templateName), equalTo(true));
88+
var templateIssues = (List<?>) issuesByTemplate.get(templateName);
89+
assertThat(((Map<?, ?>) templateIssues.getFirst()).get("message"), equalTo(SourceFieldMapper.DEPRECATION_WARNING));
10190
}
10291
}

rest-api-spec/src/main/resources/rest-api-spec/api/enrich.stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"params": {
2121
"master_timeout":{
2222
"type":"time",
23-
"description":"Timeout for processing on master node"
23+
"description":"Timeout for waiting for new cluster state in case it is blocked"
2424
}
2525
}
2626
}

server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.elasticsearch.client.Cancellable;
2929
import org.elasticsearch.client.Request;
3030
import org.elasticsearch.client.Response;
31+
import org.elasticsearch.cluster.ClusterState;
3132
import org.elasticsearch.cluster.metadata.IndexMetadata;
3233
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
3334
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
@@ -73,6 +74,7 @@
7374
import java.util.Collection;
7475
import java.util.Collections;
7576
import java.util.HashMap;
77+
import java.util.HashSet;
7678
import java.util.List;
7779
import java.util.Map;
7880
import java.util.concurrent.CancellationException;
@@ -591,21 +593,31 @@ public void testNoActiveCopy() throws Exception {
591593

592594
private void moveOrCloseShardsOnNodes(String nodeName) throws Exception {
593595
final IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodeName);
596+
final ClusterState clusterState = clusterService().state();
594597
for (IndexService indexService : indicesService) {
595598
for (IndexShard indexShard : indexService) {
596599
if (randomBoolean()) {
597600
closeShardNoCheck(indexShard, randomBoolean());
598601
} else if (randomBoolean()) {
599602
final ShardId shardId = indexShard.shardId();
600-
603+
final var assignedNodes = new HashSet<>();
604+
clusterState.routingTable().shardRoutingTable(shardId).allShards().forEach(shr -> {
605+
if (shr.currentNodeId() != null) {
606+
assignedNodes.add(shr.currentNodeId());
607+
}
608+
if (shr.relocatingNodeId() != null) {
609+
assignedNodes.add(shr.relocatingNodeId());
610+
}
611+
});
601612
final var targetNodes = new ArrayList<String>();
602613
for (final var targetIndicesService : internalCluster().getInstances(IndicesService.class)) {
603614
final var targetNode = targetIndicesService.clusterService().localNode();
604-
if (targetNode.canContainData() && targetIndicesService.getShardOrNull(shardId) == null) {
615+
if (targetNode.canContainData()
616+
&& targetIndicesService.getShardOrNull(shardId) == null
617+
&& assignedNodes.contains(targetNode.getId()) == false) {
605618
targetNodes.add(targetNode.getId());
606619
}
607620
}
608-
609621
if (targetNodes.isEmpty()) {
610622
continue;
611623
}

server/src/main/java/org/elasticsearch/cluster/action/shard/ShardStateAction.java

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.elasticsearch.cluster.ClusterStateTaskExecutor;
2424
import org.elasticsearch.cluster.ClusterStateTaskListener;
2525
import org.elasticsearch.cluster.NotMasterException;
26-
import org.elasticsearch.cluster.block.ClusterBlock;
27-
import org.elasticsearch.cluster.block.ClusterBlocks;
2826
import org.elasticsearch.cluster.coordination.FailedToCommitClusterStateException;
2927
import org.elasticsearch.cluster.metadata.IndexMetadata;
3028
import org.elasticsearch.cluster.metadata.Metadata;
@@ -72,7 +70,6 @@
7270

7371
import static org.apache.logging.log4j.Level.DEBUG;
7472
import static org.apache.logging.log4j.Level.ERROR;
75-
import static org.elasticsearch.cluster.metadata.IndexMetadata.INDEX_REFRESH_BLOCK;
7673
import static org.elasticsearch.cluster.service.MasterService.isPublishFailureException;
7774
import static org.elasticsearch.core.Strings.format;
7875

@@ -622,7 +619,6 @@ public ClusterState execute(BatchExecutionContext<StartedShardUpdateTask> batchE
622619
List<TaskContext<StartedShardUpdateTask>> tasksToBeApplied = new ArrayList<>();
623620
List<ShardRouting> shardRoutingsToBeApplied = new ArrayList<>(batchExecutionContext.taskContexts().size());
624621
Set<ShardRouting> seenShardRoutings = new HashSet<>(); // to prevent duplicates
625-
Set<Index> indicesWithUnpromotableShardsStarted = null;
626622
final Map<Index, ClusterStateTimeRanges> updatedTimestampRanges = new HashMap<>();
627623
final ClusterState initialState = batchExecutionContext.initialState();
628624
for (var taskContext : batchExecutionContext.taskContexts()) {
@@ -741,14 +737,6 @@ public ClusterState execute(BatchExecutionContext<StartedShardUpdateTask> batchE
741737
new ClusterStateTimeRanges(newTimestampMillisRange, newEventIngestedMillisRange)
742738
);
743739
}
744-
745-
if (matched.isPromotableToPrimary() == false
746-
&& initialState.blocks().hasIndexBlock(index.getName(), INDEX_REFRESH_BLOCK)) {
747-
if (indicesWithUnpromotableShardsStarted == null) {
748-
indicesWithUnpromotableShardsStarted = new HashSet<>();
749-
}
750-
indicesWithUnpromotableShardsStarted.add(index);
751-
}
752740
}
753741
}
754742
}
@@ -772,10 +760,7 @@ public ClusterState execute(BatchExecutionContext<StartedShardUpdateTask> batchE
772760
maybeUpdatedState = ClusterState.builder(maybeUpdatedState).metadata(metadataBuilder).build();
773761
}
774762

775-
maybeUpdatedState = maybeRemoveIndexRefreshBlocks(maybeUpdatedState, indicesWithUnpromotableShardsStarted);
776-
777763
assert assertStartedIndicesHaveCompleteTimestampRanges(maybeUpdatedState);
778-
assert assertRefreshBlockIsNotPresentWhenTheIndexIsSearchable(maybeUpdatedState);
779764

780765
for (final var taskContext : tasksToBeApplied) {
781766
final var task = taskContext.getTask();
@@ -791,36 +776,6 @@ public ClusterState execute(BatchExecutionContext<StartedShardUpdateTask> batchE
791776
return maybeUpdatedState;
792777
}
793778

794-
private static ClusterState maybeRemoveIndexRefreshBlocks(
795-
ClusterState clusterState,
796-
@Nullable Set<Index> indicesWithUnpromotableShardsStarted
797-
) {
798-
// The provided cluster state must include the newly STARTED unpromotable shards
799-
if (indicesWithUnpromotableShardsStarted == null) {
800-
return clusterState;
801-
}
802-
803-
ClusterBlocks.Builder clusterBlocksBuilder = null;
804-
for (Index indexWithUnpromotableShardsStarted : indicesWithUnpromotableShardsStarted) {
805-
String indexName = indexWithUnpromotableShardsStarted.getName();
806-
assert clusterState.blocks().hasIndexBlock(indexName, INDEX_REFRESH_BLOCK) : indexWithUnpromotableShardsStarted;
807-
808-
var indexRoutingTable = clusterState.routingTable().index(indexWithUnpromotableShardsStarted);
809-
if (indexRoutingTable.readyForSearch()) {
810-
if (clusterBlocksBuilder == null) {
811-
clusterBlocksBuilder = ClusterBlocks.builder(clusterState.blocks());
812-
}
813-
clusterBlocksBuilder.removeIndexBlock(indexName, INDEX_REFRESH_BLOCK);
814-
}
815-
}
816-
817-
if (clusterBlocksBuilder == null) {
818-
return clusterState;
819-
}
820-
821-
return ClusterState.builder(clusterState).blocks(clusterBlocksBuilder).build();
822-
}
823-
824779
private static boolean assertStartedIndicesHaveCompleteTimestampRanges(ClusterState clusterState) {
825780
for (Map.Entry<String, IndexRoutingTable> cursor : clusterState.getRoutingTable().getIndicesRouting().entrySet()) {
826781
assert cursor.getValue().allPrimaryShardsActive() == false
@@ -844,16 +799,6 @@ private static boolean assertStartedIndicesHaveCompleteTimestampRanges(ClusterSt
844799
return true;
845800
}
846801

847-
private static boolean assertRefreshBlockIsNotPresentWhenTheIndexIsSearchable(ClusterState clusterState) {
848-
for (Map.Entry<String, Set<ClusterBlock>> indexBlock : clusterState.blocks().indices().entrySet()) {
849-
if (indexBlock.getValue().contains(INDEX_REFRESH_BLOCK)) {
850-
assert clusterState.routingTable().index(indexBlock.getKey()).readyForSearch() == false
851-
: "Index [" + indexBlock.getKey() + "] is searchable but has an INDEX_REFRESH_BLOCK";
852-
}
853-
}
854-
return true;
855-
}
856-
857802
@Override
858803
public void clusterStatePublished(ClusterState newClusterState) {
859804
rerouteService.reroute(

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,12 @@ void checkIndex() throws IOException {
32093209
try {
32103210
doCheckIndex();
32113211
} catch (IOException e) {
3212-
store.markStoreCorrupted(e);
3212+
if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class) != null) {
3213+
// Cache-based read operations on Lucene files can throw an AlreadyClosedException wrapped into an IOException in case
3214+
// of evictions. We don't want to mark the store as corrupted for this.
3215+
} else {
3216+
store.markStoreCorrupted(e);
3217+
}
32133218
throw e;
32143219
} finally {
32153220
store.decRef();

0 commit comments

Comments
 (0)