Skip to content

Commit 17cae4a

Browse files
authored
Relax translog assertion for inference fields (#121092) (#121107)
The inference fields are synthesized from doc_values, regardless of whether the synthetic source is enabled. This change relaxes the translog assertions, allowing inference fields in the same way as we did with the synthetic source. Relates #120045 Closes #120979 Closes #121007 Closes #120980 Closes #120975
1 parent 214ffb0 commit 17cae4a

File tree

3 files changed

+32
-29
lines changed

3 files changed

+32
-29
lines changed

muted-tests.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -456,34 +456,20 @@ tests:
456456
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
457457
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}
458458
issue: https://github.com/elastic/elasticsearch/issues/120973
459-
- class: org.elasticsearch.xpack.inference.action.filter.ShardBulkInferenceActionFilterIT
460-
method: testBulkOperations {p0=false}
461-
issue: https://github.com/elastic/elasticsearch/issues/120975
462459
- class: org.elasticsearch.packaging.test.DockerTests
463460
issue: https://github.com/elastic/elasticsearch/issues/120978
464-
- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT
465-
method: testInternalRange {ASYNC}
466-
issue: https://github.com/elastic/elasticsearch/issues/120979
467-
- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT
468-
method: testWarningHeadersOnFailedConversions {ASYNC}
469-
issue: https://github.com/elastic/elasticsearch/issues/120980
470461
- class: org.elasticsearch.xpack.security.authc.jwt.JwtRealmSingleNodeTests
471462
method: testActivateProfileForJWT
472463
issue: https://github.com/elastic/elasticsearch/issues/120983
473464
- class: org.elasticsearch.xpack.security.profile.ProfileIntegTests
474465
method: testProfileIndexAutoCreation
475466
issue: https://github.com/elastic/elasticsearch/issues/120987
476-
- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT
477-
method: testOutOfRangeComparisons {ASYNC}
478-
issue: https://github.com/elastic/elasticsearch/issues/121007
479467
- class: org.elasticsearch.xpack.security.authc.service.ServiceAccountIT
480468
method: testAuthenticateShouldNotFallThroughInCaseOfFailure
481469
issue: https://github.com/elastic/elasticsearch/issues/120902
482470
- class: org.elasticsearch.xpack.security.FileSettingsRoleMappingsRestartIT
483471
method: testReservedStatePersistsOnRestart
484472
issue: https://github.com/elastic/elasticsearch/issues/120923
485-
- class: org.elasticsearch.xpack.esql.qa.multi_node.RestEsqlIT
486-
issue: https://github.com/elastic/elasticsearch/issues/120948
487473
- class: org.elasticsearch.datastreams.DataStreamsClientYamlTestSuiteIT
488474
method: test {p0=data_stream/140_data_stream_aliases/Create data stream alias}
489475
issue: https://github.com/elastic/elasticsearch/issues/120920

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static DirectoryReader create(
9696
// When using synthetic source, the translog operation must always be reindexed into an in-memory Lucene to ensure consistent
9797
// output for realtime-get operations. However, this can degrade the performance of realtime-get and update operations.
9898
// If slight inconsistencies in realtime-get operations are acceptable, the translog operation can be reindexed lazily.
99-
if (mappingLookup.isSourceSynthetic()) {
99+
if (mappingLookup.isSourceSynthetic() || mappingLookup.inferenceFields().isEmpty() == false) {
100100
onSegmentCreated.run();
101101
leafReader = createInMemoryReader(shardId, engineConfig, directory, documentParser, mappingLookup, false, operation);
102102
} else {

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public boolean assertSameIndexOperation(Translog.Index o1, Translog.Index o2) th
3838
if (super.assertSameIndexOperation(o1, o2)) {
3939
return true;
4040
}
41-
if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()) {
41+
if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()
42+
|| engineConfig.getMapperService().mappingLookup().inferenceFields().isEmpty() == false) {
4243
return super.assertSameIndexOperation(synthesizeSource(engineConfig, o1), o2)
4344
|| super.assertSameIndexOperation(o1, synthesizeSource(engineConfig, o2));
4445
}
@@ -60,26 +61,42 @@ static Translog.Index synthesizeSource(EngineConfig engineConfig, Translog.Index
6061
TrivialQueryCachingPolicy.NEVER,
6162
() -> {}
6263
);
63-
try (
64-
LuceneSyntheticSourceChangesSnapshot snapshot = new LuceneSyntheticSourceChangesSnapshot(
65-
engineConfig.getMapperService(),
66-
searcher,
67-
LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE,
68-
Integer.MAX_VALUE,
69-
op.seqNo(),
70-
op.seqNo(),
71-
true,
72-
false,
73-
engineConfig.getIndexSettings().getIndexVersionCreated()
74-
)
75-
) {
64+
try (var snapshot = newSnapshot(engineConfig, op, searcher);) {
7665
final Translog.Operation normalized = snapshot.next();
7766
assert normalized != null : "expected one operation; got zero";
7867
return (Translog.Index) normalized;
7968
}
8069
}
8170
}
8271

72+
static Translog.Snapshot newSnapshot(EngineConfig engineConfig, Translog.Index op, Engine.Searcher searcher) throws IOException {
73+
if (engineConfig.getIndexSettings().isRecoverySourceSyntheticEnabled()) {
74+
return new LuceneSyntheticSourceChangesSnapshot(
75+
engineConfig.getMapperService(),
76+
searcher,
77+
LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE,
78+
Integer.MAX_VALUE,
79+
op.seqNo(),
80+
op.seqNo(),
81+
true,
82+
false,
83+
engineConfig.getIndexSettings().getIndexVersionCreated()
84+
);
85+
} else {
86+
return new LuceneChangesSnapshot(
87+
engineConfig.getMapperService(),
88+
searcher,
89+
LuceneSyntheticSourceChangesSnapshot.DEFAULT_BATCH_SIZE,
90+
op.seqNo(),
91+
op.seqNo(),
92+
true,
93+
false,
94+
false,
95+
engineConfig.getIndexSettings().getIndexVersionCreated()
96+
);
97+
}
98+
}
99+
83100
public boolean assertSameIndexOperation(Translog.Index o1, Translog.Index o2) throws IOException {
84101
return Translog.Index.equalsWithoutAutoGeneratedTimestamp(o1, o2);
85102
}

0 commit comments

Comments
 (0)