Browse Source

HADOOP-1970. Fix deadlock in reporting progress. (Vivek Ratan via omalley)

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@581427 13f79535-47bb-0310-9956-ffa450edef68
Owen O'Malley 18 years ago
parent
commit
d62c6d024c
2 changed files with 17 additions and 5 deletions
  1. 4 1
      CHANGES.txt
  2. 13 4
      src/java/org/apache/hadoop/util/Progress.java

+ 4 - 1
CHANGES.txt

@@ -348,13 +348,16 @@ Release 0.14.2 - unreleased
 
     HADOOP-1862.  reduces are getting stuck trying to find map outputs. 
     (Arun C. Murthy via ddas)
-
+ 
     HADOOP-1977. Fixed handling of ToolBase cli options in JobClient.
     (enis via omalley)
 
     HADOOP-1972.  Fix LzoCompressor to ensure the user has actually asked
     to finish compression. (arun via omalley)
 
+    HADOOP-1970.  Fix deadlock in progress reporting in the task. (Vivek
+    Ratan via omalley)
+
 Release 0.14.1 - 2007-09-04
 
   BUG FIXES

+ 13 - 4
src/java/org/apache/hadoop/util/Progress.java

@@ -64,10 +64,19 @@ public class Progress {
   }
 
   /** Completes this node, moving the parent node to its next child. */
-  public synchronized void complete() {
-    progress = 1.0f;
-    if (parent != null) {
-      parent.startNextPhase();
+  public void complete() {
+    // we have to traverse up to our parent, so be careful about locking.
+    Progress myParent;
+    synchronized(this) {
+      progress = 1.0f;
+      myParent = parent;
+    }
+    if (myParent != null) {
+      // this will synchronize on the parent, so we make sure we release
+      // our lock before getting the parent's, since we're traversing 
+      // against the normal traversal direction used by get() or toString().
+      // We don't need transactional semantics, so we're OK doing this. 
+      myParent.startNextPhase();
     }
   }