Author: mreutegg
Date: Tue May 28 12:56:55 2019
New Revision: 1860261

URL: http://svn.apache.org/viewvc?rev=1860261&view=rev
Log:
OAK-8012: Unmerged branch changes visible after restart

Merge revision 1852493 from trunk
Enable tests, including OAK-8353

Modified:
    jackrabbit/oak/branches/1.4/oak-core/   (props changed)
    
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
    
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
    
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java

Propchange: jackrabbit/oak/branches/1.4/oak-core/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May 28 12:56:55 2019
@@ -1,5 +1,5 @@
 /jackrabbit/oak/branches/1.0/oak-core:1665962
 /jackrabbit/oak/branches/1.6/oak-core:1802566,1830228
 
/jackrabbit/oak/trunk/oak-core:1733615,1733875,1733913,1733929,1734230,1734254,1734279,1734941,1735052,1735081,1735109,1735141,1735267,1735405,1735484,1735549,1735564,1735588,1735622,1735638,1735919,1735983,1736176,1737309-1737310,1737334,1737349,1737998,1738004,1738136,1738138,1738207,1738234,1738252,1738775,1738795,1738833,1738950,1738957,1738963,1739712,1739760,1739867,1739894,1739959-1739960,1740114,1740116,1740250,1740333,1740349,1740360,1740625-1740626,1740774,1740837,1740879,1740971,1741016,1741032,1741339,1741343,1742077,1742117,1742125,1742363,1742520,1742888,1742916,1743097,1743172,1743343,1743674,1744265,1744292,1744589,1744670,1744672,1744959,1745038,1745127,1745197,1745336,1745368,1746086,1746117,1746342,1746345,1746408,1746634,1746696,1746981,1747198,1747200,1747341-1747342,1747380,1747387,1747406,1747492,1747512,1747654,1748505,1748553,1748722,1748870,1749275,1749350,1749424,1749443,1749464,1749475,1749645,1749662,1749815,1749872,1749875,1749899,1750052,1750076-175007
 
7,1750287,1750457,1750462,1750465,1750495,1750626,1750656,1750809,1750886-1750887,1751396,1751410,1751419,1751445-1751446,1751478,1751748,1751753,1751755,1751871,1752198,1752202,1752259,1752273-1752274,1752283,1752292,1752438,1752447-1752448,1752508,1752596,1752616,1752659,1752672,1753262,1753331-1753332,1753335-1753336,1753355,1753444,1753481,1754117,1754239,1755157,1755191,1756505-1756506,1756520,1756580,1757119,1757166,1758213,1758713,1759433,1759754,1759795,1759826,1760326,1760340,1760373,1760387,1760486,1760492,1760494,1760661-1760662,1760677,1760701,1760709,1760946,1761412,1761444,1761571,1761762,1761787,1761866,1761876,1762453,1762463,1762612,1762632,1762635,1762825,1763347,1763355-1763356,1763378,1763465,1763735,1764475,1764678,1764705,1764814,1764898,1765817,1765983,1766071,1766390,1766423,1766496,1766519,1766554,1766644,1766836,1767025,1767265,1767502,1767704,1768446,1768637,1769078,1769939-1769940,1770694,1770982,1771022,1771093,1771098,1771739,1771852,1771870,1771902,177
 
2155,1772162,1772228,1772593,1772768,1772906,1773190,1774141,1774256,1774445,1774497,1774519,1774787,1775474,1775622,1775628,1775757,1778112,1778423,1778968,1779137,1779478,1780388,1780424,1780538,1780543,1781068,1781075,1781386,1781846,1781907,1782476,1782966,1783066,1783089,1783104-1783105,1783110,1783619,1783720,1783738,1783773,1783855,1783891,1784023,1784034,1784130,1784251,1784551,1784574,1784689,1785283,1785838,1785946,1787074,1787217,1787425,1789056,1792463,1792742,1793013,1793088,1793644,1795314,1795330,1795475,1795488,1795491,1795613,1795618,1796144,1798035,1798832,1798834,1799219,1799389,1799861,1799924,1800974,1801011,1801013,1802548,1802973,1803026,1804437,1807308,1808125,1808128,1808142,1808240,1808246,1809024,1809026,1809163,1811380,1811952,1811963,1811986,1814332,1818645,1821325,1821516,1830160
-/jackrabbit/oak/trunk/oak-store-document:1809866,1811575,1811702,1811709,1815450,1815466,1817379,1818301,1818303,1818903,1818906,1819421,1820199,1820661,1821130,1821477,1821487,1823163,1823169,1824962,1825442,1828349,1830048,1830209,1838076,1848073,1852492,1860202
+/jackrabbit/oak/trunk/oak-store-document:1809866,1811575,1811702,1811709,1815450,1815466,1817379,1818301,1818303,1818903,1818906,1819421,1820199,1820661,1821130,1821477,1821487,1823163,1823169,1824962,1825442,1828349,1830048,1830209,1838076,1848073,1852492-1852493,1860202
 /jackrabbit/trunk/oak-core:1345480

Modified: 
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java?rev=1860261&r1=1860260&r2=1860261&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
 (original)
+++ 
jackrabbit/oak/branches/1.4/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
 Tue May 28 12:56:55 2019
@@ -1860,19 +1860,25 @@ public final class NodeDocument extends
             return false;
         }
         if (Utils.isCommitted(commitValue)) {
-            if (context.getBranches().getBranch(readRevision) == null
-                    && !readRevision.isBranch()) {
+            Branch b = context.getBranches().getBranch(readRevision);
+            if (b == null) {
+                // readRevision is not from a branch commit, though it may
+                // still be a branch revision when it references the base
+                // of a new branch that has not yet been created. In that
+                // case the branch revision is equivalent with the trunk
+                // revision.
+
                 // resolve commit revision
                 revision = resolveCommitRevision(revision, commitValue);
-                // readRevision is not from a branch
                 // compare resolved revision as is
                 return !readRevision.isRevisionNewer(revision);
             } else {
-                // on same merged branch?
-                if 
(commitValue.equals(getCommitValue(readRevision.getBranchRevision().asTrunkRevision())))
 {
-                    // compare unresolved revision
-                    return !readRevision.isRevisionNewer(revision);
-                }
+                // read revision is on a branch and the change is committed
+                // get the base revision of the branch and check
+                // if change is visible from there
+                RevisionVector baseRev = 
b.getBase(readRevision.getBranchRevision());
+                revision = resolveCommitRevision(revision, commitValue);
+                return !baseRev.isRevisionNewer(revision);
             }
         } else {
             // branch commit (not merged)
@@ -1883,9 +1889,23 @@ public final class NodeDocument extends
                 // this is an unmerged branch commit from another cluster node,
                 // hence never visible to us
                 return false;
+            } else {
+                // unmerged branch change with local clusterId
+                Branch b = context.getBranches().getBranch(readRevision);
+                if (b == null) {
+                    // reading on trunk never sees changes on an unmerged 
branch
+                    return false;
+                } else if (b.containsCommit(revision)) {
+                    // read revision is on the same branch as the
+                    // unmerged branch changes -> compare revisions as is
+                    return !readRevision.isRevisionNewer(revision);
+                } else {
+                    // read revision is on a different branch than the
+                    // unmerged branch changes -> never visible
+                    return false;
+                }
             }
         }
-        return includeRevision(context, resolveCommitRevision(revision, 
commitValue), readRevision);
     }
 
     /**
@@ -1909,37 +1929,6 @@ public final class NodeDocument extends
         return value;
     }
 
-    private static boolean includeRevision(RevisionContext context,
-                                           Revision x,
-                                           RevisionVector readRevision) {
-        Branch b = null;
-        if (x.getClusterId() == context.getClusterId()) {
-            RevisionVector branchRev = new 
RevisionVector(x).asBranchRevision(context.getClusterId());
-            b = context.getBranches().getBranch(branchRev);
-        }
-        if (b != null) {
-            // only include if read revision is also a branch revision
-            // with a history including x
-            if (readRevision.isBranch()
-                    && b.containsCommit(readRevision.getBranchRevision())) {
-                // in same branch, include if the same revision or
-                // readRevision is newer
-                return !readRevision.isRevisionNewer(x);
-            }
-            // not part of branch identified by requestedRevision
-            return false;
-        }
-        // assert: x is not a branch commit
-        b = context.getBranches().getBranch(readRevision);
-        if (b != null) {
-            // reset readRevision to branch base revision to make
-            // sure we don't include revisions committed after branch
-            // was created
-            readRevision = b.getBase(readRevision.getBranchRevision());
-        }
-        return !readRevision.isRevisionNewer(x);
-    }
-
     /**
      * Get the latest property value smaller or equal the readRevision 
revision.
      *

Modified: 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java?rev=1860261&r1=1860260&r2=1860261&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
 (original)
+++ 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BranchTest.java
 Tue May 28 12:56:55 2019
@@ -22,7 +22,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -76,7 +75,6 @@ public class BranchTest {
         assertModifiedPaths(b.getModifiedPathsUntil(c5));
     }
 
-    @Ignore("OAK-8012")
     @Test
     public void orphanedBranchTest() {
         String rootId = Utils.getIdFromPath("/");

Modified: 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
URL: 
http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java?rev=1860261&r1=1860260&r2=1860261&view=diff
==============================================================================
--- 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
 (original)
+++ 
jackrabbit/oak/branches/1.4/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/OrphanedBranchCleanupTest.java
 Tue May 28 12:56:55 2019
@@ -30,7 +30,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
 import org.apache.jackrabbit.oak.plugins.document.util.Utils;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -47,7 +46,6 @@ public class OrphanedBranchCleanupTest {
     private ExecutorService executorService = 
Executors.newSingleThreadExecutor();
 
     // OAK-8012 / OAK-8353
-    @Ignore("OAK-8353")
     @Test
     public void orphanedBranchRace() throws Exception {
         final Semaphore branchCleanupInProgress = new Semaphore(0);


Reply via email to