diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b051f2f0fb..e6074bd217 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -2646,6 +2646,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 5350974fd7..cbd412305b 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 @@ -936,8 +936,11 @@ public ReplicaInfo moveBlockAcrossStorage(ExtendedBlock block, + 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(); @@ -956,6 +959,10 @@ public ReplicaInfo moveBlockAcrossStorage(ExtendedBlock block, 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.