MySQL Shell 9.0  /  ...  /  Built-in MySQL Shell Report: Thread

10.1.6.3 Built-in MySQL Shell Report: Thread

The built-in MySQL Shell report thread provides detailed information about a specific thread in the connected MySQL server. The report works with servers running all supported MySQL 5.7 and MySQL 8.0 versions. If any item of information is not available in the MySQL Server version of the target server, the report leaves it out.

The thread report provides information for the selected thread and its activity, drawn from various sources including MySQL's Performance Schema. By default, the report shows information on the thread used by the current connection, or you can identify a thread by its ID or by the connection ID. You can select one or more categories of information, or view all of the available information about the thread. For details of the report-specific options and the information that you can include in the report, issue one of the following MySQL Shell commands to view the report help:

\help thread
\show thread --help

In addition to the report-specific options, the thread report accepts most of the standard options for the \show and \watch commands, as described in Section 10.1.5, “Running MySQL Shell Reports”. The exception is the --vertical (or -E) option for the \show command, which is not accepted. The thread report has a custom output format that includes vertical listings and tables presented in different sections, and you cannot change this output format.

The threads report uses MySQL Server's format_statement() function (see The format_statement() Function). Any truncated statements displayed in the report are truncated according to the setting for the statement_truncate_len option in MySQL Server's sys_config table, which defaults to 64 characters.

The following list summarizes the capabilities provided by the report-specific options for the threads report. See the report help for full details and the short forms of the options:

--tid, --cid

Identify the thread ID or connection ID on which you want to report.

--general

Show basic information about the thread. This information is returned by default if you do not use any of the following options.

--brief

Show a brief description of the thread on one line.

--client

Show information about the client connection and client session.

--innodb

Show information about the current InnoDB transaction using the thread, if any.

--locks

Show information about locks blocking and blocked by the thread.

--prep-stmts

Show information about the prepared statements allocated for the thread.

--status

Show information about the session status variables for the thread. You can specify a list of prefixes to match, in which case only matching variables are displayed.

--vars

Show information about the session system variables for the thread. You can specify a list of prefixes to match, in which case only matching variables are displayed.

--user-vars

Show information about the user-defined variables for the thread. You can specify a list of prefixes to match, in which case only matching variables are displayed.

--all

Show all of the above information, except for the brief description.

For example, the following command runs the thread report for the thread with thread ID 53, and returns general information about the thread, details of the client connection, and information about any locks that the thread is blocking or is blocked by:

mysql-py>  \show thread --tid 53 --general --client --locks