Skip to content

Commit 89793a0

Browse files
authored
Merge branch '8.19' into backport/8.19/pr-130210
2 parents 0471caf + d6f91f5 commit 89793a0

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

docs/changelog/130776.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 130776
2+
summary: Fix msearch request parsing when index expression is null
3+
area: Search
4+
type: bug
5+
issues:
6+
- 129631

server/src/main/java/org/elasticsearch/common/xcontent/support/XContentMapValues.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ public static Map<String, Object> nodeMapValue(Object node, String desc) {
560560
* Otherwise the node is treated as a comma-separated string.
561561
*/
562562
public static String[] nodeStringArrayValue(Object node) {
563+
if (node == null) {
564+
throw new ElasticsearchParseException("Expected a list of strings but got null");
565+
}
563566
if (isArray(node)) {
564567
List<?> list = (List<?>) node;
565568
String[] arr = new String[list.size()];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,11 +1340,12 @@ public RefreshStats refreshStats() {
13401340
}
13411341

13421342
public FlushStats flushStats() {
1343+
final Engine engine = getEngineOrNull();
13431344
return new FlushStats(
13441345
flushMetric.count(),
13451346
periodicFlushMetric.count(),
13461347
TimeUnit.NANOSECONDS.toMillis(flushMetric.sum()),
1347-
getEngineOrNull() != null ? getEngineOrNull().getTotalFlushTimeExcludingWaitingOnLockInMillis() : 0L
1348+
engine != null ? engine.getTotalFlushTimeExcludingWaitingOnLockInMillis() : 0L
13481349
);
13491350
}
13501351

server/src/test/java/org/elasticsearch/action/search/MultiSearchRequestTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
package org.elasticsearch.action.search;
1111

12+
import org.elasticsearch.ElasticsearchParseException;
1213
import org.elasticsearch.action.support.IndicesOptions;
1314
import org.elasticsearch.common.CheckedBiConsumer;
1415
import org.elasticsearch.common.Strings;
@@ -594,6 +595,14 @@ public void testFailOnExtraCharacters() throws IOException {
594595
}
595596
}
596597

598+
public void testNullIndex() throws IOException {
599+
ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parseMultiSearchRequestFromString("""
600+
{"index": null}
601+
{ "query": {"match_all": {}}}
602+
""", null));
603+
assertThat(e.getMessage(), containsString("Expected a list of strings but got null"));
604+
}
605+
597606
private static MultiSearchRequest mutate(MultiSearchRequest searchRequest) throws IOException {
598607
MultiSearchRequest mutation = copyRequest(searchRequest);
599608
List<CheckedRunnable<IOException>> mutators = new ArrayList<>();

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/DataStreamDeprecationCheckerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void testOldIndicesCheck() {
7878

7979
public void testOldIndicesCheckWithOnlyNewIndices() {
8080
// This tests what happens when any old indices that we have are closed. We expect no deprecation warning.
81-
int newOpenIndexCount = randomIntBetween(0, 100);
81+
int newOpenIndexCount = randomIntBetween(1, 100);
8282
int newClosedIndexCount = randomIntBetween(0, 100);
8383

8484
Map<String, IndexMetadata> nameToIndexMetadata = new HashMap<>();

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/AbstractPageMappingToIteratorOperator.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ public TransportVersion getMinimalSupportedVersion() {
321321
private static class AppendBlocksIterator implements ReleasableIterator<Page> {
322322
private final Page page;
323323
private final ReleasableIterator<Block[]> next;
324+
private boolean closed = false;
324325

325326
private int positionOffset;
326327

@@ -348,7 +349,15 @@ public final Page next() {
348349
for (int b = 0; b < page.getBlockCount(); b++) {
349350
page.getBlock(b).incRef();
350351
}
351-
return page.appendBlocks(read);
352+
final Page result = page.appendBlocks(read);
353+
// We need to release the blocks of the page in this iteration instead of delaying to the next,
354+
// because the blocks of this page are now shared with the output page. The output page can be
355+
// passed to a separate driver, which may run concurrently with this driver, leading to data races
356+
// of references in AbstractNonThreadSafeRefCounted, which is not thread-safe.
357+
// An alternative would be to make RefCounted for Vectors/Blocks thread-safe when they are about
358+
// to be shared with other drivers via #allowPassingToDifferentDriver.
359+
close();
360+
return result;
352361
}
353362
Block[] newBlocks = new Block[page.getBlockCount() + read.length];
354363
System.arraycopy(read, 0, newBlocks, page.getBlockCount(), read.length);
@@ -368,7 +377,10 @@ public final Page next() {
368377

369378
@Override
370379
public void close() {
371-
Releasables.closeExpectNoException(page::releaseBlocks, next);
380+
if (closed == false) {
381+
closed = true;
382+
Releasables.closeExpectNoException(page::releaseBlocks, next);
383+
}
372384
}
373385
}
374386
}

x-pack/rest-resources-zip/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929
platinumTests project(path: ':x-pack:plugin:eql:qa:rest', configuration: 'restXpackTests')
3030
platinumTests project(path: ':x-pack:plugin:ent-search', configuration: 'restXpackTests')
3131
platinumTests project(path: ':x-pack:plugin:inference', configuration: 'restXpackTests')
32+
platinumTests project(path: ':x-pack:plugin:watcher:qa:rest', configuration: 'restXpackTests')
3233
platinumCompatTests project(path: ':x-pack:plugin', configuration: 'restCompatTests')
3334
platinumCompatTests project(path: ':x-pack:plugin:eql:qa:rest', configuration: 'restCompatTests')
3435
}

0 commit comments

Comments
 (0)