Skip to content

Commit 9df15cf

Browse files
committed
Merge remote-tracking branch 'origin/main' into improve-memory-accounting
2 parents f62c5d0 + a776263 commit 9df15cf

File tree

1,289 files changed

+39368
-15866
lines changed

Some content is hidden

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

1,289 files changed

+39368
-15866
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/indices/resolution/IndexNameExpressionResolverBenchmark.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.cluster.metadata.IndexMetadata;
1818
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
1919
import org.elasticsearch.cluster.metadata.Metadata;
20+
import org.elasticsearch.cluster.project.DefaultProjectResolver;
2021
import org.elasticsearch.common.settings.Settings;
2122
import org.elasticsearch.common.util.concurrent.ThreadContext;
2223
import org.elasticsearch.index.Index;
@@ -84,7 +85,11 @@ public void setUp() {
8485
}
8586
int mid = indices.length / 2;
8687
clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(mb).build();
87-
resolver = new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY), new SystemIndices(List.of()));
88+
resolver = new IndexNameExpressionResolver(
89+
new ThreadContext(Settings.EMPTY),
90+
new SystemIndices(List.of()),
91+
DefaultProjectResolver.INSTANCE
92+
);
8893
indexListRequest = new Request(IndicesOptions.lenientExpandOpenHidden(), indices);
8994
starRequest = new Request(IndicesOptions.lenientExpandOpenHidden(), "*");
9095
String[] mixed = indices.clone();

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void setUp() throws Exception {
138138
Metadata metadata = mb.build();
139139
RoutingTable.Builder rb = RoutingTable.builder(TestShardRoutingRoleStrategies.DEFAULT_ROLE_ONLY);
140140
for (int i = 1; i <= numIndices; i++) {
141-
rb.addAsNew(metadata.index("test_" + i));
141+
rb.addAsNew(metadata.getProject().index("test_" + i));
142142
}
143143
RoutingTable routingTable = rb.build();
144144
DiscoveryNodes.Builder nb = DiscoveryNodes.builder();

docs/changelog/123492.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 123492
2+
summary: Fix function registry concurrency issues on constructor
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 123430

docs/changelog/123569.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 123569
2+
summary: Abort pending deletion on `IndicesService` close
3+
area: Store
4+
type: enhancement
5+
issues: []
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.core;
11+
12+
import java.lang.annotation.ElementType;
13+
import java.lang.annotation.Retention;
14+
import java.lang.annotation.RetentionPolicy;
15+
import java.lang.annotation.Target;
16+
17+
/**
18+
* Annotation to identify a block of code (a whole class, a method, a field, or a local variable) that needs to be reviewed (for cleanup,
19+
* removal or change) before merging the multi-project branch into main
20+
*/
21+
@Retention(RetentionPolicy.SOURCE)
22+
@Target(
23+
{ ElementType.LOCAL_VARIABLE, ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.MODULE }
24+
)
25+
public @interface FixForMultiProject {
26+
27+
/**
28+
* Some explanation on what and why for the future fix
29+
*/
30+
String description() default "";
31+
}

libs/core/src/main/java/org/elasticsearch/core/Releasables.java

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
package org.elasticsearch.core;
1111

12-
import java.io.IOException;
13-
import java.io.UncheckedIOException;
1412
import java.util.Arrays;
1513
import java.util.Iterator;
1614
import java.util.concurrent.atomic.AtomicReference;
@@ -21,11 +19,17 @@ public enum Releasables {
2119

2220
/** Release the provided {@link Releasable}s. */
2321
public static void close(Iterable<? extends Releasable> releasables) {
24-
try {
25-
// this does the right thing with respect to add suppressed and not wrapping errors etc.
26-
IOUtils.close(releasables);
27-
} catch (IOException e) {
28-
throw new UncheckedIOException(e);
22+
RuntimeException firstException = null;
23+
for (final Releasable releasable : releasables) {
24+
try {
25+
close(releasable);
26+
} catch (RuntimeException e) {
27+
firstException = useOrSuppress(firstException, e);
28+
}
29+
}
30+
31+
if (firstException != null) {
32+
throw firstException;
2933
}
3034
}
3135

@@ -38,7 +42,18 @@ public static void close(@Nullable Releasable releasable) {
3842

3943
/** Release the provided {@link Releasable}s. */
4044
public static void close(Releasable... releasables) {
41-
close(true, releasables);
45+
RuntimeException firstException = null;
46+
for (final Releasable releasable : releasables) {
47+
try {
48+
close(releasable);
49+
} catch (RuntimeException e) {
50+
firstException = useOrSuppress(firstException, e);
51+
}
52+
}
53+
54+
if (firstException != null) {
55+
throw firstException;
56+
}
4257
}
4358

4459
/** Release the provided {@link Releasable}s expecting no exception to by thrown by any of them. */
@@ -63,19 +78,21 @@ public static void closeExpectNoException(Releasable releasable) {
6378

6479
/** Release the provided {@link Releasable}s, ignoring exceptions. */
6580
public static void closeWhileHandlingException(Releasable... releasables) {
66-
close(false, releasables);
81+
for (final Releasable releasable : releasables) {
82+
try {
83+
close(releasable);
84+
} catch (RuntimeException e) {
85+
// ignored
86+
}
87+
}
6788
}
6889

69-
/** Release the provided {@link Releasable}s, ignoring exceptions if <code>success</code> is {@code false}. */
70-
private static void close(boolean success, Releasable... releasables) {
71-
try {
72-
// this does the right thing with respect to add suppressed and not wrapping errors etc.
73-
IOUtils.close(releasables);
74-
} catch (IOException e) {
75-
if (success) {
76-
throw new UncheckedIOException(e);
77-
}
90+
private static RuntimeException useOrSuppress(RuntimeException firstException, RuntimeException e) {
91+
if (firstException == null || firstException == e) {
92+
return e;
7893
}
94+
firstException.addSuppressed(e);
95+
return firstException;
7996
}
8097

8198
/** Wrap several releasables into a single one. This is typically useful for use with try-with-resources: for example let's assume

libs/entitlement/src/main/java/org/elasticsearch/entitlement/initialization/EntitlementInitialization.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.elasticsearch.entitlement.runtime.policy.entitlements.ManageThreadsEntitlement;
3434
import org.elasticsearch.entitlement.runtime.policy.entitlements.OutboundNetworkEntitlement;
3535
import org.elasticsearch.entitlement.runtime.policy.entitlements.ReadStoreAttributesEntitlement;
36+
import org.elasticsearch.entitlement.runtime.policy.entitlements.SetHttpsConnectionPropertiesEntitlement;
3637

3738
import java.lang.instrument.Instrumentation;
3839
import java.lang.reflect.Constructor;
@@ -242,7 +243,14 @@ private static PolicyManager createPolicyManager() {
242243
if (trustStorePath != null) {
243244
Collections.addAll(
244245
serverScopes,
245-
new Scope("org.bouncycastle.fips.tls", List.of(new FilesEntitlement(List.of(FileData.ofPath(trustStorePath, READ))))),
246+
new Scope(
247+
"org.bouncycastle.fips.tls",
248+
List.of(
249+
new FilesEntitlement(List.of(FileData.ofPath(trustStorePath, READ))),
250+
new OutboundNetworkEntitlement(),
251+
new ManageThreadsEntitlement()
252+
)
253+
),
246254
new Scope(
247255
"org.bouncycastle.fips.core",
248256
// read to lib dir is required for checksum validation
@@ -258,6 +266,8 @@ private static PolicyManager createPolicyManager() {
258266
List<Entitlement> agentEntitlements = List.of(
259267
new CreateClassLoaderEntitlement(),
260268
new ManageThreadsEntitlement(),
269+
new SetHttpsConnectionPropertiesEntitlement(),
270+
new OutboundNetworkEntitlement(),
261271
new FilesEntitlement(
262272
List.of(
263273
FileData.ofPath(Path.of("/co/elastic/apm/agent/"), READ),

libs/ssl-config/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ apply plugin: "elasticsearch.publish"
1010

1111
dependencies {
1212
api project(':libs:core')
13+
api project(':libs:entitlement')
1314

1415
testImplementation(project(":test:framework")) {
1516
exclude group: 'org.elasticsearch', module: 'ssl-config'

libs/ssl-config/src/main/java/module-info.java

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

1010
module org.elasticsearch.sslconfig {
1111
requires org.elasticsearch.base;
12+
requires org.elasticsearch.entitlement;
1213

1314
exports org.elasticsearch.common.ssl;
1415
}

libs/ssl-config/src/main/java/org/elasticsearch/common/ssl/PemKeyConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.common.ssl;
1111

1212
import org.elasticsearch.core.Tuple;
13+
import org.elasticsearch.entitlement.runtime.api.NotEntitledException;
1314

1415
import java.io.IOException;
1516
import java.nio.file.Path;
@@ -127,6 +128,8 @@ private PrivateKey getPrivateKey(Path path) {
127128
return privateKey;
128129
} catch (AccessControlException e) {
129130
throw SslFileUtil.accessControlFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
131+
} catch (NotEntitledException e) {
132+
throw SslFileUtil.notEntitledFailure(KEY_FILE_TYPE, List.of(path), e, configBasePath);
130133
} catch (IOException e) {
131134
throw SslFileUtil.ioException(KEY_FILE_TYPE, List.of(path), e);
132135
} catch (GeneralSecurityException e) {

0 commit comments

Comments
 (0)