MySQL 8.0 Reference Manual(读书笔记61节--Examining Server Thread (Process) Information(2))

5.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.

• After create

This occurs when the thread creates a table (including internal temporary tables), at the end of the function that creates the table. This state is used even if the table could not be created due to some error.

• altering table

The server is in the process of executing an in-place ALTER TABLE.

• Analyzing

The thread is calculating a MyISAM table key distributions (for example, for ANALYZE TABLE).

• checking permissions

The thread is checking whether the server has the required privileges to execute the statement.

• Checking table

The thread is performing a table check operation.

• cleaning up

The thread has processed one command and is preparing to free memory and reset certain state variables.

 • closing tables

The thread is flushing the changed table data to disk and closing the used tables. This should be a fast operation. If not, verify that you do not have a full disk and that the disk is not in very heavy use.

• committing alter table to storage engine

The server has finished an in-place ALTER TABLE and is committing the result.

• converting HEAP to ondisk

The thread is converting an internal temporary table from a MEMORY table to an on-disk table.

• copy to tmp table

The thread is processing an ALTER TABLE statement. This state occurs after the table with the new structure has been created but before rows are copied into it.For a thread in this state, the Performance Schema can be used to obtain about the progress of the copy operation.

• Copying to group table

If a statement has different ORDER BY and GROUP BY criteria【kraɪ'tɪriə 标准;(评判或作决定的)准则;原则;】, the rows are sorted by group and copied to a temporary table.

• Copying to tmp table

The server is copying to a temporary table in memory.

• Copying to tmp table on disk

The server is copying to a temporary table on disk. The temporary result set has become too large. Consequently【ˈkɑːnsɪkwentli 因此;所以;】, the thread is changing the temporary table from in-memory to disk-based format to save memory.

• Creating index

The thread is processing ALTER TABLE ... ENABLE KEYS for a MyISAM table.

• Creating sort index

The thread is processing a SELECT that is resolved using an internal temporary table.

• creating table

The thread is creating a table. This includes creation of temporary tables.

• Creating tmp table

The thread is creating a temporary table in memory or on disk. If the table is created in memory but later is converted to an on-disk table, the state during that operation is Copying to tmp table on disk.

• deleting from main table

The server is executing the first part of a multiple-table delete. It is deleting only from the first table, and saving columns and offsets to be used for deleting from the other (reference) tables.

• deleting from reference tables

The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables.

• discard_or_import_tablespace

The thread is processing an ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE statement. 【discard:dɪˈskɑːrd , ˈdɪskɑːrd  丢弃;抛弃;垫(牌);打出(无用的牌);

• end

This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements. For the end state, the following operations could be happening:

  • Writing an event to the binary log
  • Freeing memory buffers, including for blobs【blɑbz (颜色的)一小片,斑点;(尤指液体的)一点,一滴;】

• executing

The thread has begun executing a statement.

• Execution of init_command

The thread is executing statements in the value of the init_command system variable.

• freeing items

The thread has executed a command. This state is usually followed by cleaning up.

• FULLTEXT initialization

The server is preparing to perform a natural-language full-text search.

• init

This occurs before the initialization of ALTER TABLE, DELETE, INSERT, SELECT, or UPDATE statements. Actions taken by the server in this state include flushing the binary log and the InnoDB log.

• Killed

Someone has sent a KILL statement to the thread and it should abort next time it checks the kill flag. The flag is checked in each major loop in MySQL, but in some cases it might still take a short time for the thread to die. If the thread is locked by some other thread, the kill takes effect as soon as the other thread releases its lock.

• Locking system tables

The thread is trying to lock a system table (for example, a time zone or log table).

• logging slow query

The thread is writing a statement to the slow-query log.

• login

The initial state for a connection thread until the client has been authenticated successfully.

• manage keys

The server is enabling or disabling a table index.

• Opening system tables

The thread is trying to open a system table (for example, a time zone or log table).

• Opening tables

The thread is trying to open a table. This is should be very fast procedure, unless something prevents opening. For example, an ALTER TABLE or a LOCK TABLE statement can prevent opening a table until the statement is finished. It is also worth checking that your table_open_cache value is large enough. For system tables, the Opening system tables state is used instead.

• optimizing

The server is performing initial optimizations for a query.

• preparing

This state occurs during query optimization.

• preparing for alter table

The server is preparing to execute an in-place ALTER TABLE.

• Purging old relay logs

The thread is removing unneeded relay log files.

• query end

This state occurs after processing a query but before the freeing items state.

• Receiving from client

The server is reading a packet from the client.

• Removing duplicates

The query was using SELECT DISTINCT in such a way that MySQL could not optimize away the distinct operation at an early stage. Because of this, MySQL requires an extra stage to remove all duplicated rows before sending the result to the client.

• removing tmp table

The thread is removing an internal temporary table after processing a SELECT statement. This state is not used if no temporary table was created.

• rename

The thread is renaming a table.

• rename result table

The thread is processing an ALTER TABLE statement, has created the new table, and is renaming it to replace the original table.

• Reopen tables

The thread got a lock for the table, but noticed after getting the lock that the underlying table structure changed. It has freed the lock, closed the table, and is trying to reopen it.

• Repair by sorting

The repair code is using a sort to create indexes.

• Repair done

The thread has completed a multithreaded repair for a MyISAM table.

• Repair with keycache

The repair code is using creating keys one by one through the key cache. This is much slower than Repair by sorting.

• Rolling back

The thread is rolling back a transaction.

• Saving state

For MyISAM table operations such as repair or analysis, the thread is saving the new table state to the .MYI file header. State includes information such as number of rows, the AUTO_INCREMENT counter, and key distributions.

• Searching rows for update

The thread is doing a first phase to find all matching rows before updating them. This has to be done if the UPDATE is changing the index that is used to find the involved【ɪnˈvɑːlvd 参与;卷入的;关注;有关联;关系密切;复杂难解的;作为一部分;耗费很多时间;】 rows.

• Sending data

Prior to MySQL 8.0.17: The thread is reading and processing rows for a SELECT statement, and sending data to the client. Because operations occurring during this state tend to perform large amounts of disk access (reads), it is often the longest-running state over the lifetime of a given query. MySQL 8.0.17 and later: This state is no longer indicated separately, but rather is included in the Executing state.

• Sending to client

The server is writing a packet to the client.

• setup

The thread is beginning an ALTER TABLE operation.

• Sorting for group The thread is doing a sort to satisfy a GROUP BY.

• Sorting for order

The thread is doing a sort to satisfy an ORDER BY.

 • Sorting index

The thread is sorting index pages for more efficient【ɪˈfɪʃnt 有效率的;效率高的;有能力的;】 access during a MyISAM table optimization operation.

• Sorting result

For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables.

• starting

The first stage at the beginning of statement execution.

• statistics

The server is calculating statistics to develop a query execution plan. If a thread is in this state for a long time, the server is probably disk-bound performing other work.

• System lock

The thread has called mysql_lock_tables() and the thread state has not been updated since. This is a very general state that can occur for many reasons. For example, the thread is going to request or is waiting for an internal or external system lock for the table. This can occur when InnoDB waits for a table-level lock during execution of LOCK TABLES. If this state is being caused by requests for external locks and you are not using multiple mysqld servers that are accessing the same MyISAM tables, you can disable external system locks with the --skip-external-locking option. However, external locking is disabled by default, so it is likely that this option has no effect. For SHOW PROFILE, this state means the thread is requesting the lock (not waiting for it). For system tables, the Locking system tables state is used instead.

• update

The thread is getting ready to start updating the table.

• Updating

The thread is searching for rows to update and is updating them.

• updating main table

The server is executing the first part of a multiple-table update. It is updating only the first table, and saving columns and offsets to be used for updating the other (reference) tables.

• updating reference tables

The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.

• User lock

The thread is going to request or is waiting for an advisory lock requested with a GET_LOCK() call. For SHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).

• User sleep

The thread has invoked a SLEEP() call.

• Waiting for commit lock

FLUSH TABLES WITH READ LOCK is waiting for a commit lock.

• waiting for handler commit

The thread is waiting for a transaction to commit versus other parts of query processing.

• Waiting for tables

The thread got a notification that the underlying structure for a table has changed and it needs to reopen the table to get the new structure. However, to reopen the table, it must wait until all other threads have closed the table in question.

This notification takes place if another thread has used FLUSH TABLES or one of the following statements on the table in question: FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, or OPTIMIZE TABLE.

• Waiting for table flush

The thread is executing FLUSH TABLES and is waiting for all threads to close their tables, or the thread got a notification that the underlying structure for a table has changed and it needs to reopen the table to get the new structure. However, to reopen the table, it must wait until all other threads have closed the table in question.

This notification takes place if another thread has used FLUSH TABLES or one of the following statements on the table in question: FLUSH TABLES tbl_name, ALTER TABLE, RENAME TABLE, REPAIR TABLE, ANALYZE TABLE, or OPTIMIZE TABLE.

• Waiting for lock_type lock

The server is waiting to acquire a THR_LOCK lock or a lock from the metadata locking subsystem, where lock_type indicates the type of lock.

This state indicates a wait for a THR_LOCK:

  • Waiting for table level lock

      These states indicate a wait for a metadata lock:

  • Waiting for event metadata lock
  • Waiting for global read lock
  • Waiting for schema metadata lock
  • Waiting for stored function metadata lock
  • Waiting for stored procedure metadata lock
  • Waiting for table metadata lock
  • Waiting for trigger metadata lock

• Waiting on cond

A generic state in which the thread is waiting for a condition to become true. No specific state information is available.

• Writing to net

The server is writing a packet to the network.

6 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.

In MySQL 8.0.26, incompatible【ˌɪnkəmˈpætəbl 不相容的,不兼容的,互斥的;(与某事物)不一致,不相配;不协调的;(与某物)不匹配;(与某人)合不来的,不能和睦相处;(血型、机体组织)不能配合】 changes were made to instrumentation【ˌɪnstrəmenˈteɪʃn (一套)仪器,仪表;器乐谱写;】 names, including the names of thread stages, containing the terms “master”, which is changed to “source”, “slave”, which is changed to “replica”, and “mts” (for “multithreaded slave”), which is changed to “mta” (for “multithreaded applier”). Monitoring tools that work with these instrumentation names might be impacted. If the incompatible changes have an impact for you, set the terminology_use_previous system variable to BEFORE_8_0_26 to make MySQL Server use the old versions of the names for the objects specified in the previous list. This enables monitoring tools that rely on the old names to continue working until they can be updated to use the new names.

Set the terminology_use_previous system variable with session scope【skoʊp (题目、组织、活动等的)范围;(做或实现某事的)机会,能力;…镜(观察仪器);】 to support individual functions, or global scope to be a default for all new sessions. When global scope is used, the slow query log contains the old versions of the names.

• Finished reading one binlog; switching to next binlog

The thread has finished reading a binary log file and is opening the next one to send to the replica.

• Master has sent all binlog to slave; waiting for more updates

From MySQL 8.0.26: Source has sent all binlog to replica; waiting for more updates

The thread has read all remaining updates from the binary logs and sent them to the replica. The thread is now idle【[ˈaɪdl 空闲的;闲置的;懒惰的;闲散的;懈怠的;没有工作的;漫无目的的;】, waiting for new events to appear in the binary log resulting from new updates occurring on the source.

• Sending binlog event to slave

From MySQL 8.0.26: Sending binlog event to replica

Binary logs consist of events, where an event is usually an update plus some other information. The thread has read an event from the binary log and is now sending it to the replica.

• Waiting to finalize termination

A very brief state that occurs as the thread is stopping.

7 Replication I/O (Receiver) Thread States

The following list shows the most common states you see in the State column for a replication I/O (receiver) thread on a replica server. This state also appears in the Replica_IO_State column displayed by SHOW REPLICA STATUS (or before MySQL 8.0.22, SHOW REPLICA STATUS), so you can get a good view of what is happening by using that statement.

 In MySQL 8.0.26, incompatible changes were made to instrumentation names, including the names of thread stages, containing the terms “master”, which is changed to “source”, “slave”, which is changed to “replica”, and “mts” (for “multithreaded slave”), which is changed to “mta” (for “multithreaded applier”). Monitoring tools that work with these instrumentation names might be impacted. If the incompatible changes have an impact for you, set the terminology_use_previous system variable to BEFORE_8_0_26 to make MySQL Server use the old versions of the names for the objects specified in the previous list. This enables monitoring tools that rely on the old names to continue working until they can be updated to use the new names.

Set the terminology_use_previous system variable with session scope to support individual functions, or global scope to be a default for all new sessions. When global scope is used, the slow query log contains the old versions of the names.

• Checking master version

From MySQL 8.0.26: Checking source version

A state that occurs very briefly【ˈbriːfli 简要地;简短地;短暂地;暂时地;】, after the connection to the source is established.

• Connecting to master

From MySQL 8.0.26: Connecting to source

The thread is attempting to connect to the source.

• Queueing master event to the relay log

From MySQL 8.0.26: Queueing source event to the relay log

The thread has read an event and is copying it to the relay log so that the SQL thread can process it.

• Reconnecting after a failed binlog dump request

The thread is trying to reconnect to the source.

• Reconnecting after a failed master event read

From MySQL 8.0.26: Reconnecting after a failed source event read

The thread is trying to reconnect to the source. When connection is established again, the state becomes Waiting for master to send event.

• Registering slave on master

From MySQL 8.0.26: Registering replica on source

A state that occurs very briefly after the connection to the source is established.

• Requesting binlog dump

A state that occurs very briefly, after the connection to the source is established. The thread sends to the source a request for the contents of its binary logs, starting from the requested binary log file name and position.

• Waiting for its turn to commit

A state that occurs when the replica thread is waiting for older worker threads to commit if replica_preserve_commit_order or slave_preserve_commit_order is enabled.

• Waiting for master to send event

From MySQL 8.0.26: Waiting for source to send event

The thread has connected to the source and is waiting for binary log events to arrive. This can last for a long time if the source is idle. If the wait lasts for replica_net_timeout or slave_net_timeout seconds, a timeout occurs. At that point, the thread considers the connection to be broken and makes an attempt to reconnect.

• Waiting for master update

From MySQL 8.0.26: Waiting for source update

The initial state before Connecting to master or Connecting to source.

• Waiting for slave mutex on exit

From MySQL 8.0.26: Waiting for replica mutex on exit

A state that occurs briefly as the thread is stopping.

• Waiting for the slave SQL thread to free enough relay log space

From MySQL 8.0.26: Waiting for the replica SQL thread to free enough relay log space

You are using a nonzero relay_log_space_limit value, and the relay logs have grown large enough that their combined size exceeds this value. The I/O (receiver) thread is waiting until the SQL (applier) thread frees enough space by processing relay log contents so that it can delete some relay log files.

• Waiting to reconnect after a failed binlog dump request

If the binary log dump request failed (due to disconnection), the thread goes into this state while it sleeps, then tries to reconnect periodically. The interval between retries can be specified using the CHANGE REPLICATION SOURCE TO statement (from MySQL 8.0.23) or CHANGE MASTER TO statement (before MySQL 8.0.23).

• Waiting to reconnect after a failed master event read

From MySQL 8.0.26: Waiting to reconnect after a failed source event read

An error occurred while reading (due to disconnection). The thread is sleeping for the number of seconds set by the CHANGE REPLICATION SOURCE TO statement (from MySQL 8.0.23) or CHANGE MASTER TO statement (before MySQL 8.0.23), which defaults to 60, before attempting to reconnect.

8 Replication SQL Thread States

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

In MySQL 8.0.26, incompatible changes were made to instrumentation names, including the names of thread stages, containing the terms “master”, which is changed to “source”, “slave”, which is changed to “replica”, and “mts” (for “multithreaded slave”), which is changed to “mta” (for “multithreaded applier”). Monitoring tools that work with these instrumentation names might be impacted. If the incompatible changes have an impact for you, set the terminology_use_previous system variable to BEFORE_8_0_26 to make MySQL Server use the old versions of the names for the objects specified in the previous list. This enables monitoring tools that rely on the old names to continue working until they can be updated to use the new names.

Set the terminology_use_previous system variable with session scope to support individual functions, or global scope to be a default for all new sessions. When global scope is used, the slow query log contains the old versions of the names.

• Making temporary file (append) before replaying LOAD DATA INFILE

The thread is executing a LOAD DATA statement and is appending the data to a temporary file containing the data from which the replica reads rows.

• Making temporary file (create) before replaying LOAD DATA INFILE

The thread is executing a LOAD DATA statement and is creating a temporary file containing the data from which the replica reads rows. This state can only be encountered if the original LOAD DATA statement was logged by a source running a version of MySQL lower than MySQL 5.0.3.

• Reading event from the relay log

The thread has read an event from the relay log so that the event can be processed.

• Slave has read all relay log; waiting for more updates

From MySQL 8.0.26: Replica has read all relay log; waiting for more updates The thread has processed all events in the relay log files, and is now waiting for the I/O (receiver) thread to write new events to the relay log.

• Waiting for an event from Coordinator

Using the multithreaded replica (replica_parallel_workers or slave_parallel_workers is greater than 1), one of the replica worker threads is waiting for an event from the coordinator thread.

• Waiting for slave mutex on exit

From MySQL 8.0.26: Waiting for replica mutex on exit

A very brief state that occurs as the thread is stopping.

• Waiting for Slave Workers to free pending events

From MySQL 8.0.26: Waiting for Replica Workers to free pending events

This waiting action occurs when the total size of events being processed by Workers exceeds the size of the replica_pending_jobs_size_max or slave_pending_jobs_size_max system variable. The Coordinator resumes scheduling when the size drops below this limit. This state occurs only when replica_parallel_workers or slave_parallel_workers is set greater than 0.

• Waiting for the next event in relay log

The initial state before Reading event from the relay log.

• Waiting until MASTER_DELAY seconds after master executed event

From MySQL 8.0.26: Waiting until SOURCE_DELAY seconds after master executed event

The SQL thread has read an event but is waiting for the replica delay to lapse【læps 失效;(逐渐)消失,结束;背弃,放弃(宗教信仰);衰退;期满终止;衰弱;】. This delay is set with the SOURCE_DELAY | MASTER_DELAY option of the CHANGE REPLICATION SOURCE TO statement (from MySQL 8.0.23) or CHANGE MASTER TO statement (before MySQL 8.0.23).

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.

9 Replication 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.

In MySQL 8.0.26, incompatible changes were made to instrumentation names, including the names of thread stages, containing the terms “master”, which is changed to “source”, “slave”, which is changed to “replica”, and “mts” (for “multithreaded slave”), which is changed to “mta” (for “multithreaded applier”). Monitoring tools that work with these instrumentation names might be impacted. If the incompatible changes have an impact for you, set the terminology_use_previous system variable to BEFORE_8_0_26 to make MySQL Server use the old versions of the names for the objects specified in the previous list. This enables monitoring tools that rely on the old names to continue working until they can be updated to use the new names.

Set the terminology_use_previous system variable with session scope to support individual functions, or global scope to be a default for all new sessions. When global scope is used, the slow query log contains the old versions of the names.

• Changing master

From MySQL 8.0.26: Changing replication source

The thread is processing a CHANGE REPLICATION SOURCE TO statement (from MySQL 8.0.23) or CHANGE MASTER TO statement (before MySQL 8.0.23).

• Killing slave

The thread is processing a STOP REPLICA statement.

• Opening master dump table

This state occurs after Creating table from master dump.

• Reading master dump table data

This state occurs after Opening master dump table.

• Rebuilding the index on master dump table

This state occurs after Reading master dump table data.

 

热门相关:傲世武皇   超级融合   霸道女皇爱上我   天命为妃   巨星小甜妻:前夫,请出局