priyeshkaratha commented on code in PR #11187:
URL: https://github.com/apache/ozone/pull/11187#discussion_r4284585664


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMDeletedBlockTransactionStatusManager.java:
##########
@@ -461,25 +469,35 @@ public void 
addTransactions(ArrayList<DeletedBlocksTransaction> txList) throws I
     }
     if 
(VersionedDatanodeFeatures.isFinalized(HDDSLayoutFeature.STORAGE_SPACE_DISTRIBUTION)
 &&
         !disableDataDistributionForTest) {
-      for (DeletedBlocksTransaction tx: txList) {
-        if (tx.hasTotalBlockSize()) {
-          incrDeletedBlocksSummary(tx);
-        }
-      }
+      transactionBuffer.lock();
       try {
-        deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
-      } catch (IOException e) {
-        if (isRatisTimeout(e)) {
-          throw e;
+        DeletedBlocksTransactionSummary summary;
+        synchronized (summaryLock) {
+          for (DeletedBlocksTransaction tx: txList) {
+            if (tx.hasTotalBlockSize()) {
+              incrDeletedBlocksSummary(tx);
+            }
+          }
+          onSummaryUpdatedForTest();
+          summary = getSummary();
         }
-        // Revert the in-memory changes if the DB update fails
-        for (DeletedBlocksTransaction tx: txList) {
-          if (tx.hasTotalBlockSize()) {
-            rollbackDeletedBlocksSummary(tx);
-            LOG.warn("{} is decreased from summary due to DB update failure", 
transactionToString(tx));
+        try {
+          deletedBlockLogStateManager.addTransactionsToDB(txList, summary);

Review Comment:
   Fixed. The caller no longer holds the buffer lock while it waits for Ratis. 
The buffer lock is taken only around the local buffer writes in 
DeletedBlockLogStateManagerImpl.addTransactionsToDB and 
removeTransactionsFromDB, which run on the apply side. The Ratis wait is 
outside any buffer lock, so a queued flush writer can't block the applier's 
read-lock acquisition. The reload-race protection comes from summaryLock plus 
inFlightOps and flushAndRun, not from holding the buffer lock.



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