-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAK-11594 - Converting existing indexes from a type to another leaves the async lane the same #2173
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
… the async lane the same
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -36,6 +36,7 @@ | |||||||||
import org.apache.jackrabbit.oak.plugins.index.MetricsUtils; | ||||||||||
import org.apache.jackrabbit.oak.plugins.index.importer.AsyncIndexerLock.LockToken; | ||||||||||
import org.apache.jackrabbit.oak.plugins.index.upgrade.IndexDisabler; | ||||||||||
import org.apache.jackrabbit.oak.plugins.memory.PropertyStates; | ||||||||||
import org.apache.jackrabbit.oak.spi.commit.EditorDiff; | ||||||||||
import org.apache.jackrabbit.oak.spi.commit.VisibleEditor; | ||||||||||
import org.apache.jackrabbit.oak.spi.state.NodeBuilder; | ||||||||||
|
@@ -58,6 +59,9 @@ | |||||||||
import static org.apache.jackrabbit.oak.commons.conditions.Validate.checkArgument; | ||||||||||
import static java.util.Objects.requireNonNull; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_COUNT; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEXING_MODE_NRT; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.ASYNC_PROPERTY_NAME; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.IndexUtils.INDEXING_PHASE_LOGGER; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.importer.IndexDefinitionUpdater.INDEX_DEFINITIONS_JSON; | ||||||||||
import static org.apache.jackrabbit.oak.plugins.index.importer.NodeStoreUtils.mergeWithConcurrentCheck; | ||||||||||
|
@@ -67,6 +71,10 @@ public class IndexImporter { | |||||||||
* Symbolic name use to indicate sync indexes | ||||||||||
*/ | ||||||||||
static final String ASYNC_LANE_SYNC = "sync"; | ||||||||||
/** | ||||||||||
* Symbolic name use to indicate elasticsearch index type | ||||||||||
*/ | ||||||||||
static final String TYPE_ELASTICSEARCH = "elasticsearch"; | ||||||||||
/* | ||||||||||
* System property name for flag for preserve checkpoint. If this is set to true, then checkpoint cleanup will be skipped. | ||||||||||
* Default is set to false. | ||||||||||
|
@@ -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); | ||||||||||
Comment on lines
+217
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would improve this message:
Suggested change
|
||||||||||
|
||||||||||
List<String> asyncLaneList = indexInfo.type.equals(TYPE_ELASTICSEARCH) ? | ||||||||||
List.of(indexInfo.asyncLaneName) : List.of(indexInfo.asyncLaneName, INDEXING_MODE_NRT); | ||||||||||
Comment on lines
+220
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is always correct. When the provided index is not of type As an example, try to change the unit test at line 173 with
I would expect the async-previous at line 188 to be I think that when the index types differ, we should always use |
||||||||||
|
||||||||||
PropertyState asyncProperty = PropertyStates.createProperty(ASYNC_PROPERTY_NAME, asyncLaneList, Type.STRINGS); | ||||||||||
idxBuilder.setProperty(asyncProperty); | ||||||||||
} | ||||||||||
AsyncLaneSwitcher.switchLane(idxBuilder, AsyncLaneSwitcher.getTempLaneName(indexInfo.asyncLaneName)); | ||||||||||
} | ||||||||||
} | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be replaced with
StringUtils.equals()