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

infoschema: add current txn start time in processlist table #11491

Merged
merged 4 commits into from
Jul 29, 2019
Merged

infoschema: add current txn start time in processlist table #11491

merged 4 commits into from
Jul 29, 2019

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jul 29, 2019

What problem does this PR solve?

help identify long-running transaction(maybe client forgot to commit/rollback) add TxnStart column to information_schema.processlist

mysql> select * from information_schema.processlist;
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
| ID   | USER | HOST      | DB   | COMMAND | TIME | STATE | INFO                                         | MEM  | TxnStart |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
|    1 | root | 127.0.0.1 | test | Query   |    0 | 2     | select * from information_schema.processlist |    0 |          |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
1 row in set (0.00 sec)

mysql> begin;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from information_schema.processlist;
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------------------------------------+
| ID   | USER | HOST      | DB   | COMMAND | TIME | STATE | INFO                                         | MEM  | TxnStart                               |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------------------------------------+
|    1 | root | 127.0.0.1 | test | Query   |    0 | 3     | select * from information_schema.processlist |    0 | 07-29 12:34:29.166(410091485702651904) |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------------------------------------+
1 row in set (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from information_schema.processlist;
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
| ID   | USER | HOST      | DB   | COMMAND | TIME | STATE | INFO                                         | MEM  | TxnStart |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
|    1 | root | 127.0.0.1 | test | Query   |    0 | 2     | select * from information_schema.processlist |    0 |          |
+------+------+-----------+------+---------+------+-------+----------------------------------------------+------+----------+
1 row in set (0.00 sec)

What is changed and how it works?

add a column to info schema table, but didn't change show proceslist to keep compatibility.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • add new column to infoschema

Side effects

  • N/A

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

This change is Reviewable

@lysu
Copy link
Contributor Author

lysu commented Jul 29, 2019

/run-all-tests

infoschema/tables_test.go Outdated Show resolved Hide resolved
util/misc.go Outdated Show resolved Hide resolved
Copy link
Member

@jackysp jackysp left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp
Copy link
Member

jackysp commented Jul 29, 2019

The CI failed, seems we need to consider the time zone.

... obtained string = "" +
...     "[1 user-1 localhost information_schema Quit 9223372036 1 <nil> 0 ]\n" +
...     "[2 user-2 localhost <nil> Init DB 9223372036 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 07-29 03:26:05.158(410090409861578752)]\n"
... expected string = "" +
...     "[1 user-1 localhost information_schema Quit 9223372036 1 <nil> 0 ]\n" +
...     "[2 user-2 localhost <nil> Init DB 9223372036 2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 0 07-29 11:26:05.158(410090409861578752)]\n"

@codecov
Copy link

codecov bot commented Jul 29, 2019

Codecov Report

Merging #11491 into master will increase coverage by 0.0201%.
The diff coverage is 100%.

@@               Coverage Diff               @@
##             master    #11491        +/-   ##
===============================================
+ Coverage   81.3308%   81.351%   +0.0201%     
===============================================
  Files           424       424                
  Lines         91247     90922       -325     
===============================================
- Hits          74212     73966       -246     
+ Misses        11710     11635        -75     
+ Partials       5325      5321         -4

@lysu
Copy link
Contributor Author

lysu commented Jul 29, 2019

/run-all-tests

@jackysp PTAL

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

@jackysp jackysp merged commit 05b4e22 into pingcap:master Jul 29, 2019
@jackysp
Copy link
Member

jackysp commented Jul 29, 2019

LGTM

@sre-bot
Copy link
Contributor

sre-bot commented Jul 29, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @lysu PTAL.

@lysu
Copy link
Contributor Author

lysu commented Apr 8, 2020

/run-cherry-picker

@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-3.0 in PR #16160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants