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 md...@apache.org on 2015/10/12 10:19:11 UTC

svn commit: r1708049 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java

Author: mduerig
Date: Mon Oct 12 08:19:10 2015
New Revision: 1708049

URL: http://svn.apache.org/viewvc?rev=1708049&view=rev
Log:
OAK-3493: Deadlock when closing a concurrently used FileStore 2.0
Flush outside the FileStore lock to prevent deadlock

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1708049&r1=1708048&r2=1708049&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java Mon Oct 12 08:19:10 2015
@@ -1037,12 +1037,11 @@ public class FileStore implements Segmen
         closeAndLogOnFail(compactionThread);
         closeAndLogOnFail(flushThread);
         closeAndLogOnFail(diskSpaceThread);
-        synchronized (this) {
-            try {
-                flush();
-
+        try {
+            flush();
+            tracker.getWriter().dropCache();
+            synchronized (this) {
                 closeAndLogOnFail(writer);
-                tracker.getWriter().dropCache();
 
                 List<TarReader> list = readers;
                 readers = newArrayList();
@@ -1055,10 +1054,10 @@ public class FileStore implements Segmen
                 }
                 closeAndLogOnFail(lockFile);
                 closeAndLogOnFail(journalFile);
-            } catch (IOException e) {
-                throw new RuntimeException(
-                        "Failed to close the TarMK at " + directory, e);
             }
+        } catch (IOException e) {
+            throw new RuntimeException(
+                    "Failed to close the TarMK at " + directory, e);
         }
 
         System.gc(); // for any memory-mappings that are no longer used