Browse Source

HDFS-14048. DFSOutputStream close() throws exception on subsequent call after DataNode restart. Contributed by Erik Krogen.

(cherry picked from commit 887244de4adebe27693ed4ad3296a6f700cfa8c1)
Inigo Goiri 6 years ago
parent
commit
c4d390a775

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DataStreamer.java

@@ -1781,6 +1781,7 @@ class DataStreamer extends Daemon {
         blockStream = out;
         blockStream = out;
         result =  true; // success
         result =  true; // success
         errorState.resetInternalError();
         errorState.resetInternalError();
+        lastException.clear();
         // remove all restarting nodes from failed nodes list
         // remove all restarting nodes from failed nodes list
         failed.removeAll(restartingNodes);
         failed.removeAll(restartingNodes);
         restartingNodes.clear();
         restartingNodes.clear();

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestClientProtocolForPipelineRecovery.java

@@ -436,6 +436,8 @@ public class TestClientProtocolForPipelineRecovery {
           0, out.getStreamer().getPipelineRecoveryCount());
           0, out.getStreamer().getPipelineRecoveryCount());
       out.write(1);
       out.write(1);
       out.close();
       out.close();
+      // Ensure that subsequent closes are idempotent and do not throw errors
+      out.close();
     } finally {
     } finally {
       if (cluster != null) {
       if (cluster != null) {
         cluster.shutdown();
         cluster.shutdown();