Browse Source

HDFS-7884. Fix NullPointerException in BlockSender when the generation stamp provided by the client is larger than the one stored in the datanode. Contributed by Brahma Reddy Battula

(cherry picked from commit fe693b72dec703ecbf4ab3919d61d06ea8735a9e)
(cherry picked from commit 4c648779d69a668f5147b183af2d40d45d1227d2)
Tsz-Wo Nicholas Sze 10 years ago
parent
commit
9b105b78d4

+ 4 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -102,6 +102,10 @@ Release 2.6.1 - UNRELEASED
 
 
     HDFS-7930. commitBlockSynchronization() does not remove locations. (yliu)
     HDFS-7930. commitBlockSynchronization() does not remove locations. (yliu)
 
 
+    HDFS-7884. Fix NullPointerException in BlockSender when the generation stamp
+    provided by the client is larger than the one stored in the datanode.
+    (Brahma Reddy Battula via szetszwo)
+
 Release 2.6.0 - 2014-11-18
 Release 2.6.0 - 2014-11-18
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 7 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java

@@ -240,6 +240,13 @@ class BlockSender implements java.io.Closeable {
       if (replica.getGenerationStamp() < block.getGenerationStamp()) {
       if (replica.getGenerationStamp() < block.getGenerationStamp()) {
         throw new IOException("Replica gen stamp < block genstamp, block="
         throw new IOException("Replica gen stamp < block genstamp, block="
             + block + ", replica=" + replica);
             + block + ", replica=" + replica);
+      } else if (replica.getGenerationStamp() > block.getGenerationStamp()) {
+        if (DataNode.LOG.isDebugEnabled()) {
+          DataNode.LOG.debug("Bumping up the client provided"
+              + " block's genstamp to latest " + replica.getGenerationStamp()
+              + " for block " + block);
+        }
+        block.setGenerationStamp(replica.getGenerationStamp());
       }
       }
       if (replicaVisibleLength < 0) {
       if (replicaVisibleLength < 0) {
         throw new IOException("Replica is not readable, block="
         throw new IOException("Replica is not readable, block="