GlenGeng commented on a change in pull request #1780: URL: https://github.com/apache/ozone/pull/1780#discussion_r563630055
########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImplV2.java ########## @@ -360,18 +375,33 @@ public DatanodeDeletedBlockTransactions getTransactions( } catch (ContainerNotFoundException ex) { LOG.warn("Container: " + id + " was not found for the transaction: " + txn); - builder.addTxID(txn.getTxID()); + txIDs.add(txn.getTxID()); } } - deletedBlockLogStateManager.removeTransactionsFromDB(builder.build()); + removeTransactionsFromDB(txIDs); } return transactions; } finally { lock.unlock(); } } + private void removeTransactionsFromDB(ArrayList<Long> txIDs) + throws IOException { + Iterator<Long> iter = txIDs.iterator(); + while (iter.hasNext()) { + long txID = iter.next(); + if (deletingTxIDs.contains(txID)) { + iter.remove(); + } else { + deletingTxIDs.add(txID); + } + } + + deletedBlockLogStateManager.removeTransactionsFromDB(txIDs); Review comment: This `deletingTxIDs` should be saved in deletedBlockLogStateManager. When `deletedBlockLogStateManager.removeTransactionsFromDB` is called, add the txID into `deletingTxIDs`. When buffer.flush is called, clear the `deletingTxIDs` During iterating of the delete table, ignore the txID that exists in `deletingTxIDs`. ########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java ########## @@ -152,6 +154,13 @@ public void notifyLeaderChanged(RaftGroupMemberId groupMemberId, LOG.info("current SCM becomes leader of term {}.", term); scm.getScmContext().updateIsLeaderAndTerm(true, term); + + DeletedBlockLog deletedBlockLog = scm.getScmBlockManager() + .getDeletedBlockLog(); + if (deletedBlockLog instanceof DeletedBlockLogImplV2) { Review comment: Preconditions.checkArgument(deletedBlockLog instanceof DeletedBlockLogImplV2) ########## File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java ########## @@ -176,6 +185,11 @@ public long takeSnapshot() throws IOException { } transactionBuffer.flush(); + DeletedBlockLog deletedBlockLog = scm.getScmBlockManager() + .getDeletedBlockLog(); + if (deletedBlockLog instanceof DeletedBlockLogImplV2) { + ((DeletedBlockLogImplV2) deletedBlockLog).clearDeletingTxIDs(); Review comment: This should be called in `SCMDBTransactionBuffer.flush` ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@ozone.apache.org For additional commands, e-mail: issues-h...@ozone.apache.org