hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1212255 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
Date Fri, 09 Dec 2011 06:15:37 GMT
Author: stack
Date: Fri Dec  9 06:15:36 2011
New Revision: 1212255

URL: http://svn.apache.org/viewvc?rev=1212255&view=rev
Log:
HBASE-4987 wrong use of incarnation var in SplitLogManager

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1212255&r1=1212254&r2=1212255&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Fri Dec  9 06:15:36 2011
@@ -491,6 +491,7 @@ Release 0.92.0 - Unreleased
    HBASE-4868  TestOfflineMetaRebuildBase#testMetaRebuild occasionally fails
                (Gao Jinchao)
    HBASE-4874  Run tests with non-secure random, some tests hang otherwise (Lars H)
+   HBASE-4987  wrong use of incarnation var in SplitLogManager (Prakash Khemani)
 
   IMPROVEMENTS
    HBASE-3290  Max Compaction Size (Nicolas Spiegelberg via Stack)  

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java?rev=1212255&r1=1212254&r2=1212255&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java
Fri Dec  9 06:15:36 2011
@@ -331,22 +331,24 @@ public class SplitLogManager extends Zoo
         LOG.debug("unacquired orphan task is done " + path);
       }
     } else {
-      // if in stopTrackingTasks() we were to make tasks orphan instead of
-      // forgetting about them then we will have to handle the race when
-      // accessing task.batch here.
-      if (!task.isOrphan()) {
-        synchronized (task.batch) {
-          if (status == SUCCESS) {
-            task.batch.done++;
-          } else {
-            task.batch.error++;
-          }
-          if ((task.batch.done + task.batch.error) == task.batch.installed) {
-            task.batch.notify();
+      synchronized (task) {
+        task.deleted = true;
+        // if in stopTrackingTasks() we were to make tasks orphan instead of
+        // forgetting about them then we will have to handle the race when
+        // accessing task.batch here.
+        if (!task.isOrphan()) {
+          synchronized (task.batch) {
+            if (status == SUCCESS) {
+              task.batch.done++;
+            } else {
+              task.batch.error++;
+            }
+            if ((task.batch.done + task.batch.error) == task.batch.installed) {
+              task.batch.notify();
+            }
           }
         }
       }
-      task.deleted = true;
     }
     // delete the task node in zk. Keep trying indefinitely - its an async
     // call and no one is blocked waiting for this node to be deleted. All
@@ -593,12 +595,27 @@ public class SplitLogManager extends Zoo
    */
   private Task createTaskIfAbsent(String path, TaskBatch batch) {
     Task oldtask;
+    // batch.installed is only changed via this function and
+    // a single thread touches batch.installed.
     oldtask = tasks.putIfAbsent(path, new Task(batch));
-    if (oldtask != null && oldtask.isOrphan()) {
-        LOG.info("Previously orphan task " + path +
-            " is now being waited upon");
-        oldtask.setBatch(batch);
-        return (null);
+    if (oldtask != null) {
+      synchronized (oldtask) {
+        // new task was not used.
+        batch.installed--;
+        if (oldtask.isOrphan()) {
+          if (oldtask.deleted) {
+            // The task is already done. Do not install the batch for this
+            // task because it might be too late for setDone() to update
+            // batch.done. There is no need for the batch creator to wait for
+            // this task to complete.
+            return (null);
+          }
+          LOG.info("Previously orphan task " + path +
+              " is now being waited upon");
+          oldtask.setBatch(batch);
+          return (null);
+        }
+      }
     }
     return oldtask;
   }
@@ -741,9 +758,7 @@ public class SplitLogManager extends Zoo
       }
       this.batch = batch;
       if (batch != null) {
-        if (this.incarnation == 0) {
-          batch.installed++;
-        }
+        batch.installed++;
       }
     }
 



Mime
View raw message