fabriziofortino commented on code in PR #2173:
URL: https://github.com/apache/jackrabbit-oak/pull/2173#discussion_r1995777093
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java:
##########
@@ -200,6 +208,21 @@ void switchLanes() throws CommitFailedException {
if (!indexInfo.newIndex) {
NodeBuilder idxBuilder =
NodeStoreUtils.childBuilder(builder, indexInfo.indexPath);
indexPathsToUpdate.add(indexInfo.indexPath);
+ String idxBuilderType =
idxBuilder.getString(TYPE_PROPERTY_NAME);
+
+ // check if provided index definitions is of different
type than existing one
+ if (idxBuilderType != null &&
+ !idxBuilderType.equals(indexInfo.type)) {
+
+ LOG.info("Provided index [{}] has a different type
compared to the existing index." +
+ " Using lane from the index definition
provided", indexInfo.indexPath);
+
+ List<String> asyncLaneList =
indexInfo.type.equals(TYPE_ELASTICSEARCH) ?
+ List.of(indexInfo.asyncLaneName) :
List.of(indexInfo.asyncLaneName, INDEXING_MODE_NRT);
Review Comment:
I don't think this is always correct. When the provided index is not of type
`elasticsearch`, we are always adding `nrt`. This is wrong when we would
convert an elasticsearch to lucene that does not need to be `nrt`.
As an example, try to change the unit test at line 173 with
```
builder.child("idx-a").setProperty("async", asList("async"), Type.STRINGS);
```
I would expect the async-previous at line 188 to be `async` and not `async,
nrt`.
I think that when the index types differ, we should always use
`List.of(indexInfo.asyncLaneName)`. If we want to make sure that this logic is
executed only when there is a conversion from lucene to elastic or viceversa,
we can check that at least one of the types (provided or existing) is
elasticsearch and completely skip this logic.
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/IndexImporter.java:
##########
@@ -200,6 +208,21 @@ void switchLanes() throws CommitFailedException {
if (!indexInfo.newIndex) {
NodeBuilder idxBuilder =
NodeStoreUtils.childBuilder(builder, indexInfo.indexPath);
indexPathsToUpdate.add(indexInfo.indexPath);
+ String idxBuilderType =
idxBuilder.getString(TYPE_PROPERTY_NAME);
+
+ // check if provided index definitions is of different
type than existing one
+ if (idxBuilderType != null &&
+ !idxBuilderType.equals(indexInfo.type)) {
+
+ LOG.info("Provided index [{}] has a different type
compared to the existing index." +
+ " Using lane from the index definition
provided", indexInfo.indexPath);
Review Comment:
I would improve this message:
```suggestion
LOG.info("Provided index [{}] has a different type
[{}] compared to the existing index [{}]." +
" Using lane from the index definition
provided", indexInfo.indexPath, indexInfo.type, idxBuilderType);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]