From d8b18e82f05a101bd3cafa3df8705e427092be17 Mon Sep 17 00:00:00 2001 From: Bharat Viswanadham Date: Tue, 28 May 2019 11:27:16 -0700 Subject: [PATCH] HDDS-1602. Fix TestContainerPersistence#testDeleteBlockTwice. (#858) --- .../ozone/container/keyvalue/impl/BlockManagerImpl.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 f62a013f4c..8fe0b810a3 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 void deleteBlock(Container container, BlockID blockID) throws // 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(); }