You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/07/22 08:23:43 UTC

[GitHub] [ozone] Xushaohong opened a new pull request, #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Xushaohong opened a new pull request, #3615:
URL: https://github.com/apache/ozone/pull/3615

   ## What changes were proposed in this pull request?
   
   Due to some cases, the deleted block transactions are not executed successfully on the Datanodes. The Ozone might consider these blocks  be missing or the owner datanode of these blocks be non-exist after the maximum times of retrying. 
   The fact that these datanodes could be somehow blocked and not working so well, but they do exist. No matter whether the datanodes work normally or not, these block txns retry counts had already been set to -1 and never could be restored by the ozone self.
   
   Thus we suggest adding a new CLI to trigger/renew these retry counts. In this way, these blocks will be sent to DN again and deleted if they still exist.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-7023
   
   ## How was this patch tested?
   
   See UT 
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928592785


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.

Review Comment:
   A left comment from the copy file. Oops, i would change it.
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936392763


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   Thanks @Xushaohong! In case the admin is providing the list of transactionIds, it would be sub optimal to scan the entire table for failed transactions. I think we can optimise for that case.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r931902487


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/SCMAction.java:
##########
@@ -49,7 +49,8 @@ public enum SCMAction implements AuditAction {
   GET_CONTAINER_BALANCER_STATUS,
   GET_CONTAINER_WITH_PIPELINE_BATCH,
   ADD_SCM,
-  GET_REPLICATION_MANAGER_REPORT;
+  GET_REPLICATION_MANAGER_REPORT,
+  RENEW_DELETED_BLOCK_RETRY_COUNT;

Review Comment:
   Shall use reset here instead of renew to be consistent?  Actually, I think renew is more precise than reset. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935524476


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   @lokeshj1703  Actually, this action is buffered and mostly takes effect(flushed) when SCM `take snapshot`, due to this uncontrollable flush interval, such a case is inevitable.
   For example:
   user send cmd for the first time
   user find RDB not take effect
   buffer flushes
   txn retry count increase from 0 to be 1 ( increment count action also will be added into this buffer)
   user send cmd for the second time
   buffer flushes
   
   For the whole process, txn retry count is  -1 -> 0 -> 1 -> 0 . Even if we add a check when getting this txn from DB and before adding the change into the buffer, this case still could happen. 
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1206108239

   +1.  Thanks @adoroszlai @lokeshj1703  for the code review and @Xushaohong for working on it. 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936517395


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +182,25 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException, TimeoutException {
+    lock.lock();
+    try {
+      if (txIDs == null || txIDs.isEmpty()) {
+        txIDs = getFailedTransactions().stream()
+            .map(DeletedBlocksTransaction::getTxID)
+            .collect(Collectors.toList());
+      }
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+          new ArrayList<>(new HashSet<>(txIDs)));

Review Comment:
   > resetRetryCountOfTransactionInDB can take List as input. Then we dont need the conversions.
   
   Here the first conversion to ArrayList is essential, coz the list itself is an interface and cannot be instantiated when triggering @Replicate method,  the argument needs to be instantiated. 
   The second conversion is to eliminate the duplicate txns, this also helps reduce further processes and data transfer if send too much same txId. I think it also meaningful.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934419870


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   > > This is already handled in DeletedBlockLogImpl, only the filtered txns will be processed.
   > 
   > I think we should still handle this case, o.w we may end up hitting NPE.
   
   Do you mean adding a null check here?
   ```suggestion
         Objects.requireNonNull(txId, "transactionId cannot be null");
         DeletedBlocksTransaction transaction = deletedTable.get(txId);
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928589088


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   Using set is a better choice, I would adopt it! But why the second stream is not allowed? These two streams are independent processes I think.  I  find no such convention, haha. Please let me know if it is true.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928714072


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   > why the second stream is not allowed? These two streams are independent processes I think
   
   It is allowed, but unnecessary.  Stream pipelines support multiple non-terminal operations (`filter()`, `map()`, etc.):
   
   ```suggestion
       Stream<Long> stream = getFailedTransactions().stream()
           .map(DeletedBlocksTransaction::getTxID);
       if (txIDs != null && !txIDs.isEmpty()) {
         stream = stream.filter(txIDs::contains);
       }
       List<Long> failedTransactions = stream.collect(Collectors.toList());
   ```
   
   This is better than the one with `Set` if the filter is expected to drop many items.  We save the cost of materializing the bigger collection.
   
   However, since this command is not performance-critical, both solutions are fine.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934419870


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   > > This is already handled in DeletedBlockLogImpl, only the filtered txns will be processed.
   > 
   > I think we should still handle this case, o.w we may end up hitting NPE.
   
   Do you mean adding a null check here?
   ```suggestion
         Objects.requireNonNull(txId, "transactionId cannot be null");
         DeletedBlocksTransaction transaction = deletedTable.get(txId);
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934424169


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {

Review Comment:
   Accepted.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934420550


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,27 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int resetDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    getScm().checkAdminAccess(getRemoteUser());
+    try {
+      int count = scm.getScmBlockManager().getDeletedBlockLog().
+          resetCount(txIDs);
+      scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();
+
+      auditMap.put("txIDs", txIDs.stream().map(String::valueOf).
+          collect(Collectors.joining(",")));

Review Comment:
   > What about simply `txIDs.toString()`?
   
   Accepted.
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1193491836

   @ChenSammi @adoroszlai  PTAL~


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928829515


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java:
##########
@@ -72,6 +72,15 @@ List<DeletedBlocksTransaction> getFailedTransactions()
   void incrementCount(List<Long> txIDs)
       throws IOException, TimeoutException;
 
+
+  /**
+   * Reset DeletedBlock transaction retry count.
+   *
+   * @return the

Review Comment:
   Done



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928600674


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }
+    lock.lock();
+    try {
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+            new ArrayList<>(failedTransactions));
+    } catch (TimeoutException | IOException ex) {
+      LOG.error("Cannot reset block deletion transactions {}",
+          failedTransactions, ex);
+      return 0;

Review Comment:
   I referred to the line in BlockManagerImpl:259,  both exceptions could be treated as the same, and the maintainer shall find the stack through the log to recognize the root cause. If it is still not a good idea, pls comment this again.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r931920205


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,27 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int resetDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    getScm().checkAdminAccess(getRemoteUser());
+    try {
+      int count = scm.getScmBlockManager().getDeletedBlockLog().
+          resetCount(txIDs);
+      scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();

Review Comment:
   Why flush is required here? 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935169724


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -213,6 +214,7 @@ public void increaseRetryCountOfTransactionInDB(
   public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
       throws IOException {
     for (long txId: txIDs) {
+      Objects.requireNonNull(txId, "transactionId cannot be null");

Review Comment:
   This `requireNonNull` check is unnecessary.
   
   `txIDs` may be `null`, or it may contain a `null` element.  In both cases `for (long txId: txIDs)` would fail before reaching `requireNonNull`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935524476


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   @lokeshj1703  Actually, this action is buffered and only takes effect(flushed) when SCM `take snapshot`, due to this uncontrollable flush interval, such a case is inevitable.
   For example:
   user send cmd for the first time
   user find RDB not take effect
   buffer flushes
   txn retry count increase from 0 to be 1 ( increment count action also will be added into this buffer)
   user send cmd for the second time
   buffer flushes
   
   For the whole process, txn retry count is  -1 -> 0 -> 1 -> 0 . Even if we add a check when getting this txn from DB and before adding the change into the buffer, this case still could happen. 
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934412325


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   The server will reset will failed transactions for this case as the argument list txIds is empty.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934424327


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/SCMAction.java:
##########
@@ -49,7 +49,8 @@ public enum SCMAction implements AuditAction {
   GET_CONTAINER_BALANCER_STATUS,
   GET_CONTAINER_WITH_PIPELINE_BATCH,
   ADD_SCM,
-  GET_REPLICATION_MANAGER_REPORT;
+  GET_REPLICATION_MANAGER_REPORT,
+  RENEW_DELETED_BLOCK_RETRY_COUNT;

Review Comment:
   Good catch



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936297536


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   Ideally the scenario should not happen, we should keep the transactionBuffer data in memory as well I think.
   But we can still make best effort anyways.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928492433


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   Nit: the stream should be collected only once, after the map and optional filter operations.  Or we can use `Set.retainAll` instead of `filter(txIDs::contains)`.
   
   ```suggestion
       Set<Long> failedTransactions = getFailedTransactions().stream()
           .map(DeletedBlocksTransaction::getTxID)
           .collect(Collectors.toSet());
       if (txIDs != null && !txIDs.isEmpty()) {
         failedTransactions.retainAll(txIDs);
       }
   ```



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+
+  @CommandLine.Option(names = {"-l", "--list"},
+      split = ",",
+      description = "Renew the only given deletedBlock transaction ID list, " +
+          "e.g 100,101,102.(Separated by ',')")
+  private List<Long> txList;
+
+  @Override
+  public Class<?> getParentType() {
+    return OzoneDebug.class;

Review Comment:
   I think this is an admin command, albeit a very obscure one, since it modifies state.



##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestDeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.shell;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.block.DeletedBlockLog;
+import org.apache.hadoop.hdds.scm.cli.ContainerOperationClient;
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
+import org.apache.hadoop.ozone.debug.DeletedBlockRetryCountRenewer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_BLOCK_DELETION_MAX_RETRY;
+
+/**
+ * Test for DeletedBlockRetryCountRenewer Cli.
+ */
+public class TestDeletedBlockRetryCountRenewer {
+
+  private static final Logger LOG = LoggerFactory
+      .getLogger(TestDeletedBlockRetryCountRenewer.class);
+  private MiniOzoneHAClusterImpl cluster = null;
+  private OzoneConfiguration conf;
+  private String clusterId;
+  private String scmId;
+  private String scmServiceId;
+  private int numOfSCMs = 3;
+
+  /**
+   * Create a MiniOzoneHACluster for testing.
+   *
+   * @throws IOException
+   */
+  @BeforeEach
+  public void init() throws Exception {
+    conf = new OzoneConfiguration();
+    clusterId = UUID.randomUUID().toString();
+    scmId = UUID.randomUUID().toString();
+    scmServiceId = "scm-service-test1";
+
+    conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
+    conf.setInt(OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 20);
+
+    cluster = (MiniOzoneHAClusterImpl) MiniOzoneCluster.newOMHABuilder(conf)
+        .setClusterId(clusterId)
+        .setScmId(scmId)
+        .setSCMServiceId(scmServiceId)
+        .setNumOfStorageContainerManagers(numOfSCMs)
+        .setNumOfActiveSCMs(numOfSCMs)
+        .setNumOfOzoneManagers(1)
+        .build();
+    cluster.waitForClusterToBeReady();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  @AfterEach
+  public void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  //<containerID,  List<blockID>>
+  private Map<Long, List<Long>> generateData(int dataSize) {
+    Map<Long, List<Long>> blockMap = new HashMap<>();
+    Random random = new Random(1);
+    int continerIDBase = random.nextInt(100);
+    int localIDBase = random.nextInt(1000);
+    for (int i = 0; i < dataSize; i++) {
+      long containerID = continerIDBase + i;
+      List<Long> blocks = new ArrayList<>();
+      for (int j = 0; j < 5; j++)  {
+        long localID = localIDBase + j;
+        blocks.add(localID);
+      }
+      blockMap.put(containerID, blocks);
+    }
+    return blockMap;
+  }
+
+  private StorageContainerManager getSCMLeader() {
+    return cluster.getStorageContainerManagersList()
+        .stream().filter(a -> a.getScmContext().isLeaderReady())
+        .collect(Collectors.toList()).get(0);
+  }
+
+  @Test
+  public void testRenewCmd() throws IOException, TimeoutException {
+    int maxRetry = conf.getInt(OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 20);
+    // add some block deletion transactions
+    DeletedBlockLog deletedBlockLog = getSCMLeader().
+        getScmBlockManager().getDeletedBlockLog();
+    deletedBlockLog.addTransactions(generateData(30));
+    getSCMLeader().getScmHAManager().asSCMHADBTransactionBuffer().flush();
+    LOG.info("Valid num of txns: {}", deletedBlockLog.
+        getNumOfValidTransactions());
+    Assertions.assertEquals(deletedBlockLog.getNumOfValidTransactions(), 30);

Review Comment:
   Nit: `assertEquals` arguments should be swapped (`expected`, `actual`) in all assertions.
   
   https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/Assertions.html#assertEquals(int,int)



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLog.java:
##########
@@ -72,6 +72,15 @@ List<DeletedBlocksTransaction> getFailedTransactions()
   void incrementCount(List<Long> txIDs)
       throws IOException, TimeoutException;
 
+
+  /**
+   * Reset DeletedBlock transaction retry count.
+   *
+   * @return the

Review Comment:
   Nit: incomplete comment.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }
+    lock.lock();
+    try {
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+            new ArrayList<>(failedTransactions));
+    } catch (TimeoutException | IOException ex) {
+      LOG.error("Cannot reset block deletion transactions {}",
+          failedTransactions, ex);
+      return 0;

Review Comment:
   I think the method should either declare `throws IOException` or catch it, but not both.



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.

Review Comment:
   What does this comment mean?



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/client/ScmClient.java:
##########
@@ -360,6 +360,12 @@ StartContainerBalancerResponseProto startContainerBalancer(
    */
   List<String> getScmRatisRoles() throws IOException;
 
+  /**
+   * Renew the expired deleted block retry count.
+   * @throws IOException
+   */
+  int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException;

Review Comment:
   Since the operation is called `resetCount` in `DeletedBlockLog`, would it make sense to use `reset` instead of `renew` consistently?



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+

Review Comment:
   What is the reason for adding this required option?  Do you want to print the help by default to avoid accidentally executing the command without a list of IDs?



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,16 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    getScm().checkAdminAccess(getRemoteUser());
+    AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
+        SCMAction.RENEW_DELETED_BLOCK_RETRY_COUNT, null));

Review Comment:
   Audit should log success only after the operation is done.  Exceptions should be logged as failure (and re-thrown).  Both should include the command's parameters.  See `listContainer` for an example.
   
   https://github.com/apache/ozone/blob/58c3166094cc27f65da49f5edd5a12ff1103a96e/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java#L492-L549



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928589088


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   Using set is a better choice, I would adopt this suggestion! But why the second stream is not allowed? These two streams are independent processes I think.  I  find no such convention, haha. Please let me know if it is true.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934411255


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());
+    } else {
+      if (group.txList == null || group.txList.isEmpty()) {
+        System.out.println("TransactionId list could not be empty");

Review Comment:
   Accepted.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934351998


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   > We need to handle the case where txn is not present in db.
   
   This is already handled in `DeletedBlockLogImpl`,  only the filtered txns will be processed.
   
   
   > Also what if retry count of this transaction is > 0 already?
   
   In this case, we do nothing for them now.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928673003


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+

Review Comment:
   Great.  I think we could achieve the same in a more helpful way by:
   
   1. changing this option to `--all` (and updating the description)
   2. declaring `--list` and `--all` to be [mutually exclusive](https://picocli.info/#_mutually_exclusive_options) and required



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934376198


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/SCMAction.java:
##########
@@ -49,7 +49,8 @@ public enum SCMAction implements AuditAction {
   GET_CONTAINER_BALANCER_STATUS,
   GET_CONTAINER_WITH_PIPELINE_BATCH,
   ADD_SCM,
-  GET_REPLICATION_MANAGER_REPORT;
+  GET_REPLICATION_MANAGER_REPORT,
+  RENEW_DELETED_BLOCK_RETRY_COUNT;

Review Comment:
   Nit: `RENEW` -> `RESET`



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {

Review Comment:
   Nit: I think `class TransactionsOption` would be a more descriptive name.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,27 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int resetDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    getScm().checkAdminAccess(getRemoteUser());
+    try {
+      int count = scm.getScmBlockManager().getDeletedBlockLog().
+          resetCount(txIDs);
+      scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();
+
+      auditMap.put("txIDs", txIDs.stream().map(String::valueOf).
+          collect(Collectors.joining(",")));

Review Comment:
   What about simply `txIDs.toString()`?



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java:
##########
@@ -1221,12 +1221,24 @@ private void handleUnderReplicatedContainer(final ContainerInfo container,
               id, misRepDelta);
         }
       } else {
+        replicas.stream().filter(rp -> rp.getState().equals(State.UNHEALTHY))
+            .forEach(rp -> {
+              sendDeleteCommand(container, rp.getDatanodeDetails(), true);
+              LOG.info("Send deleteCmd to force delete the unhealthy " +
+                  "replica {}", rp);
+            });
+        container.setNumberOfKeys(0);
+        container.setUsedBytes(0);
+        containerManager.updateContainerState(container.containerID(),
+            HddsProtos.LifeCycleEvent.DELETE);
         LOG.warn("Cannot replicate container {}, no healthy replica found.",
             container.containerID());
       }
     } catch (IOException | IllegalStateException ex) {
       LOG.warn("Exception while replicating container {}.",
           container.getContainerID(), ex);
+    } catch (InvalidStateTransitionException | TimeoutException e) {
+      e.printStackTrace();

Review Comment:
   This "force delete" part looks a bit fishy, and was added in a commit with message `temp cleanup unhealthy container`.  Is this intended to be part of the final change?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1202242371

   Since noticing some defects in the logic, I have updated a new commit, which does these things:
   1. prevent NPE when `deletedTable.get(txId);`
   2. improve the logic that now returns the correct successful reset count and throws exceptions instead of returning 0;
   @adoroszlai @lokeshj1703  PTAL :)


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935172684


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,27 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int resetDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    getScm().checkAdminAccess(getRemoteUser());
+    try {
+      int count = scm.getScmBlockManager().getDeletedBlockLog().
+          resetCount(txIDs);
+      scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();

Review Comment:
   I think SCM will handle the flush itself.  We don't need to control it.  Unless flush is a must to have here, I will recommend to remove it. Otherwise, if user frequently call this API, SCM performance can be impacted. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928590893


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+
+  @CommandLine.Option(names = {"-l", "--list"},
+      split = ",",
+      description = "Renew the only given deletedBlock transaction ID list, " +
+          "e.g 100,101,102.(Separated by ',')")
+  private List<Long> txList;
+
+  @Override
+  public Class<?> getParentType() {
+    return OzoneDebug.class;

Review Comment:
   Sure, I have chatted with Sammi before and made such a draft. It's fine to move it to admin cmd~
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928621843


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/client/ScmClient.java:
##########
@@ -360,6 +360,12 @@ StartContainerBalancerResponseProto startContainerBalancer(
    */
   List<String> getScmRatisRoles() throws IOException;
 
+  /**
+   * Renew the expired deleted block retry count.
+   * @throws IOException
+   */
+  int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException;

Review Comment:
   Usually commands are in verb form: e.g. `... key put`, `... volume create`, instead of `... key putter`, `... volume creator`.
   
   So I think `ozone admin scm reset-deleted-block-retry-count` would be better.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928829299


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+

Review Comment:
   I have updated it 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936343506


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   ```
     public int resetCount(List<Long> txIDs) throws IOException, TimeoutException {
       lock.lock();
       try {
         Set<Long> failedTransactions = getFailedTransactions().stream()
             .map(DeletedBlocksTransaction::getTxID)
             .collect(Collectors.toSet());
         if (txIDs != null && !txIDs.isEmpty()) {
           failedTransactions.retainAll(txIDs);
         }
         return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
             new ArrayList<>(failedTransactions));
       } finally {
         lock.unlock();
       }
     }
   ```
   In DeletedBlockLogImpl, we first get all -1 txns from DB and if the argument `txIds` is empty, we will reset all DB txns, otherwise, we deal with the intersection of DB txns and `txIds`



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi merged pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi merged PR #3615:
URL: https://github.com/apache/ozone/pull/3615


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934354837


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   >This is already handled in DeletedBlockLogImpl, only the filtered txns will be processed.
   
   I think we should still handle this case, o.w we may end up hitting NPE.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1202079830

   > > Thanks @Xushaohong for working on this. The overall patch LGTM. Besides some minor inline comments,
   > > could you help to implement another CLI which hows all the failed transactions, and provide the available tx information for this CLI. And also for tx list, can we support tx file as one type of parameter? So that we have provide a file with txs if there are too much txs.
   > 
   > Do you mean a series of CLI about failed transactions?
   > 
   >     1. Get all failed txns (could output to a file)
   > 
   >     2. Reset all failed txns (could input through a file)
   
   Right.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935185145


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -213,6 +214,7 @@ public void increaseRetryCountOfTransactionInDB(
   public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
       throws IOException {
     for (long txId: txIDs) {
+      Objects.requireNonNull(txId, "transactionId cannot be null");

Review Comment:
   You are right.  I should wait for Lokeshj to give a clarification on the possible NPE. From my view, the lock should have prevented resetting the nonexisting txIds.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935284654


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   Can you please point me to the code where this is handled? Somehow I am missing it.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935281142


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -213,6 +214,7 @@ public void increaseRetryCountOfTransactionInDB(
   public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
       throws IOException {
     for (long txId: txIDs) {
+      Objects.requireNonNull(txId, "transactionId cannot be null");

Review Comment:
   I meant handling NPE for this code.
   `deletedTable.get(txId);`
   The table may not have entry for a particular transactionID.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935524476


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   @lokeshj1703  
   For example:
   user send cmd for the first time
   user find RDB not take effect
   buffer flushes
   txn retry count increase from 0 to be 1 ( increment count action also will be added into this buffer)
   user send cmd for the second time
   buffer flushes
   
   For the whole process, txn retry count is  -1 -> 0 -> 1 -> 0 . 
   If we add a check when getting this txn from DB and before adding the change into the buffer, this case still be -1 -> 0 -> 1 -> 1. I think this is what you said.
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1206110116

   Thanks @ChenSammi  @adoroszlai @lokeshj1703  for the review :)


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928831764


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }
+    lock.lock();
+    try {
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+            new ArrayList<>(failedTransactions));
+    } catch (TimeoutException | IOException ex) {
+      LOG.error("Cannot reset block deletion transactions {}",
+          failedTransactions, ex);
+      return 0;

Review Comment:
   Most excepetions in `DeletedBlockLogImpl` are not thrown, so I inherited this.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928596275


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,16 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    getScm().checkAdminAccess(getRemoteUser());
+    AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
+        SCMAction.RENEW_DELETED_BLOCK_RETRY_COUNT, null));

Review Comment:
   Thx for pointing out this.
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928589088


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   Using set is a better choice, I would adopt this suggestion! 
   Curiously why the second stream is not allowed? These two streams are independent processes I think.  I  find no such convention, haha. Please let me know ~



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ChenSammi commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
ChenSammi commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1197832227

   Thanks @Xushaohong for working on this. The overall patch LGTM.  Besides some minor inline comments, 
   
   could you help to implement another CLI which hows all the failed transactions, and provide the available tx information for this CLI.  And also for tx list, can we support tx file as one type of parameter?  So that we have provide a file with txs if there are too much txs. 
   
    


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934421754


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/replication/LegacyReplicationManager.java:
##########
@@ -1221,12 +1221,24 @@ private void handleUnderReplicatedContainer(final ContainerInfo container,
               id, misRepDelta);
         }
       } else {
+        replicas.stream().filter(rp -> rp.getState().equals(State.UNHEALTHY))
+            .forEach(rp -> {
+              sendDeleteCommand(container, rp.getDatanodeDetails(), true);
+              LOG.info("Send deleteCmd to force delete the unhealthy " +
+                  "replica {}", rp);
+            });
+        container.setNumberOfKeys(0);
+        container.setUsedBytes(0);
+        containerManager.updateContainerState(container.containerID(),
+            HddsProtos.LifeCycleEvent.DELETE);
         LOG.warn("Cannot replicate container {}, no healthy replica found.",
             container.containerID());
       }
     } catch (IOException | IllegalStateException ex) {
       LOG.warn("Exception while replicating container {}.",
           container.getContainerID(), ex);
+    } catch (InvalidStateTransitionException | TimeoutException e) {
+      e.printStackTrace();

Review Comment:
   My mistake, this is my temp solution to the unhealthy containers, not the part of this patch.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935528771


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   I have removed the manual flush according to the discussion with Sammi since SCM buffer needs an external regular check and flush as a common solution, not in this case as a certain solution.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935281142


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -213,6 +214,7 @@ public void increaseRetryCountOfTransactionInDB(
   public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
       throws IOException {
     for (long txId: txIDs) {
+      Objects.requireNonNull(txId, "transactionId cannot be null");

Review Comment:
   I meant handling NPE for this code.
   `deletedTable.get(txId);`
   The table may not have entry for a particular transactionID. There can be a race condition where entry gets deleted.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r931938818


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/audit/SCMAction.java:
##########
@@ -49,7 +49,8 @@ public enum SCMAction implements AuditAction {
   GET_CONTAINER_BALANCER_STATUS,
   GET_CONTAINER_WITH_PIPELINE_BATCH,
   ADD_SCM,
-  GET_REPLICATION_MANAGER_REPORT;
+  GET_REPLICATION_MANAGER_REPORT,
+  RENEW_DELETED_BLOCK_RETRY_COUNT;

Review Comment:
   Hi Sammi, the latest commit includes this change ~ Now all places use `reset`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928591364


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestDeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.shell;
+
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.block.DeletedBlockLog;
+import org.apache.hadoop.hdds.scm.cli.ContainerOperationClient;
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
+import org.apache.hadoop.ozone.debug.DeletedBlockRetryCountRenewer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.TimeoutException;
+import java.util.stream.Collectors;
+
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_BLOCK_DELETION_MAX_RETRY;
+
+/**
+ * Test for DeletedBlockRetryCountRenewer Cli.
+ */
+public class TestDeletedBlockRetryCountRenewer {
+
+  private static final Logger LOG = LoggerFactory
+      .getLogger(TestDeletedBlockRetryCountRenewer.class);
+  private MiniOzoneHAClusterImpl cluster = null;
+  private OzoneConfiguration conf;
+  private String clusterId;
+  private String scmId;
+  private String scmServiceId;
+  private int numOfSCMs = 3;
+
+  /**
+   * Create a MiniOzoneHACluster for testing.
+   *
+   * @throws IOException
+   */
+  @BeforeEach
+  public void init() throws Exception {
+    conf = new OzoneConfiguration();
+    clusterId = UUID.randomUUID().toString();
+    scmId = UUID.randomUUID().toString();
+    scmServiceId = "scm-service-test1";
+
+    conf.setBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, true);
+    conf.setInt(OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 20);
+
+    cluster = (MiniOzoneHAClusterImpl) MiniOzoneCluster.newOMHABuilder(conf)
+        .setClusterId(clusterId)
+        .setScmId(scmId)
+        .setSCMServiceId(scmServiceId)
+        .setNumOfStorageContainerManagers(numOfSCMs)
+        .setNumOfActiveSCMs(numOfSCMs)
+        .setNumOfOzoneManagers(1)
+        .build();
+    cluster.waitForClusterToBeReady();
+  }
+
+  /**
+   * Shutdown MiniDFSCluster.
+   */
+  @AfterEach
+  public void shutdown() {
+    if (cluster != null) {
+      cluster.shutdown();
+    }
+  }
+
+  //<containerID,  List<blockID>>
+  private Map<Long, List<Long>> generateData(int dataSize) {
+    Map<Long, List<Long>> blockMap = new HashMap<>();
+    Random random = new Random(1);
+    int continerIDBase = random.nextInt(100);
+    int localIDBase = random.nextInt(1000);
+    for (int i = 0; i < dataSize; i++) {
+      long containerID = continerIDBase + i;
+      List<Long> blocks = new ArrayList<>();
+      for (int j = 0; j < 5; j++)  {
+        long localID = localIDBase + j;
+        blocks.add(localID);
+      }
+      blockMap.put(containerID, blocks);
+    }
+    return blockMap;
+  }
+
+  private StorageContainerManager getSCMLeader() {
+    return cluster.getStorageContainerManagersList()
+        .stream().filter(a -> a.getScmContext().isLeaderReady())
+        .collect(Collectors.toList()).get(0);
+  }
+
+  @Test
+  public void testRenewCmd() throws IOException, TimeoutException {
+    int maxRetry = conf.getInt(OZONE_SCM_BLOCK_DELETION_MAX_RETRY, 20);
+    // add some block deletion transactions
+    DeletedBlockLog deletedBlockLog = getSCMLeader().
+        getScmBlockManager().getDeletedBlockLog();
+    deletedBlockLog.addTransactions(generateData(30));
+    getSCMLeader().getScmHAManager().asSCMHADBTransactionBuffer().flush();
+    LOG.info("Valid num of txns: {}", deletedBlockLog.
+        getNumOfValidTransactions());
+    Assertions.assertEquals(deletedBlockLog.getNumOfValidTransactions(), 30);

Review Comment:
   Got it!



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928595655


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/client/ScmClient.java:
##########
@@ -360,6 +360,12 @@ StartContainerBalancerResponseProto startContainerBalancer(
    */
   List<String> getScmRatisRoles() throws IOException;
 
+  /**
+   * Renew the expired deleted block retry count.
+   * @throws IOException
+   */
+  int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException;

Review Comment:
   Yep, 'reset' this action itself is better, but the resetter is strange, so I used 'renewer' in the shell. I will change it to reset since the file name is now changed to ResetDeletedBlockRetryCountSubcommand



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] adoroszlai commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
adoroszlai commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928730469


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }
+    lock.lock();
+    try {
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+            new ArrayList<>(failedTransactions));
+    } catch (TimeoutException | IOException ex) {
+      LOG.error("Cannot reset block deletion transactions {}",
+          failedTransactions, ex);
+      return 0;

Review Comment:
   Grouping `IOException` and `TimeoutException` in the same `catch` is not a problem.  Sorry if my original comment was not clear.
   
   This method is declared as:
   
   ```java
   int resetCount(List<Long> txIDs) throws IOException;
   ```
   
   but it never throws `IOException`, since the method catches it and returns 0 instead.  So we can simplify the definition as:
   
   ```java
   int resetCount(List<Long> txIDs);
   ```
   
   Or we can keep `throws`, but drop `IOException` from the `catch`.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928589946


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/DeletedBlockRetryCountRenewer.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.debug;
+
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Tool to edit on-disk container meta.
+ */
+@CommandLine.Command(
+    name = "deletedBlockRetryCountRenewer",
+    description = "Renew deleted block transactions whose retry count is -1")
+@MetaInfServices(SubcommandWithParent.class)
+public class DeletedBlockRetryCountRenewer extends ScmSubcommand implements
+    SubcommandWithParent {
+
+  @CommandLine.Option(names = {"-r", "--renew"},
+      required = true,
+      description = "Renew the deleted block transaction retry count from" +
+          " -1 to 0. By default renew all expired transactions.")
+  private boolean toRenew;
+

Review Comment:
   Yes,  that's exactly what I concerned!



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for renewing the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928595655


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/client/ScmClient.java:
##########
@@ -360,6 +360,12 @@ StartContainerBalancerResponseProto startContainerBalancer(
    */
   List<String> getScmRatisRoles() throws IOException;
 
+  /**
+   * Renew the expired deleted block retry count.
+   * @throws IOException
+   */
+  int renewDeletedBlockRetryCount(List<Long> txIDs) throws IOException;

Review Comment:
   Yep, 'reset' this action itself is better, but the resetter is strange, so I used 'renewer' in shell.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r928827820


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +181,31 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   * @throws IOException
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException {
+    List<Long> failedTransactions = getFailedTransactions().stream()
+        .map(DeletedBlocksTransaction::getTxID).collect(Collectors.toList());
+    if (txIDs != null && !txIDs.isEmpty()) {
+      failedTransactions = failedTransactions.stream().filter(txIDs::contains)
+          .collect(Collectors.toList());
+    }

Review Comment:
   Thx for the explanation! 
   



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935327580


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -213,6 +214,7 @@ public void increaseRetryCountOfTransactionInDB(
   public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
       throws IOException {
     for (long txId: txIDs) {
+      Objects.requireNonNull(txId, "transactionId cannot be null");

Review Comment:
   You are right, I find the case in the other place and applied it here now.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r931990667


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -783,6 +783,27 @@ public ScmInfo getScmInfo() throws IOException {
     }
   }
 
+  @Override
+  public int resetDeletedBlockRetryCount(List<Long> txIDs) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    getScm().checkAdminAccess(getRemoteUser());
+    try {
+      int count = scm.getScmBlockManager().getDeletedBlockLog().
+          resetCount(txIDs);
+      scm.getScmHAManager().asSCMHADBTransactionBuffer().flush();

Review Comment:
   This manually triggers the batch operation flushing into RDB, otherwise,  it wouldn't take effect after the next natural flush (e.g `take snapshot`/ ` 'download SCM' ), which is uncontrollable.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on PR #3615:
URL: https://github.com/apache/ozone/pull/3615#issuecomment-1197971000

   > Thanks @Xushaohong for working on this. The overall patch LGTM. Besides some minor inline comments,
   > 
   > could you help to implement another CLI which hows all the failed transactions, and provide the available tx information for this CLI. And also for tx list, can we support tx file as one type of parameter? So that we have provide a file with txs if there are too much txs.
   
   Do you mean a series of CLI about failed transactions?  
   1. Get all failed txns (could output to a file)
   2. Reset all failed txns (could input through a file)


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r934344713


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   We are currently not handling -all option in the code?



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   We need to handle the case where txn is not present in db.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   Also what if retry count of this transaction is > 0 already?



##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());
+    } else {
+      if (group.txList == null || group.txList.isEmpty()) {
+        System.out.println("TransactionId list could not be empty");

Review Comment:
   NIT: could -> should



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r935279533


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogStateManagerImpl.java:
##########
@@ -209,6 +209,23 @@ public void increaseRetryCountOfTransactionInDB(
     }
   }
 
+  @Override
+  public int resetRetryCountOfTransactionInDB(ArrayList<Long> txIDs)
+      throws IOException {
+    for (long txId: txIDs) {
+      DeletedBlocksTransaction transaction = deletedTable.get(txId);

Review Comment:
   If retry count is > 0 for a transaction, we should not reset its count.
   It is possible user tries to reset count for non-existent transactions or transactions already being processed. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] Xushaohong commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
Xushaohong commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936410354


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ResetDeletedBlockRetryCountSubcommand.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.hadoop.ozone.admin.scm;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Handler of the expired deleted blocks from SCM side.
+ */
+@CommandLine.Command(
+    name = "resetDeletedBlockRetryCount",
+    description = "Reset deleted block transactions whose retry count is -1",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ResetDeletedBlockRetryCountSubcommand extends ScmSubcommand {
+
+  @CommandLine.ArgGroup(multiplicity = "1")
+  private ExclusiveGroup group;
+
+  static class ExclusiveGroup {
+    @CommandLine.Option(names = {"-a", "--all"},
+        description = "reset all expired deleted block transaction retry" +
+            " count from -1 to 0.")
+    private boolean resetAll;
+
+    @CommandLine.Option(names = {"-l", "--list"},
+        split = ",",
+        description = "reset the only given deletedBlock transaction ID" +
+            " list, e.g 100,101,102.(Separated by ',')")
+    private List<Long> txList;
+  }
+
+  @CommandLine.ParentCommand
+  private ScmAdmin parent;
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    int count;
+    if (group.resetAll) {
+      count = client.resetDeletedBlockRetryCount(new ArrayList<>());

Review Comment:
   @lokeshj1703 Hi lokeshj, I have modified the logic here. PTAL



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] lokeshj1703 commented on a diff in pull request #3615: HDDS-7023. Add CLI for reseting the expired deleted block txn

Posted by GitBox <gi...@apache.org>.
lokeshj1703 commented on code in PR #3615:
URL: https://github.com/apache/ozone/pull/3615#discussion_r936494414


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java:
##########
@@ -181,6 +182,25 @@ public void incrementCount(List<Long> txIDs)
     }
   }
 
+  /**
+   * {@inheritDoc}
+   *
+   */
+  @Override
+  public int resetCount(List<Long> txIDs) throws IOException, TimeoutException {
+    lock.lock();
+    try {
+      if (txIDs == null || txIDs.isEmpty()) {
+        txIDs = getFailedTransactions().stream()
+            .map(DeletedBlocksTransaction::getTxID)
+            .collect(Collectors.toList());
+      }
+      return deletedBlockLogStateManager.resetRetryCountOfTransactionInDB(
+          new ArrayList<>(new HashSet<>(txIDs)));

Review Comment:
   resetRetryCountOfTransactionInDB can take List as input. Then we dont need the conversions.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org