You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2021/08/19 14:00:38 UTC

[jackrabbit-oak] branch OAK-9540 created (now edc1113)

This is an automated email from the ASF dual-hosted git repository.

thomasm pushed a change to branch OAK-9540
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git.


      at edc1113  OAK-9540 SegmentNotFoundException in IndexDefinition.hasMatchingNodeTypeReg

This branch includes the following new commits:

     new edc1113  OAK-9540 SegmentNotFoundException in IndexDefinition.hasMatchingNodeTypeReg

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[jackrabbit-oak] 01/01: OAK-9540 SegmentNotFoundException in IndexDefinition.hasMatchingNodeTypeReg

Posted by th...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

thomasm pushed a commit to branch OAK-9540
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git

commit edc1113e3bad6a6d042c5ef05ba0c055f693cabb
Author: thomasm <th...@apache.org>
AuthorDate: Thu Aug 19 16:00:29 2021 +0200

    OAK-9540 SegmentNotFoundException in IndexDefinition.hasMatchingNodeTypeReg
---
 .../oak/plugins/index/lucene/IndexTracker.java           | 13 ++++++++++++-
 .../oak/plugins/index/search/IndexDefinition.java        | 16 +++++++++++++---
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java
index 5e05fae..a65824d 100644
--- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java
+++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexTracker.java
@@ -65,6 +65,11 @@ import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE
  */
 public class IndexTracker {
 
+    // auto-refresh every hour
+    private static final long AUTO_REFRESH_MILLIS = Long.getLong(
+            "oak.indexTracker.autoRefresh",
+            60 * 60 * 1000);
+
     /** Logger instance. */
     private static final Logger log = LoggerFactory.getLogger(IndexTracker.class);
     private static final PerfLogger PERF_LOGGER =
@@ -81,6 +86,7 @@ public class IndexTracker {
     private volatile Map<String, LuceneIndexNodeManager> indices = emptyMap();
 
     private volatile boolean refresh;
+    private volatile long nextAutoRefresh = System.currentTimeMillis() + AUTO_REFRESH_MILLIS;
 
     public IndexTracker() {
         this((IndexCopier)null);
@@ -98,7 +104,7 @@ public class IndexTracker {
         this.readerFactory = readerFactory;
         this.nrtFactory = nrtFactory;
     }
-    
+
     public MountInfoProvider getMountInfoProvider() {
         return readerFactory.getMountInfoProvider();
     }
@@ -124,6 +130,11 @@ public class IndexTracker {
             log.info("Refreshed the opened indexes");
         } else {
             diffAndUpdate(root);
+            long now = System.currentTimeMillis();
+            if (!refresh && now > nextAutoRefresh) {
+                refresh = true;
+                nextAutoRefresh = now + AUTO_REFRESH_MILLIS;
+            }
         }
     }
 
diff --git a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
index 21ada52..ec6bc80 100644
--- a/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
+++ b/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/IndexDefinition.java
@@ -43,6 +43,7 @@ import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
 import com.google.common.primitives.Ints;
 import org.apache.jackrabbit.JcrConstants;
+import org.apache.jackrabbit.oak.api.IllegalRepositoryStateException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
@@ -743,9 +744,18 @@ public class IndexDefinition implements Aggregate.AggregateMapper {
 
     //~---------------------------------------------------< IndexRule >
 
-    public boolean hasMatchingNodeTypeReg(NodeState root){
-        return this.root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES)
-                .equals(root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES));
+    public boolean hasMatchingNodeTypeReg(NodeState root) {
+        try {
+            return this.root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES)
+                    .equals(root.getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES));
+        } catch (IllegalRepositoryStateException e) {
+            // the root might be so old that a SegmentNotFoundException
+            // is thrown - in which case we can't be sure
+            // that the node type registry wasn't changed
+            log.warn("Possibly old root: {}", e.toString());
+            log.debug("Possibly old root", e);
+            return false;
+        }
     }