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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions executor/executor_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func (msm *mockSessionManager) Kill(cid uint64, query bool) {

func (s *testExecSuite) TestShowProcessList(c *C) {
// Compose schema.
names := []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info", "Mem"}
names := []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info"}
ftypes := []byte{mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar,
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString, mysql.TypeLonglong}
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString}
schema := buildSchema(names, ftypes)

// Compose a mocked session manager.
Expand Down
1 change: 0 additions & 1 deletion executor/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ func (e *ShowExec) fetchShowProcessList() error {
uint64(time.Since(pi.Time) / time.Second),
fmt.Sprintf("%d", pi.State),
info,
pi.Mem,
})
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1662,9 +1662,9 @@ func buildShowSchema(s *ast.ShowStmt) (schema *expression.Schema) {
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar,
}
case ast.ShowProcessList:
names = []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info", "Mem"}
names = []string{"Id", "User", "Host", "db", "Command", "Time", "State", "Info"}
ftypes = []byte{mysql.TypeLonglong, mysql.TypeVarchar, mysql.TypeVarchar,
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString, mysql.TypeLonglong}
mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeLong, mysql.TypeVarchar, mysql.TypeString}
case ast.ShowStatsMeta:
names = []string{"Db_name", "Table_name", "Partition_name", "Update_time", "Modify_count", "Row_count"}
ftypes = []byte{mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeVarchar, mysql.TypeDatetime, mysql.TypeLonglong, mysql.TypeLonglong}
Expand Down
1 change: 0 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,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.

}
return pi
}
Expand Down
1 change: 0 additions & 1 deletion util/processinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type ProcessInfo struct {
Time time.Time
State uint16
Info string
Mem int64
}

// SessionManager is an interface for session manage. Show processlist and
Expand Down