Author: catholicon
Date: Wed Jul 27 11:10:23 2016
New Revision: 1754243
URL: http://svn.apache.org/viewvc?rev=1754243&view=rev
Log:
OAK-4600: Node children cache shouldn't get duplicated entries with differing
branch flags for branch commits (backport r1754239 from trunk)
Also fix the issue (which was already fixed on trunk)
OAK-4601: Node cache shouldn't get duplicated entries with differing branch
flags for branch commits (backport r1754117 from turnk)
Although, there wasn't any valid issue identified... adding test case
nonetheless
Modified:
jackrabbit/oak/branches/1.4/ (props changed)
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Propchange: jackrabbit/oak/branches/1.4/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 27 11:10:23 2016
@@ -1,3 +1,3 @@
/jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625-1740626,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342,1746345,1746696,1746981,1747341-1747342,1747492,1747512,1748505,1748553,1748722,1748870,1749275,1749350,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750076-1750077,1750287,1750457,1750465,1750495,1750626,1750809,1751410,1751478,1751755,1751871,1752273-1752274,1752438,1752447,1752508,1752616,1752659,1752672,1753262,1753444
+/jackrabbit/oak/trunk:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738775,1738795,1738833,1738950,1738957,1738963,1739894,1740116,1740625-1740626,1740971,1741032,1741339,1741343,1742520,1742888,1742916,1743097,1743172,1743343,1744265,1744959,1745038,1745197,1745368,1746086,1746117,1746342,1746345,1746696,1746981,1747341-1747342,1747492,1747512,1748505,1748553,1748722,1748870,1749275,1749350,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750076-1750077,1750287,1750457,1750465,1750495,1750626,1750809,1751410,1751478,1751755,1751871,1752273-1752274,1752438,1752447,1752508,1752616,1752659,1752672,1753262,1753444,1754117,1754239
/jackrabbit/trunk:1345480
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java?rev=1754243&r1=1754242&r2=1754243&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/Commit.java
Wed Jul 27 11:10:23 2016
@@ -652,7 +652,9 @@ public class Commit {
}
list.add(p);
}
- RevisionVector after = before.update(revision);
+ // the commit revision with branch flag if this is a branch commit
+ Revision rev = isBranchCommit ? revision.asBranchRevision() : revision;
+ RevisionVector after = before.update(rev);
DiffCache.Entry cacheEntry = nodeStore.getDiffCache().newEntry(before,
after, true);
LastRevTracker tracker = nodeStore.createTracker(revision,
isBranchCommit);
List<String> added = new ArrayList<String>();
Modified:
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1754243&r1=1754242&r2=1754243&view=diff
==============================================================================
---
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
(original)
+++
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
Wed Jul 27 11:10:23 2016
@@ -2580,6 +2580,49 @@ public class DocumentNodeStoreTest {
assertTrue(diff.modified.contains("/parent/node-x/child"));
}
+ // OAK-4600
+ @Test
+ public void nodeChildrenCacheForBranchCommit() throws Exception {
+ DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore();
+
+ NodeBuilder b1 = ns.getRoot().builder();
+
+ //this would push children cache entries as childX->subChildX
+ for (int i = 0; i < DocumentRootBuilder.UPDATE_LIMIT + 1; i++) {
+ b1.child("child" + i).child("subChild" + i);
+ }
+
+ //The fetch would happen on "br" format of revision
+ for (int i = 0; i < DocumentRootBuilder.UPDATE_LIMIT + 1; i++) {
+ Iterables.size(b1.getChildNode("child" + i).getChildNodeNames());
+ }
+
+ //must not have duplicated cache entries
+ assertTrue(ns.getNodeChildrenCacheStats().getElementCount() <
2*DocumentRootBuilder.UPDATE_LIMIT);
+ }
+
+ // OAK-4601
+ @Test
+ public void nodeCacheForBranchCommit() throws Exception {
+ DocumentNodeStore ns = builderProvider.newBuilder().getNodeStore();
+
+ NodeBuilder b1 = ns.getRoot().builder();
+
+ final int NUM_CHILDREN = 3*DocumentRootBuilder.UPDATE_LIMIT + 1;
+ //this would push node cache entries for children
+ for (int i = 0; i < NUM_CHILDREN; i++) {
+ b1.child("child" + i);
+ }
+
+ //this would push cache entries
+ for (int i = 0; i < NUM_CHILDREN; i++) {
+ b1.getChildNode("child" + i);
+ }
+
+ //must not have duplicated cache entries
+ assertTrue(ns.getNodeCacheStats().getElementCount() < 2*NUM_CHILDREN);
+ }
+
@Test
public void lastRevWithRevisionVector() throws Exception {
MemoryDocumentStore store = new MemoryDocumentStore();