diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java index 36367b3905..88a8714b62 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java @@ -507,8 +507,15 @@ public void run() { } // write out data to remote datanode - blockStream.write(buf.array(), buf.position(), buf.remaining()); - blockStream.flush(); + try { + blockStream.write(buf.array(), buf.position(), buf.remaining()); + blockStream.flush(); + } catch (IOException e) { + // HDFS-3398 treat primary DN is down since client is unable to + // write to primary DN + errorIndex = 0; + throw e; + } lastPacket = System.currentTimeMillis(); if (one.isHeartbeatPacket()) { //heartbeat packet