stefan-egli commented on code in PR #1779:
URL: https://github.com/apache/jackrabbit-oak/pull/1779#discussion_r1829546975


##########
oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreIT.java:
##########
@@ -188,6 +196,255 @@ public void blockingBlob() throws Exception {
         }
     }
 
+    /**
+     * OAK-11184 : a cluster node A is merging a change on root. That involves 
two
+     * updates : the first one writing the changes. The second one updating the
+     * commit root (with a revisions=c). If a cluster node B reads the root 
while
+     * the commit root was not yet updated, it has to read previous documents 
as
+     * part resolving the value of a property in getNodeAtRevision. Only to 
find
+     * that the new property does not exist in any previous document and is 
thus
+     * non-existent. Cluster node B will have to repeat going through
+     * previous documents whenever reading root - until B is
+     * able to do a backgroundRead. The backgroundRead however could be 
blocked by a
+     * number of merge operations - as those merge operations acquire the
+     * backgroundOperationLock - and backgroundRead wants that lock 
exclusively.
+     *
+     * The test reproduces only part one of the above (expensiveness of reading
+     * not-yet-visible property of a document with many previous documents).
+     */
+    @Test
+    public void unmergedCommitOnRoot_withPrevNoPropCache() throws Exception {
+        doUnmergedCommitOnRoot(true);
+    }
+
+    /**
+     * This variant tests without the case and is thus expected to fail with
+     * an AssertionError
+     */
+    @Test(expected = AssertionError.class)
+    public void unmergedCommitOnRoot_withoutPrevNoPropCache() throws Exception 
{
+        doUnmergedCommitOnRoot(false);
+    }
+
+    private void doUnmergedCommitOnRoot(boolean prevNoPropCacheEnabled) throws 
Exception {
+        Clock clock = new Clock.Virtual();
+        clock.waitUntil(System.currentTimeMillis());
+        Revision.setClock(clock);
+        ClusterNodeInfo.setClock(clock);
+
+        FailingDocumentStore fs1 = new FailingDocumentStore(ds);
+        PausableDocumentStore store1 = new PausableDocumentStore(fs1);
+        DocumentNodeStore ns1 = 
builderProvider.newBuilder().setClusterId(1).setAsyncDelay(0).clock(clock)
+                
.setPrevNoPropCacheFeature(createFeature(prevNoPropCacheEnabled))
+                .setDocumentStore(store1).build();
+
+        NodeBuilder b1 = ns1.getRoot().builder();
+        b1.setProperty("prop", -1);
+        ns1.merge(b1, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+        // create MANY previous docs
+        System.out.println(new Date() + " - creating MANY previous docs...");

Review Comment:
   don't like system outs? :) 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to