Skip to content

Commit a5213e2

Browse files
authored
Merge branch '9.1' into backport/9.1/pr-138097
2 parents 9301040 + 2f09d16 commit a5213e2

File tree

56 files changed

+1266
-231
lines changed

Some content is hidden

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

56 files changed

+1266
-231
lines changed

docs/changelog/135873.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135873
2+
summary: Convert `BytesTransportResponse` when proxying response from/to local node
3+
area: "Network"
4+
type: bug
5+
issues: []

docs/changelog/137652.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 137652
2+
summary: Fix default value for some settings when filtered
3+
area: Infra/Settings
4+
type: bug
5+
issues:
6+
- 136333

docs/changelog/138132.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 138132
2+
summary: Fix integer overflow in block memory estimation
3+
area: ES|QL
4+
type: bug
5+
issues: []

muted-tests.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,21 +395,12 @@ tests:
395395
- class: org.elasticsearch.xpack.esql.inference.rerank.RerankOperatorTests
396396
method: testSimpleCircuitBreaking
397397
issue: https://github.com/elastic/elasticsearch/issues/133619
398-
- class: org.elasticsearch.upgrades.SearchStatesIT
399-
method: testBWCSearchStates
400-
issue: https://github.com/elastic/elasticsearch/issues/137681
401398
- class: org.elasticsearch.readiness.ReadinessClusterIT
402399
method: testReadinessDuringRestartsNormalOrder
403400
issue: https://github.com/elastic/elasticsearch/issues/136955
404-
- class: org.elasticsearch.upgrades.SearchStatesIT
405-
method: testCanMatch
406-
issue: https://github.com/elastic/elasticsearch/issues/137687
407401
- class: org.elasticsearch.xpack.inference.InferenceRestIT
408402
method: test {p0=inference/70_text_similarity_rank_retriever/Text similarity reranker with min_score zero includes all docs}
409403
issue: https://github.com/elastic/elasticsearch/issues/137732
410-
- class: org.elasticsearch.xpack.shutdown.NodeShutdownIT
411-
method: testStalledShardMigrationProperlyDetected
412-
issue: https://github.com/elastic/elasticsearch/issues/115697
413404

414405
# Examples:
415406
#
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action.admin.indices.settings.get;
11+
12+
import org.elasticsearch.common.settings.Settings;
13+
import org.elasticsearch.test.ESIntegTestCase;
14+
import org.elasticsearch.test.LambdaMatchers;
15+
16+
import java.util.Map;
17+
18+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
19+
import static org.hamcrest.Matchers.equalTo;
20+
21+
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE)
22+
public class GetSettingsIT extends ESIntegTestCase {
23+
public void testGetDefaultValueWhenDependentOnOtherSettings() {
24+
final String indexName = "test-index-1";
25+
26+
Settings expectedSettings = Settings.builder()
27+
.put("index.mapping.source.mode", "SYNTHETIC")
28+
.put("index.mapping.total_fields.ignore_dynamic_beyond_limit", true)
29+
.put("index.recovery.use_synthetic_source", true)
30+
.put("index.mapping.ignore_above", 8191)
31+
.build();
32+
33+
assertAcked(prepareCreate(indexName).setSettings(Settings.builder().put("index.mode", "logsdb")).get());
34+
GetSettingsResponse unfilteredResponse = indicesAdmin().getSettings(
35+
new GetSettingsRequest(TEST_REQUEST_TIMEOUT).indices(indexName).includeDefaults(true)
36+
).actionGet();
37+
for (String key : expectedSettings.keySet()) {
38+
assertThat(unfilteredResponse.getSetting(indexName, key), equalTo(expectedSettings.get(key)));
39+
GetSettingsResponse filteredResponse = indicesAdmin().getSettings(
40+
new GetSettingsRequest(TEST_REQUEST_TIMEOUT).indices(indexName).includeDefaults(true).names(key)
41+
).actionGet();
42+
43+
var expectedFilteredSettingsMap = Map.of(indexName, expectedSettings.filter(key::equals));
44+
assertThat(
45+
filteredResponse,
46+
LambdaMatchers.transformedMatch(GetSettingsResponse::getIndexToDefaultSettings, equalTo(expectedFilteredSettingsMap))
47+
);
48+
}
49+
50+
}
51+
}

server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
1616
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
1717
import org.elasticsearch.cluster.ClusterChangedEvent;
18+
import org.elasticsearch.cluster.ClusterState;
1819
import org.elasticsearch.cluster.ClusterStateListener;
1920
import org.elasticsearch.cluster.metadata.ReservedStateErrorMetadata;
2021
import org.elasticsearch.cluster.metadata.ReservedStateHandlerMetadata;
@@ -39,6 +40,7 @@
3940
import java.util.concurrent.ExecutionException;
4041
import java.util.concurrent.TimeUnit;
4142
import java.util.concurrent.atomic.AtomicLong;
43+
import java.util.function.Function;
4244
import java.util.stream.Stream;
4345

4446
import static org.elasticsearch.cluster.metadata.ReservedStateMetadata.EMPTY_VERSION;
@@ -194,22 +196,29 @@ private Tuple<CountDownLatch, AtomicLong> setupClusterStateListener(String node,
194196
ClusterService clusterService = internalCluster().clusterService(node);
195197
CountDownLatch savedClusterState = new CountDownLatch(1);
196198
AtomicLong metadataVersion = new AtomicLong(-1);
199+
Function<ClusterState, Boolean> clusterStateProcessor = clusterState -> {
200+
ReservedStateMetadata reservedState = clusterState.metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE);
201+
if (reservedState != null && reservedState.version() == fileSettingsVersion) {
202+
metadataVersion.set(clusterState.metadata().version());
203+
savedClusterState.countDown();
204+
logger.info(
205+
"done waiting for file settings [version: {}, metadata version: {}]",
206+
clusterState.version(),
207+
clusterState.metadata().version()
208+
);
209+
return true;
210+
}
211+
return false;
212+
};
197213
clusterService.addListener(new ClusterStateListener() {
198214
@Override
199215
public void clusterChanged(ClusterChangedEvent event) {
200-
ReservedStateMetadata reservedState = event.state().metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE);
201-
if (reservedState != null && reservedState.version() == fileSettingsVersion) {
216+
if (clusterStateProcessor.apply(event.state())) {
202217
clusterService.removeListener(this);
203-
metadataVersion.set(event.state().metadata().version());
204-
savedClusterState.countDown();
205-
logger.info(
206-
"done waiting for file settings [version: {}, metadata version: {}]",
207-
event.state().version(),
208-
event.state().metadata().version()
209-
);
210218
}
211219
}
212220
});
221+
clusterStateProcessor.apply(clusterService.state());
213222

214223
return new Tuple<>(savedClusterState, metadataVersion);
215224
}

server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/TransportGetSettingsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected void localClusterStateOperation(
127127

128128
indexToSettings.put(concreteIndex.getName(), indexSettings);
129129
if (indexToDefaultSettings != null) {
130-
Settings defaultSettings = settingsFilter.filter(indexScopedSettings.diff(indexSettings, Settings.EMPTY));
130+
Settings defaultSettings = settingsFilter.filter(indexScopedSettings.diff(indexMetadata.getSettings(), Settings.EMPTY));
131131
if (isFilteredRequest(request)) {
132132
defaultSettings = defaultSettings.filter(k -> Regex.simpleMatch(request.names(), k));
133133
}

server/src/main/java/org/elasticsearch/action/search/SearchQueryThenFetchAsyncAction.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,13 @@ static void registerNodeSearchAction(
654654
}
655655
}
656656
);
657-
TransportActionProxy.registerProxyAction(transportService, NODE_SEARCH_ACTION_NAME, true, NodeQueryResponse::new);
657+
TransportActionProxy.registerProxyAction(
658+
transportService,
659+
NODE_SEARCH_ACTION_NAME,
660+
true,
661+
NodeQueryResponse::new,
662+
namedWriteableRegistry
663+
);
658664
}
659665

660666
private static void releaseLocalContext(
@@ -863,7 +869,10 @@ void onShardDone() {
863869
}
864870
}
865871

866-
ActionListener.respondAndRelease(channelListener, new BytesTransportResponse(out.moveToBytesReference()));
872+
ActionListener.respondAndRelease(
873+
channelListener,
874+
new BytesTransportResponse(out.moveToBytesReference(), out.getTransportVersion())
875+
);
867876
}
868877

869878
// Writes the "successful" response (see NodeQueryResponse for the corresponding read logic)
@@ -987,7 +996,10 @@ void bwcRespond() {
987996
out.close();
988997
}
989998
}
990-
ActionListener.respondAndRelease(channelListener, new BytesTransportResponse(out.moveToBytesReference()));
999+
ActionListener.respondAndRelease(
1000+
channelListener,
1001+
new BytesTransportResponse(out.moveToBytesReference(), out.getTransportVersion())
1002+
);
9911003
}
9921004

9931005
private void maybeFreeContext(

server/src/main/java/org/elasticsearch/action/search/SearchTransportService.java

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.elasticsearch.client.internal.OriginSettingClient;
2222
import org.elasticsearch.client.internal.node.NodeClient;
2323
import org.elasticsearch.cluster.node.DiscoveryNode;
24+
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
2425
import org.elasticsearch.common.io.stream.StreamInput;
2526
import org.elasticsearch.common.io.stream.StreamOutput;
2627
import org.elasticsearch.common.io.stream.Writeable;
@@ -384,7 +385,11 @@ public void writeTo(StreamOutput out) throws IOException {
384385
}
385386
}
386387

387-
public static void registerRequestHandler(TransportService transportService, SearchService searchService) {
388+
public static void registerRequestHandler(
389+
TransportService transportService,
390+
SearchService searchService,
391+
NamedWriteableRegistry namedWriteableRegistry
392+
) {
388393
final TransportRequestHandler<ScrollFreeContextRequest> freeContextHandler = (request, channel, task) -> {
389394
logger.trace("releasing search context [{}]", request.id());
390395
boolean freed = searchService.freeReaderContext(request.id());
@@ -401,7 +406,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
401406
transportService,
402407
FREE_CONTEXT_SCROLL_ACTION_NAME,
403408
false,
404-
SearchFreeContextResponse::readFrom
409+
SearchFreeContextResponse::readFrom,
410+
namedWriteableRegistry
405411
);
406412

407413
// TODO: remove this handler once the lowest compatible version stops using it
@@ -411,7 +417,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
411417
OriginalIndices.readOriginalIndices(in);
412418
return res;
413419
}, freeContextHandler);
414-
TransportActionProxy.registerProxyAction(transportService, FREE_CONTEXT_ACTION_NAME, false, SearchFreeContextResponse::readFrom);
420+
TransportActionProxy.registerProxyAction(
421+
transportService,
422+
FREE_CONTEXT_ACTION_NAME,
423+
false,
424+
SearchFreeContextResponse::readFrom,
425+
namedWriteableRegistry
426+
);
415427

416428
transportService.registerRequestHandler(
417429
CLEAR_SCROLL_CONTEXTS_ACTION_NAME,
@@ -426,7 +438,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
426438
transportService,
427439
CLEAR_SCROLL_CONTEXTS_ACTION_NAME,
428440
false,
429-
(in) -> ActionResponse.Empty.INSTANCE
441+
(in) -> ActionResponse.Empty.INSTANCE,
442+
namedWriteableRegistry
430443
);
431444

432445
transportService.registerRequestHandler(
@@ -435,7 +448,7 @@ public static void registerRequestHandler(TransportService transportService, Sea
435448
ShardSearchRequest::new,
436449
(request, channel, task) -> searchService.executeDfsPhase(request, (SearchShardTask) task, new ChannelActionListener<>(channel))
437450
);
438-
TransportActionProxy.registerProxyAction(transportService, DFS_ACTION_NAME, true, DfsSearchResult::new);
451+
TransportActionProxy.registerProxyAction(transportService, DFS_ACTION_NAME, true, DfsSearchResult::new, namedWriteableRegistry);
439452

440453
transportService.registerRequestHandler(
441454
QUERY_ACTION_NAME,
@@ -451,7 +464,8 @@ public static void registerRequestHandler(TransportService transportService, Sea
451464
transportService,
452465
QUERY_ACTION_NAME,
453466
true,
454-
(request) -> ((ShardSearchRequest) request).numberOfShards() == 1 ? QueryFetchSearchResult::new : QuerySearchResult::new
467+
(request) -> ((ShardSearchRequest) request).numberOfShards() == 1 ? QueryFetchSearchResult::new : QuerySearchResult::new,
468+
namedWriteableRegistry
455469
);
456470

457471
transportService.registerRequestHandler(
@@ -465,7 +479,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
465479
channel.getVersion()
466480
)
467481
);
468-
TransportActionProxy.registerProxyAction(transportService, QUERY_ID_ACTION_NAME, true, QuerySearchResult::new);
482+
TransportActionProxy.registerProxyAction(
483+
transportService,
484+
QUERY_ID_ACTION_NAME,
485+
true,
486+
QuerySearchResult::new,
487+
namedWriteableRegistry
488+
);
469489

470490
transportService.registerRequestHandler(
471491
QUERY_SCROLL_ACTION_NAME,
@@ -478,7 +498,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
478498
channel.getVersion()
479499
)
480500
);
481-
TransportActionProxy.registerProxyAction(transportService, QUERY_SCROLL_ACTION_NAME, true, ScrollQuerySearchResult::new);
501+
TransportActionProxy.registerProxyAction(
502+
transportService,
503+
QUERY_SCROLL_ACTION_NAME,
504+
true,
505+
ScrollQuerySearchResult::new,
506+
namedWriteableRegistry
507+
);
482508

483509
transportService.registerRequestHandler(
484510
QUERY_FETCH_SCROLL_ACTION_NAME,
@@ -490,7 +516,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
490516
new ChannelActionListener<>(channel)
491517
)
492518
);
493-
TransportActionProxy.registerProxyAction(transportService, QUERY_FETCH_SCROLL_ACTION_NAME, true, ScrollQueryFetchSearchResult::new);
519+
TransportActionProxy.registerProxyAction(
520+
transportService,
521+
QUERY_FETCH_SCROLL_ACTION_NAME,
522+
true,
523+
ScrollQueryFetchSearchResult::new,
524+
namedWriteableRegistry
525+
);
494526

495527
final TransportRequestHandler<RankFeatureShardRequest> rankShardFeatureRequest = (request, channel, task) -> searchService
496528
.executeRankFeaturePhase(request, (SearchShardTask) task, new ChannelActionListener<>(channel));
@@ -500,7 +532,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
500532
RankFeatureShardRequest::new,
501533
rankShardFeatureRequest
502534
);
503-
TransportActionProxy.registerProxyAction(transportService, RANK_FEATURE_SHARD_ACTION_NAME, true, RankFeatureResult::new);
535+
TransportActionProxy.registerProxyAction(
536+
transportService,
537+
RANK_FEATURE_SHARD_ACTION_NAME,
538+
true,
539+
RankFeatureResult::new,
540+
namedWriteableRegistry
541+
);
504542

505543
final TransportRequestHandler<ShardFetchRequest> shardFetchRequestHandler = (request, channel, task) -> searchService
506544
.executeFetchPhase(request, (SearchShardTask) task, new ChannelActionListener<>(channel));
@@ -510,7 +548,13 @@ public static void registerRequestHandler(TransportService transportService, Sea
510548
ShardFetchRequest::new,
511549
shardFetchRequestHandler
512550
);
513-
TransportActionProxy.registerProxyAction(transportService, FETCH_ID_SCROLL_ACTION_NAME, true, FetchSearchResult::new);
551+
TransportActionProxy.registerProxyAction(
552+
transportService,
553+
FETCH_ID_SCROLL_ACTION_NAME,
554+
true,
555+
FetchSearchResult::new,
556+
namedWriteableRegistry
557+
);
514558

515559
transportService.registerRequestHandler(
516560
FETCH_ID_ACTION_NAME,
@@ -520,15 +564,27 @@ public static void registerRequestHandler(TransportService transportService, Sea
520564
ShardFetchSearchRequest::new,
521565
shardFetchRequestHandler
522566
);
523-
TransportActionProxy.registerProxyAction(transportService, FETCH_ID_ACTION_NAME, true, FetchSearchResult::new);
567+
TransportActionProxy.registerProxyAction(
568+
transportService,
569+
FETCH_ID_ACTION_NAME,
570+
true,
571+
FetchSearchResult::new,
572+
namedWriteableRegistry
573+
);
524574

525575
transportService.registerRequestHandler(
526576
QUERY_CAN_MATCH_NODE_NAME,
527577
transportService.getThreadPool().executor(ThreadPool.Names.SEARCH_COORDINATION),
528578
CanMatchNodeRequest::new,
529579
(request, channel, task) -> searchService.canMatch(request, new ChannelActionListener<>(channel))
530580
);
531-
TransportActionProxy.registerProxyAction(transportService, QUERY_CAN_MATCH_NODE_NAME, true, CanMatchNodeResponse::new);
581+
TransportActionProxy.registerProxyAction(
582+
transportService,
583+
QUERY_CAN_MATCH_NODE_NAME,
584+
true,
585+
CanMatchNodeResponse::new,
586+
namedWriteableRegistry
587+
);
532588
}
533589

534590
private static Executor buildFreeContextExecutor(TransportService transportService) {

server/src/main/java/org/elasticsearch/action/search/TransportOpenPointInTimeAction.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ public TransportOpenPointInTimeAction(
9494
ShardOpenReaderRequest::new,
9595
new ShardOpenReaderRequestHandler()
9696
);
97-
TransportActionProxy.registerProxyAction(transportService, OPEN_SHARD_READER_CONTEXT_NAME, false, ShardOpenReaderResponse::new);
97+
TransportActionProxy.registerProxyAction(
98+
transportService,
99+
OPEN_SHARD_READER_CONTEXT_NAME,
100+
false,
101+
ShardOpenReaderResponse::new,
102+
namedWriteableRegistry
103+
);
98104
}
99105

100106
@Override

0 commit comments

Comments
 (0)