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

*: Hide "Mem" column from SHOW PROCESSSLIST #8543

Merged
merged 3 commits into from
Dec 5, 2018
Merged

*: Hide "Mem" column from SHOW PROCESSSLIST #8543

merged 3 commits into from
Dec 5, 2018

Conversation

morgo
Copy link
Contributor

@morgo morgo commented Dec 2, 2018

What problem does this PR solve?

#8482

What is changed and how it works?

The command SHOW PROCESSLIST has a column called 'Mem', which at least for me has always showed a zero value. This patch removes the column completely, but an alternative fix (beyond my current skill) could be to fix the output to be correct.

In MySQL the memory info is available in perfschema (try for example: SELECT * FROM sys.session) , but since TiDB does not implement perfschema maybe extending processlist is the best way to present it? I could be convinced either way, but I am submitting this patch because a zero value is a bad first experience.

MySQL 5.7.40:

mysql57> mysql57> SHOW PROCESSLIST;
+----+----------+-----------+------+---------+------+----------+------------------+
| Id | User     | Host      | db   | Command | Time | State    | Info             |
+----+----------+-----------+------+---------+------+----------+------------------+
|  2 | msandbox | localhost | NULL | Query   |   -1 | starting | SHOW PROCESSLIST |
+----+----------+-----------+------+---------+------+----------+------------------+
1 row in set (0.00 sec)

TiDB master:

mysql> SHOW PROCESSLIST;
+------+------+-----------+------+---------+------+-------+------------------+------+
| Id   | User | Host      | db   | Command | Time | State | Info             | Mem  |
+------+------+-----------+------+---------+------+-------+------------------+------+
|    1 | root | 127.0.0.1 |      | Query   |    0 | 2     | SHOW PROCESSLIST |    0 |
+------+------+-----------+------+---------+------+-------+------------------+------+
1 row in set (0.00 sec)

TiDB master + this patch:

mysql> SHOW PROCESSLIST;
+------+------+-----------+------+---------+------+-------+------------------+
| Id   | User | Host      | db   | Command | Time | State | Info             |
+------+------+-----------+------+---------+------+-------+------------------+
|    2 | root | 127.0.0.1 |      | Query   |    0 | 2     | SHOW PROCESSLIST |
+------+------+-----------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

Check List

Tests

  • Manual test

Ran manual test + fixed tests that broke.

Code changes

  • Has interface methods change

Side effects

  • Breaking backward compatibility

Related changes

  • Need to update the documentation
  • Need to be included in the release note

This change is Reviewable

Always shows zero.  Column not present in MySQL.
@shenli
Copy link
Member

shenli commented Dec 3, 2018

@morgo Will this break the compatibility with MySQL. AFAK, some admin tools rely some specific columns of SHOW PROCESSSLIST.

@morgo
Copy link
Contributor Author

morgo commented Dec 3, 2018

@shenli I've updated the description to make it clearer. 'Mem' is not a column in MySQL - it was a TiDB extension not fully implemented.

@@ -1504,7 +1504,6 @@ func (s *session) ShowProcess() util.ProcessInfo {
tmp := s.processInfo.Load()
if tmp != nil {
pi = tmp.(util.ProcessInfo)
pi.Mem = s.GetSessionVars().StmtCtx.MemTracker.BytesConsumed()
Copy link
Contributor

Choose a reason for hiding this comment

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

The Mem is not 0 if you run a memory consuming query simultaneously with SHOW PROCESSLIST. For example:

mysql> SHOW PROCESSLIST;
+------+------+-----------+------+---------+------+-------+-----------------------------------------------------------------+--------+
| Id   | User | Host      | db   | Command | Time | State | Info                                                            | Mem    |
+------+------+-----------+------+---------+------+-------+-----------------------------------------------------------------+--------+
|    1 | root | 127.0.0.1 | tmp  | Query   |    0 | 2     | SHOW PROCESSLIST                                                |      0 |
|    2 | root | 127.0.0.1 | tmp  | Query   |    2 | 2     | insert into tbl select t1.a, t1.b, t1.c from tbl t1 join tbl t2 | 245616 |
+------+------+-----------+------+---------+------+-------+-----------------------------------------------------------------+--------+
2 rows in set (0.02 sec)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting it is not accurate for my select and load data statements:

mysql> SHOW PROCESSLIST;
+------+------+-----------+-----------+---------+------+-------+------------------------------------------------------------------------------------------------------+------+
| Id   | User | Host      | db        | Command | Time | State | Info                                                                                                 | Mem  |
+------+------+-----------+-----------+---------+------+-------+------------------------------------------------------------------------------------------------------+------+
|    5 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2011-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED BY  |    0 |
|    6 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2012Q4-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|    4 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2012Q1-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|    7 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2016Q3-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|   11 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2013Q3-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|    9 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2014Q3-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|   12 | root | 127.0.0.1 |           | Query   |   53 | 2     | SELECT SLEEP(100)                                                                                    |    0 |
|   13 | root | 127.0.0.1 | bikeshare | Query   |    7 | 2     | SELECT * FROM trips WHERE sleep(10)=0 LIMIT 10                                                       |    0 |
|    1 | root | 127.0.0.1 |           | Query   |    0 | 2     | SHOW PROCESSLIST                                                                                     |    0 |
|    8 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2014Q1-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
|   10 | root | 127.0.0.1 | bikeshare | Query   |  153 | 2     | LOAD DATA LOCAL INFILE './2013Q2-capitalbikeshare-tripdata.csv' INTO TABLE trips FIELDS TERMINATED B |    0 |
+------+------+-----------+-----------+---------+------+-------+------------------------------------------------------------------------------------------------------+------+
11 rows in set (0.01 sec)

Copy link
Member

Choose a reason for hiding this comment

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

For now, we only trace the memory usage in some memory intensive SQL operators, for example, HashJoin/IndexLookupJoin/IndexLookupReader, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, then I prefer removing this Mem field since it may confuse users without this knowledge.

@zz-jason zz-jason added the sig/execution SIG execution label Dec 3, 2018
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 3, 2018
@jackysp
Copy link
Member

jackysp commented Dec 4, 2018

How to get the values of Mem if we remove it? @morgo

@jackysp
Copy link
Member

jackysp commented Dec 4, 2018

/run-all-tests

@morgo
Copy link
Contributor Author

morgo commented Dec 4, 2018

@jackysp When I had written the patch, I thought they were always zero. It turns out there are cases of non-zero :(

How about adding an extension SHOW PROCESSLIST MEMINFO, where the column is shown?

@zz-jason
Copy link
Member

zz-jason commented Dec 5, 2018

@jackysp When I had written the patch, I thought they were always zero. It turns out there are cases of non-zero :(

How about adding an extension SHOW PROCESSLIST MEMINFO, where the column is shown?

Glade to see this new feature. 😄

@zz-jason
Copy link
Member

zz-jason commented Dec 5, 2018

/run-integration-ddl-test

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Dec 5, 2018
@eurekaka eurekaka merged commit 3128e9b into pingcap:master Dec 5, 2018
@morgo morgo deleted the processlist branch December 5, 2018 09:43
iamzhoug37 pushed a commit to iamzhoug37/tidb that referenced this pull request Dec 13, 2018
@sre-bot sre-bot added the contribution This PR is from a community contributor. label Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants