diff --git a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java index f62a013f4cc..8fe0b810a3c 100644 --- a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java +++ b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java @@ -229,12 +229,13 @@ public class BlockManagerImpl implements BlockManager { // to delete a Block which might have just gotten inserted after // the get check. byte[] kKey = Longs.toByteArray(blockID.getLocalID()); - try { - db.getStore().delete(kKey); - } catch (IOException e) { + + byte[] kData = db.getStore().get(kKey); + if (kData == null) { throw new StorageContainerException("Unable to find the block.", NO_SUCH_BLOCK); } + db.getStore().delete(kKey); // Decrement blockcount here container.getContainerData().decrKeyCount(); }