From 1a2cd965a767733a9da88cb93d5c602861fd648e Mon Sep 17 00:00:00 2001 From: fanluoo <958909146@qq.com> Date: Sat, 29 Apr 2023 19:54:56 +0800 Subject: [PATCH] HDFS-16897. Fix abundant Broken pipe exception in BlockSender (#5329). Contributed by fanluo. Signed-off-by: Ayush Saxena --- .../org/apache/hadoop/hdfs/server/datanode/BlockSender.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java index b2bc09bc39..20dd5e95ef 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockSender.java @@ -654,8 +654,12 @@ private int sendPacket(ByteBuffer pkt, int maxChunks, OutputStream out, 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);