antonhosgood commented on code in PR #2812:
URL: https://github.com/apache/jackrabbit-oak/pull/2812#discussion_r3009222115


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/importer/AsyncLaneSwitcher.java:
##########
@@ -52,17 +56,33 @@ public class AsyncLaneSwitcher {
     private static final String TEMP_LANE_PREFIX = "temp-";
 
     /**
-     * Make a copy of current async value and replace it with one required for 
offline reindexing
-     * The switch lane operation can be safely repeated and if the index
-     * lane is found to be switched already it would not be modified
+     * Make a copy of current async value and replace it with one required for 
offline reindexing.
+     * The switch lane operation can be safely repeated: if the index lane is 
already set to the
+     * target lane, the call is a no-op.
+     * <p>
+     * If {@code async-previous} is present but {@code async} does not already 
equal
+     * {@code laneName}, the property is treated as stale (e.g. copied from a 
running system
+     * into a user-provided index definition). In that case the stale value is 
discarded and
+     * the switch proceeds normally so the index is not silently skipped 
during reindexing.
+     * If {@code async-previous} is missing, then the switch to the temporary 
lane required for
+     * offline reindexing has not yet happened and will be carried out.
      */
     public static void switchLane(NodeBuilder idxBuilder, String laneName) {
         PropertyState currentAsyncState = 
idxBuilder.getProperty(ASYNC_PROPERTY_NAME);
         PropertyState newAsyncState = 
PropertyStates.createProperty(ASYNC_PROPERTY_NAME, laneName, Type.STRING);
 
-        if (idxBuilder.hasProperty(ASYNC_PREVIOUS)){
-            //Lane already switched
-            return;
+        if (idxBuilder.hasProperty(ASYNC_PREVIOUS)) {
+            if (currentAsyncState != null
+                    && !currentAsyncState.isArray()
+                    && 
laneName.equals(currentAsyncState.getValue(Type.STRING))) {
+                // Lane already switched to the target — no-op
+                return;

Review Comment:
   Added a similar comment - in this case, the property is not necessarily 
stale.



-- 
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]

Reply via email to