Author: catholicon
Date: Wed Dec  5 14:24:37 2018
New Revision: 1848217

URL: http://svn.apache.org/viewvc?rev=1848217&view=rev
Log:
OAK-7929: Incorrect Facet Count With Large Dataset and ACLs

While backporting to 1.6 branch there were test failure due to missing
code paths added during hybridV2 implementation (1.8). Changed random
seed injection slightly to make it compatible with 1.6 branch as well.

Modified:
    
jackrabbit/oak/trunk/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextIndexEditorContext.java

Modified: 
jackrabbit/oak/trunk/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextIndexEditorContext.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextIndexEditorContext.java?rev=1848217&r1=1848216&r2=1848217&view=diff
==============================================================================
--- 
jackrabbit/oak/trunk/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextIndexEditorContext.java
 (original)
+++ 
jackrabbit/oak/trunk/oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/editor/FulltextIndexEditorContext.java
 Wed Dec  5 14:24:37 2018
@@ -251,40 +251,41 @@ public abstract class FulltextIndexEdito
 
   private IndexDefinition createIndexDefinition(NodeState root, NodeBuilder 
definition, IndexingContext
       indexingContext, boolean asyncIndexing) {
-
-    // A good time to check and see if we want to inject our random
-    // seed - required due to OAK-7929 but could be useful otherwise too.
-    Long defRandom = 
getLongPropertyOrNull(definition.getProperty(PROP_RANDOM_SEED));
-    if (defRandom == null) {
-      long seed = UUID.randomUUID().getMostSignificantBits();
-      definition.setProperty(PROP_RANDOM_SEED, seed);
-      defRandom = seed;
-    }
-
     NodeState defnState = definition.getBaseState();
-    if (asyncIndexing && !IndexDefinition.isDisableStoredIndexDefinition()){
-      if (definition.getBoolean(PROP_REFRESH_DEFN)){
-        definition.removeProperty(PROP_REFRESH_DEFN);
-        NodeState clonedState = NodeStateCloner.cloneVisibleState(defnState);
-        definition.setChildNode(INDEX_DEFINITION_NODE, clonedState);
-        log.info("Refreshed the index definition for [{}]", 
indexingContext.getIndexPath());
-        if (log.isDebugEnabled()){
-          log.debug("Updated index definition is {}", 
NodeStateUtils.toString(clonedState));
-        }
-      } else if (!definition.hasChildNode(INDEX_DEFINITION_NODE)){
-        definition.setChildNode(INDEX_DEFINITION_NODE, 
NodeStateCloner.cloneVisibleState(defnState));
-        log.info("Stored the cloned index definition for [{}]. Changes in 
index definition would now only be " +
-            "effective post reindexing", indexingContext.getIndexPath());
-      } else {
-        // This is neither reindex nor refresh. So, let's update cloned def 
with random seed
-        // if it doesn't match what's there in main definition
-        // Reindex would require another indexing cycle to update cloned def.
-        // Refresh would anyway is going to do a real clone so that's ok
-        NodeState clonedState = defnState.getChildNode(INDEX_DEFINITION_NODE);
-        Long clonedRandom = 
getLongPropertyOrNull(clonedState.getProperty(PROP_RANDOM_SEED));
+    if (asyncIndexing) {
+      // A good time to check and see if we want to inject our random
+      // seed - required due to OAK-7929 but could be useful otherwise too.
+      Long defRandom = 
getLongPropertyOrNull(definition.getProperty(PROP_RANDOM_SEED));
+      if (defRandom == null) {
+        long seed = UUID.randomUUID().getMostSignificantBits();
+        definition.setProperty(PROP_RANDOM_SEED, seed);
+        defRandom = seed;
+      }
+
+      if (!IndexDefinition.isDisableStoredIndexDefinition()) {
+        if (definition.getBoolean(PROP_REFRESH_DEFN)) {
+          definition.removeProperty(PROP_REFRESH_DEFN);
+          NodeState clonedState = NodeStateCloner.cloneVisibleState(defnState);
+          definition.setChildNode(INDEX_DEFINITION_NODE, clonedState);
+          log.info("Refreshed the index definition for [{}]", 
indexingContext.getIndexPath());
+          if (log.isDebugEnabled()) {
+            log.debug("Updated index definition is {}", 
NodeStateUtils.toString(clonedState));
+          }
+        } else if (!definition.hasChildNode(INDEX_DEFINITION_NODE)) {
+          definition.setChildNode(INDEX_DEFINITION_NODE, 
NodeStateCloner.cloneVisibleState(defnState));
+          log.info("Stored the cloned index definition for [{}]. Changes in 
index definition would now only be " +
+                  "effective post reindexing", indexingContext.getIndexPath());
+        } else {
+          // This is neither reindex nor refresh. So, let's update cloned def 
with random seed
+          // if it doesn't match what's there in main definition
+          // Reindex would require another indexing cycle to update cloned def.
+          // Refresh would anyway is going to do a real clone so that's ok
+          NodeState clonedState = 
defnState.getChildNode(INDEX_DEFINITION_NODE);
+          Long clonedRandom = 
getLongPropertyOrNull(clonedState.getProperty(PROP_RANDOM_SEED));
 
-        if (clonedRandom == null || clonedRandom != defRandom) {
-          
definition.getChildNode(INDEX_DEFINITION_NODE).setProperty(PROP_RANDOM_SEED, 
defRandom);
+          if (clonedRandom == null || clonedRandom != defRandom) {
+            
definition.getChildNode(INDEX_DEFINITION_NODE).setProperty(PROP_RANDOM_SEED, 
defRandom);
+          }
         }
       }
     }


Reply via email to