Skip to content

Commit 5e83d03

Browse files
committed
Merge branch 'main' into fix-setting-shards
2 parents 874de75 + bccd6f2 commit 5e83d03

File tree

71 files changed

+970
-135
lines changed

Some content is hidden

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

71 files changed

+970
-135
lines changed

docs/changelog/125479.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 125479
2+
summary: ES|QL - Allow full text functions to be used in STATS
3+
area: ES|QL
4+
type: enhancement
5+
issues:
6+
- 125481

docs/changelog/127877.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127877
2+
summary: Check hidden frames in entitlements
3+
area: Infra/Core
4+
type: bug
5+
issues: []

docs/changelog/127921.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 127921
2+
summary: "[9.x] Revert \"Enable madvise by default for all builds\""
3+
area: Vector Search
4+
type: bug
5+
issues: []

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/Util.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
package org.elasticsearch.entitlement.bridge;
1111

1212
import java.util.Optional;
13+
import java.util.Set;
1314

1415
import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE;
16+
import static java.lang.StackWalker.Option.SHOW_HIDDEN_FRAMES;
1517

1618
public class Util {
1719
/**
@@ -23,6 +25,8 @@ public class Util {
2325
public static final Class<?> NO_CLASS = new Object() {
2426
}.getClass();
2527

28+
private static final Set<String> skipInternalPackages = Set.of("java.lang.invoke", "java.lang.reflect", "jdk.internal.reflect");
29+
2630
/**
2731
* Why would we write this instead of using {@link StackWalker#getCallerClass()}?
2832
* Because that method throws {@link IllegalCallerException} if called from the "outermost frame",
@@ -32,9 +36,10 @@ public class Util {
3236
*/
3337
@SuppressWarnings("unused") // Called reflectively from InstrumenterImpl
3438
public static Class<?> getCallerClass() {
35-
Optional<Class<?>> callerClassIfAny = StackWalker.getInstance(RETAIN_CLASS_REFERENCE)
39+
Optional<Class<?>> callerClassIfAny = StackWalker.getInstance(Set.of(RETAIN_CLASS_REFERENCE, SHOW_HIDDEN_FRAMES))
3640
.walk(
3741
frames -> frames.skip(2) // Skip this method and its caller
42+
.filter(frame -> skipInternalPackages.contains(frame.getDeclaringClass().getPackageName()) == false)
3843
.findFirst()
3944
.map(StackWalker.StackFrame::getDeclaringClass)
4045
);

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/entitlements/FilesEntitlement.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ private static BaseDir parseBaseDir(String baseDir) {
182182
case "config" -> BaseDir.CONFIG;
183183
case "data" -> BaseDir.DATA;
184184
case "home" -> BaseDir.USER_HOME;
185-
// NOTE: shared_repo is _not_ accessible to policy files, only internally
185+
// it would be nice to limit this to just ES modules, but we don't have a way to plumb that through to here
186+
// however, we still don't document in the error case below that shared_repo is valid
187+
case "shared_repo" -> BaseDir.SHARED_REPO;
186188
default -> throw new PolicyValidationException(
187189
"invalid relative directory: " + baseDir + ", valid values: [config, data, home]"
188190
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1+
org.elasticsearch.repository.url:
2+
- outbound_network
3+
- files:
4+
- relative_path: .
5+
relative_to: shared_repo
6+
mode: read
17
org.apache.httpcomponents.httpclient:
28
- outbound_network # for URLHttpClient

muted-tests.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ tests:
6666
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
6767
method: test {p0=transform/transforms_start_stop/Test start already started transform}
6868
issue: https://github.com/elastic/elasticsearch/issues/98802
69-
- class: org.elasticsearch.xpack.deprecation.DeprecationHttpIT
70-
method: testDeprecatedSettingsReturnWarnings
71-
issue: https://github.com/elastic/elasticsearch/issues/108628
7269
- class: org.elasticsearch.xpack.shutdown.NodeShutdownIT
7370
method: testAllocationPreventedForRemoval
7471
issue: https://github.com/elastic/elasticsearch/issues/116363
@@ -408,9 +405,6 @@ tests:
408405
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
409406
method: testLookupExplosionNoFetch
410407
issue: https://github.com/elastic/elasticsearch/issues/127365
411-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
412-
method: test
413-
issue: https://github.com/elastic/elasticsearch/issues/127536
414408
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
415409
method: test {p0=ml/data_frame_analytics_cat_apis/Test cat data frame analytics all jobs with header}
416410
issue: https://github.com/elastic/elasticsearch/issues/127625
@@ -432,9 +426,6 @@ tests:
432426
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
433427
method: test {p0=search/350_point_in_time/point-in-time with index filter}
434428
issue: https://github.com/elastic/elasticsearch/issues/127741
435-
- class: org.elasticsearch.compute.aggregation.FilteredGroupingAggregatorFunctionTests
436-
method: testSimpleCircuitBreaking
437-
issue: https://github.com/elastic/elasticsearch/issues/127833
438429
- class: org.elasticsearch.packaging.test.DockerTests
439430
method: test025SyncPluginsUsingProxy
440431
issue: https://github.com/elastic/elasticsearch/issues/127138
@@ -462,6 +453,18 @@ tests:
462453
- class: org.elasticsearch.cluster.routing.allocation.decider.DiskThresholdDeciderIT
463454
method: testRestoreSnapshotAllocationDoesNotExceedWatermarkWithMultipleRestores
464455
issue: https://github.com/elastic/elasticsearch/issues/127787
456+
- class: org.elasticsearch.indices.stats.IndexStatsIT
457+
method: testThrottleStats
458+
issue: https://github.com/elastic/elasticsearch/issues/126359
459+
- class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests
460+
method: testRandomWithFilter
461+
issue: https://github.com/elastic/elasticsearch/issues/127963
462+
- class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests
463+
method: testSearchBoost
464+
issue: https://github.com/elastic/elasticsearch/issues/127969
465+
- class: org.elasticsearch.packaging.test.DockerTests
466+
method: test040JavaUsesTheOsProvidedKeystore
467+
issue: https://github.com/elastic/elasticsearch/issues/127437
465468

466469
# Examples:
467470
#

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ public void onFailure(Exception failure) {
913913

914914
@Override
915915
public Releasable captureResponseHeaders() {
916-
final var storedContext = threadContext.newStoredContext();
916+
final var storedContext = threadContextSupplier.get();
917917
return Releasables.wrap(() -> {
918918
final var newResponseHeaders = threadContext.getResponseHeaders();
919919
if (newResponseHeaders.isEmpty()) {

server/src/main/java/org/elasticsearch/index/store/FsDirectoryFactory.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
import org.apache.lucene.store.MMapDirectory;
2121
import org.apache.lucene.store.NIOFSDirectory;
2222
import org.apache.lucene.store.NativeFSLockFactory;
23+
import org.apache.lucene.store.ReadAdvice;
2324
import org.apache.lucene.store.SimpleFSLockFactory;
2425
import org.elasticsearch.common.settings.Setting;
2526
import org.elasticsearch.common.settings.Setting.Property;
27+
import org.elasticsearch.common.util.FeatureFlag;
2628
import org.elasticsearch.core.IOUtils;
2729
import org.elasticsearch.index.IndexModule;
2830
import org.elasticsearch.index.IndexSettings;
@@ -43,6 +45,7 @@
4345
public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
4446

4547
private static final Logger Log = LogManager.getLogger(FsDirectoryFactory.class);
48+
private static final FeatureFlag MADV_RANDOM_FEATURE_FLAG = new FeatureFlag("madv_random");
4649

4750
public static final Setting<LockFactory> INDEX_LOCK_FACTOR_SETTING = new Setting<>("index.store.fs.fs_lock", "native", (s) -> {
4851
return switch (s) {
@@ -75,12 +78,20 @@ protected Directory newFSDirectory(Path location, LockFactory lockFactory, Index
7578
// Use Lucene defaults
7679
final FSDirectory primaryDirectory = FSDirectory.open(location, lockFactory);
7780
if (primaryDirectory instanceof MMapDirectory mMapDirectory) {
78-
return new HybridDirectory(lockFactory, setPreload(mMapDirectory, preLoadExtensions));
81+
Directory dir = new HybridDirectory(lockFactory, setPreload(mMapDirectory, preLoadExtensions));
82+
if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
83+
dir = disableRandomAdvice(dir);
84+
}
85+
return dir;
7986
} else {
8087
return primaryDirectory;
8188
}
8289
case MMAPFS:
83-
return setPreload(new MMapDirectory(location, lockFactory), preLoadExtensions);
90+
Directory dir = setPreload(new MMapDirectory(location, lockFactory), preLoadExtensions);
91+
if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
92+
dir = disableRandomAdvice(dir);
93+
}
94+
return dir;
8495
case SIMPLEFS:
8596
case NIOFS:
8697
return new NIOFSDirectory(location, lockFactory);
@@ -108,6 +119,23 @@ static BiPredicate<String, IOContext> getPreloadFunc(Set<String> preLoadExtensio
108119
return MMapDirectory.NO_FILES;
109120
}
110121

122+
/**
123+
* Return a {@link FilterDirectory} around the provided {@link Directory} that forcefully disables {@link IOContext#readAdvice random
124+
* access}.
125+
*/
126+
static Directory disableRandomAdvice(Directory dir) {
127+
return new FilterDirectory(dir) {
128+
@Override
129+
public IndexInput openInput(String name, IOContext context) throws IOException {
130+
if (context.readAdvice() == ReadAdvice.RANDOM) {
131+
context = context.withReadAdvice(ReadAdvice.NORMAL);
132+
}
133+
assert context.readAdvice() != ReadAdvice.RANDOM;
134+
return super.openInput(name, context);
135+
}
136+
};
137+
}
138+
111139
/**
112140
* Returns true iff the directory is a hybrid fs directory
113141
*/

server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ public void testThreadContext() {
299299
}
300300

301301
try (ThreadContext.StoredContext ignored = threadPool.getThreadContext().stashContext()) {
302-
303302
final var expectedHeaders = new HashMap<String, String>();
304303
expectedHeaders.put(randomIdentifier(), randomIdentifier());
305304
for (final var copiedHeader : Task.HEADERS_TO_COPY) {
@@ -319,8 +318,10 @@ public void testThreadContext() {
319318
new AckedClusterStateUpdateTask(ackedRequest(ackTimeout, masterTimeout), null) {
320319
@Override
321320
public ClusterState execute(ClusterState currentState) {
322-
assertTrue(threadPool.getThreadContext().isSystemContext());
323-
assertEquals(Collections.emptyMap(), threadPool.getThreadContext().getHeaders());
321+
// the task is executed in the context in which the task was originally created.
322+
// note: this is typically not a system context.
323+
assertExpectedThreadContext(Map.of());
324+
324325
expectedResponseHeaders.forEach(
325326
(name, values) -> values.forEach(v -> threadPool.getThreadContext().addResponseHeader(name, v))
326327
);

0 commit comments

Comments
 (0)