You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "antonhosgood (via GitHub)" <gi...@apache.org> on 2026/03/23 09:01:07 UTC

[PR] OAK-12143 - Fix AsyncLaneSwitcher not switching lanes when async-previous pre-set [jackrabbit-oak]

antonhosgood opened a new pull request, #2812:
URL: https://github.com/apache/jackrabbit-oak/pull/2812

   Currently, `switchLane` returns early whenever `async-previous` is set, assuming the lane has already been switched. However, `async-previous` can legitimately appear in user-provided index definitions (e.g. copied from a running system), causing the switch to be skipped incorrectly and the index to be silently dropped from reindexing.
   
   The fix tightens the early-return check: only skip if `async-previous` is present and `async` already equals the target lane. If `async-previous` is present but `async` does not match the target lane, the property is treated as stale, discarded, and the switch proceeds normally.


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-12143 - Fix AsyncLaneSwitcher not switching lanes when async-previous pre-set [jackrabbit-oak]

Posted by "thomasmueller (via GitHub)" <gi...@apache.org>.
thomasmueller merged PR #2812:
URL: https://github.com/apache/jackrabbit-oak/pull/2812


-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-12143 - Fix AsyncLaneSwitcher not switching lanes when async-previous pre-set [jackrabbit-oak]

Posted by "thomasmueller (via GitHub)" <gi...@apache.org>.
thomasmueller commented on code in PR #2812:
URL: https://github.com/apache/jackrabbit-oak/pull/2812#discussion_r3009137467


##########
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:
   ```suggestion
                   // Lane already switched to the target — no-op
                   LOG.info("Index definition contains stale '{}' property (async='{}', target lane='{}') - " +
                       "retaining the old value because it matches the value", ASYNC_PREVIOUS, currentAsyncState, laneName);
                   return;
   ```



-- 
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] OAK-12143 - Fix AsyncLaneSwitcher not switching lanes when async-previous pre-set [jackrabbit-oak]

Posted by "antonhosgood (via GitHub)" <gi...@apache.org>.
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: oak-dev-unsubscribe@jackrabbit.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org