This is an automated email from the ASF dual-hosted git repository.
priyeshkaratha pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 8f9237ef3a4 HDDS-17158. Fix pending deletion bytes release for EC
blocks in DN (#11629)
8f9237ef3a4 is described below
commit 8f9237ef3a416a37c10ac6b174e9b851642051c0
Author: Priyesh Karatha <[email protected]>
AuthorDate: Thu Oct 22 08:47:02 2026 +0530
HDDS-17158. Fix pending deletion bytes release for EC blocks in DN (#11629)
---
.../statemachine/background/BlockDeletingTask.java | 4 +-
.../container/common/TestBlockDeletingService.java | 53 ++++++++++++++++++++--
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java
index a4ab1a7ef0e..a730eed2028 100644
---
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java
+++
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/statemachine/background/BlockDeletingTask.java
@@ -495,7 +495,9 @@ private DeleteTransactionStats deleteTransactions(
// TODO: handle the bytesReleased correctly for the unexpected
exception.
}
}
- bytesProcessed += entry.getTotalBlockSize();
+ // Release the same size that DeleteBlocksCommandHandler added to the
pending deletion bytes.
+ // Transactions received before totalSizePerReplica existed were added
with totalBlockSize.
+ bytesProcessed += entry.hasTotalSizePerReplica() ?
entry.getTotalSizePerReplica() : entry.getTotalBlockSize();
deletedBlocksTxs.add(entry);
Duration execTime = Duration.between(startTime, Instant.now());
if (deletedBlocksTxs.size() < delBlocks.size() &&
diff --git
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
index 896de38e340..65573fd4852 100644
---
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
+++
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/TestBlockDeletingService.java
@@ -138,6 +138,8 @@ public class TestBlockDeletingService {
private MutableVolumeSet volumeSet;
private BlockDeletingServiceTestImpl blockDeletingService;
private static final int BLOCK_CHUNK_SIZE = 100;
+ // If positive, delete transactions are created as for EC blocks with this
many data replicas.
+ private int ecDataNum;
@BeforeEach
public void init() throws IOException {
@@ -283,12 +285,19 @@ private void createPendingDeleteBlocksViaTxn(int
numOfBlocksPerContainer,
private void createTxn(KeyValueContainerData data, List<Long>
containerBlocks,
int txnID, long containerID) {
try (DBHandle metadata = BlockUtils.getDB(data, conf)) {
- StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction dtx =
+ long sizePerReplica = containerBlocks.size() * BLOCK_CHUNK_SIZE;
+ StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction.Builder
dtxBuilder =
StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction
.newBuilder().setTxID(txnID).setContainerID(containerID)
.addAllLocalID(containerBlocks)
- .setTotalBlockSize(containerBlocks.size() * BLOCK_CHUNK_SIZE)
- .setCount(0).build();
+ .setCount(0);
+ if (ecDataNum > 0) {
+ // Like SCM does for EC: logical block size spans all data replicas,
each DN holds one share of it.
+ dtxBuilder.setTotalBlockSize(sizePerReplica *
ecDataNum).setTotalSizePerReplica(sizePerReplica);
+ } else {
+ dtxBuilder.setTotalBlockSize(sizePerReplica);
+ }
+ StorageContainerDatanodeProtocolProtos.DeletedBlocksTransaction dtx =
dtxBuilder.build();
try (BatchOperation batch = metadata.getStore().getBatchHandler()
.initBatchOperation()) {
DatanodeStore ds = metadata.getStore();
@@ -743,6 +752,44 @@ public void
testBlockDeletionMetricsUpdatedProperlyAfterEachExecution(ContainerT
}
}
+ /**
+ * For EC blocks, the DN adds totalSizePerReplica of a delete transaction to
the pending deletion bytes.
+ * Processing the transaction must release the same amount, not the logical
totalBlockSize.
+ */
+ @ContainerTestVersionInfo.ContainerTest
+ public void
testPendingDeletionBytesForECTransactions(ContainerTestVersionInfo versionInfo)
throws Exception {
+ setLayoutAndSchemaForTest(versionInfo);
+ // Schema V1 does not use delete transactions on the DN.
+ Assumptions.assumeFalse(isSameSchemaVersion(schemaVersion, SCHEMA_V1));
+ ecDataNum = 3;
+ DatanodeConfiguration dnConf = conf.getObject(DatanodeConfiguration.class);
+ dnConf.setBlockDeletionLimit(1);
+ this.blockLimitPerInterval = dnConf.getBlockDeletionLimit();
+ conf.setFromObject(dnConf);
+ ContainerSet containerSet = newContainerSet();
+ // 3 transactions, one block each, each with per-replica size
BLOCK_CHUNK_SIZE.
+ KeyValueContainerData data = createToDeleteBlocks(containerSet, 3, 1);
+ ContainerMetrics metrics = ContainerMetrics.create(conf);
+ KeyValueHandler keyValueHandler =
+ ContainerTestUtils.getKeyValueHandler(conf, datanodeUuid,
containerSet, volumeSet, metrics);
+ createBlockDeletingService(containerSet, conf, keyValueHandler);
+ blockDeletingService.start();
+ GenericTestUtils.waitFor(blockDeletingService::isStarted, 100, 3000);
+ BlockDeletingServiceMetrics deletingServiceMetrics =
blockDeletingService.getMetrics();
+
+ assertEquals(3 * BLOCK_CHUNK_SIZE, data.getBlockPendingDeletionBytes());
+
+ // Each interval processes one transaction, which should release only its
per-replica size.
+ for (int processed = 1; processed <= 3; processed++) {
+ deleteAndWait(blockDeletingService, processed);
+ long remaining = 3 - processed;
+ GenericTestUtils.waitFor(() -> data.getNumPendingDeletionBlocks() ==
remaining, 100, 3000);
+ assertEquals(remaining * BLOCK_CHUNK_SIZE,
data.getBlockPendingDeletionBytes());
+ // The metric is computed before the deletion in the same interval.
+ assertEquals((remaining + 1) * BLOCK_CHUNK_SIZE,
deletingServiceMetrics.getTotalPendingBlockBytes());
+ }
+ }
+
@ContainerTestVersionInfo.ContainerTest
public void testWithUnrecordedBlocks(ContainerTestVersionInfo versionInfo)
throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]