jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1548137 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Date Thu, 05 Dec 2013 13:51:20 GMT
Author: jukka
Date: Thu Dec  5 13:51:19 2013
New Revision: 1548137

URL: http://svn.apache.org/r1548137
Log:
OAK-593: Segment-based MK

Fix another deadlock in FileStore.close vs. the flush thread:
the flushThread.join() call must not be within a synchronized block.

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=1548137&r1=1548136&r2=1548137&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
Thu Dec  5 13:51:19 2013
@@ -152,7 +152,8 @@ public class FileStore extends AbstractS
                         try {
                             flush();
                         } catch (IOException e) {
-                            log.warn("Failed to flush TarMK state", e);
+                            log.warn("Failed to flush the TarMK at" +
+                                    FileStore.this.directory, e);
                         }
                         timeToClose.await(5, SECONDS);
                     }
@@ -193,28 +194,38 @@ public class FileStore extends AbstractS
     }
 
     @Override
-    public synchronized void close() {
+    public void close() {
         try {
-            super.close();
-
+            // avoid deadlocks while joining the flush thread
             timeToClose.countDown();
-            flushThread.join();
-            flush();
+            try {
+                flushThread.join();
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+                log.warn("Interrupted while joining the TarMK flush thread", e);
+            }
 
-            journalFile.close();
+            synchronized (this) {
+                super.close();
 
-            for (TarFile file : bulkFiles) {
-                file.close();
-            }
-            bulkFiles.clear();
-            for (TarFile file : dataFiles) {
-                file.close();
-            }
-            dataFiles.clear();
+                flush();
 
-            System.gc(); // for any memory-mappings that are no longer used
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+                journalFile.close();
+
+                for (TarFile file : bulkFiles) {
+                    file.close();
+                }
+                bulkFiles.clear();
+                for (TarFile file : dataFiles) {
+                    file.close();
+                }
+                dataFiles.clear();
+
+                System.gc(); // for any memory-mappings that are no longer used
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(
+                    "Failed to close the TarMK at " + directory, e);
         }
     }
 



Mime
View raw message