You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/06/29 16:45:09 UTC

[GitHub] keith-turner closed pull request #539: Fix WAL race condition between zookeeper and metadata table

keith-turner closed pull request #539: Fix WAL race condition between zookeeper and metadata table
URL: https://github.com/apache/accumulo/pull/539
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 1e0ffcc7b0..508e87ef52 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -2458,11 +2458,22 @@ public void importMapFiles(long tid, Map<FileRef,MapFileInfo> fileMap, boolean s
 
   private Set<DfsLogger> currentLogs = new HashSet<>();
 
-  public synchronized void removeInUseLogs(Set<DfsLogger> candidates) {
-    // remove logs related to minor compacting data
-    candidates.removeAll(otherLogs);
-    // remove logs related to tablets in memory data
-    candidates.removeAll(currentLogs);
+  public void removeInUseLogs(Set<DfsLogger> candidates) {
+    // This lock is held while clearing otherLogs and adding a minc file to metadata table. Not
+    // holding this lock leads to a small chance of data loss if tserver dies between clearing
+    // otherLogs and adding file to metadata table AND this method was called in the time between.
+    logLock.lock();
+    try {
+      // acquire locks in same order as other places in code to avoid deadlock
+      synchronized (this) {
+        // remove logs related to minor compacting data
+        candidates.removeAll(otherLogs);
+        // remove logs related to tablets in memory data
+        candidates.removeAll(currentLogs);
+      }
+    } finally {
+      logLock.unlock();
+    }
   }
 
   Set<String> beginClearingUnusedLogs() {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services