Skip to content

Commit 8dfed18

Browse files
committed
Merge branch 'main' into rocket_coalesce
2 parents f28f6af + 30948ac commit 8dfed18

File tree

414 files changed

+6048
-3670
lines changed

Some content is hidden

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

414 files changed

+6048
-3670
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/EvalBenchmark.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.core.TimeValue;
2828
import org.elasticsearch.xpack.esql.core.expression.Expression;
2929
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
30+
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
3031
import org.elasticsearch.xpack.esql.core.expression.Literal;
3132
import org.elasticsearch.xpack.esql.core.expression.predicate.regex.RLikePattern;
3233
import org.elasticsearch.xpack.esql.core.tree.Source;
@@ -72,12 +73,11 @@ public class EvalBenchmark {
7273
BigArrays.NON_RECYCLING_INSTANCE
7374
);
7475

76+
private static final FoldContext FOLD_CONTEXT = FoldContext.small();
77+
7578
private static final int BLOCK_LENGTH = 8 * 1024;
7679

77-
static final DriverContext driverContext = new DriverContext(
78-
BigArrays.NON_RECYCLING_INSTANCE,
79-
BlockFactory.getInstance(new NoopCircuitBreaker("noop"), BigArrays.NON_RECYCLING_INSTANCE)
80-
);
80+
static final DriverContext driverContext = new DriverContext(BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
8181

8282
static {
8383
// Smoke test all the expected values and force loading subclasses more like prod
@@ -118,18 +118,20 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
118118
return switch (operation) {
119119
case "abs" -> {
120120
FieldAttribute longField = longField();
121-
yield EvalMapper.toEvaluator(new Abs(Source.EMPTY, longField), layout(longField)).get(driverContext);
121+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Abs(Source.EMPTY, longField), layout(longField)).get(driverContext);
122122
}
123123
case "add" -> {
124124
FieldAttribute longField = longField();
125125
yield EvalMapper.toEvaluator(
126+
FOLD_CONTEXT,
126127
new Add(Source.EMPTY, longField, new Literal(Source.EMPTY, 1L, DataType.LONG)),
127128
layout(longField)
128129
).get(driverContext);
129130
}
130131
case "add_double" -> {
131132
FieldAttribute doubleField = doubleField();
132133
yield EvalMapper.toEvaluator(
134+
FOLD_CONTEXT,
133135
new Add(Source.EMPTY, doubleField, new Literal(Source.EMPTY, 1D, DataType.DOUBLE)),
134136
layout(doubleField)
135137
).get(driverContext);
@@ -145,6 +147,7 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
145147
rhs = new Add(Source.EMPTY, rhs, new Literal(Source.EMPTY, 1L, DataType.LONG));
146148
}
147149
EvalOperator.ExpressionEvaluator evaluator = EvalMapper.toEvaluator(
150+
FOLD_CONTEXT,
148151
new Case(Source.EMPTY, condition, List.of(lhs, rhs)),
149152
layout(f1, f2)
150153
).get(driverContext);
@@ -162,6 +165,7 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
162165
lhs = new Add(Source.EMPTY, lhs, new Literal(Source.EMPTY, 1L, DataType.LONG));
163166
}
164167
EvalOperator.ExpressionEvaluator evaluator = EvalMapper.toEvaluator(
168+
FOLD_CONTEXT,
165169
new Coalesce(Source.EMPTY, lhs, List.of(f2)),
166170
layout(f1, f2)
167171
).get(driverContext);
@@ -178,35 +182,37 @@ private static EvalOperator.ExpressionEvaluator evaluator(String operation) {
178182
new EsField("timestamp", DataType.DATETIME, Map.of(), true)
179183
);
180184
yield EvalMapper.toEvaluator(
185+
FOLD_CONTEXT,
181186
new DateTrunc(Source.EMPTY, new Literal(Source.EMPTY, Duration.ofHours(24), DataType.TIME_DURATION), timestamp),
182187
layout(timestamp)
183188
).get(driverContext);
184189
}
185190
case "equal_to_const" -> {
186191
FieldAttribute longField = longField();
187192
yield EvalMapper.toEvaluator(
193+
FOLD_CONTEXT,
188194
new Equals(Source.EMPTY, longField, new Literal(Source.EMPTY, 100_000L, DataType.LONG)),
189195
layout(longField)
190196
).get(driverContext);
191197
}
192198
case "long_equal_to_long" -> {
193199
FieldAttribute lhs = longField();
194200
FieldAttribute rhs = longField();
195-
yield EvalMapper.toEvaluator(new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
201+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
196202
}
197203
case "long_equal_to_int" -> {
198204
FieldAttribute lhs = longField();
199205
FieldAttribute rhs = intField();
200-
yield EvalMapper.toEvaluator(new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
206+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new Equals(Source.EMPTY, lhs, rhs), layout(lhs, rhs)).get(driverContext);
201207
}
202208
case "mv_min", "mv_min_ascending" -> {
203209
FieldAttribute longField = longField();
204-
yield EvalMapper.toEvaluator(new MvMin(Source.EMPTY, longField), layout(longField)).get(driverContext);
210+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, new MvMin(Source.EMPTY, longField), layout(longField)).get(driverContext);
205211
}
206212
case "rlike" -> {
207213
FieldAttribute keywordField = keywordField();
208214
RLike rlike = new RLike(Source.EMPTY, keywordField, new RLikePattern(".ar"));
209-
yield EvalMapper.toEvaluator(rlike, layout(keywordField)).get(driverContext);
215+
yield EvalMapper.toEvaluator(FOLD_CONTEXT, rlike, layout(keywordField)).get(driverContext);
210216
}
211217
default -> throw new UnsupportedOperationException();
212218
};

distribution/tools/server-cli/src/main/java/org/elasticsearch/server/cli/APMJvmOptions.java

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,12 @@ static String agentCommandLineOption(Path agentJar, Path tmpPropertiesFile) {
187187
static void extractSecureSettings(SecureSettings secrets, Map<String, String> propertiesMap) {
188188
final Set<String> settingNames = secrets.getSettingNames();
189189
for (String key : List.of("api_key", "secret_token")) {
190-
for (String prefix : List.of("telemetry.", "tracing.apm.")) {
191-
if (settingNames.contains(prefix + key)) {
192-
if (propertiesMap.containsKey(key)) {
193-
throw new IllegalStateException(
194-
Strings.format("Duplicate telemetry setting: [telemetry.%s] and [tracing.apm.%s]", key, key)
195-
);
196-
}
197-
198-
try (SecureString token = secrets.getString(prefix + key)) {
199-
propertiesMap.put(key, token.toString());
200-
}
190+
String prefix = "telemetry.";
191+
if (settingNames.contains(prefix + key)) {
192+
try (SecureString token = secrets.getString(prefix + key)) {
193+
propertiesMap.put(key, token.toString());
201194
}
202195
}
203-
204196
}
205197
}
206198

@@ -227,44 +219,12 @@ private static Map<String, String> extractDynamicSettings(Map<String, String> pr
227219
static Map<String, String> extractApmSettings(Settings settings) throws UserException {
228220
final Map<String, String> propertiesMap = new HashMap<>();
229221

230-
// tracing.apm.agent. is deprecated by telemetry.agent.
231222
final String telemetryAgentPrefix = "telemetry.agent.";
232-
final String deprecatedTelemetryAgentPrefix = "tracing.apm.agent.";
233223

234224
final Settings telemetryAgentSettings = settings.getByPrefix(telemetryAgentPrefix);
235225
telemetryAgentSettings.keySet().forEach(key -> propertiesMap.put(key, String.valueOf(telemetryAgentSettings.get(key))));
236226

237-
final Settings apmAgentSettings = settings.getByPrefix(deprecatedTelemetryAgentPrefix);
238-
for (String key : apmAgentSettings.keySet()) {
239-
if (propertiesMap.containsKey(key)) {
240-
throw new IllegalStateException(
241-
Strings.format(
242-
"Duplicate telemetry setting: [%s%s] and [%s%s]",
243-
telemetryAgentPrefix,
244-
key,
245-
deprecatedTelemetryAgentPrefix,
246-
key
247-
)
248-
);
249-
}
250-
propertiesMap.put(key, String.valueOf(apmAgentSettings.get(key)));
251-
}
252-
253227
StringJoiner globalLabels = extractGlobalLabels(telemetryAgentPrefix, propertiesMap, settings);
254-
if (globalLabels.length() == 0) {
255-
globalLabels = extractGlobalLabels(deprecatedTelemetryAgentPrefix, propertiesMap, settings);
256-
} else {
257-
StringJoiner tracingGlobalLabels = extractGlobalLabels(deprecatedTelemetryAgentPrefix, propertiesMap, settings);
258-
if (tracingGlobalLabels.length() != 0) {
259-
throw new IllegalArgumentException(
260-
"Cannot have global labels with tracing.agent prefix ["
261-
+ globalLabels
262-
+ "] and telemetry.apm.agent prefix ["
263-
+ tracingGlobalLabels
264-
+ "]"
265-
);
266-
}
267-
}
268228
if (globalLabels.length() > 0) {
269229
propertiesMap.put("global_labels", globalLabels.toString());
270230
}
@@ -274,7 +234,7 @@ static Map<String, String> extractApmSettings(Settings settings) throws UserExce
274234
if (propertiesMap.containsKey(key)) {
275235
throw new UserException(
276236
ExitCodes.CONFIG,
277-
"Do not set a value for [tracing.apm.agent." + key + "], as this is configured automatically by Elasticsearch"
237+
"Do not set a value for [telemetry.agent." + key + "], as this is configured automatically by Elasticsearch"
278238
);
279239
}
280240
}

distribution/tools/server-cli/src/test/java/org/elasticsearch/server/cli/APMJvmOptionsTests.java

Lines changed: 47 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@
2525
import java.util.HashMap;
2626
import java.util.List;
2727
import java.util.Map;
28-
import java.util.function.Function;
2928

3029
import static org.elasticsearch.test.MapMatcher.matchesMap;
3130
import static org.hamcrest.Matchers.allOf;
3231
import static org.hamcrest.Matchers.containsInAnyOrder;
33-
import static org.hamcrest.Matchers.containsString;
3432
import static org.hamcrest.Matchers.endsWith;
3533
import static org.hamcrest.Matchers.equalTo;
3634
import static org.hamcrest.Matchers.hasEntry;
3735
import static org.hamcrest.Matchers.hasKey;
3836
import static org.hamcrest.Matchers.hasSize;
39-
import static org.hamcrest.Matchers.is;
4037
import static org.hamcrest.Matchers.not;
4138
import static org.mockito.Mockito.doReturn;
4239
import static org.mockito.Mockito.mock;
@@ -82,109 +79,63 @@ public void testFileDeleteWorks() throws IOException {
8279
}
8380

8481
public void testExtractSecureSettings() {
85-
MockSecureSettings duplicateSecureSettings = new MockSecureSettings();
82+
MockSecureSettings secureSettings = new MockSecureSettings();
83+
secureSettings.setString("telemetry.secret_token", "token");
84+
secureSettings.setString("telemetry.api_key", "key");
8685

87-
for (String prefix : List.of("telemetry.", "tracing.apm.")) {
88-
MockSecureSettings secureSettings = new MockSecureSettings();
89-
secureSettings.setString(prefix + "secret_token", "token");
90-
secureSettings.setString(prefix + "api_key", "key");
91-
92-
duplicateSecureSettings.setString(prefix + "api_key", "secret");
93-
94-
Map<String, String> propertiesMap = new HashMap<>();
95-
APMJvmOptions.extractSecureSettings(secureSettings, propertiesMap);
96-
97-
assertThat(propertiesMap, matchesMap(Map.of("secret_token", "token", "api_key", "key")));
98-
}
99-
100-
Exception exception = expectThrows(
101-
IllegalStateException.class,
102-
() -> APMJvmOptions.extractSecureSettings(duplicateSecureSettings, new HashMap<>())
103-
);
104-
assertThat(exception.getMessage(), containsString("Duplicate telemetry setting"));
105-
assertThat(exception.getMessage(), containsString("telemetry.api_key"));
106-
assertThat(exception.getMessage(), containsString("tracing.apm.api_key"));
86+
Map<String, String> propertiesMap = new HashMap<>();
87+
APMJvmOptions.extractSecureSettings(secureSettings, propertiesMap);
10788

89+
assertThat(propertiesMap, matchesMap(Map.of("secret_token", "token", "api_key", "key")));
10890
}
10991

11092
public void testExtractSettings() throws UserException {
111-
Function<String, Settings.Builder> buildSettings = (prefix) -> Settings.builder()
112-
.put(prefix + "server_url", "https://myurl:443")
113-
.put(prefix + "service_node_name", "instance-0000000001");
114-
115-
for (String prefix : List.of("tracing.apm.agent.", "telemetry.agent.")) {
116-
var name = "APM Tracing";
117-
var deploy = "123";
118-
var org = "456";
119-
var extracted = APMJvmOptions.extractApmSettings(
120-
buildSettings.apply(prefix)
121-
.put(prefix + "global_labels.deployment_name", name)
122-
.put(prefix + "global_labels.deployment_id", deploy)
123-
.put(prefix + "global_labels.organization_id", org)
124-
.build()
125-
);
126-
127-
assertThat(
128-
extracted,
129-
allOf(
130-
hasEntry("server_url", "https://myurl:443"),
131-
hasEntry("service_node_name", "instance-0000000001"),
132-
hasEntry(equalTo("global_labels"), not(endsWith(","))), // test that we have collapsed all global labels into one
133-
not(hasKey("global_labels.organization_id")) // tests that we strip out the top level label keys
134-
)
135-
);
136-
137-
List<String> labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
138-
assertThat(labels, hasSize(3));
139-
assertThat(labels, containsInAnyOrder("deployment_name=APM Tracing", "organization_id=" + org, "deployment_id=" + deploy));
140-
141-
// test replacing with underscores and skipping empty
142-
name = "APM=Tracing";
143-
deploy = "";
144-
org = ",456";
145-
extracted = APMJvmOptions.extractApmSettings(
146-
buildSettings.apply(prefix)
147-
.put(prefix + "global_labels.deployment_name", name)
148-
.put(prefix + "global_labels.deployment_id", deploy)
149-
.put(prefix + "global_labels.organization_id", org)
150-
.build()
151-
);
152-
labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
153-
assertThat(labels, hasSize(2));
154-
assertThat(labels, containsInAnyOrder("deployment_name=APM_Tracing", "organization_id=_456"));
155-
}
156-
157-
IllegalStateException err = expectThrows(
158-
IllegalStateException.class,
159-
() -> APMJvmOptions.extractApmSettings(
160-
Settings.builder()
161-
.put("tracing.apm.agent.server_url", "https://myurl:443")
162-
.put("telemetry.agent.server_url", "https://myurl-2:443")
163-
.build()
164-
)
165-
);
166-
assertThat(err.getMessage(), is("Duplicate telemetry setting: [telemetry.agent.server_url] and [tracing.apm.agent.server_url]"));
167-
}
168-
169-
public void testNoMixedLabels() {
170-
String telemetryAgent = "telemetry.agent.";
171-
String tracingAgent = "tracing.apm.agent.";
172-
Settings settings = Settings.builder()
173-
.put("tracing.apm.enabled", true)
174-
.put(telemetryAgent + "server_url", "https://myurl:443")
175-
.put(telemetryAgent + "service_node_name", "instance-0000000001")
176-
.put(tracingAgent + "global_labels.deployment_id", "123")
177-
.put(telemetryAgent + "global_labels.organization_id", "456")
93+
Settings defaults = Settings.builder()
94+
.put("telemetry.agent.server_url", "https://myurl:443")
95+
.put("telemetry.agent.service_node_name", "instance-0000000001")
17896
.build();
17997

180-
IllegalArgumentException err = assertThrows(IllegalArgumentException.class, () -> APMJvmOptions.extractApmSettings(settings));
98+
var name = "APM Tracing";
99+
var deploy = "123";
100+
var org = "456";
101+
var extracted = APMJvmOptions.extractApmSettings(
102+
Settings.builder()
103+
.put(defaults)
104+
.put("telemetry.agent.global_labels.deployment_name", name)
105+
.put("telemetry.agent.global_labels.deployment_id", deploy)
106+
.put("telemetry.agent.global_labels.organization_id", org)
107+
.build()
108+
);
109+
181110
assertThat(
182-
err.getMessage(),
183-
is(
184-
"Cannot have global labels with tracing.agent prefix [organization_id=456] and"
185-
+ " telemetry.apm.agent prefix [deployment_id=123]"
111+
extracted,
112+
allOf(
113+
hasEntry("server_url", "https://myurl:443"),
114+
hasEntry("service_node_name", "instance-0000000001"),
115+
hasEntry(equalTo("global_labels"), not(endsWith(","))), // test that we have collapsed all global labels into one
116+
not(hasKey("global_labels.organization_id")) // tests that we strip out the top level label keys
186117
)
187118
);
119+
120+
List<String> labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
121+
assertThat(labels, hasSize(3));
122+
assertThat(labels, containsInAnyOrder("deployment_name=APM Tracing", "organization_id=" + org, "deployment_id=" + deploy));
123+
124+
// test replacing with underscores and skipping empty
125+
name = "APM=Tracing";
126+
deploy = "";
127+
org = ",456";
128+
extracted = APMJvmOptions.extractApmSettings(
129+
Settings.builder()
130+
.put(defaults)
131+
.put("telemetry.agent.global_labels.deployment_name", name)
132+
.put("telemetry.agent.global_labels.deployment_id", deploy)
133+
.put("telemetry.agent.global_labels.organization_id", org)
134+
.build()
135+
);
136+
labels = Arrays.stream(extracted.get("global_labels").split(",")).toList();
137+
assertThat(labels, hasSize(2));
138+
assertThat(labels, containsInAnyOrder("deployment_name=APM_Tracing", "organization_id=_456"));
188139
}
189140

190141
private Path makeFakeAgentJar() throws IOException {

docs/changelog/118602.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 118602
2+
summary: Limit memory usage of `fold`
3+
area: ES|QL
4+
type: bug
5+
issues: []

docs/changelog/119227.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pr: 119227
2+
summary: Remove unfreeze REST endpoint
3+
area: Indices APIs
4+
type: breaking
5+
issues: []
6+
breaking:
7+
title: Remove unfreeze REST endpoint
8+
area: REST API
9+
details: >-
10+
The `/{index}/_unfreeze` REST endpoint is no longer supported. This API was deprecated, and the corresponding
11+
`/{index}/_freeze` endpoint was removed in 8.0.
12+
impact: None, since it is not possible to have a frozen index in a version which is readable by Elasticsearch 9.0
13+
notable: false

docs/changelog/119772.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 119772
2+
summary: ESQL Support IN operator for Date nanos
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 118578

docs/changelog/119831.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 119831
2+
summary: Run `TransportClusterGetSettingsAction` on local node
3+
area: Infra/Settings
4+
type: enhancement
5+
issues: []

0 commit comments

Comments
 (0)