Przeglądaj źródła

HADOOP-1046 - clean up tmp files belonging to stale incomplete blocks.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@513652 13f79535-47bb-0310-9956-ffa450edef68
Andrzej Bialecki 18 lat temu
rodzic
commit
65aec0b145
2 zmienionych plików z 11 dodań i 0 usunięć
  1. 1 0
      CHANGES.txt
  2. 10 0
      src/java/org/apache/hadoop/dfs/FSDataset.java

+ 1 - 0
CHANGES.txt

@@ -177,6 +177,7 @@ Trunk (unreleased changes)
 53. HADOOP-1037.  Fix bin/slaves.sh, which currently only works with
     /bin/bash, to specify /bin/bash rather than /bin/sh.  (cutting)
 
+54. HADOOP-1046. Clean up tmp from partially received stale block files. (ab)
 
 Release 0.11.2 - 2007-02-16
 

+ 10 - 0
src/java/org/apache/hadoop/dfs/FSDataset.java

@@ -435,8 +435,18 @@ class FSDataset implements FSConstants {
             // Is it already in the create process?
             //
             if (ongoingCreates.containsKey(b)) {
+              // check how old is the temp file - wait 1 hour
+              File tmp = (File)ongoingCreates.get(b);
+              if ((System.currentTimeMillis() - tmp.lastModified()) < 3600 * 1000) {
                 throw new IOException("Block " + b +
                     " has already been started (though not completed), and thus cannot be created.");
+              } else {
+                // stale temp file - remove
+                if (!tmp.delete()) {
+                  throw new IOException("Can't write the block - unable to remove stale temp file " + tmp);
+                }
+                ongoingCreates.remove(b);
+              }
             }
             FSVolume v = null;
             synchronized ( volumes ) {