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

trace peers' availability info on leader side #13209

Merged
merged 14 commits into from Oct 12, 2022

Conversation

ethercflow
Copy link
Member

@ethercflow ethercflow commented Aug 2, 2022

Issue Number: ref #12876

Signed-off-by: Wenbo Zhang ethercflow@gmail.com

What is changed and how it works?

Issue Number: Close #xxx

What's Changed:

trace peers' availability info on leader side

Related changes

  • No

Check List

Tests

  • No code

Side effects

  • Performance regression
    • Consumes more CPU
    • Consumes more MEM

Release note

trace peers' availability info on leader side

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Aug 2, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • BusyJay
  • Connor1996

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added size/L and removed size/M labels Aug 9, 2022
@ethercflow ethercflow marked this pull request as ready for review August 10, 2022 03:06
@BusyJay
Copy link
Member

BusyJay commented Aug 10, 2022

What's the purpose of this PR?

@ethercflow
Copy link
Member Author

What's the purpose of this PR?

It'll be used to judge pending peer: whose (except witness) apply index is smaller than leader's truncated index

@BusyJay
Copy link
Member

BusyJay commented Aug 10, 2022

It'll be used to judge pending peer: whose (except witness) apply index is smaller than leader's truncated index

Why it has to be apply index? Why can't matched be used? What's the exact definition and purpose of pending peer?

@Connor1996
Copy link
Member

Connor1996 commented Aug 10, 2022

What's the purpose of this PR?

  • For witness -> non-witness conf-change, we need to know when the snapshot has been applied. The witness or uninitialized peer would always report apply index of 0. And once the snapshot is applied, it reports the latest apply index then PD gets to know the operator is finished.
  • It's a general feature that can benefit other features:
    • Tiflash has a demand to detect slow apply tiflash peer
    • Pre-transfer-leader doesn't need to send a message to get the target peer's apply index

@BusyJay
Copy link
Member

BusyJay commented Aug 10, 2022

For witness -> non-witness conf-change, we need to know when the snapshot has been applied. The witness or uninitialized peer would always report apply index of 0. And once the snapshot is applied, it reports the latest apply index then PD gets to know the operator is finished.

Instead of querying index, I suggest to reply with the exact information that whether it's applying snapshot or whether it's in healthy state that can serve at least stale read.

  * Tiflash has a demand to detect slow apply tiflash peer

Index less than truncated index doesn't mean it's slow. Leader is free to truncate logs whenever it wants despite other peers' apply progress. Slow apply should be monitored by time. The requirement is false.

  * Pre-transfer-leader doesn't need to send a message to get the target peer's apply index

pre-transfer-leader doesn't just check for apply index. A message is always required.

@Connor1996
Copy link
Member

Instead of querying index, I suggest to reply with the exact information that whether it's applying snapshot or whether it's in healthy state that can serve at least stale read.

I don't think exact information is general enough, what if we want to do flow control based on slow apply, it still needs to trace apply index progress.

Index less than truncated index doesn't mean it's slow. Leader is free to truncate logs whenever it wants despite other peers' apply progress. Slow apply should be monitored by time. The requirement is false.

Yes, it may be false-positive when compared to the truncated index, but it can compare to the leader's apply index.

pre-transfer-leader doesn't just check for apply index. A message is always required.

I know, but it can be a quick return when the apply index is lagged.

@BusyJay
Copy link
Member

BusyJay commented Aug 10, 2022

what if we want to do flow control based on slow apply, it still needs to trace apply index progress.

Slow apply should not be measured by index. Instead, it should be measured by memory, CPU and disk capacity/IO. Only the follower knows whether it's overloaded and suggest leader to do a flow control. We already have such control by actively reject leader's MsgAppend.

Yes, it may be false-positive when compared to the truncated index, but it can compare to the leader's apply index.

What's the point? They are doing different work and have different access pattern.

@Connor1996
Copy link
Member

Connor1996 commented Aug 10, 2022

Slow apply should not be measured by index. Instead, it should be measured by memory, CPU and disk capacity/IO. Only the follower knows whether it's overloaded and suggest leader to do a flow control. We already have such control by actively reject leader's MsgAppend.

Not want to deep into the details of slow apply. My point is the apply index fits the witness requirement, and it also can be used by other features. So why bother to pass exact information dedicated to witness instead of a general one -- apply index?

What's the point? They are doing different work and have different access pattern.

The point is that the slow Tiflash can be detected by the tiflash peer's apply index with leader apply index, it's not a false requirement. This issue of tiflash isn't related with time, it needs to know the index to check if the tiflash is ready, see https://pingcap.feishu.cn/docx/doxcnxQfXMgxnLV0pQqNxP9mQad

ref tikv#12876

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
@ethercflow
Copy link
Member Author

/run-tests

1 similar comment
@ethercflow
Copy link
Member Author

/run-tests

components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Show resolved Hide resolved
Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added the status/LGT1 Status: PR - There is already 1 approval label Oct 9, 2022
Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
ref tikv#12876

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

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

Any test case?

components/raftstore/src/store/fsm/peer.rs Outdated Show resolved Hide resolved
components/raftstore/src/store/fsm/peer.rs Show resolved Hide resolved
Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>
@ethercflow
Copy link
Member Author

ethercflow commented Oct 11, 2022

Any test case?

I've added integration tests here because currently there is no place for these functions to be called in this PR.

@ti-chi-bot ti-chi-bot added status/LGT2 Status: PR - There are already 2 approvals and removed status/LGT1 Status: PR - There is already 1 approval labels Oct 11, 2022
@Connor1996
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 4ee908a

@ti-chi-bot ti-chi-bot added the status/can-merge Status: Can merge to base branch label Oct 12, 2022
@ti-chi-bot
Copy link
Member

@ethercflow: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot merged commit f702db2 into tikv:master Oct 12, 2022
@ti-chi-bot ti-chi-bot added this to the Pool milestone Oct 12, 2022
ethercflow added a commit to ethercflow/tikv that referenced this pull request Oct 19, 2022
ref tikv#12876

Signed-off-by: Wenbo Zhang <ethercflow@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/L status/can-merge Status: Can merge to base branch status/LGT2 Status: PR - There are already 2 approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants