You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2014/07/09 12:26:32 UTC
svn commit: r1609081 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/index/
test/java/org/apache/jackrabbit/oak/plugins/index/
Author: alexparvulescu
Date: Wed Jul 9 10:26:32 2014
New Revision: 1609081
URL: http://svn.apache.org/r1609081
Log:
OAK-1959 AsyncIndexUpdate unable to cope with missing checkpoint ref
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java?rev=1609081&r1=1609080&r2=1609081&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdate.java Wed Jul 9 10:26:32 2014
@@ -318,7 +318,7 @@ public class AsyncIndexUpdate implements
throws CommitFailedException {
// check for concurrent updates by this async task
NodeState async = before.getChildNode(ASYNC);
- if (Objects.equal(checkpoint, async.getString(name))
+ if (checkpoint == null || Objects.equal(checkpoint, async.getString(name))
&& lease == async.getLong(name + "-lease")) {
return after;
} else {
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java?rev=1609081&r1=1609080&r2=1609081&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/AsyncIndexUpdateTest.java Wed Jul 9 10:26:32 2014
@@ -367,6 +367,36 @@ public class AsyncIndexUpdateTest {
}
}
+ /**
+ * OAK-1959, stale ref to checkpoint thorws the indexer into a reindexing
+ * loop
+ */
+ @Test
+ public void recoverFromMissingCpRef() throws Exception {
+ MemoryNodeStore store = new MemoryNodeStore();
+ IndexEditorProvider provider = new PropertyIndexEditorProvider();
+
+ NodeBuilder builder = store.getRoot().builder();
+ createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME),
+ "rootIndex", true, false, ImmutableSet.of("foo"), null)
+ .setProperty(ASYNC_PROPERTY_NAME, "async");
+ builder.child("testRoot").setProperty("foo", "abc");
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+ new AsyncIndexUpdate("async", store, provider).run();
+ checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex",
+ INDEX_CONTENT_NODE_NAME, "abc", "testRoot");
+
+ builder = store.getRoot().builder();
+ // change cp ref to point to a non-existing one
+ builder.child(AsyncIndexUpdate.ASYNC).setProperty("async", "faulty");
+ builder.child("testAnother").setProperty("foo", "def");
+ store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
+
+ new AsyncIndexUpdate("async", store, provider).run();
+ checkPathExists(store.getRoot(), INDEX_DEFINITIONS_NAME, "rootIndex",
+ INDEX_CONTENT_NODE_NAME, "def", "testAnother");
+ }
+
@Test
public void cpCleanupNoChanges() throws Exception {
MemoryNodeStore store = new MemoryNodeStore();
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java?rev=1609081&r1=1609080&r2=1609081&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexUpdateTest.java Wed Jul 9 10:26:32 2014
@@ -240,7 +240,7 @@ public class IndexUpdateTest {
PropertyValues.newString(value)));
}
- private static NodeState checkPathExists(NodeState state, String... verify) {
+ static NodeState checkPathExists(NodeState state, String... verify) {
NodeState c = state;
for (String p : verify) {
c = c.getChildNode(p);