From 3d38c1ef3ad31362b0be638fb0225b4b8c5b3d96 Mon Sep 17 00:00:00 2001 From: Vinayakumar B Date: Wed, 20 Jan 2016 21:04:21 +0530 Subject: [PATCH] HDFS-9661. Deadlock in DN.FsDatasetImpl between moveBlockAcrossStorage and createRbw (Contributed by ade) (cherry picked from commit 14255786908f991fd2022480fe5575533a3dc7ce) --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../server/datanode/fsdataset/impl/FsDatasetImpl.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 04a323f6df4..7ef5a74ebbe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1712,6 +1712,9 @@ Release 2.7.3 - UNRELEASED HDFS-9648. TestStartup.testImageChecksum is broken by HDFS-9569's message change. (Wei-Chiu Chuang via Yongjun Zhang) + HDFS-9661. Deadlock in DN.FsDatasetImpl between moveBlockAcrossStorage and + createRbw (ade via vinayakumarb) + Release 2.7.2 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java index 544169d9084..950462ac521 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java @@ -939,8 +939,11 @@ class FsDatasetImpl implements FsDatasetSpi { + replicaInfo.getVolume().getStorageType()); } - try (FsVolumeReference volumeRef = volumes.getNextVolume( - targetStorageType, block.getNumBytes())) { + FsVolumeReference volumeRef = null; + synchronized (this) { + volumeRef = volumes.getNextVolume(targetStorageType, block.getNumBytes()); + } + try { File oldBlockFile = replicaInfo.getBlockFile(); File oldMetaFile = replicaInfo.getMetaFile(); FsVolumeImpl targetVolume = (FsVolumeImpl) volumeRef.getVolume(); @@ -959,6 +962,10 @@ class FsDatasetImpl implements FsDatasetSpi { removeOldReplica(replicaInfo, newReplicaInfo, oldBlockFile, oldMetaFile, oldBlockFile.length(), oldMetaFile.length(), block.getBlockPoolId()); + } finally { + if (volumeRef != null) { + volumeRef.close(); + } } // Replace the old block if any to reschedule the scanning.