Author: mreutegg
Date: Tue Jul 25 16:12:44 2017
New Revision: 1802973
URL: http://svn.apache.org/viewvc?rev=1802973&view=rev
Log:
OAK-6495: Fallback to classic diff when journal is broken
Add ignored test
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Modified:
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1802973&r1=1802972&r2=1802973&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Tue Jul 25 16:12:44 2017
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.plugin
import static java.util.Collections.emptyList;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.jackrabbit.oak.api.CommitFailedException.CONSTRAINT;
+import static org.apache.jackrabbit.oak.plugins.document.Collection.JOURNAL;
import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
import static org.apache.jackrabbit.oak.plugins.document.Collection.SETTINGS;
import static
org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS;
@@ -29,6 +30,7 @@ import static org.apache.jackrabbit.oak.
import static
org.apache.jackrabbit.oak.plugins.document.util.Utils.isCommitted;
import static org.hamcrest.CoreMatchers.everyItem;
import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@@ -3411,6 +3413,61 @@ public class DocumentNodeStoreTest {
}
}
+ // OAK-6495
+ @Ignore("OAK-6495")
+ @Test
+ public void diffWithBrokenJournal() throws Exception {
+ Clock clock = new Clock.Virtual();
+ clock.waitUntil(System.currentTimeMillis());
+ Revision.setClock(clock);
+ MemoryDocumentStore docStore = new MemoryDocumentStore();
+ DocumentNodeStore ns = builderProvider.newBuilder()
+ .setDocumentStore(docStore).setUpdateLimit(100)
+ .setJournalGCMaxAge(TimeUnit.HOURS.toMillis(6))
+ .setBundlingDisabled(true)
+ .setAsyncDelay(0).clock(clock).getNodeStore();
+
+ NodeBuilder builder = ns.getRoot().builder();
+ builder.child("test");
+ merge(ns, builder);
+
+ NodeState before = ns.getRoot().getChildNode("test");
+
+ builder = ns.getRoot().builder();
+ NodeBuilder test = builder.child("test");
+ String firstChildId = Utils.getIdFromPath("/test/child-0");
+ for (int i = 0; ; i++) {
+ NodeBuilder child = test.child("child-" + i);
+ for (int j = 0; j < 10; j++) {
+ child.setProperty("p-" + j, "value");
+ }
+ if (docStore.find(NODES, firstChildId) != null) {
+ // branch was created
+ break;
+ }
+ }
+ merge(ns, builder);
+ ns.runBackgroundOperations();
+
+ Revision head = ns.getHeadRevision().getRevision(ns.getClusterId());
+ assertNotNull(head);
+
+ JournalEntry entry = ns.getDocumentStore().find(JOURNAL,
JournalEntry.asId(head));
+ assertNotNull(entry);
+
+ // must reference at least one branch commit
+ assertThat(Iterables.size(entry.getBranchCommits()), greaterThan(0));
+ // now remove them
+ for (JournalEntry bc : entry.getBranchCommits()) {
+ docStore.remove(JOURNAL, bc.getId());
+ }
+
+ // compare must still succeed even when branch commits
+ // are missing in the journal
+ NodeState after = ns.getRoot().getChildNode("test");
+ after.compareAgainstBaseState(before, new DefaultNodeStateDiff());
+ }
+
private static class WriteCountingStore extends MemoryDocumentStore {
private final ThreadLocal<Boolean> createMulti = new ThreadLocal<>();
int count;