*: Add tidbCPU/tikvCPU for show processlist command
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:
- tidbCPU is collected using topsql mechanism, so it works only when "tidb_enable_top_sql" is enabled.
- The PR added extra columns in information_schema.processlists, while not changing the outputs of
show processlistscommand, since the later command shows only brief info. - 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
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.
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.
/cc @wshwsh12 @crazycs520 @mornyx
/retest
@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.
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: |
/test unit-test
@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.
/test unit-test
@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.
/test check-dev2
@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.
/test unit-test
@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.
/cc @YangKeao
/test unit-test
/retest
@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.
/ok-to-test
/cc @songrijie
/test unit-test
@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.
/test unit-test
@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.
@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.
/test pull-br-integration-test
@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.
/approve
for ddl/infoschema pkg
[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.
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