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 to...@apache.org on 2017/06/15 13:18:55 UTC
svn commit: r1798832 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Author: tomekr
Date: Thu Jun 15 13:18:55 2017
New Revision: 1798832
URL: http://svn.apache.org/viewvc?rev=1798832&view=rev
Log:
OAK-6294: The "missing" node cache value breaks the DocumentNodeStore#applyChanges
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1798832&r1=1798831&r2=1798832&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Thu Jun 15 13:18:55 2017
@@ -1385,8 +1385,19 @@ public final class DocumentNodeStore
int depth = PathUtils.getDepth(path);
for (int i = 1; i <= depth && beforeState != null; i++) {
String p = PathUtils.getAncestorPath(path, depth - i);
- PathRev key = new PathRev(p, beforeState.getLastRevision());
+ RevisionVector lastRev = beforeState.getLastRevision();
+ PathRev key = new PathRev(p, lastRev);
beforeState = nodeCache.getIfPresent(key);
+ if (missing.equals(beforeState)) {
+ // This is unexpected. The before state should exist.
+ // Invalidate the relevant cache entries. (OAK-6294)
+ LOG.warn("Before state is missing {}. Invalidating " +
+ "affected cache entries.", key.asString());
+ store.invalidateCache(NODES, Utils.getIdFromPath(p));
+ nodeCache.invalidate(key);
+ nodeChildrenCache.invalidate(childNodeCacheKey(path, lastRev, null));
+ beforeState = null;
+ }
}
DocumentNodeState.Children children = null;
if (beforeState != null) {
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=1798832&r1=1798831&r2=1798832&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 Thu Jun 15 13:18:55 2017
@@ -16,6 +16,7 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+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.NODES;
@@ -3058,6 +3059,25 @@ public class DocumentNodeStoreTest {
}
}
+ // OAK-6294
+ @Test
+ public void missingLastRevInApplyChanges() throws CommitFailedException {
+ DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore();
+ DocumentNodeState root = ns.getRoot();
+
+ RevisionVector before = root.getLastRevision();
+ Revision rev = ns.newRevision();
+ RevisionVector after = new RevisionVector(ns.newRevision());
+
+ String path = "/foo";
+ ns.getNode(path, before);
+ assertNotNull(ns.getNodeCache().getIfPresent(new PathRev(path, before)));
+
+ ns.applyChanges(before, after, rev, path, false,
+ emptyList(), emptyList(), emptyList());
+ assertNull(ns.getNodeCache().getIfPresent(new PathRev(path, before)));
+ }
+
private static class WriteCountingStore extends MemoryDocumentStore {
private final ThreadLocal<Boolean> createMulti = new ThreadLocal<>();
int count;