tidb icon indicating copy to clipboard operation
tidb copied to clipboard

*: Add tidbCPU/tikvCPU for show processlist command

Open yibin87 opened this issue 1 year ago • 16 comments

What problem does this PR solve?

Issue Number: close #55542

Problem Summary: For executing slow queries, users may want to know some basic infos to know why it executes so slow. While "explain connection" provide executor-level infos, processlist tables provide more general and user-friendly infos. Tidb/tikv cpu info is easy to understand, and it can guide users where the bottlenecks are: tidb side or tikv side. Besides, these memory system tables can be recorded regularly in tikv in future, as a complement for current dianostic technics: Currently, slow query log is one of the most used diagnostic technics. The slow log info is so large that we can't record all queries. However, it's very hard or almost impossible to design a perfect algorithm to recoginize these "need-to-check" queries.

What changed and how does it work?

Several details about the changes:

  1. tidbCPU is collected using topsql mechanism, so it works only when "tidb_enable_top_sql" is enabled.
  2. The PR added extra columns in information_schema.processlists, while not changing the outputs of show processlists command, since the later command shows only brief info.
  3. Use connID + sqlID as the global unique label for each command, sqlID is increased by 1 each time. sqlID will turned to 0 when it exceeds the uint64 MAX, thus there is little possibility that later command with smaller sqlID. Since the possibility is very very small, and affects only the observability not functionality, just ignore.

Check List

Tests

  • [x] Unit test
  • [ ] Integration test
  • [ ] Manual test (add detailed scripts or steps below)
  • [ ] No need to test
    • [ ] I checked and no code files have been changed.

Side effects

  • [ ] Performance regression: Consumes more CPU
  • [ ] Performance regression: Consumes more Memory
  • [ ] Breaking backward compatibility

Documentation

  • [ ] Affects user behaviors
  • [ ] Contains syntax changes
  • [ ] Contains variable changes
  • [ ] Contains experimental features
  • [ ] Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

yibin87 avatar Aug 16 '24 02:08 yibin87

PR needs rebase.

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[bot] avatar Aug 16 '24 02:08 ti-chi-bot[bot]

Hi @yibin87. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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-sigs/prow repository.

tiprow[bot] avatar Aug 16 '24 02:08 tiprow[bot]

/cc @wshwsh12 @crazycs520 @mornyx

yibin87 avatar Aug 21 '24 02:08 yibin87

/retest

yibin87 avatar Aug 21 '24 03:08 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

tiprow[bot] avatar Aug 21 '24 03:08 tiprow[bot]

Codecov Report

Attention: Patch coverage is 96.42857% with 6 lines in your changes missing coverage. Please review.

Project coverage is 57.3975%. Comparing base (487ef06) to head (dc3a491). Report is 6 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #55455         +/-   ##
=================================================
- Coverage   72.8514%   57.3975%   -15.4539%     
=================================================
  Files          1598       1745        +147     
  Lines        444454     621258     +176804     
=================================================
+ Hits         323791     356587      +32796     
- Misses       100734     240120     +139386     
- Partials      19929      24551       +4622     
Flag Coverage Δ
integration 39.6520% <42.6751%> (?)
tiprow_ft ?
unit 72.0888% <92.2619%> (+0.1181%) :arrow_up:

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 63.1774% <ø> (+17.4041%) :arrow_up:

codecov[bot] avatar Aug 21 '24 05:08 codecov[bot]

/test unit-test

yibin87 avatar Aug 21 '24 07:08 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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-sigs/prow repository.

tiprow[bot] avatar Aug 21 '24 07:08 tiprow[bot]

/test unit-test

yibin87 avatar Aug 21 '24 09:08 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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-sigs/prow repository.

tiprow[bot] avatar Aug 21 '24 09:08 tiprow[bot]

/test check-dev2

yibin87 avatar Aug 21 '24 09:08 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test check-dev2

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-sigs/prow repository.

tiprow[bot] avatar Aug 21 '24 09:08 tiprow[bot]

/test unit-test

yibin87 avatar Aug 26 '24 06:08 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test unit-test

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-sigs/prow repository.

tiprow[bot] avatar Aug 26 '24 06:08 tiprow[bot]

/cc @YangKeao

yibin87 avatar Aug 26 '24 07:08 yibin87

/test unit-test

yibin87 avatar Sep 02 '24 08:09 yibin87

/retest

yibin87 avatar Sep 03 '24 01:09 yibin87

@yibin87: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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-sigs/prow repository.

tiprow[bot] avatar Sep 03 '24 01:09 tiprow[bot]

/ok-to-test

hawkingrei avatar Sep 03 '24 03:09 hawkingrei

/cc @songrijie

yibin87 avatar Sep 04 '24 01:09 yibin87

/test unit-test

yibin87 avatar Sep 04 '24 02:09 yibin87

@yibin87: The specified target(s) for /test were not found. The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test unit-test

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-sigs/prow repository.

tiprow[bot] avatar Sep 04 '24 02:09 tiprow[bot]

/test unit-test

yibin87 avatar Sep 04 '24 03:09 yibin87

@yibin87: The specified target(s) for /test were not found. The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test unit-test

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-sigs/prow repository.

tiprow[bot] avatar Sep 04 '24 03:09 tiprow[bot]

@songrijie: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

The purpose and user interfaces look good to me.

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[bot] avatar Sep 04 '24 06:09 ti-chi-bot[bot]

/test pull-br-integration-test

yibin87 avatar Sep 04 '24 06:09 yibin87

@yibin87: The specified target(s) for /test were not found. The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test pull-br-integration-test

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-sigs/prow repository.

tiprow[bot] avatar Sep 04 '24 06:09 tiprow[bot]

/approve

for ddl/infoschema pkg

D3Hunter avatar Sep 04 '24 09:09 D3Hunter

[LGTM Timeline notifier]

Timeline:

  • 2024-09-04 06:46:02.873918729 +0000 UTC m=+426887.391971656: :ballot_box_with_check: agreed by wshwsh12.
  • 2024-09-05 03:39:54.891085648 +0000 UTC m=+502119.409138667: :ballot_box_with_check: agreed by crazycs520.

ti-chi-bot[bot] avatar Sep 05 '24 03:09 ti-chi-bot[bot]

LGTM, this PR currently misses a lot of fast-sql's cpu-time, I hope your future data-persistence work can fix this problem.

BTW, the cpu_time in the statements_summary system table can be accurate, after the profile is complete, let the profile collector update the data of the statements_summary.

File a new issut to track the statements_summary improvements: https://github.com/pingcap/tidb/issues/55869

yibin87 avatar Sep 05 '24 05:09 yibin87