You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/11/01 06:23:47 UTC

[GitHub] [jackrabbit-oak] tihom88 opened a new pull request, #741: OAK-9980: Index Purging Logic fails when trying to delete :oak:mount-…

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

   …libs* (read-only) node under index definition for composite nodestore


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

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


[GitHub] [jackrabbit-oak] thomasmueller commented on a diff in pull request #741: OAK-9980: Index Purging Logic fails when trying to delete :oak:mount-…

Posted by GitBox <gi...@apache.org>.
thomasmueller commented on code in PR #741:
URL: https://github.com/apache/jackrabbit-oak/pull/741#discussion_r1010201797


##########
oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/Persistence.java:
##########
@@ -138,15 +140,22 @@ public static Persistence openComposite(File globalDir, File libsDir, Config con
         FileStore globalFileStore = openFileStore(globalDir, config.blobStore);
         result.fileStores.add(globalFileStore);
         SegmentNodeStore globalStore = openSegmentStore(globalFileStore);
-        NodeStore cn = new CompositeNodeStore.Builder(
+        result.compositeNodestore = new CompositeNodeStore.Builder(
                 MOUNT_INFO_PROVIDER,
                 globalStore).addMount("libs", libsStore).
                 setPartialReadOnly(true).build();
-        result.repository = openRepsitory(cn, config.indexDir);
+        result.repository = openRepsitory(result.compositeNodestore, config.indexDir);
         result.session = result.repository.login(createCredentials());
         return result;
     }
 
+    public NodeStore getCompositeNodestore() throws Exception {
+        if (compositeNodestore == null){

Review Comment:
   Nitpick: space before { is missing



##########
oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/IndexUtils.java:
##########
@@ -147,4 +155,38 @@ public static void checkLibsIsReadOnly(Persistence p) throws RepositoryException
         }
     }
 
+    public static boolean isIndexDisabledAndHiddenNodesDeleted(NodeStore store, String path) throws CommitFailedException {
+        NodeState nodeState = NodeStateUtils.getNode(store.getRoot(), path);
+        if (!nodeState.getProperty("type").getValue(Type.STRING).equals("disabled")) {

Review Comment:
   Comment: getProperty could return null, but as this is just a test, I think it's fine and we don't need to check for null. But in production code, we would need to verify. In the test case, I actually prefer shorter / simpler code, even if it's slightly dangerous. The only problem is when someone moves the code to /src/main. What about adding a comment
   
   // could throw NPE, but we don't care as it's a test
   
   So this won't be forgotten when the code is moved



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

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


[GitHub] [jackrabbit-oak] tihom88 merged pull request #741: OAK-9980: Index Purging Logic fails when trying to delete :oak:mount-…

Posted by GitBox <gi...@apache.org>.
tihom88 merged PR #741:
URL: https://github.com/apache/jackrabbit-oak/pull/741


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

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


[GitHub] [jackrabbit-oak] fabriziofortino commented on a diff in pull request #741: OAK-9980: Index Purging Logic fails when trying to delete :oak:mount-…

Posted by GitBox <gi...@apache.org>.
fabriziofortino commented on code in PR #741:
URL: https://github.com/apache/jackrabbit-oak/pull/741#discussion_r1010213857


##########
oak-run/src/test/java/org/apache/jackrabbit/oak/indexversion/PurgeOldIndexVersionIT.java:
##########
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.indexversion;
+
+import ch.qos.logback.classic.Level;
+import org.apache.jackrabbit.oak.commons.junit.LogCustomizer;
+import org.apache.jackrabbit.oak.composite.blueGreen.IndexUtils;
+import org.apache.jackrabbit.oak.composite.blueGreen.Persistence;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
+public class PurgeOldIndexVersionIT {
+
+    private final Persistence.Config config = new Persistence.Config();
+
+    @Rule
+    public TemporaryFolder tempDir = new TemporaryFolder(new File("target"));
+
+    private File globalDir;
+    private File libsDir;
+    private File datastoreDir;
+    private File indexDir;
+    private LogCustomizer purgeOldIndexVersionLogger;
+
+    @Before
+    public void setup() {
+        purgeOldIndexVersionLogger = LogCustomizer.forLogger(PurgeOldIndexVersion.class.getName())
+                .enable(Level.INFO).contains("Found some index need to be purged over base").create();
+    }
+
+    @After
+    public void teardown() {
+        purgeOldIndexVersionLogger.finished();
+    }
+
+    @Test
+    public void test() throws Exception {
+        createFolders();
+        config.blobStore = Persistence.getFileBlobStore(datastoreDir);
+        config.indexDir = indexDir;
+        initGlobal();
+        initLibs();
+        compositeLibs();
+
+        purgeOldIndexVersionLogger.starting();
+        PurgeOldIndexVersion purgeOldIndexVersion = new PurgeOldIndexVersion();
+        Persistence p = Persistence.openComposite(globalDir, libsDir, config);
+        NodeStore n = p.getCompositeNodestore();
+        purgeOldIndexVersion.execute(n, true, 1, Arrays.asList("/oak:index"));
+
+        String purgeLog = "Found some index need to be purged over base'/oak:index/test':" +
+                " '[/oak:index/test-1 base=/oak:index/test versioned product=1 custom=0 operation:DELETE_HIDDEN_AND_DISABLE]'";
+        Assert.assertEquals(1, purgeOldIndexVersionLogger.getLogs().size());
+        Assert.assertEquals(purgeLog, purgeOldIndexVersionLogger.getLogs().get(0).toString());

Review Comment:
   no need to call toString here
   ```suggestion
           Assert.assertEquals(purgeLog, purgeOldIndexVersionLogger.getLogs().get(0));
   ```



##########
oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/Persistence.java:
##########
@@ -138,15 +140,22 @@ public static Persistence openComposite(File globalDir, File libsDir, Config con
         FileStore globalFileStore = openFileStore(globalDir, config.blobStore);
         result.fileStores.add(globalFileStore);
         SegmentNodeStore globalStore = openSegmentStore(globalFileStore);
-        NodeStore cn = new CompositeNodeStore.Builder(
+        result.compositeNodestore = new CompositeNodeStore.Builder(
                 MOUNT_INFO_PROVIDER,
                 globalStore).addMount("libs", libsStore).
                 setPartialReadOnly(true).build();
-        result.repository = openRepsitory(cn, config.indexDir);
+        result.repository = openRepsitory(result.compositeNodestore, config.indexDir);
         result.session = result.repository.login(createCredentials());
         return result;
     }
 
+    public NodeStore getCompositeNodestore() throws Exception {
+        if (compositeNodestore == null){
+            throw new Exception("persistence object was not opened in composite mode");

Review Comment:
   would it be better to throw an `IllegalStateException` here?



##########
oak-lucene/src/test/java/org/apache/jackrabbit/oak/composite/blueGreen/IndexUtils.java:
##########
@@ -147,4 +155,38 @@ public static void checkLibsIsReadOnly(Persistence p) throws RepositoryException
         }
     }
 
+    public static boolean isIndexDisabledAndHiddenNodesDeleted(NodeStore store, String path) throws CommitFailedException {

Review Comment:
   `CommitFailedException` is not thrown here. Please remove it.



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

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