Skip to content

Commit 0159767

Browse files
committed
Merge remote-tracking branch 'upstream/main' into entitlements/nio-files-1
2 parents 83f5814 + 388c4a1 commit 0159767

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

libs/entitlement/asm-provider/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ apply plugin: 'elasticsearch.build'
1212
dependencies {
1313
compileOnly project(':libs:entitlement')
1414
compileOnly project(':libs:core')
15+
compileOnly project(':libs:logging')
1516
implementation 'org.ow2.asm:asm:9.7.1'
1617
testImplementation project(":test:framework")
1718
testImplementation project(":libs:entitlement:bridge")

libs/entitlement/asm-provider/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
requires org.elasticsearch.entitlement;
1616

1717
requires static org.elasticsearch.base; // for SuppressForbidden
18+
requires org.elasticsearch.logging;
1819

1920
provides InstrumentationService with InstrumentationServiceImpl;
2021
}

libs/entitlement/asm-provider/src/main/java/org/elasticsearch/entitlement/instrumentation/impl/InstrumenterImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.elasticsearch.entitlement.instrumentation.CheckMethod;
1313
import org.elasticsearch.entitlement.instrumentation.Instrumenter;
1414
import org.elasticsearch.entitlement.instrumentation.MethodKey;
15+
import org.elasticsearch.logging.LogManager;
16+
import org.elasticsearch.logging.Logger;
1517
import org.objectweb.asm.AnnotationVisitor;
1618
import org.objectweb.asm.ClassReader;
1719
import org.objectweb.asm.ClassVisitor;
@@ -36,6 +38,7 @@
3638
import static org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
3739

3840
public class InstrumenterImpl implements Instrumenter {
41+
private static final Logger logger = LogManager.getLogger(InstrumenterImpl.class);
3942

4043
private final String getCheckerClassMethodDescriptor;
4144
private final String handleClass;
@@ -155,10 +158,10 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str
155158
var key = new MethodKey(className, name, Stream.of(Type.getArgumentTypes(descriptor)).map(Type::getInternalName).toList());
156159
var instrumentationMethod = checkMethods.get(key);
157160
if (instrumentationMethod != null) {
158-
// System.out.println("Will instrument method " + key);
161+
logger.debug("Will instrument {}", key);
159162
return new EntitlementMethodVisitor(Opcodes.ASM9, mv, isStatic, isCtor, descriptor, instrumentationMethod);
160163
} else {
161-
// System.out.println("Will not instrument method " + key);
164+
logger.trace("Will not instrument {}", key);
162165
}
163166
}
164167
return mv;

muted-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ tests:
6161
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
6262
method: test {p0=transform/transforms_start_stop/Verify start transform reuses destination index}
6363
issue: https://github.com/elastic/elasticsearch/issues/115808
64-
- class: org.elasticsearch.search.StressSearchServiceReaperIT
65-
method: testStressReaper
66-
issue: https://github.com/elastic/elasticsearch/issues/115816
6764
- class: org.elasticsearch.xpack.application.connector.ConnectorIndexServiceTests
6865
issue: https://github.com/elastic/elasticsearch/issues/116087
6966
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
@@ -329,6 +326,8 @@ tests:
329326
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
330327
method: testEnrichExplosionManyMatches
331328
issue: https://github.com/elastic/elasticsearch/issues/122913
329+
- class: org.elasticsearch.xpack.search.AsyncSearchSecurityIT
330+
issue: https://github.com/elastic/elasticsearch/issues/122940
332331

333332
# Examples:
334333
#

server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
29252925
* {@link IndexWriter#commit()} call flushes all documents, we defer computation of the maximum sequence number to the time
29262926
* of invocation of the commit data iterator (which occurs after all documents have been flushed to Lucene).
29272927
*/
2928-
final Map<String, String> extraCommitUserData = getCommitExtraUserData();
2928+
final Map<String, String> extraCommitUserData = getCommitExtraUserData(localCheckpoint);
29292929
final Map<String, String> commitData = Maps.newMapWithExpectedSize(8 + extraCommitUserData.size());
29302930
commitData.putAll(extraCommitUserData);
29312931
commitData.put(Translog.TRANSLOG_UUID_KEY, translog.getTranslogUUID());
@@ -2973,8 +2973,10 @@ protected void commitIndexWriter(final IndexWriter writer, final Translog transl
29732973
/**
29742974
* Allows InternalEngine extenders to return custom key-value pairs which will be included in the Lucene commit user-data. Custom user
29752975
* data keys can be overwritten by if their keys conflict keys used by InternalEngine.
2976+
*
2977+
* @param localCheckpoint the local checkpoint of the commit
29762978
*/
2977-
protected Map<String, String> getCommitExtraUserData() {
2979+
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
29782980
return Collections.emptyMap();
29792981
}
29802982

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4491,14 +4491,17 @@ public void waitForEngineOrClosedShard(ActionListener<Void> listener) {
44914491
}
44924492

44934493
/**
4494-
* Registers a listener for an event when the shard advances to the provided primary term and segment generation
4494+
* Registers a listener for an event when the shard advances to the provided primary term and segment generation.
4495+
* Completes the listener with a {@link IndexShardClosedException} if the shard is closed.
44954496
*/
44964497
public void waitForPrimaryTermAndGeneration(long primaryTerm, long segmentGeneration, ActionListener<Long> listener) {
4497-
waitForEngineOrClosedShard(
4498-
listener.delegateFailureAndWrap(
4499-
(l, ignored) -> getEngine().addPrimaryTermAndGenerationListener(primaryTerm, segmentGeneration, l)
4500-
)
4501-
);
4498+
waitForEngineOrClosedShard(listener.delegateFailureAndWrap((l, ignored) -> {
4499+
if (state == IndexShardState.CLOSED) {
4500+
l.onFailure(new IndexShardClosedException(shardId));
4501+
} else {
4502+
getEngine().addPrimaryTermAndGenerationListener(primaryTerm, segmentGeneration, l);
4503+
}
4504+
}));
45024505
}
45034506

45044507
/**

server/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7327,7 +7327,7 @@ public void testExtraUserDataIsCommitted() throws IOException {
73277327
engine.close();
73287328
engine = new InternalEngine(engine.config()) {
73297329
@Override
7330-
protected Map<String, String> getCommitExtraUserData() {
7330+
protected Map<String, String> getCommitExtraUserData(final long localCheckpoint) {
73317331
return Map.of("userkey", "userdata", ES_VERSION, IndexVersions.ZERO.toString());
73327332
}
73337333
};

server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.lucene.util.BytesRef;
2828
import org.apache.lucene.util.Constants;
2929
import org.elasticsearch.ElasticsearchException;
30+
import org.elasticsearch.ExceptionsHelper;
3031
import org.elasticsearch.action.ActionListener;
3132
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
3233
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest;
@@ -3334,6 +3335,21 @@ public void testWaitForClosedListener() throws IOException {
33343335
assertThat("listener should have been called", called.get(), equalTo(true));
33353336
}
33363337

3338+
public void testWaitForPrimaryTermAndGenerationFailsForClosedShard() throws IOException {
3339+
Settings settings = indexSettings(IndexVersion.current(), 1, 1).build();
3340+
IndexMetadata metadata = IndexMetadata.builder("test").putMapping("""
3341+
{ "properties": { "foo": { "type": "text"}}}""").settings(settings).primaryTerm(0, 1).build();
3342+
IndexShard initializingShard = newShard(new ShardId(metadata.getIndex(), 0), true, "n1", metadata, null);
3343+
3344+
var future = new PlainActionFuture<Long>();
3345+
initializingShard.waitForPrimaryTermAndGeneration(0L, 0L, future);
3346+
3347+
assertFalse("waitForPrimaryTermAndGeneration should be waiting", future.isDone());
3348+
closeShards(initializingShard);
3349+
// Should bail out earlier without calling the engine
3350+
assertNotNull(ExceptionsHelper.unwrap(expectThrows(Exception.class, future::get), IndexShardClosedException.class));
3351+
}
3352+
33373353
public void testRecoverFromLocalShard() throws IOException {
33383354
Settings settings = indexSettings(IndexVersion.current(), 1, 1).build();
33393355
IndexMetadata metadata = IndexMetadata.builder("source")

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/elastic/completion/ElasticInferenceServiceCompletionServiceSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public class ElasticInferenceServiceCompletionServiceSettings extends FilteredXC
3535

3636
public static final String NAME = "elastic_inference_service_completion_service_settings";
3737

38-
// TODO what value do we put here?
3938
private static final RateLimitSettings DEFAULT_RATE_LIMIT_SETTINGS = new RateLimitSettings(720L);
4039

4140
public static ElasticInferenceServiceCompletionServiceSettings fromMap(Map<String, Object> map, ConfigurationParseContext context) {

0 commit comments

Comments
 (0)