diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 535f4b8e99..5aafbe622a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -754,6 +754,9 @@ Release 2.0.2-alpha - 2012-09-07 HDFS-2757. Cannot read a local block that's being written to when using the local read short circuit. (Jean-Daniel Cryans via eli) + + HDFS-3664. BlockManager race when stopping active services. + (Colin Patrick McCabe via eli) BREAKDOWN OF HDFS-3042 SUBTASKS diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index 7215aa5582..bd6a494b9f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -363,11 +363,10 @@ public void close() { replicationThread.join(3000); } } catch (InterruptedException ie) { - } finally { - if (pendingReplications != null) pendingReplications.stop(); - blocksMap.close(); - datanodeManager.close(); } + datanodeManager.close(); + pendingReplications.stop(); + blocksMap.close(); } /** @return the datanodeManager */ diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java index f7594284a4..454509936b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeManager.java @@ -192,7 +192,13 @@ void activate(final Configuration conf) { } void close() { - if (decommissionthread != null) decommissionthread.interrupt(); + if (decommissionthread != null) { + decommissionthread.interrupt(); + try { + decommissionthread.join(3000); + } catch (InterruptedException e) { + } + } heartbeatManager.close(); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/HeartbeatManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/HeartbeatManager.java index 449619ced7..3030007707 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/HeartbeatManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/HeartbeatManager.java @@ -74,6 +74,11 @@ void activate(Configuration conf) { void close() { heartbeatThread.interrupt(); + try { + // This will no effect if the thread hasn't yet been started. + heartbeatThread.join(3000); + } catch (InterruptedException e) { + } } synchronized int getLiveDatanodeCount() {