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

encryption: refine key manager watcher loop #4111

Merged
merged 6 commits into from
Sep 24, 2021

Conversation

HunDunDM
Copy link
Member

What problem does this PR solve?

Fix #4071

What is changed and how it works?

encryption: refine key manager watcher loop

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 13, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • nolouch

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 the release-note-none Denotes a PR that doesn't merit a release note. label Sep 13, 2021
@HunDunDM HunDunDM added type/bugfix This PR fixes a bug. component/security Security logic. needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. needs-cherry-pick-release-5.1 Type: Need cherry pick to release-5.1 needs-cherry-pick-release-5.2 Type: Need cherry pick to release-5.2 labels Sep 13, 2021
@HunDunDM
Copy link
Member Author

cc @yiwu-arbug

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 14, 2021
m.helper.eventAfterTicker()
}

select {

Choose a reason for hiding this comment

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

when server being shutdown, will it stop the watcher loop?

Copy link
Member Author

Choose a reason for hiding this comment

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

watcher.Watch uses ctx, when ctx is Done, it will break.

for {
select {
case resp, ok = <-rch:
if !ok || resp.CompactRevision != 0 || resp.Canceled {

Choose a reason for hiding this comment

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

what does compact revision != 0 mean? It has been a while I forget most about etcd.

Copy link
Member Author

Choose a reason for hiding this comment

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

api#watch-streams

Compact_Revision - set to the minimum historical revision available to etcd if a watcher tries watching at a compacted revision. This happens when creating a watcher at a compacted revision or the watcher cannot catch up with the progress of the key-value store. The watcher will be canceled; creating new watches with the same start_revision will fail.

Choose a reason for hiding this comment

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

can you add inline comment about it?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@nolouch nolouch Sep 16, 2021

Choose a reason for hiding this comment

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

I think you can use !ok || resp.Err() != nil directly.

@ti-chi-bot
Copy link
Member

@yiwu-arbug: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

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.

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

rest lgtm

Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 24, 2021
@nolouch
Copy link
Contributor

nolouch commented Sep 24, 2021

/merge

@ti-chi-bot
Copy link
Member

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

/run-all-tests

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: ec196b1

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 24, 2021
@codecov
Copy link

codecov bot commented Sep 24, 2021

Codecov Report

Merging #4111 (ec196b1) into master (62c6647) will increase coverage by 0.05%.
The diff coverage is 67.74%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4111      +/-   ##
==========================================
+ Coverage   74.37%   74.43%   +0.05%     
==========================================
  Files         260      260              
  Lines       26467    26476       +9     
==========================================
+ Hits        19686    19707      +21     
+ Misses       5000     4993       -7     
+ Partials     1781     1776       -5     
Flag Coverage Δ
unittests 74.43% <67.74%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/encryptionkm/key_manager.go 72.80% <67.74%> (+1.01%) ⬆️
pkg/dashboard/adapter/manager.go 78.72% <0.00%> (-4.26%) ⬇️
server/schedulers/random_merge.go 60.00% <0.00%> (-3.34%) ⬇️
pkg/etcdutil/etcdutil.go 84.70% <0.00%> (-1.18%) ⬇️
server/core/storage.go 68.04% <0.00%> (-0.76%) ⬇️
server/server.go 71.40% <0.00%> (-0.60%) ⬇️
server/schedule/placement/rule_manager.go 83.95% <0.00%> (-0.58%) ⬇️
server/tso/allocator_manager.go 63.83% <0.00%> (-0.34%) ⬇️
server/cluster/cluster.go 82.33% <0.00%> (-0.24%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62c6647...ec196b1. Read the comment docs.

@ti-chi-bot ti-chi-bot merged commit bab9092 into tikv:master Sep 24, 2021
@HunDunDM HunDunDM deleted the fix-keymanager-deadloop branch September 24, 2021 10:44
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4153.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4154.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Sep 24, 2021
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #4155.

ti-chi-bot added a commit that referenced this pull request Oct 13, 2021
* remove watcherEnabled

Signed-off-by: HunDunDM <hundundm@gmail.com>

* encryption: refine key manager watcher loop

Signed-off-by: HunDunDM <hundundm@gmail.com>

* fix log

Signed-off-by: HunDunDM <hundundm@gmail.com>

* add comment

Signed-off-by: HunDunDM <hundundm@gmail.com>

* add comment

Signed-off-by: HunDunDM <hundundm@gmail.com>

* address comment

Signed-off-by: HunDunDM <hundundm@gmail.com>

* *: use SerialSuites to reduce the servers in tests at the same time (#4171)

Signed-off-by: HunDunDM <hundundm@gmail.com>

Co-authored-by: HunDunDM <hundundm@gmail.com>
hzh0425 pushed a commit to hzh0425/pd that referenced this pull request Nov 16, 2021
* remove watcherEnabled

Signed-off-by: HunDunDM <hundundm@gmail.com>

* encryption: refine key manager watcher loop

Signed-off-by: HunDunDM <hundundm@gmail.com>

* fix log

Signed-off-by: HunDunDM <hundundm@gmail.com>

* add comment

Signed-off-by: HunDunDM <hundundm@gmail.com>

* add comment

Signed-off-by: HunDunDM <hundundm@gmail.com>

* address comment

Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: hzh0425 <642256541@qq.com>
nolouch pushed a commit that referenced this pull request Nov 30, 2021
* This is an automated cherry-pick of #4111

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
nolouch pushed a commit that referenced this pull request Nov 30, 2021
* encryption: refine key manager watcher loop

Signed-off-by: HunDunDM <hundundm@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/security Security logic. needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. needs-cherry-pick-release-5.1 Type: Need cherry pick to release-5.1 needs-cherry-pick-release-5.2 Type: Need cherry pick to release-5.2 release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PD enters deadloop in key manager watch routine and costs 100% CPU
5 participants