8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 98%

10.14.3 一般线程状态10.14.3 General Thread States

下面的列表描述了与一般查询处理相关的线程State值,而不是与更专业的活动(如复制)相关的状态值。其中许多状态只对寻找服务器中的错误有用。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 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 altering table

    服务器正在执行原地 ALTER TABLE。The server is in the process of executing an in-place ALTER TABLE.

  • Analyzing Analyzing

    线程正在计算 MyISAM 表的键分布(例如,用于 ANALYZE TABLE)。The thread is calculating a MyISAM table key distributions (for example, for ANALYZE TABLE).

  • checking permissions checking permissions

    该线程正在检查服务器是否具有执行该语句所需的权限。The thread is checking whether the server has the required privileges to execute the statement.

  • Checking table Checking table

    线程正在执行表检查操作。The thread is performing a table check operation.

  • cleaning up cleaning up

    该线程已经处理了一个命令,并正在准备释放内存并重置某些状态变量。The thread has processed one command and is preparing to free memory and reset certain state variables.

  • closing tables 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 committing alter table to storage engine

    服务器已完成就地 ALTER TABLE 并正在提交结果。The server has finished an in-place ALTER TABLE and is committing the result.

  • converting HEAP to ondisk converting HEAP to ondisk

    线程正在将内部临时表从 MEMORY 表转换为磁盘表。The thread is converting an internal temporary table from a MEMORY table to an on-disk table.

  • copy to tmp table copy to tmp table

    线程正在处理一个ALTER 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.

    对于处于此状态的线程,可以使用性能模式(Performance Schema)来获取有关复制操作进度的信息。请参阅第 29.12.5 节,“性能模式阶段事件表”。For a thread in this state, the Performance Schema can be used to obtain about the progress of the copy operation. See Section 29.12.5, “Performance Schema Stage Event Tables”.

  • Copying to group table Copying to group table

    如果语句具有不同的ORDER BY和GROUP BY条件,则行将按组排序并复制到临时表中。If a statement has different ORDER BY and GROUP BY criteria, the rows are sorted by group and copied to a temporary table.

  • Copying to tmp table Copying to tmp table

    服务器正在将数据复制到内存中的临时表。The server is copying to a temporary table in memory.

  • Copying to tmp table on disk Copying to tmp table on disk

    服务器正在将数据复制到磁盘上的临时表。临时结果集变得过大(参见 第 10.4.4 节,“MySQL 中的内部临时表使用”)。因此,该线程正在将临时表从内存格式更改为基于磁盘的格式以节省内存。The server is copying to a temporary table on disk. The temporary result set has become too large (see Section 10.4.4, “Internal Temporary Table Use in MySQL”). Consequently, the thread is changing the temporary table from in-memory to disk-based format to save memory.

  • Creating index Creating index

    该线程正在处理 ALTER TABLE ... ENABLE KEYS 用于 MyISAM 表。The thread is processing ALTER TABLE ... ENABLE KEYS for a MyISAM table.

  • Creating sort index Creating sort index

    线程正在处理一个通过内部临时表解决的 SELECT。The thread is processing a SELECT that is resolved using an internal temporary table.

  • creating table creating table

    该线程正在创建表。这包括创建临时表。The thread is creating a table. This includes creation of temporary tables.

  • Creating tmp table Creating tmp table

    该线程正在内存中或磁盘上创建临时表。如果表最初是在内存中创建的,但后来被转换为磁盘上的表,则在该操作期间的状态为 Copying to tmp table on disk。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 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 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

    该线程正在处理一个 ALTER TABLE ... DISCARD TABLESPACE 或 ALTER TABLE ... IMPORT TABLESPACE 语句。The thread is processing an ALTER TABLE ... DISCARD TABLESPACE or ALTER TABLE ... IMPORT TABLESPACE statement.

  • end

    这发生在 ALTER TABLE、CREATE VIEW、DELETE、INSERT、SELECT 或 UPDATE 语句的清理之前和结束时。This occurs at the end but before the cleanup of ALTER TABLE, CREATE VIEW, DELETE, INSERT, SELECT, or UPDATE statements.

    对于 end 状态,可能正在发生以下操作:For the end state, the following operations could be happening:

    • 将事件写入二进制日志Writing an event to the binary log

    • 释放内存缓冲区,包括用于二进制大对象(BLOB)的缓冲区Freeing memory buffers, including for blobs

  • executing executing

    该线程已开始执行一条语句。The thread has begun executing a statement.

  • Execution of init_command Execution of init_command

    线程正在执行 init_command 系统变量中的语句。The thread is executing statements in the value of the init_command system variable.

  • freeing items freeing items

    线程已经执行了一个命令。此状态通常会紧接着 cleaning up。The thread has executed a command. This state is usually followed by cleaning up.

  • FULLTEXT initialization FULLTEXT initialization

    服务器正在准备执行自然语言全文搜索。The server is preparing to perform a natural-language full-text search.

  • init

    这发生在ALTER TABLE、DELETE、INSERT、SELECT或UPDATE语句初始化之前。服务器在此状态下执行的操作包括刷新二进制日志和InnoDB日志。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 Killed

    有人向线程发送了一个 KILL 语句,下次线程检查终止标志时应当中止。该标志会在 MySQL 的每个主要循环中检查,但在某些情况下,线程完全终止可能仍需短时间。如果线程被其他线程锁定,一旦其他线程释放其锁定,终止将立即生效。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 Locking system tables

    该线程正在尝试锁定系统表(例如,时区表或日志表)。The thread is trying to lock a system table (for example, a time zone or log table).

  • logging slow query logging slow query

    该线程正在向慢查询日志写入一条语句。The thread is writing a statement to the slow-query log.

  • login login

    连接线程的初始状态,直到客户端成功通过身份验证。The initial state for a connection thread until the client has been authenticated successfully.

  • manage keys manage keys

    服务器正在启用或禁用表索引。The server is enabling or disabling a table index.

  • Opening system tables Opening system tables

    该线程正在尝试打开一个系统表(例如,时区表或日志表)。The thread is trying to open a system table (for example, a time zone or log table).

  • Opening tables Opening tables

    线程正在尝试打开一个表。这个过程应该非常快,除非有某些因素阻止打开。例如,ALTER TABLE 或 LOCK TABLE 语句可能会阻止表在该语句完成之前被打开。还值得检查您的 table_open_cache 值是否足够大。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.

    对于系统表,则使用 Opening system tables 状态。For system tables, the Opening system tables state is used instead.

  • optimizing optimizing

    服务器正在为查询执行初始优化。The server is performing initial optimizations for a query.

  • preparing preparing

    这种状态发生在查询优化过程中。This state occurs during query optimization.

  • preparing for alter table preparing for alter table

    服务器正在准备执行就地 ALTER TABLE。The server is preparing to execute an in-place ALTER TABLE.

  • Purging old relay logs Purging old relay logs

    线程正在删除不需要的中继日志文件。The thread is removing unneeded relay log files.

  • query end query end

    该状态发生在处理查询之后,但在 freeing items 状态之前。This state occurs after processing a query but before the freeing items state.

  • Receiving from client Receiving from client

    服务器正在从客户端读取数据包。The server is reading a packet from the client.

  • Removing duplicates Removing duplicates

    该查询使用了 SELECT DISTINCT,MySQL 无法在早期阶段优化去重操作。因此,MySQL 需要额外的步骤在将结果发送给客户端之前删除所有重复的行。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 removing tmp table

    线程在处理 SELECT 语句后正在删除内部临时表。如果没有创建临时表,则不会使用此状态。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 rename

    该线程正在重命名一个表。The thread is renaming a table.

  • rename result table rename result table

    该线程正在处理一个 ALTER 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 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 Repair by sorting

    修复代码正在使用排序来创建索引。The repair code is using a sort to create indexes.

  • Repair done Repair done

    该线程已完成对一个 MyISAM 表的多线程修复。The thread has completed a multithreaded repair for a MyISAM table.

  • Repair with keycache Repair with keycache

    修复代码正在通过键缓存逐个创建键。这比 Repair by sorting 慢得多。The repair code is using creating keys one by one through the key cache. This is much slower than Repair by sorting.

  • Rolling back Rolling back

    该线程正在回滚事务。The thread is rolling back a transaction.

  • Saving state Saving state

    对于 MyISAM 表操作,如修复或分析,线程正在将新的表状态保存到 .MYI 文件头。状态包括行数、AUTO_INCREMENT 计数器以及键分布等信息。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 Searching rows for update

    线程正在进行第一阶段,以在更新之前找到所有匹配的行。如果 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 rows.

  • Sending dataSending data

    该状态现在包含在 Executing 状态中。This state is now included in the Executing state.

  • Sending to client Sending to client

    服务器正在向客户端写入一个数据包。The server is writing a packet to the client.

  • setup setup

    线程正在开始一个 ALTER TABLE 操作。The thread is beginning an ALTER TABLE operation.

  • Sorting for group Sorting for group

    线程正在进行排序以满足 GROUP BY。The thread is doing a sort to satisfy a GROUP BY.

  • Sorting for order Sorting for order

    线程正在进行排序以满足 ORDER BY。The thread is doing a sort to satisfy an ORDER BY.

  • Sorting index Sorting index

    该线程正在对索引页进行排序,以在 MyISAM 表优化操作期间实现更高效的访问。The thread is sorting index pages for more efficient access during a MyISAM table optimization operation.

  • Sorting result Sorting result

    对于 SELECT 语句,这类似于 Creating sort index,但针对非临时表。For a SELECT statement, this is similar to Creating sort index, but for nontemporary tables.

  • starting starting

    语句执行开始时的第一个阶段。The first stage at the beginning of statement execution.

  • statistics 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 System lock

    线程已经调用了 mysql_lock_tables(),并且线程状态自那时起未被更新。这是一个非常通用的状态,可能由多种原因引起。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.

    例如,线程将请求或正在等待表的内部或外部系统锁。当 InnoDB 在执行 LOCK TABLES 时等待表级锁时,就可能发生这种情况。如果此状态是由对外部锁的请求引起,并且您没有使用多个访问相同 MyISAM 表的 mysqld 服务器,则可以使用 --skip-external-locking 选项来禁用外部系统锁。然而,默认情况下外部锁是禁用的,因此很可能此选项没有效果。对于 SHOW PROFILE,此状态意味着线程正在请求锁(而不是等待锁)。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).

    对于系统表,使用 Locking system tables 状态。For system tables, the Locking system tables state is used instead.

  • update update

    线程正在准备开始更新表格。The thread is getting ready to start updating the table.

  • Updating Updating

    线程正在搜索要更新的行并正在更新它们。The thread is searching for rows to update and is updating them.

  • updating main table 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 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 User lock

    该线程将请求或正在等待通过 GET_LOCK() 调用请求的建议锁。对于 SHOW PROFILE,此状态意味着线程正在请求锁(而不是在等待锁)。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 User sleep

    该线程已调用 SLEEP()。The thread has invoked a SLEEP() call.

  • Waiting for commit lock Waiting for commit lock

    FLUSH TABLES WITH READ LOCK 正在等待提交锁。FLUSH TABLES WITH READ LOCK is waiting for a commit lock.

  • waiting for handler commit waiting for handler commit

    该线程正在等待一个事务提交,以便与查询处理的其他部分协调。The thread is waiting for a transaction to commit versus other parts of query processing.

  • Waiting for tables 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.

    如果另一线程在相关表上使用了 FLUSH TABLES 或以下语句之一,则会发生此通知:FLUSH TABLES tbl_name、ALTER TABLE、RENAME TABLE、REPAIR TABLE、ANALYZE TABLE 或 OPTIMIZE TABLE。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 Waiting for table flush

    该线程正在执行 FLUSH TABLES 并且正在等待所有线程关闭它们的表,或者该线程收到通知表的底层结构已更改,需要重新打开表以获取新结构。但是,要重新打开表,它必须等待所有其他线程关闭相关表。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.

    如果另一线程在相关表上使用了 FLUSH TABLES 或以下语句之一,则会发生此通知:FLUSH TABLES tbl_name、ALTER TABLE、RENAME TABLE、REPAIR TABLE、ANALYZE TABLE 或 OPTIMIZE TABLE。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 Waiting for lock_type lock

    服务器正在等待获取 THR_LOCK 锁或来自元数据锁子系统的锁,其中 lock_type 表示锁的类型。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.

    此状态表示等待 THR_LOCK:This state indicates a wait for a THR_LOCK:

    • Waiting for table level lockWaiting for table level lock

    这些状态表示正在等待元数据锁:These states indicate a wait for a metadata lock:

    • Waiting for event metadata lockWaiting for event metadata lock

    • Waiting for global read lockWaiting for global read lock

    • Waiting for schema metadata lockWaiting for schema metadata lock

    • Waiting for stored function metadata lockWaiting for stored function metadata lock

    • Waiting for stored procedure metadata lockWaiting for stored procedure metadata lock

    • Waiting for table metadata lockWaiting for table metadata lock

    • Waiting for trigger metadata lockWaiting for trigger metadata lock

    有关表锁指示器的信息,请参见 第 10.11.1 节,“内部锁定方法”。有关元数据锁定的信息,请参见 第 10.11.4 节,“元数据锁定”。要查看哪些锁正在阻止锁请求,请使用 第 29.12.13 节,“性能模式锁表” 中描述的性能模式锁表。For information about table lock indicators, see Section 10.11.1, “Internal Locking Methods”. For information about metadata locking, see Section 10.11.4, “Metadata Locking”. To see which locks are blocking lock requests, use the Performance Schema lock tables described at Section 29.12.13, “Performance Schema Lock Tables”.

  • Waiting on cond 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 Writing to net

    服务器正在向网络写入一个数据包。The server is writing a packet to the network.