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

api: add role_name and is_learner to the returned peer info (#3643) #3743

Merged

Conversation

ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Jun 4, 2021

This is an automated cherry-pick of #3643

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

What problem does this PR solve?

close #3372 tidb#24293

What is changed and how it works?

  • api: add role_name and is_learner to the returned peer info

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Before

region 83693
{
  "id": 83693,
  "peers": [
    {
      "id": 83694,
      "store_id": 1
    },
    {
      "id": 83695,
      "store_id": 51
    },
    {
      "id": 83696,
      "store_id": 76
    },
    {
      "id": 104792,
      "store_id": 101,
      "role": 1
    }
  ],
  "leader": {
    "id": 83694,
    "store_id": 1
  },
  ...
}
SELECT * FROM INFORMATION_SCHEMA.TIKV_REGION_PEERS WHERE REGION_ID=83693;
+-----------+---------+----------+------------+-----------+--------+--------------+
| REGION_ID | PEER_ID | STORE_ID | IS_LEARNER | IS_LEADER | STATUS | DOWN_SECONDS |
+-----------+---------+----------+------------+-----------+--------+--------------+
|     83693 |   83694 |        1 |          0 |         1 | NORMAL |         NULL |
|     83693 |   83695 |       51 |          0 |         0 | NORMAL |         NULL |
|     83693 |   83696 |       76 |          0 |         0 | NORMAL |         NULL |
|     83693 |  104792 |      101 |          0 |         0 | NORMAL |         NULL |
+-----------+---------+----------+------------+-----------+--------+--------------+

After

region 83693                                                                                                                                   
{
  "id": 83693,
  "peers": [
    {
      "id": 83694,
      "store_id": 1,
      "role_name": "Voter"
    },
    {
      "id": 83695,
      "store_id": 51,
      "role_name": "Voter"
    },
    {
      "id": 83696,
      "store_id": 76,
      "role_name": "Voter"
    },
    {
      "id": 104792,
      "store_id": 101,
      "role": 1,
      "role_name": "Learner",
      "is_learner": true
    }
  ],
  "leader": {
    "id": 83696,
    "store_id": 76,
    "role_name": "Voter"
  },
  ...
}
SELECT * FROM INFORMATION_SCHEMA.TIKV_REGION_PEERS WHERE REGION_ID=83693;
+-----------+---------+----------+------------+-----------+--------+--------------+
| REGION_ID | PEER_ID | STORE_ID | IS_LEARNER | IS_LEADER | STATUS | DOWN_SECONDS |
+-----------+---------+----------+------------+-----------+--------+--------------+
|     83693 |   83694 |        1 |          0 |         0 | NORMAL |         NULL |
|     83693 |   83695 |       51 |          0 |         0 | NORMAL |         NULL |
|     83693 |   83696 |       76 |          0 |         1 | NORMAL |         NULL |
|     83693 |  104792 |      101 |          1 |         0 | NORMAL |         NULL |
+-----------+---------+----------+------------+-----------+--------+--------------+

Side effects

  • Possible performance regression
    • When /regions returns a large number of regions

Before

goos: darwin
goarch: amd64
pkg: github.com/tikv/pd/server/api
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkConvertToAPIRegions-4               571           1918032 ns/op
BenchmarkConvertToAPIRegions-4               584           1892309 ns/op
BenchmarkConvertToAPIRegions-4               570           1918750 ns/op
BenchmarkConvertToAPIRegions-4               592           2220998 ns/op
BenchmarkConvertToAPIRegions-4               598           1936396 ns/op

After

goos: darwin
goarch: amd64
pkg: github.com/tikv/pd/server/api
cpu: Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
BenchmarkConvertToAPIRegions-4               368           3293800 ns/op
BenchmarkConvertToAPIRegions-4               375           3128312 ns/op
BenchmarkConvertToAPIRegions-4               368           3121975 ns/op
BenchmarkConvertToAPIRegions-4               374           3114500 ns/op
BenchmarkConvertToAPIRegions-4               373           3083650 ns/op

Related changes

  • Need to cherry-pick to the release branch

Release note

Fix the bug that the `is_learner` field of the Region Peer in TiDB is incorrect.

HunDunDM added 12 commits June 4, 2021 03:27
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>
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
Copy link
Member Author

@ti-chi-bot: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

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 kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot added component/api HTTP API. type/bugfix This PR fixes a bug. type/cherry-pick-for-release-5.0 The PR belongs to release-5.0 cherry pick. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 4, 2021
@ti-chi-bot ti-chi-bot requested a review from nolouch June 4, 2021 03:27
@ti-chi-bot ti-chi-bot requested review from disksing and rleungx June 4, 2021 03:27
@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #3743 (f24c091) into release-5.0 (09e8392) will increase coverage by 0.02%.
The diff coverage is 96.66%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release-5.0    #3743      +/-   ##
===============================================
+ Coverage        74.73%   74.76%   +0.02%     
===============================================
  Files              245      245              
  Lines            24188    24208      +20     
===============================================
+ Hits             18076    18098      +22     
+ Misses            4503     4500       -3     
- Partials          1609     1610       +1     
Flag Coverage Δ
unittests 74.76% <96.66%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
server/api/region.go 65.84% <96.15%> (+1.66%) ⬆️
tests/pdctl/helper.go 100.00% <100.00%> (ø)
pkg/dashboard/adapter/manager.go 79.78% <0.00%> (-3.20%) ⬇️
server/tso/allocator_manager.go 76.91% <0.00%> (-2.50%) ⬇️
server/election/leadership.go 85.88% <0.00%> (-1.18%) ⬇️
server/schedule/operator/step.go 67.44% <0.00%> (-1.00%) ⬇️
server/core/storage.go 67.68% <0.00%> (-0.77%) ⬇️
server/tso/tso.go 73.61% <0.00%> (-0.62%) ⬇️
server/schedule/placement/rule_manager.go 82.87% <0.00%> (-0.62%) ⬇️
server/server.go 72.48% <0.00%> (-0.46%) ⬇️
... and 10 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 09e8392...f24c091. Read the comment docs.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 8, 2021
@zhouqiang-cl zhouqiang-cl added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 25, 2021
@ti-chi-bot
Copy link
Member Author

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • disksing
  • 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.

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/merge

@ti-chi-bot
Copy link
Member Author

@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 Author

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

Commit hash: 125c08c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 25, 2021
@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-integration-ddl-test

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/rebuild

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-all-tests

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/merge

@ti-chi-bot
Copy link
Member Author

@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.

@purelind
Copy link
Contributor

/rebuild

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-all-tests

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-integration-ddl-test

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-integration-compatibility-test

@nolouch
Copy link
Contributor

nolouch commented Jun 25, 2021

/run-integration-common-test

2 similar comments
@nolouch
Copy link
Contributor

nolouch commented Jun 26, 2021

/run-integration-common-test

@nolouch
Copy link
Contributor

nolouch commented Jun 28, 2021

/run-integration-common-test

@nolouch
Copy link
Contributor

nolouch commented Jun 28, 2021

/run-integration-ddl-test

@zhouqiang-cl
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member Author

@zhouqiang-cl: 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.

@zhouqiang-cl
Copy link
Contributor

/run-integration-ddl-test

@zhouqiang-cl zhouqiang-cl removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Jun 28, 2021
@ti-chi-bot ti-chi-bot merged commit 9fff28d into tikv:release-5.0 Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. component/api HTTP API. 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. type/cherry-pick-for-release-5.0 The PR belongs to release-5.0 cherry pick.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants