diff --git a/muted-tests.yml b/muted-tests.yml index 0a55156b8a665..66b3864bf2a96 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -456,34 +456,20 @@ tests: - class: org.elasticsearch.xpack.test.rest.XPackRestIT method: test {p0=snapshot/20_operator_privileges_disabled/Operator only settings can be set and restored by non-operator user when operator privileges is disabled} issue: https://github.com/elastic/elasticsearch/issues/120973 -- class: org.elasticsearch.xpack.inference.action.filter.ShardBulkInferenceActionFilterIT - method: testBulkOperations {p0=false} - issue: https://github.com/elastic/elasticsearch/issues/120975 - class: org.elasticsearch.packaging.test.DockerTests issue: https://github.com/elastic/elasticsearch/issues/120978 -- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT - method: testInternalRange {ASYNC} - issue: https://github.com/elastic/elasticsearch/issues/120979 -- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT - method: testWarningHeadersOnFailedConversions {ASYNC} - issue: https://github.com/elastic/elasticsearch/issues/120980 - class: org.elasticsearch.xpack.security.authc.jwt.JwtRealmSingleNodeTests method: testActivateProfileForJWT issue: https://github.com/elastic/elasticsearch/issues/120983 - class: org.elasticsearch.xpack.security.profile.ProfileIntegTests method: testProfileIndexAutoCreation issue: https://github.com/elastic/elasticsearch/issues/120987 -- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT - method: testOutOfRangeComparisons {ASYNC} - issue: https://github.com/elastic/elasticsearch/issues/121007 - class: org.elasticsearch.xpack.security.authc.service.ServiceAccountIT method: testAuthenticateShouldNotFallThroughInCaseOfFailure issue: https://github.com/elastic/elasticsearch/issues/120902 - class: org.elasticsearch.xpack.security.FileSettingsRoleMappingsRestartIT method: testReservedStatePersistsOnRestart issue: https://github.com/elastic/elasticsearch/issues/120923 -- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT - issue: https://github.com/elastic/elasticsearch/issues/120948 - class: org.elasticsearch.datastreams.DataStreamsClientYamlTestSuiteIT method: test {p0=data_stream/140_data_stream_aliases/Create data stream alias} issue: https://github.com/elastic/elasticsearch/issues/120920 diff --git a/server/src/main/java/org/elasticsearch/index/engine/TranslogDirectoryReader.java b/server/src/main/java/org/elasticsearch/index/engine/TranslogDirectoryReader.java index 662fbb3677c3a..f81a93aa47146 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/TranslogDirectoryReader.java +++ b/server/src/main/java/org/elasticsearch/index/engine/TranslogDirectoryReader.java @@ -96,7 +96,7 @@ static DirectoryReader create( // When using synthetic source, the translog operation must always be reindexed into an in-memory Lucene to ensure consistent // output for realtime-get operations. However, this can degrade the performance of realtime-get and update operations. // If slight inconsistencies in realtime-get operations are acceptable, the translog operation can be reindexed lazily. - if (mappingLookup.isSourceSynthetic()) { + if (mappingLookup.isSourceSynthetic() || mappingLookup.inferenceFields().isEmpty() == false) { onSegmentCreated.run(); leafReader = createInMemoryReader(shardId, engineConfig, directory, documentParser, mappingLookup, false, operation); } else { diff --git a/server/src/main/java/org/elasticsearch/index/engine/TranslogOperationAsserter.java b/server/src/main/java/org/elasticsearch/index/engine/TranslogOperationAsserter.java index 4170d06c4d6ea..90eaea78b3893 100644 --- a/server/src/main/java/org/elasticsearch/index/engine/TranslogOperationAsserter.java +++ b/server/src/main/java/org/elasticsearch/index/engine/TranslogOperationAsserter.java @@ -38,7 +38,8 @@ public boolean assertSameIndexOperation(Translog.Index o1, Translog.Index o2) th if (super.assertSameIndexOperation(o1, o2)) { return true; } - if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()) { + if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled() + || engineConfig.getMapperService().mappingLookup().inferenceFields().isEmpty() == false) { return super.assertSameIndexOperation(synthesizeSource(engineConfig, o1), o2) || super.assertSameIndexOperation(o1, synthesizeSource(engineConfig, o2)); } @@ -60,19 +61,7 @@ static Translog.Index synthesizeSource(EngineConfig engineConfig, Translog.Index TrivialQueryCachingPolicy.NEVER, () -> {} ); - try ( - LuceneSyntheticSourceChangesSnapshot snapshot = new LuceneSyntheticSourceChangesSnapshot( - engineConfig.getMapperService(), - searcher, - LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE, - Integer.MAX_VALUE, - op.seqNo(), - op.seqNo(), - true, - false, - engineConfig.getIndexSettings().getIndexVersionCreated() - ) - ) { + try (var snapshot = newSnapshot(engineConfig, op, searcher);) { final Translog.Operation normalized = snapshot.next(); assert normalized != null : "expected one operation; got zero"; return (Translog.Index) normalized; @@ -80,6 +69,34 @@ static Translog.Index synthesizeSource(EngineConfig engineConfig, Translog.Index } } + static Translog.Snapshot newSnapshot(EngineConfig engineConfig, Translog.Index op, Engine.Searcher searcher) throws IOException { + if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()) { + return new LuceneSyntheticSourceChangesSnapshot( + engineConfig.getMapperService(), + searcher, + LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE, + Integer.MAX_VALUE, + op.seqNo(), + op.seqNo(), + true, + false, + engineConfig.getIndexSettings().getIndexVersionCreated() + ); + } else { + return new LuceneChangesSnapshot( + engineConfig.getMapperService(), + searcher, + LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE, + op.seqNo(), + op.seqNo(), + true, + false, + false, + engineConfig.getIndexSettings().getIndexVersionCreated() + ); + } + } + public boolean assertSameIndexOperation(Translog.Index o1, Translog.Index o2) throws IOException { return Translog.Index.equalsWithoutAutoGeneratedTimestamp(o1, o2); }