ChenSammi commented on code in PR #10650:
URL: https://github.com/apache/ozone/pull/10650#discussion_r3568660387
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMDeletedBlockTransactionStatusManager.java:
##########
@@ -467,17 +465,37 @@ public void
addTransactions(ArrayList<DeletedBlocksTransaction> txList) throws I
incrDeletedBlocksSummary(tx);
}
}
- deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
+ try {
+ deletedBlockLogStateManager.addTransactionsToDB(txList, getSummary());
+ } catch (IOException e) {
+ // Revert the in-memory changes if the DB update fails
+ for (DeletedBlocksTransaction tx: txList) {
+ if (tx.hasTotalBlockSize()) {
+ descDeletedBlocksSummary(tx);
+ LOG.warn("{} is decreased from summary due to DB update failure",
transactionToString(tx));
+ }
+ }
+ throw e;
+ }
return;
}
deletedBlockLogStateManager.addTransactionsToDB(txList);
}
+ private void incrDeletedBlocksSummary(TxBlockInfo txBlockInfo) {
+ totalTxCount.addAndGet(1);
+ totalBlockCount.addAndGet(txBlockInfo.getTotalBlockCount());
+ totalBlocksSize.addAndGet(txBlockInfo.getTotalBlockSize());
+
totalReplicatedBlocksSize.addAndGet(txBlockInfo.getTotalReplicatedBlockSize());
+ LOG.debug("Increase summary for {} to {}", txBlockInfo,
summaryToString(getSummary()));
Review Comment:
isDebugEnabled() check is not required now.
https://stackoverflow.com/questions/963492/in-log4j-does-checking-isdebugenabled-before-logging-improve-performance
--
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]