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

executor: fix panic when fetching processlist table data in some cases (#11688) #16309

Merged
merged 1 commit into from
Apr 13, 2020
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
fixup (#11688)
  • Loading branch information
qw4990 committed Apr 13, 2020
commit 1146a85f0cbcadbc576c6c47a956027832610782
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (cc *clientConn) connectInfo() *variable.ConnectionInfo {
// ShowProcessList implements the SessionManager interface.
func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo {
s.rwlock.RLock()
defer s.rwlock.RUnlock()
rs := make(map[uint64]*util.ProcessInfo, len(s.clients))
for _, client := range s.clients {
if atomic.LoadInt32(&client.status) == connStatusWaitShutdown {
Expand All @@ -457,7 +458,6 @@ func (s *Server) ShowProcessList() map[uint64]*util.ProcessInfo {
rs[pi.ID] = pi
}
}
s.rwlock.RUnlock()
return rs
}

Expand Down
6 changes: 5 additions & 1 deletion util/processinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ func (pi *ProcessInfo) txnStartTs(tz *time.Location) (txnStart string) {
// ToRow returns []interface{} for the row data of
// "SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST".
func (pi *ProcessInfo) ToRow(tz *time.Location) []interface{} {
return append(pi.ToRowForShow(true), pi.StmtCtx.MemTracker.BytesConsumed(), pi.txnStartTs(tz))
bytesConsumed := int64(0)
if pi.StmtCtx.MemTracker != nil {
bytesConsumed = pi.StmtCtx.MemTracker.BytesConsumed()
}
return append(pi.ToRowForShow(true), bytesConsumed, pi.txnStartTs(tz))
}

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