From 62800dc8b60a8c09ca9a40c8498c366842466460 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Mon, 25 Jul 2016 18:41:13 -0700 Subject: [PATCH] HDFS-10688. BPServiceActor may run into a tight loop for sending block report when hitting IOException. Contributed by Chen Liang. (cherry picked from commit 0cde9e12a7175e4d8bc4ccd5c36055b280d1fbd6) (cherry picked from commit 30c772fc595b71d3b26a13bd0473570a84b5e807) --- .../hdfs/server/datanode/BPServiceActor.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java index 70004e0e72f..24b1378c1b5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/BPServiceActor.java @@ -649,19 +649,24 @@ class BPServiceActor implements Runnable { return; } LOG.warn("RemoteException in offerService", re); - try { - long sleepTime = Math.min(1000, dnConf.heartBeatInterval); - Thread.sleep(sleepTime); - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } + sleepAfterException(); } catch (IOException e) { LOG.warn("IOException in offerService", e); + sleepAfterException(); } processQueueMessages(); } // while (shouldRun()) } // offerService + private void sleepAfterException() { + try { + long sleepTime = Math.min(1000, dnConf.heartBeatInterval); + Thread.sleep(sleepTime); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } + /** * Register one bp with the corresponding NameNode *