Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-8882. Manage status of DeleteBlocksCommand in SCM to avoid sending duplicates to Datanode #4988

Merged
merged 28 commits into from
Dec 18, 2023

Conversation

xichen01
Copy link
Contributor

@xichen01 xichen01 commented Jun 27, 2023

What changes were proposed in this pull request?

Currently SCM will send a duplicate DeletedBlocksTransaction to the specify DN if the DN not report the transactions have been finish by the Heartbeat. So if the DeleteBlocksCommandHandler Thread of a DN was Blocked cause by some reason (Such as wait Container lock) the SCM will send a duplicate DeletedBlocksTransaction to this DN.

Summary

The Status of DeleteBlocksCommand

    public enum CmdStatus {
      // The DeleteBlocksCommand has not yet been sent.
      // This is the initial status of the command after it's created.
      TO_BE_SENT,
      // If the DeleteBlocksCommand has been sent but has not been executed
      // completely by DN, the DeleteBlocksCommand's state will be SENT.
      // Note that the state of SENT includes the following possibilities.
      //   - The command was sent but not received
      //   - The command was sent and received by the DN,
      //     and is waiting to be executed.
      //   - The Command sent and being executed by DN
      SENT,
    }

State Transfer

  • TO_BE_SENT -> SENT: The DeleteBlocksCommand is sent by SCM, The follow-up status has not been updated by Datanode.

  • SENT -> null (remove state recode from SCMDeleteBlocksCommandStatusManager)
    Once the DN executes DeleteBlocksCommands, regardless of whether DeleteBlocksCommands is executed successfully or not, it will be deleted from record.
    Successful DeleteBlocksCommands are recorded in SCMDeletedBlockTransactionStatusManager#transactionToDNsCommitMap.

DeleteBlocksCommand resent

The DeleteBlocksCommand on the TO_BE_SENT, SENT will not be resent by SCM.

SCMDeletedBlockTransactionStatusManager

SCMDeletedBlockTransactionStatusManager contains the transactionToDNsCommitMap migrated from DeletedBlockLogImpl use to manage the commited DeletedBlocksTransaction.
And the SCMDeletedBlockTransactionStatusManager#SCMDeleteBlocksCommandStatusManager use to manage the DeletedBlocksTransaction which are uncommited.
The "commited" means that DeletedBlockTransaction is executed on DN and reported to SCM by the heartbeat

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-8882

Please replace this section with the link to the Apache JIRA)

How was this patch tested?

integration test

… sending duplicate delete transactions to the DN
@xichen01 xichen01 marked this pull request as draft June 27, 2023 17:06
@xichen01
Copy link
Contributor Author

xichen01 commented Jun 27, 2023

// todo. Implementing unit test and integration test, Draft is set before the test case is completed, but any suggestions are welcome

@github-actions
Copy link

No such command. / Available commands:

  • /close : Close pending pull request temporary
  • /help : Show all the available comment commands
  • /label : add new label to the issue: /label <label>
  • /pending : Add a REQUESTED_CHANGE type review to mark issue non-mergeable: /pending <reason>
  • /ready : Dismiss all the blocking reviews by github-actions bot
  • /retest : provide help on how to trigger new CI build

1 similar comment
@github-actions
Copy link

No such command. / Available commands:

  • /close : Close pending pull request temporary
  • /help : Show all the available comment commands
  • /label : add new label to the issue: /label <label>
  • /pending : Add a REQUESTED_CHANGE type review to mark issue non-mergeable: /pending <reason>
  • /ready : Dismiss all the blocking reviews by github-actions bot
  • /retest : provide help on how to trigger new CI build

@xichen01 xichen01 marked this pull request as ready for review June 30, 2023 08:49
@xichen01
Copy link
Contributor Author

xichen01 commented Jul 7, 2023

@adoroszlai PTAL Thanks.

@adoroszlai adoroszlai requested review from sumitagrawl, sodonnel and symious and removed request for sodonnel July 7, 2023 18:01
Copy link
Contributor

@sumitagrawl sumitagrawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 thanks for working over this, this seems good improvement to send new blocks and retry with some delay avoiding duplicate command. This is feasible now after removal of strict ordering of transactionId check at DN HDDS-8228. The metrics added for outOfOrder may not be required now at Dn with this change as it will be common to be out-of-order.

Additionally, at SCM, state is managed in DB with retry, and multiple map. We need relook and refactor to have combined state for the Txs.

@xichen01
Copy link
Contributor Author

@sumitagrawl PTAL Thanks.

Copy link
Contributor

@sumitagrawl sumitagrawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 I tried to understand the changes and impact, I am just getting lost in code,
My Understanding,
Here, State Machine to avoid duplicate sending for DeleteBlock command but can not find any good action for these state.

TO_BE_SENT: initial state
NEED_EXECUTED, EXECUTED: just removed on timeout, no other action on keep these
PENDING_EXECUTED, SENT: just to avoid retry, and on timeout, remove

Do we really need so many states? Or just, "INTIAL" & "SENT", and cleanup on timeout or executed.

  • One improvement can see from this PR that next command, it includes new set of blocks (even current blocks are not yet executed).

I think we should have refactored code including transactionToDNsCommitMap, transactionToRetryCountMap to take advantage of these state management and simplified the code.

@xichen01
Copy link
Contributor Author

xichen01 commented Oct 8, 2023

@xichen01 I tried to understand the changes and impact, I am just getting lost in code, My Understanding, Here, State Machine to avoid duplicate sending for DeleteBlock command but can not find any good action for these state.

TO_BE_SENT: initial state NEED_EXECUTED, EXECUTED: just removed on timeout, no other action on keep these PENDING_EXECUTED, SENT: just to avoid retry, and on timeout, remove

Do we really need so many states? Or just, "INTIAL" & "SENT", and cleanup on timeout or executed.

  • One improvement can see from this PR that next command, it includes new set of blocks (even current blocks are not yet executed).

I think we should have refactored code including transactionToDNsCommitMap, transactionToRetryCountMap to take advantage of these state management and simplified the code.

OK, I'll try to compress some of the state to reduce the complexity of the code.

@ashishkumar50
Copy link
Contributor

@xichen01, Thanks for working on this.
Whether the latest comments given by @sumitagrawl is addressed?

# Conflicts:
#	hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/block/DeletedBlockLogImpl.java
@xichen01
Copy link
Contributor Author

xichen01 commented Nov 6, 2023

@xichen01, Thanks for working on this. Whether the latest comments given by @sumitagrawl is addressed?

Yes, CmdStatus has been reduced to two states, and transactionToRetryCountMap had been moved into SCMDeletedBlockGTransactionStatus

@adoroszlai adoroszlai changed the title HDDS-8882. Add status management of SCM's DeleteBlocksCommand to avoid sending duplicate delete transactions to the DN HDDS-8882. Manage status of DeleteBlocksCommand in SCM to avoid sending duplicates to Datanode Nov 27, 2023
Copy link
Contributor

@sumitagrawl sumitagrawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 Thanks for update, given few comments for this PR. Overall looks good.
Will recheck for commandStatusMap for cleanup after fix.

# Conflicts:
#	hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/SCMNodeManager.java
@adoroszlai
Copy link
Contributor

Thanks @xichen01 for updating the patch. Can you please check TestDeletedBlockLog failures?

https://github.com/xichen01/ozone/actions/runs/7057702518/job/19212125760#step:5:1833

@xichen01
Copy link
Contributor Author

xichen01 commented Dec 4, 2023

Copy link
Contributor

@sumitagrawl sumitagrawl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 LGTM

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @xichen01 for the patch.

Comment on lines 90 to 91
SCMDeletedBlockTransactionStatusManager
getSCMDeletedBlockTransactionStatusManager();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeletedBlockLog interface is defined in terms of operations . I don't think exposing a manager object is appropriate for the interface, it should be an implementation detail. Similarly, sharing the same lock between the two objects does not seem right.

Maybe the interface should define operations that the implementation passes through to the manager. Alternatively the manager object should have an interface defined separately, and act as a way to manipulate the DeletedBlockLog.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the getSCMDeletedBlockTransactionStatusManager interface from DeletedBlockLog and added DeletedBlockTransactionStatusManager related actions to DeletedBlockLog.

@sumitagrawl sumitagrawl merged commit 88e18e3 into apache:master Dec 18, 2023
34 checks passed
@adoroszlai
Copy link
Contributor

@xichen01 Could you please check HDDS-9962, intermittent failure in TestBlockDeletion? It started happening after this PR was merged.

@xichen01
Copy link
Contributor Author

@xichen01 Could you please check HDDS-9962, intermittent failure in TestBlockDeletion? It started happening after this PR was merged.

OK, I will check this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants