hanishakoneru commented on a change in pull request #3034:
URL: https://github.com/apache/ozone/pull/3034#discussion_r801069862



##########
File path: 
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java
##########
@@ -143,11 +135,24 @@ public static long persistPutBlock(KeyValueContainer 
container,
             containerBCSId, bcsId);
         return data.getSize();
       }
+
       // update the blockData as well as BlockCommitSequenceId here
       try (BatchOperation batch = db.getStore().getBatchHandler()
           .initBatchOperation()) {
+        String dbKeyForBlock = Long.toString(data.getLocalID());
+
+        // If incrBlockCount is absent, then check the DB if the block exists
+        // or not. If it does not exist, increment the blockCount.
+        if (!incrBlockCount.isPresent()) {
+          if (db.getStore().getBlockDataTable().get(dbKeyForBlock) == null) {
+            incrBlockCount = Optional.of(false);
+          } else {
+            incrBlockCount = Optional.of(true);
+          }
+        }

Review comment:
       It would be one extra read call to the DB for every putBlock call. So it 
would be better to use this information from client if it is available.
   Also, realized that when key is null, we need to incrBlockCount (if else 
case needs to be reversed).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to