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

pd-ctl: avoid initializing a new PD client for each cmd execution #7804

Merged
merged 5 commits into from
Feb 5, 2024

Conversation

JmPotato
Copy link
Member

@JmPotato JmPotato commented Feb 5, 2024

What problem does this PR solve?

Issue Number: ref #7300.

What is changed and how does it work?

Avoid initializing a new PD client for each cmd execution. Now we will only initialize a new one when the cluster changes.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
./bin/pd-ctl -i
» tso 123
system:  1970-01-01 08:00:00 +0800 CST
logic:   123
» cluster
Usage:
  pd-ctl cluster [flags]
  pd-ctl cluster [command]

Available Commands:
  status      show the cluster status

Flags:
  -h, --help   help for cluster

Use "pd-ctl cluster [command] --help" for more information about a command.

Get "http://127.0.0.1:2379/pd/api/v1/cluster": dial tcp 127.0.0.1:2379: connect: connection refused
// Start the cluster
» cluster
{
  "id": 7332031263979491699,
  "max_peer_count": 3
}
// Start another cluster
» -u http://127.0.0.1:63039 cluster
{
  "id": 7332031352003469768,
  "max_peer_count": 3
}
» -u http://127.0.0.1:63 cluster
Usage:
  pd-ctl cluster [flags]
  pd-ctl cluster [command]

Available Commands:
  status      show the cluster status

Flags:
  -h, --help   help for cluster

Use "pd-ctl cluster [command] --help" for more information about a command.

Get "http://127.0.0.1:63/pd/api/v1/cluster": dial tcp 127.0.0.1:63: connect: connection refused
» store 1
{
  "store": {
    "id": 1,
    "address": "127.0.0.1:20160",
    "version": "8.0.0-alpha",
    "peer_address": "127.0.0.1:20160",
    "status_address": "127.0.0.1:20180",
    "git_hash": "04370e9ef47c2768d368cb62309631018be3eaa8",
    "start_timestamp": 1707121719,
    "deploy_path": "/Users/jmpotato/.tiup/components/tikv/v8.0.0-alpha-nightly",
    "last_heartbeat": 1707121729917357000,
    "node_state": 1,
    "state_name": "Up"
  },
  "status": {
    "capacity": "460.4GiB",
    "available": "145.2GiB",
    "used_size": "290.8MiB",
    "leader_count": 61,
    "leader_weight": 1,
    "leader_score": 61,
    "leader_size": 60,
    "region_count": 61,
    "region_weight": 1,
    "region_score": 140.93049047606394,
    "region_size": 60,
    "slow_score": 1,
    "slow_trend": {
      "cause_value": 250010.35204081633,
      "cause_rate": 0,
      "result_value": 0,
      "result_rate": 0
    },
    "is_busy": true,
    "start_ts": "2024-02-05T16:28:39+08:00",
    "last_heartbeat_ts": "2024-02-05T16:28:49.917357+08:00",
    "uptime": "10.917357s"
  }
}
» -u http://127.0.0.1:63693 store 1
{
  "store": {
    "id": 1,
    "address": "127.0.0.1:63694",
    "version": "8.0.0-alpha",
    "peer_address": "127.0.0.1:63694",
    "status_address": "127.0.0.1:63695",
    "git_hash": "04370e9ef47c2768d368cb62309631018be3eaa8",
    "start_timestamp": 1707121730,
    "deploy_path": "/Users/jmpotato/.tiup/components/tikv/v8.0.0-alpha-nightly",
    "last_heartbeat": 1707121760528419000,
    "node_state": 1,
    "state_name": "Up"
  },
  "status": {
    "capacity": "460.4GiB",
    "available": "145GiB",
    "used_size": "290.8MiB",
    "leader_count": 61,
    "leader_weight": 1,
    "leader_score": 61,
    "leader_size": 60,
    "region_count": 61,
    "region_weight": 1,
    "region_score": 141.0322261693217,
    "region_size": 60,
    "slow_score": 1,
    "slow_trend": {
      "cause_value": 250007.81016949154,
      "cause_rate": 0,
      "result_value": 19.5,
      "result_rate": 0
    },
    "is_busy": true,
    "start_ts": "2024-02-05T16:28:50+08:00",
    "last_heartbeat_ts": "2024-02-05T16:29:20.528419+08:00",
    "uptime": "30.528419s"
  }
}

Release note

None.

@JmPotato JmPotato added the component/tools Tools. label Feb 5, 2024
@JmPotato JmPotato requested review from rleungx and HuSharp February 5, 2024 04:07
Copy link
Contributor

ti-chi-bot bot commented Feb 5, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • CabinfeverB
  • HuSharp

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 bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 5, 2024
Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Merging #7804 (07eac54) into master (37be34e) will decrease coverage by 0.07%.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7804      +/-   ##
==========================================
- Coverage   73.47%   73.40%   -0.07%     
==========================================
  Files         432      432              
  Lines       47842    47842              
==========================================
- Hits        35151    35119      -32     
- Misses       9648     9675      +27     
- Partials     3043     3048       +5     
Flag Coverage Δ
unittests 73.40% <ø> (-0.07%) ⬇️

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

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 5, 2024
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Copy link
Member

@HuSharp HuSharp 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 bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 5, 2024
@HuSharp
Copy link
Member

HuSharp commented Feb 5, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Feb 5, 2024

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

Copy link
Contributor

ti-chi-bot bot commented Feb 5, 2024

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

Commit hash: e1c5dc0

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Feb 5, 2024
Copy link
Contributor

ti-chi-bot bot commented Feb 5, 2024

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

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 bot merged commit ddf810b into tikv:master Feb 5, 2024
24 of 26 checks passed
@JmPotato JmPotato deleted the refine_pd_ctl_test branch February 5, 2024 10:39
@HuSharp HuSharp mentioned this pull request Feb 8, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/tools Tools. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants