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 re...@apache.org on 2018/11/16 15:33:05 UTC

svn commit: r1846721 - in /jackrabbit/oak/branches/1.8: ./ oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/ oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/

Author: reschke
Date: Fri Nov 16 15:33:05 2018
New Revision: 1846721

URL: http://svn.apache.org/viewvc?rev=1846721&view=rev
Log:
OAK-7709: DocumentNodeStore dispose aborts when store was disposed due to LeaseUpdate error (ported to 1.8)

with test case essentially disabled because it needs OAK-7626

Modified:
    jackrabbit/oak/branches/1.8/   (props changed)
    jackrabbit/oak/branches/1.8/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
    jackrabbit/oak/branches/1.8/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java

Propchange: jackrabbit/oak/branches/1.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Nov 16 15:33:05 2018
@@ -1,3 +1,3 @@
 /jackrabbit/oak/branches/1.0:1665962
-/jackrabbit/oak/trunk:1820660-1820661,1820729,1820734,1820859,1820861,1820878,1820888,1820947,1821027,1821130,1821140-1821141,1821178,1821237,1821240,1821249,1821258,1821325,1821358,1821361-1821362,1821370,1821375,1821393,1821477,1821487,1821516,1821617,1821663,1821665,1821668,1821681,1821847,1821975-1821983,1822121,1822201,1822207,1822527,1822642,1822723,1822808,1822850,1822934,1823135,1823163,1823169,1823172,1823655,1823669,1824196,1824198,1824253,1824255,1824896,1824962,1825065,1825362,1825381,1825442,1825448,1825466,1825470-1825471,1825475,1825523,1825525,1825561,1825619-1825621,1825651,1825654,1825992,1826079,1826090,1826096,1826216,1826237,1826338,1826516,1826532,1826551,1826560,1826638,1826640,1826730,1826833,1826932,1826957,1827423,1827472,1827486,1827816,1827977,1828349,1828439,1828502,1828529,1828948,1829527,1829534,1829546,1829569,1829587,1829665,1829854,1829864,1829978,1829985,1829987,1829998,1830019,1830048,1830160,1830171,1830197,1830209,1830239,1830347,1830748,1830911
 ,1830923,1831157-1831158,1831163,1831190,1831374,1831560,1831689,1832258,1832376,1832379,1832535,1833308,1833347,1833833,1834112,1834117,1834287,1834291,1834302,1834326,1834328,1834336,1834428,1834468,1834483,1834610,1834648-1834649,1834681,1834823,1834857-1834858,1835060,1835518,1835521,1835635,1835642,1835780,1835819,1836082,1836121,1836167-1836168,1836170-1836187,1836189-1836196,1836206,1836487,1836493,1837057,1837274,1837296,1837326,1837475,1837503,1837547,1837569,1837600,1837657,1837718,1837998,1838076,1838637,1839549,1839570,1839637,1839746,1840019,1840024,1840031,1840226,1840455,1840574,1841314,1841352,1842089,1842677,1843222,1843231,1843398,1843618,1843652,1843911,1844325,1844549,1844625,1844627,1844642,1844728,1844775,1844932,1845336,1846057
+/jackrabbit/oak/trunk:1820660-1820661,1820729,1820734,1820859,1820861,1820878,1820888,1820947,1821027,1821130,1821140-1821141,1821178,1821237,1821240,1821249,1821258,1821325,1821358,1821361-1821362,1821370,1821375,1821393,1821477,1821487,1821516,1821617,1821663,1821665,1821668,1821681,1821847,1821975-1821983,1822121,1822201,1822207,1822527,1822642,1822723,1822808,1822850,1822934,1823135,1823163,1823169,1823172,1823655,1823669,1824196,1824198,1824253,1824255,1824896,1824962,1825065,1825362,1825381,1825442,1825448,1825466,1825470-1825471,1825475,1825523,1825525,1825561,1825619-1825621,1825651,1825654,1825992,1826079,1826090,1826096,1826216,1826237,1826338,1826516,1826532,1826551,1826560,1826638,1826640,1826730,1826833,1826932,1826957,1827423,1827472,1827486,1827816,1827977,1828349,1828439,1828502,1828529,1828948,1829527,1829534,1829546,1829569,1829587,1829665,1829854,1829864,1829978,1829985,1829987,1829998,1830019,1830048,1830160,1830171,1830197,1830209,1830239,1830347,1830748,1830911
 ,1830923,1831157-1831158,1831163,1831190,1831374,1831560,1831689,1832258,1832376,1832379,1832535,1833308,1833347,1833833,1834112,1834117,1834287,1834291,1834302,1834326,1834328,1834336,1834428,1834468,1834483,1834610,1834648-1834649,1834681,1834823,1834857-1834858,1835060,1835518,1835521,1835635,1835642,1835780,1835819,1836082,1836121,1836167-1836168,1836170-1836187,1836189-1836196,1836206,1836487,1836493,1837057,1837274,1837296,1837326,1837475,1837503,1837547,1837569,1837600,1837657,1837718,1837998,1838076,1838637,1839549,1839570,1839637,1839746,1840019,1840024,1840031,1840226,1840455,1840462,1840574,1841314,1841352,1842089,1842677,1843222,1843231,1843398,1843618,1843652,1843911,1844325,1844549,1844625,1844627,1844642,1844728,1844775,1844932,1845336,1846057
 /jackrabbit/trunk:1345480

Modified: jackrabbit/oak/branches/1.8/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java?rev=1846721&r1=1846720&r2=1846721&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.8/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java (original)
+++ jackrabbit/oak/branches/1.8/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java Fri Nov 16 15:33:05 2018
@@ -758,19 +758,28 @@ public final class DocumentNodeStore
                 backgroundUpdateThread,
                 backgroundSweepThread);
 
+        DocumentStoreException ex = null;
+
         // create a tombstone commit revision after isDisposed is set to true.
         // commits created earlier than this revision will be able to finish
         // and we'll get a headOfQueue() callback when they are done
         // after this call there are no more pending trunk commits and
         // the commit queue is empty and stays empty
-        Revision tombstone = commitQueue.createRevision();
-        commitQueue.done(tombstone, new CommitQueue.Callback() {
-            @Override
-            public void headOfQueue(@NotNull Revision revision) {
-                setRoot(getHeadRevision().update(revision));
-                unsavedLastRevisions.put(ROOT_PATH, revision);
+        if (!readOnlyMode) {
+            try {
+                Revision tombstone = commitQueue.createRevision();
+                commitQueue.done(tombstone, new CommitQueue.Callback() {
+                    @Override
+                    public void headOfQueue(@NotNull Revision revision) {
+                        setRoot(getHeadRevision().update(revision));
+                        unsavedLastRevisions.put(ROOT_PATH, revision);
+                    }
+                });
+            } catch (DocumentStoreException e) {
+                LOG.error("dispose: a DocumentStoreException happened during dispose's attempt to commit a tombstone: " + e, e);
+                ex = e;
             }
-        });
+        }
 
         try {
             bundlingConfigHandler.close();
@@ -778,7 +787,6 @@ public final class DocumentNodeStore
             LOG.warn("Error closing bundlingConfigHandler", bundlingConfigHandler, e);
         }
 
-        DocumentStoreException ex = null;
         // do a final round of background operations after
         // the background thread stopped
         if (!readOnlyMode) {

Modified: jackrabbit/oak/branches/1.8/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/branches/1.8/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java?rev=1846721&r1=1846720&r2=1846721&view=diff
==============================================================================
--- jackrabbit/oak/branches/1.8/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java (original)
+++ jackrabbit/oak/branches/1.8/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreTest.java Fri Nov 16 15:33:05 2018
@@ -757,6 +757,43 @@ public class DocumentNodeStoreTest {
         assertTrue(store2.getRoot().getChildNode("test").getChildNode("node").exists());
     }
 
+    // verify that the dispose method does a best effort in releasing resources (see OAK-7709)
+    @Test
+    public void disposeAfterLeaseFailure() throws Exception {
+        try {
+            final AtomicBoolean documentStoreDisposeWasReached = new AtomicBoolean(false);
+            Clock clock = new Clock.Virtual();
+            clock.waitUntil(System.currentTimeMillis());
+
+            MemoryDocumentStore docStore = new MemoryDocumentStore() {
+                @Override
+                public void dispose() {
+                    documentStoreDisposeWasReached.set(true);
+                }
+            };
+
+            DocumentNodeStore store1 = builderProvider.newBuilder().setDocumentStore(docStore).setAsyncDelay(0).clock(clock)
+                    .setClusterId(1).getNodeStore();
+
+            ClusterNodeInfo.setClock(clock);
+            // wait until lease expires
+            clock.waitUntil(clock.getTime() + store1.getClusterInfo().getLeaseTime() + 1000);
+
+            assertFalse(documentStoreDisposeWasReached.get());
+            try {
+                store1.dispose();
+                // check disabled as this branch has not strict lease failure
+                // checking mode (see OAK-7626)
+                // fail("expected lease failure exception; test setup may be incorrect");
+            } catch (DocumentStoreException expected) {
+                // due to lease update failure
+            }
+            assertTrue("The DocumentStore instance's dispose() method was not called", documentStoreDisposeWasReached.get());
+        } finally {
+            ClusterNodeInfo.resetClockToDefault();
+        }
+    }
+
     // OAK-2336
     @Test
     public void readBranchCommit() throws Exception {