Browse Source

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/trunk@674932 13f79535-47bb-0310-9956-ffa450edef68

Raghu Angadi 17 years ago
parent
commit
6df28d8c53

+ 8 - 1
CHANGES.txt

@@ -785,7 +785,14 @@ Release 0.18.0 - Unreleased
 
 
     HADOOP-3691. Fix streaming and tutorial docs. (Jothi Padmanabhan via ddas)
     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
   INCOMPATIBLE CHANGES
 
 

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

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

+ 1 - 0
src/test/org/apache/hadoop/hdfs/TestFileCreationDelete.java

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