Przeglądaj źródła

HADOOP-3681. DFSClient can get into an infinite loop while closing
a file if there are some errors. (Lohit Vijayarenu via rangadi)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.18@674931 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 17 lat temu
rodzic
commit
a57c89589f

+ 8 - 1
CHANGES.txt

@@ -734,7 +734,14 @@ Release 0.18.0 - Unreleased
 
     HADOOP-3691. Fix streaming and tutorial docs. (Jothi Padmanabhan via ddas)
 
-Release 0.17.1 - Unreleased
+Release 0.17.2 - Unreleased
+
+  BUG FIXES
+
+    HADOOP-3681. DFSClient can get into an infinite loop while closing
+    a file if there are some errors. (Lohit Vijayarenu via rangadi)
+
+Release 0.17.1 - 2008-06-23
 
   INCOMPATIBLE CHANGES
 

+ 9 - 2
src/hdfs/org/apache/hadoop/dfs/DFSClient.java

@@ -1948,8 +1948,9 @@ class DFSClient implements FSConstants {
                           " offsetInBlock:" + one.offsetInBlock + 
                           " lastPacketInBlock:" + one.lastPacketInBlock);
               }
-            } catch (IOException e) {
-              LOG.warn("DataStreamer Exception: " + e);
+            } catch (Throwable e) {
+              LOG.warn("DataStreamer Exception: " + 
+                       StringUtils.stringifyException(e));
               hasError = true;
             }
           }
@@ -2698,6 +2699,7 @@ class DFSClient implements FSConstants {
           }
 
         flushInternal();             // flush all data to Datanodes
+        isClosed();
         closed = true;
 
         closeThreads();
@@ -2720,6 +2722,8 @@ class DFSClient implements FSConstants {
 
         long localstart = System.currentTimeMillis();
         boolean fileComplete = false;
+        int fileCompleteRetry = 0;
+        final int checkFileCompleteRetry = 10;
         while (!fileComplete) {
           fileComplete = namenode.complete(src, clientName);
           if (!fileComplete) {
@@ -2730,6 +2734,9 @@ class DFSClient implements FSConstants {
               }
             } catch (InterruptedException ie) {
             }
+            // after retrying for checkFileCompleteRetry times check isClosed() 
+            if ((++fileCompleteRetry % checkFileCompleteRetry) == 0) 
+              isClosed();
           }
         }
       } finally {

+ 2 - 1
src/test/org/apache/hadoop/dfs/TestFileCreationDelete.java

@@ -88,7 +88,8 @@ public class TestFileCreationDelete extends junit.framework.TestCase {
       assertTrue(!fs.exists(file1));
       assertTrue(fs.exists(file2));
     } finally {
+      fs.close();
       cluster.shutdown();
     }
   }
-}
+}