This is an automated email from the ASF dual-hosted git repository.
adoroszlai 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 fda247cf51 HDDS-7306. DeleteBlock retry count increased at incorrect
place (#3818)
fda247cf51 is described below
commit fda247cf51539b9b1e2ed76212e652b2522525d1
Author: Symious <[email protected]>
AuthorDate: Sat Feb 4 20:16:50 2023 +0800
HDDS-7306. DeleteBlock retry count increased at incorrect place (#3818)
---
.../hadoop/hdds/scm/block/SCMBlockDeletingService.java | 9 +++++++++
.../hdds/scm/server/SCMDatanodeProtocolServer.java | 17 -----------------
.../statemachine/commandhandler/TestBlockDeletion.java | 8 ++++++++
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
index e6f4decd95..1b587c7b4b 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/SCMBlockDeletingService.java
@@ -18,12 +18,16 @@ package org.apache.hadoop.hdds.scm.block;
import java.io.IOException;
import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
@@ -143,11 +147,15 @@ public class SCMBlockDeletingService extends
BackgroundService
return EmptyTaskResult.newResult();
}
+ Set<Long> processedTxIDs = new HashSet<>();
for (Map.Entry<UUID, List<DeletedBlocksTransaction>> entry :
transactions.getDatanodeTransactionMap().entrySet()) {
UUID dnId = entry.getKey();
List<DeletedBlocksTransaction> dnTXs = entry.getValue();
if (!dnTXs.isEmpty()) {
+ processedTxIDs.addAll(dnTXs.stream()
+ .map(DeletedBlocksTransaction::getTxID)
+ .collect(Collectors.toSet()));
// TODO commandQueue needs a cap.
// We should stop caching new commands if num of un-processed
// command is bigger than a limit, e.g 50. In case datanode goes
@@ -174,6 +182,7 @@ public class SCMBlockDeletingService extends
BackgroundService
transactions.getBlocksDeleted(),
transactions.getDatanodeTransactionMap().size(),
Time.monotonicNow() - startTime);
+ deletedBlockLog.incrementCount(new ArrayList<>(processedTxIDs));
} catch (NotLeaderException nle) {
LOG.warn("Skip current run, since not leader any more.", nle);
return EmptyTaskResult.newResult();
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java
index bc00f4d142..dc6ed2ccb1 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMDatanodeProtocolServer.java
@@ -28,7 +28,6 @@ import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.concurrent.TimeoutException;
-import java.util.stream.Collectors;
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
@@ -349,22 +348,6 @@ public class SCMDatanodeProtocolServer implements
.getDefaultInstance())
.build();
case deleteBlocksCommand:
- // Once SCM sends out the deletion message, increment the count.
- // this is done here instead of when SCM receives the ACK, because
- // DN might not be able to response the ACK for sometime. In case
- // it times out, SCM needs to re-send the message some more times.
- List<Long> txs =
- ((DeleteBlocksCommand) cmd)
- .blocksTobeDeleted()
- .stream()
- .map(tx -> tx.getTxID())
- .collect(Collectors.toList());
- /*
- * TODO: Can we avoid this?
- * This introduces a Ratis call while processing datanode heartbeat,
- * which is not good.
- */
- scm.getScmBlockManager().getDeletedBlockLog().incrementCount(txs);
return builder
.setCommandType(deleteBlocksCommand)
.setDeleteBlocksCommandProto(
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
index e8ac072c5d..67f1a9cafa 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestBlockDeletion.java
@@ -180,6 +180,8 @@ public class TestBlockDeletion {
public void testBlockDeletion(ReplicationConfig repConfig) throws Exception {
String volumeName = UUID.randomUUID().toString();
String bucketName = UUID.randomUUID().toString();
+ GenericTestUtils.LogCapturer logCapturer = GenericTestUtils.LogCapturer
+ .captureLogs(DeleteBlocksCommandHandler.LOG);
String value = RandomStringUtils.random(1024 * 1024);
store.createVolume(volumeName);
@@ -284,6 +286,12 @@ public class TestBlockDeletion {
metrics.getNumBlockDeletionTransactionFailure() +
metrics.getNumBlockDeletionTransactionSuccess());
LOG.info(metrics.toString());
+
+ // Datanode should receive retried requests with continuous retry counts.
+ Assertions.assertTrue(logCapturer.getOutput().contains("1(0)"));
+ Assertions.assertTrue(logCapturer.getOutput().contains("1(1)"));
+ Assertions.assertTrue(logCapturer.getOutput().contains("1(2)"));
+ Assertions.assertTrue(logCapturer.getOutput().contains("1(3)"));
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]