Author: mreutegg Date: Wed Jul 16 15:16:48 2014 New Revision: 1611041 URL: http://svn.apache.org/r1611041 Log: OAK-1972: Async property index update may fail on DocumentMK with more than 100 index changes
Test to reproduce the issue 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=1611041&r1=1611040&r2=1611041&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 Wed Jul 16 15:16:48 2014 @@ -50,6 +50,7 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.stats.Clock; import org.junit.After; +import org.junit.Ignore; import org.junit.Test; import com.google.common.collect.Iterables; @@ -59,6 +60,7 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES; import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS; import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.MODIFIED_IN_SECS_RESOLUTION; +import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.NUM_REVS_THRESHOLD; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -507,6 +509,48 @@ public class DocumentNodeStoreTest { maxLimit.get() <= DocumentNodeState.INITIAL_FETCH_SIZE + 1); } + // OAK-1972 + @Ignore + @Test + public void readFromPreviousDoc() throws CommitFailedException { + DocumentStore docStore = new MemoryDocumentStore(); + DocumentNodeStore ns = new DocumentMK.Builder() + .setDocumentStore(docStore).getNodeStore(); + NodeBuilder builder = ns.getRoot().builder(); + builder.child("test").setProperty("prop", "initial"); + ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); + ns.dispose(); + + ns = new DocumentMK.Builder().setClusterId(2).setAsyncDelay(0) + .setDocumentStore(docStore).getNodeStore(); + builder = ns.getRoot().builder(); + builder.child("test").setProperty("prop", "value"); + ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); + + Revision rev = ns.getHeadRevision(); + NodeDocument doc = docStore.find(Collection.NODES, Utils.getIdFromPath("/test")); + assertNotNull(doc); + DocumentNodeState state = doc.getNodeAtRevision(ns, rev, null); + assertNotNull(state); + assertTrue(state.hasProperty("prop")); + assertEquals("value", state.getProperty("prop").getValue(Type.STRING)); + + for (int i = 0; i < NUM_REVS_THRESHOLD; i++) { + builder = ns.getRoot().builder(); + builder.child("test").setProperty("prop", "v-" + i); + ns.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); + } + ns.runBackgroundOperations(); + + // must still return the same value as before the split + doc = docStore.find(Collection.NODES, Utils.getIdFromPath("/test")); + assertNotNull(doc); + state = doc.getNodeAtRevision(ns, rev, null); + assertNotNull(state); + assertTrue(state.hasProperty("prop")); + assertEquals("value", state.getProperty("prop").getValue(Type.STRING)); + } + private static class TestHook extends EditorHook { TestHook(final String prefix) {