Skip to content

Commit 52b699d

Browse files
authored
Fixing indexing regression and bug fixes for grouping criteria (#20145)
Signed-off-by: RS146BIJAY <rishavsagar4b1@gmail.com>
1 parent f6c78d7 commit 52b699d

17 files changed

+716
-334
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
3131
- Fix SearchPhaseExecutionException to properly initCause ([#20320](https://github.com/opensearch-project/OpenSearch/pull/20320))
3232
- Fix `cluster.remote.<cluster_alias>.server_name` setting no populating SNI ([#20321](https://github.com/opensearch-project/OpenSearch/pull/20321))
3333
- Fix X-Opaque-Id header propagation (along with other response headers) for streaming Reactor Netty 4 transport ([#20371](https://github.com/opensearch-project/OpenSearch/pull/20371))
34+
- Fix indexing regression and bug fixes for grouping criteria. ([20145](https://github.com/opensearch-project/OpenSearch/pull/20145))
3435

3536
### Dependencies
3637
- Bump `com.google.auth:google-auth-library-oauth2-http` from 1.38.0 to 1.41.0 ([#20183](https://github.com/opensearch-project/OpenSearch/pull/20183))

server/src/main/java/org/opensearch/OpenSearchServerException.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import static org.opensearch.Version.V_2_7_0;
2525
import static org.opensearch.Version.V_3_0_0;
2626
import static org.opensearch.Version.V_3_2_0;
27-
import static org.opensearch.Version.V_3_3_0;
2827

2928
/**
3029
* Utility class to register server exceptions
@@ -1242,13 +1241,5 @@ public static void registerExceptions() {
12421241
V_3_2_0
12431242
)
12441243
);
1245-
registerExceptionHandle(
1246-
new OpenSearchExceptionHandle(
1247-
org.opensearch.index.engine.LookupMapLockAcquisitionException.class,
1248-
org.opensearch.index.engine.LookupMapLockAcquisitionException::new,
1249-
CUSTOM_ELASTICSEARCH_EXCEPTIONS_BASE_ID + 2,
1250-
V_3_3_0
1251-
)
1252-
);
12531244
}
12541245
}

server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
import org.opensearch.index.IndexingPressureService;
8888
import org.opensearch.index.SegmentReplicationPressureService;
8989
import org.opensearch.index.engine.Engine;
90-
import org.opensearch.index.engine.LookupMapLockAcquisitionException;
9190
import org.opensearch.index.engine.VersionConflictEngineException;
9291
import org.opensearch.index.get.GetResult;
9392
import org.opensearch.index.mapper.MapperException;
@@ -728,15 +727,7 @@ && isConflictException(executionResult.getFailure().getCause())
728727
&& context.getRetryCounter() < ((UpdateRequest) docWriteRequest).retryOnConflict()) {
729728
context.resetForExecutionForRetry();
730729
return;
731-
} else if (isFailed
732-
&& context.getPrimary() != null
733-
&& context.getPrimary().indexSettings() != null
734-
&& context.getPrimary().indexSettings().isContextAwareEnabled()
735-
&& isLookupMapLockAcquisitionException(executionResult.getFailure().getCause())
736-
&& context.getRetryCounter() < context.getPrimary().indexSettings().getMaxRetryOnLookupMapAcquisitionException()) {
737-
context.resetForExecutionForRetry();
738-
return;
739-
}
730+
}
740731
final BulkItemResponse response;
741732
if (isUpdate) {
742733
response = processUpdateResponse((UpdateRequest) docWriteRequest, context.getConcreteIndex(), executionResult, updateResult);
@@ -765,10 +756,6 @@ private static boolean isConflictException(final Exception e) {
765756
return ExceptionsHelper.unwrapCause(e) instanceof VersionConflictEngineException;
766757
}
767758

768-
private static boolean isLookupMapLockAcquisitionException(final Exception e) {
769-
return ExceptionsHelper.unwrapCause(e) instanceof LookupMapLockAcquisitionException;
770-
}
771-
772759
/**
773760
* Creates a new bulk item result from the given requests and result of performing the update operation on the shard.
774761
*/

server/src/main/java/org/opensearch/index/engine/CompositeIndexWriter.java

Lines changed: 135 additions & 98 deletions
Large diffs are not rendered by default.

server/src/main/java/org/opensearch/index/engine/DocumentIndexWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.Closeable;
2020
import java.io.IOException;
21+
import java.util.List;
2122
import java.util.Map;
2223

2324
/**
@@ -52,13 +53,13 @@ public interface DocumentIndexWriter extends Closeable, ReferenceManager.Refresh
5253

5354
void deleteUnusedFiles() throws IOException;
5455

55-
long addDocuments(Iterable<ParseContext.Document> docs, Term uid) throws IOException;
56+
long addDocuments(List<ParseContext.Document> docs, Term uid) throws IOException;
5657

5758
long addDocument(ParseContext.Document doc, Term uid) throws IOException;
5859

5960
void softUpdateDocuments(
6061
Term uid,
61-
Iterable<ParseContext.Document> docs,
62+
List<ParseContext.Document> docs,
6263
long version,
6364
long seqNo,
6465
long primaryTerm,

server/src/main/java/org/opensearch/index/engine/LookupMapLockAcquisitionException.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

server/src/main/java/org/opensearch/index/engine/LuceneIndexWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.opensearch.index.mapper.ParseContext;
1717

1818
import java.io.IOException;
19+
import java.util.List;
1920
import java.util.Map;
2021

2122
/**
@@ -131,7 +132,7 @@ public void deleteUnusedFiles() throws IOException {
131132
}
132133

133134
@Override
134-
public long addDocuments(Iterable<ParseContext.Document> docs, Term uid) throws IOException {
135+
public long addDocuments(final List<ParseContext.Document> docs, Term uid) throws IOException {
135136
return indexWriter.addDocuments(docs);
136137
}
137138

@@ -143,7 +144,7 @@ public long addDocument(ParseContext.Document doc, Term uid) throws IOException
143144
@Override
144145
public void softUpdateDocuments(
145146
Term uid,
146-
Iterable<ParseContext.Document> docs,
147+
List<ParseContext.Document> docs,
147148
long version,
148149
long seqNo,
149150
long primaryTerm,

server/src/main/java/org/opensearch/index/engine/NativeLuceneIndexWriterFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public IndexWriterConfig buildIndexWriterConfig() {
195195
iwc.setMergePolicy(new OpenSearchMergePolicy(mergePolicy));
196196
iwc.setSimilarity(engineConfig.getSimilarity());
197197
iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().getMbFrac());
198+
// We are setting the codec here rather than in the CodecService because each CriteriaBasedCodec requires
199+
// associatedCriteria to be attached upon creation during IndexWriter initialisation. This criteria is
200+
// determined on a per-document basis and is only available within the InternalEngine. Therefore, the codec
201+
// for the child writer is created here where the necessary criteria information is accessible
198202
if (engineConfig.getIndexSettings().isContextAwareEnabled()) {
199203
iwc.setCodec(new CriteriaBasedCodec(engineConfig.getCodec(), associatedCriteria));
200204
} else {

server/src/main/java/org/opensearch/index/mapper/ContextAwareGroupingFieldMapper.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package org.opensearch.index.mapper;
1010

11+
import org.apache.lucene.index.LeafReader;
12+
import org.opensearch.core.xcontent.XContentBuilder;
1113
import org.opensearch.script.ContextAwareGroupingScript;
1214
import org.opensearch.script.Script;
1315

@@ -181,4 +183,18 @@ public ContextAwareGroupingFieldType fieldType() {
181183
protected String contentType() {
182184
return CONTENT_TYPE;
183185
}
186+
187+
/**
188+
* Context Aware Segment field is not a part of an ingested document, so omitting it from Context Aware Segment
189+
* validation.
190+
*/
191+
@Override
192+
public void canDeriveSource() {}
193+
194+
/**
195+
* Context Aware Segment field is not a part of an ingested document, so omitting it from Context Aware Segment
196+
* generation.
197+
*/
198+
@Override
199+
public void deriveSource(XContentBuilder builder, LeafReader leafReader, int docId) throws IOException {}
184200
}

server/src/main/java/org/opensearch/index/mapper/MapperService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import java.util.function.BooleanSupplier;
8585
import java.util.function.Function;
8686
import java.util.function.Supplier;
87+
import java.util.stream.Collectors;
8788

8889
import static java.util.Collections.emptyMap;
8990
import static java.util.Collections.unmodifiableMap;
@@ -690,7 +691,9 @@ public boolean isCompositeIndexPresent() {
690691
}
691692

692693
public Set<CompositeMappedFieldType> getCompositeFieldTypes() {
693-
return compositeMappedFieldTypes;
694+
return compositeMappedFieldTypes.stream()
695+
.filter(compositeMappedFieldType -> compositeMappedFieldType instanceof CompositeDataCubeFieldType)
696+
.collect(Collectors.toSet());
694697
}
695698

696699
private Set<CompositeMappedFieldType> getCompositeFieldTypesFromMapper() {

0 commit comments

Comments
 (0)