8.14 Examining Server Thread (Process) Information

To ascertain what your MySQL server is doing, it can be helpful to examine the process list, which indicates the operations currently being performed by the set of threads executing within the server. For example:

 mysql> SHOW PROCESSLIST\G
 *************************** 1. row ***************************
      Id: 1
    User: event_scheduler
    Host: localhost
      db: NULL
 Command: Daemon
    Time: 2756681
   State: Waiting on empty queue
    Info: NULL
 *************************** 2. row ***************************
      Id: 20
    User: me
    Host: localhost:52943
      db: test
 Command: Query
    Time: 0
   State: starting
    Info: SHOW PROCESSLIST

Threads can be killed with the note 'KILL': kill. statement. See note kill::.

 File: manual.info.tmp, Node: processlist-access, Next: thread-commands, Prev: thread-information, Up: thread-information

8.14.1 Accessing the Process List

The following discussion enumerates the sources of process information, the privileges required to see process information, and describes the content of process list entries.

Sources of Process Information

Process information is available from these sources:

The note 'threads': performance-schema-threads-table. table compares to note 'SHOW PROCESSLIST': show-processlist, 'INFORMATION_SCHEMA' note 'PROCESSLIST': information-schema-processlist-table, and note 'mysqladmin processlist': mysqladmin. as follows:

For these reasons, DBAs who perform server monitoring using one of the other thread information sources may wish to monitor using the *note 'threads': performance-schema-threads-table. table instead.

The 'sys' schema note 'processlist': sys-processlist. view presents information from the Performance Schema note 'threads': performance-schema-threads-table. table in a more accessible format. The 'sys' schema note 'session': sys-session. view presents information about user sessions like the 'sys' schema note 'processlist': sys-processlist. view, but with background processes filtered out.

Privileges Required to Access the Process List

For most sources of process information, if you have the 'PROCESS' privilege, you can see all threads, even those belonging to other users. Otherwise (without the 'PROCESS' privilege), nonanonymous users have access to information about their own threads but not threads for other users, and anonymous users have no access to thread information.

The Performance Schema note 'threads': performance-schema-threads-table. table also provides thread information, but table access uses a different privilege model. See note performance-schema-threads-table::.

Content of Process List Entries

Each process list entry contains several pieces of information. The following list describes them using the labels from *note 'SHOW PROCESSLIST': show-processlist. output. Other process information sources use similar labels.

 File: manual.info.tmp, Node: thread-commands, Next: general-thread-states, Prev: processlist-access, Up: thread-information

8.14.2 Thread Command Values

A thread can have any of the following 'Command' values:

 File: manual.info.tmp, Node: general-thread-states, Next: query-cache-thread-states, Prev: thread-commands, Up: thread-information

8.14.3 General Thread States

The following list describes thread 'State' values that are associated with general query processing and not more specialized activities such as replication. Many of these are useful only for finding bugs in the server.

 File: manual.info.tmp, Node: query-cache-thread-states, Next: source-thread-states, Prev: general-thread-states, Up: thread-information

8.14.4 Query Cache Thread States

These thread states are associated with the query cache (see *note query-cache::).

 File: manual.info.tmp, Node: source-thread-states, Next: replica-io-thread-states, Prev: query-cache-thread-states, Up: thread-information

8.14.5 Replication Source Thread States

The following list shows the most common states you may see in the 'State' column for the 'Binlog Dump' thread of the replication source. If you see no 'Binlog Dump' threads on a source, this means that replication is not running; that is, that no replicas are currently connected.

 File: manual.info.tmp, Node: replica-io-thread-states, Next: replica-sql-thread-states, Prev: source-thread-states, Up: thread-information

8.14.6 Replication Replica I/O Thread States

The following list shows the most common states you see in the 'State' column for a replica server I/O thread. This state also appears in the 'Slave_IO_State' column displayed by *note 'SHOW SLAVE STATUS': show-slave-status, so you can get a good view of what is happening by using that statement.

 File: manual.info.tmp, Node: replica-sql-thread-states, Next: replica-connection-thread-states, Prev: replica-io-thread-states, Up: thread-information

8.14.7 Replication Replica SQL Thread States

The following list shows the most common states you may see in the 'State' column for a replica server SQL thread:

The 'Info' column for the SQL thread may also show the text of a statement. This indicates that the thread has read an event from the relay log, extracted the statement from it, and may be executing it.

 File: manual.info.tmp, Node: replica-connection-thread-states, Next: mysql-cluster-thread-states, Prev: replica-sql-thread-states, Up: thread-information

8.14.8 Replication Replica Connection Thread States

These thread states occur on a replica server but are associated with connection threads, not with the I/O or SQL threads.

 File: manual.info.tmp, Node: mysql-cluster-thread-states, Next: event-scheduler-thread-states, Prev: replica-connection-thread-states, Up: thread-information

8.14.9 NDB Cluster Thread States

 File: manual.info.tmp, Node: event-scheduler-thread-states, Prev: mysql-cluster-thread-states, Up: thread-information

8.14.10 Event Scheduler Thread States

These states occur for the Event Scheduler thread, threads that are created to execute scheduled events, or threads that terminate the scheduler.

 File: manual.info.tmp, Node: optimizer-tracing, Prev: thread-information, Up: optimization