lokeshj1703 commented on a change in pull request #1643:
URL: https://github.com/apache/ozone/pull/1643#discussion_r535076573



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
##########
@@ -354,26 +356,43 @@ public DatanodeDeletedBlockTransactions getTransactions(
           ? extends Table.KeyValue<Long, DeletedBlocksTransaction>> iter =
                scmMetadataStore.getDeletedBlocksTXTable().iterator()) {
         int numBlocksAdded = 0;
+        BatchOperation batch =
+            scmMetadataStore.getBatchHandler().initBatchOperation();
+        List<DeletedBlocksTransaction> delTx =

Review comment:
       Lets rename the list to "txnsToBePurged" or sth better.

##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
##########
@@ -354,26 +356,43 @@ public DatanodeDeletedBlockTransactions getTransactions(
           ? extends Table.KeyValue<Long, DeletedBlocksTransaction>> iter =
                scmMetadataStore.getDeletedBlocksTXTable().iterator()) {
         int numBlocksAdded = 0;
+        BatchOperation batch =
+            scmMetadataStore.getBatchHandler().initBatchOperation();
+        List<DeletedBlocksTransaction> delTx =
+            new ArrayList<>();
         while (iter.hasNext() && numBlocksAdded < blockDeletionLimit) {
-          Table.KeyValue<Long, DeletedBlocksTransaction> keyValue =
-              iter.next();
+          Table.KeyValue<Long, DeletedBlocksTransaction> keyValue = 
iter.next();
           DeletedBlocksTransaction txn = keyValue.getValue();
           final ContainerID id = ContainerID.valueof(txn.getContainerID());
-          if (txn.getCount() > -1 && txn.getCount() <= maxRetry
-              && !containerManager.getContainer(id).isOpen()) {
-            numBlocksAdded += txn.getLocalIDCount();
-            getTransaction(txn, transactions);
-            transactionToDNsCommitMap
-                .putIfAbsent(txn.getTxID(), new LinkedHashSet<>());
+          try {
+            if (txn.getCount() > -1 && txn.getCount() <= maxRetry
+                && !containerManager.getContainer(id).isOpen()) {
+              numBlocksAdded += txn.getLocalIDCount();
+              getTransaction(txn, transactions);
+              transactionToDNsCommitMap
+                  .putIfAbsent(txn.getTxID(), new LinkedHashSet<>());
+            }
+          } catch (ContainerNotFoundException ex) {
+            delTx.add(txn);
           }
         }
+        deleteTransaction(delTx, batch);
+        scmMetadataStore.getBatchHandler().commitBatchOperation(batch);
       }
       return transactions;
     } finally {
       lock.unlock();
     }
   }
 
+  public void deleteTransaction(List<DeletedBlocksTransaction> delTx,

Review comment:
       Since we are passing a list, lets create a batch Operation in the 
function itself. Lets rename the function to purgeTransactions.




----------------------------------------------------------------
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.

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