This is an automated email from the ASF dual-hosted git repository. jojochuang pushed a commit to branch ozone-2.1 in repository https://gitbox.apache.org/repos/asf/ozone.git
commit a255c5bc6bef209dcca32065742e67b88d3ce52e Author: Sammi Chen <[email protected]> AuthorDate: Fri Jun 26 21:20:04 2026 +0800 HDDS-15665. Race condition of deletingTxIDs between readOnlyIterator and onFlush (#10613) (cherry picked from commit 01a8446f6fbb3155a13cadcb74e4ef704bb920a1) Change-Id: I6012cca651b515cdd0a432fdf63c0f48e30f059e --- .../hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java index b6976c3c3f3..a03b8096928 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java @@ -52,7 +52,7 @@ public class DeletedBlockLogStateManagerImpl private Table<Long, DeletedBlocksTransaction> deletedTable; private ContainerManager containerManager; private final DBTransactionBuffer transactionBuffer; - private final Set<Long> deletingTxIDs; + private volatile Set<Long> deletingTxIDs; public DeletedBlockLogStateManagerImpl(ConfigurationSource conf, Table<Long, DeletedBlocksTransaction> deletedTable, @@ -69,6 +69,7 @@ public Table.KeyValueIterator<Long, DeletedBlocksTransaction> getReadOnlyIterato return new Table.KeyValueIterator<Long, DeletedBlocksTransaction>() { private final Table.KeyValueIterator<Long, DeletedBlocksTransaction> iter = deletedTable.iterator(); + private final Set<Long> snapshotDeletingTxIDs = deletingTxIDs; private TypedTable.KeyValue<Long, DeletedBlocksTransaction> nextTx; { @@ -80,7 +81,7 @@ private void findNext() { final TypedTable.KeyValue<Long, DeletedBlocksTransaction> next = iter.next(); final long txID = next.getKey(); - if ((!deletingTxIDs.contains(txID))) { + if (!snapshotDeletingTxIDs.contains(txID)) { nextTx = next; if (LOG.isTraceEnabled()) { LOG.trace("DeletedBlocksTransaction matching txID:{}", txID); @@ -185,7 +186,8 @@ public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs) public void onFlush() { // onFlush() can be invoked only when ratis is enabled. Preconditions.checkNotNull(deletingTxIDs); - deletingTxIDs.clear(); + // avoid synchronization of deletingTxIDs as onFlush is called by SCM statemachine thread + deletingTxIDs = ConcurrentHashMap.newKeySet(); } @Override --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
