浏览代码

HDFS-16897. Fix abundant Broken pipe exception in BlockSender (#5329). Contributed by fanluo.

Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
fanluoo 2 年之前
父节点
当前提交
408c5c53b1

+ 5 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java

@@ -653,8 +653,12 @@ class BlockSender implements java.io.Closeable {
           if (ioem.startsWith(EIO_ERROR)) {
             throw new DiskFileCorruptException("A disk IO error occurred", e);
           }
+          String causeMessage = e.getCause() != null ? e.getCause().getMessage() : "";
+          causeMessage = causeMessage != null ? causeMessage : "";
           if (!ioem.startsWith("Broken pipe")
-              && !ioem.startsWith("Connection reset")) {
+              && !ioem.startsWith("Connection reset")
+              && !causeMessage.startsWith("Broken pipe")
+              && !causeMessage.startsWith("Connection reset")) {
             LOG.error("BlockSender.sendChunks() exception: ", e);
             datanode.getBlockScanner().markSuspectBlock(
                 ris.getVolumeRef().getVolume().getStorageID(), block);