[ 
https://issues.apache.org/jira/browse/OAK-333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13940524#comment-13940524
 ] 

Thomas Mueller commented on OAK-333:
------------------------------------

Proposed patch (excluding the test above):

{noformat}
Index: 
src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidator.java
===================================================================
--- 
src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidator.java
        (revision 1579182)
+++ 
src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/CacheInvalidator.java
        (working copy)
@@ -279,13 +279,24 @@
                 //key is referring to a split document
                 result.cacheSize++;
                 CachedNodeDocument doc = e.getValue();
+                String path;
                 if (doc == NodeDocument.NULL) {
-                     // we only need to process documents that exist
-                    continue;
+                    String id = e.getKey().toString();
+                    if (Utils.isIdFromLongPath(id)) {
+                        LOG.debug("Negative cache entry with long path {}. 
Invalidating", id);
+                        documentStore.invalidateCache(Collection.NODES, id);
+                        path = null;
+                    } else {
+                        path = Utils.getPathFromId(id);
+                    }
+                } else {
+                    path = doc.getPath();
                 }
-                String path = doc.getPath();
-                for (String name : PathUtils.elements(path)) {
-                    current = current.child(name);
+                if (path != null) {
+                    for (String name : PathUtils.elements(path)) {
+                        current = current.child(name);
+                    }
                 }
             }
             return root;
Index: src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java
===================================================================
--- src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java    
(revision 1579181)
+++ src/main/java/org/apache/jackrabbit/oak/plugins/document/util/Utils.java    
(working copy)
@@ -260,12 +260,17 @@
         }
         return true;
     }
+    
+    public static boolean isIdFromLongPath(String id) {
+        int index = id.indexOf(':');
+        return id.charAt(index + 1) == 'h';
+    }
 
     public static String getPathFromId(String id) {
-        int index = id.indexOf(':');
-        if (id.charAt(index + 1) == 'h') {
+        if (isIdFromLongPath(id)) {
             throw new IllegalArgumentException("Id is hashed: " + id);
         }
+        int index = id.indexOf(':');
         return id.substring(index + 1);
     }
{noformat}

> 1000 byte path limit in MongoMK
> -------------------------------
>
>                 Key: OAK-333
>                 URL: https://issues.apache.org/jira/browse/OAK-333
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>          Components: mongomk
>    Affects Versions: 0.5
>            Reporter: Mete Atamel
>            Assignee: Thomas Mueller
>            Priority: Minor
>             Fix For: 0.19
>
>         Attachments: NodeNameLimitsTest.java, OAK-333.patch
>
>
> In an infinite loop try to add nodes one under another to have N0/N1/N2...NN. 
> At some point, the current parent node will not be found and the current 
> commit will fail. I think this happens when the path length exceeds 1000 
> characters. Is this enough for a path? I was able to create this way only 222 
> levels in the tree (and my node names were really short N1, N2 ...)
> There's an automated tests for this: NodeExistsCommandMongoTest.testTreeDepth



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to