Skip to content

Commit be7edc3

Browse files
authored
Merge branch '9.0' into backport/9.0/pr-128439
2 parents 9e94fef + 7e42563 commit be7edc3

File tree

11 files changed

+160
-8
lines changed

11 files changed

+160
-8
lines changed

docs/changelog/128260.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pr: 128260
2+
summary: Fix validation NPE in Enrich and add extra @Nullable annotations
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 126297
7+
- 126253

docs/changelog/128320.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 128320
2+
summary: Use new source loader when lower `docId` is accessed
3+
area: Codec
4+
type: bug
5+
issues: []

docs/reference/elasticsearch/mapping-reference/parent-join.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
---
2+
applies_to:
3+
serverless: unavailable
24
navigation_title: "Join"
35
mapped_pages:
46
- https://www.elastic.co/guide/en/elasticsearch/reference/current/parent-join.html
57
---
68

79
# Join field type [parent-join]
810

9-
1011
The `join` data type is a special field that creates parent/child relation within documents of the same index. The `relations` section defines a set of possible relations within the documents, each relation being a parent name and a child name.
1112

1213
::::{warning}

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ tests:
260260
- class: org.elasticsearch.packaging.test.EnrollmentProcessTests
261261
method: test20DockerAutoFormCluster
262262
issue: https://github.com/elastic/elasticsearch/issues/128113
263+
- class: org.elasticsearch.packaging.test.DockerTests
264+
method: test011SecurityEnabledStatus
265+
issue: https://github.com/elastic/elasticsearch/issues/124990
263266

264267
# Examples:
265268
#

server/src/main/java/org/elasticsearch/search/lookup/SyntheticSourceProvider.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ public Source getSource(LeafReaderContext ctx, int doc) throws IOException {
3838
provider = new SyntheticSourceLeafLoader(ctx);
3939
var existing = leaves.put(id, provider);
4040
assert existing == null : "unexpected source provider [" + existing + "]";
41+
} else if (doc < provider.lastSeenDocId) {
42+
// When queries reference the same runtime field in multiple clauses, each clause re-reads the values from the source in
43+
// increasing docId order. So the last docId accessed by the first clause is higher than the first docId read by the second
44+
// clause. This is okay for stored source, as stored fields do not restrict the order that docIds that can be accessed.
45+
// But with synthetic source, field values may come from doc values, which require than docIds only be read in increasing order.
46+
// To handle this, we detect lower docIds and create a new doc value reader for each clause.
47+
provider = new SyntheticSourceLeafLoader(ctx);
48+
leaves.put(id, provider);
4149
}
4250
return provider.getSource(doc);
4351
}
4452

4553
private class SyntheticSourceLeafLoader {
4654
private final LeafStoredFieldLoader leafLoader;
4755
private final SourceLoader.Leaf leaf;
56+
int lastSeenDocId = -1;
4857

4958
SyntheticSourceLeafLoader(LeafReaderContext ctx) throws IOException {
5059
this.leafLoader = (sourceLoader.requiredStoredFields().isEmpty())
@@ -54,6 +63,7 @@ private class SyntheticSourceLeafLoader {
5463
}
5564

5665
Source getSource(int doc) throws IOException {
66+
this.lastSeenDocId = doc;
5767
leafLoader.advanceTo(doc);
5868
return leaf.source(leafLoader, doc);
5969
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ static RoleDescriptor kibanaSystem(String name) {
470470
"logs-aws.securityhub_findings-*",
471471
"logs-aws.securityhub_findings_full_posture-*",
472472
"logs-aws.inspector-*",
473+
"logs-aws.config-*",
473474
"logs-amazon_security_lake.findings-*",
474475
"logs-qualys_vmdr.asset_host_detection-*",
475476
"logs-tenable_sc.vulnerability-*",

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ public void testKibanaSystemRole() {
16441644
"logs-aws.securityhub_findings-" + randomAlphaOfLength(randomIntBetween(0, 13)),
16451645
"logs-aws.securityhub_findings_full_posture-" + randomAlphaOfLength(randomIntBetween(0, 13)),
16461646
"logs-aws.inspector-" + randomAlphaOfLength(randomIntBetween(0, 13)),
1647+
"logs-aws.config-" + randomAlphaOfLength(randomIntBetween(0, 13)),
16471648
"logs-amazon_security_lake.findings-" + randomAlphaOfLength(randomIntBetween(0, 13)),
16481649
"logs-qualys_vmdr.asset_host_detection-" + randomAlphaOfLength(randomIntBetween(0, 13)),
16491650
"logs-tenable_sc.vulnerability-" + randomAlphaOfLength(randomIntBetween(0, 13)),

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/AbstractLookupService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public ThreadContext getThreadContext() {
177177
/**
178178
* Build a list of queries to perform inside the actual lookup.
179179
*/
180-
protected abstract QueryList queryList(T request, SearchExecutionContext context, Block inputBlock, DataType inputDataType);
180+
protected abstract QueryList queryList(T request, SearchExecutionContext context, Block inputBlock, @Nullable DataType inputDataType);
181181

182182
/**
183183
* Build the response.
@@ -193,7 +193,7 @@ protected static QueryList termQueryList(
193193
MappedFieldType field,
194194
SearchExecutionContext searchExecutionContext,
195195
Block block,
196-
DataType inputDataType
196+
@Nullable DataType inputDataType
197197
) {
198198
return switch (inputDataType) {
199199
case IP -> QueryList.ipTermQueryList(field, searchExecutionContext, (BytesRefBlock) block);

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/EnrichLookupService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.compute.data.BlockStreamInput;
2424
import org.elasticsearch.compute.data.Page;
2525
import org.elasticsearch.compute.operator.lookup.QueryList;
26+
import org.elasticsearch.core.Nullable;
2627
import org.elasticsearch.core.Releasables;
2728
import org.elasticsearch.index.mapper.MappedFieldType;
2829
import org.elasticsearch.index.mapper.RangeFieldMapper;
@@ -98,7 +99,12 @@ protected TransportRequest transportRequest(EnrichLookupService.Request request,
9899
}
99100

100101
@Override
101-
protected QueryList queryList(TransportRequest request, SearchExecutionContext context, Block inputBlock, DataType inputDataType) {
102+
protected QueryList queryList(
103+
TransportRequest request,
104+
SearchExecutionContext context,
105+
Block inputBlock,
106+
@Nullable DataType inputDataType
107+
) {
102108
MappedFieldType fieldType = context.getFieldType(request.matchField);
103109
validateTypes(inputDataType, fieldType);
104110
return switch (request.matchType) {
@@ -121,8 +127,8 @@ protected LookupResponse readLookupResponse(StreamInput in, BlockFactory blockFa
121127
return new LookupResponse(in, blockFactory);
122128
}
123129

124-
private static void validateTypes(DataType inputDataType, MappedFieldType fieldType) {
125-
if (fieldType instanceof RangeFieldMapper.RangeFieldType rangeType) {
130+
private static void validateTypes(@Nullable DataType inputDataType, MappedFieldType fieldType) {
131+
if (fieldType instanceof RangeFieldMapper.RangeFieldType rangeType && inputDataType != null) {
126132
// For range policy types, the ENRICH index field type will be one of a list of supported range types,
127133
// which need to match the input data type (eg. ip-range -> ip, date-range -> date, etc.)
128134
if (rangeTypesCompatible(rangeType.rangeType(), inputDataType) == false) {
@@ -135,7 +141,7 @@ private static void validateTypes(DataType inputDataType, MappedFieldType fieldT
135141
// For geo_match, type validation is done earlier, in the Analyzer.
136142
}
137143

138-
private static boolean rangeTypesCompatible(RangeType rangeType, DataType inputDataType) {
144+
private static boolean rangeTypesCompatible(RangeType rangeType, @Nullable DataType inputDataType) {
139145
if (inputDataType.noText() == DataType.KEYWORD) {
140146
// We allow runtime parsing of string types to numeric types
141147
return true;

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/enrich/LookupFromIndexService.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.elasticsearch.compute.data.BlockStreamInput;
1919
import org.elasticsearch.compute.data.Page;
2020
import org.elasticsearch.compute.operator.lookup.QueryList;
21+
import org.elasticsearch.core.Nullable;
2122
import org.elasticsearch.core.Releasables;
2223
import org.elasticsearch.index.query.SearchExecutionContext;
2324
import org.elasticsearch.index.shard.ShardId;
@@ -76,7 +77,12 @@ protected TransportRequest transportRequest(LookupFromIndexService.Request reque
7677
}
7778

7879
@Override
79-
protected QueryList queryList(TransportRequest request, SearchExecutionContext context, Block inputBlock, DataType inputDataType) {
80+
protected QueryList queryList(
81+
TransportRequest request,
82+
SearchExecutionContext context,
83+
Block inputBlock,
84+
@Nullable DataType inputDataType
85+
) {
8086
return termQueryList(context.getFieldType(request.matchField), context, inputBlock, inputDataType).onlySingleValues();
8187
}
8288

0 commit comments

Comments
 (0)