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

*: show memory usage in "show processlist" #6266

Merged
merged 4 commits into from
Apr 12, 2018

Conversation

zz-jason
Copy link
Member

after this PR:

TiDB(localhost) > show processlist;
+------+------+-----------+------+---------+------+-------+--------------------------------+----------+
| Id   | User | Host      | db   | Command | Time | State | Info                           | Mem      |
+------+------+-----------+------+---------+------+-------+--------------------------------+----------+
|    3 | root | 127.0.0.1 | test | Query   |    0 | 2     | show processlist               |        0 |
|    1 | root | 127.0.0.1 | test | Query   |  162 | 2     | select * from t t1, t t2, t t3 | 19906560 |
+------+------+-----------+------+---------+------+-------+--------------------------------+----------+
2 rows in set (0.01 sec)

@zz-jason zz-jason changed the title *: show memory usage in "show processlis" *: show memory usage in "show processlist" Apr 11, 2018
@zz-jason
Copy link
Member Author

@winoros @XuHuaiyu @shenli PTAL

@winkyao
Copy link
Contributor

winkyao commented Apr 11, 2018

CI failed

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

reset LGTM

@zz-jason
Copy link
Member Author

/run-all-tests

@@ -1380,6 +1380,7 @@ 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.

Could we do it in SetProcessInfo?

Copy link
Member Author

Choose a reason for hiding this comment

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

No we can not. Memory usage is dynamically changed value, we should calculate the memory usage when "show processlist" is called not when a query is being executed.

Copy link
Contributor

@alivxxx alivxxx 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 merged commit 27fa552 into pingcap:master Apr 12, 2018
@zz-jason zz-jason deleted the dev/showmem branch April 12, 2018 03:44
@zz-jason zz-jason added the status/LGT2 Indicates that a PR has LGTM 2. label Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants