下面的列表描述了与一般查询处理相关的线程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.
当线程创建一个表(包括内部临时表)时,会在创建表的函数结束时发生这种情况。即使由于某些错误导致表无法创建,也会使用这种状态。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.
服务器正在执行原地
ALTER TABLE。The server is in the process of executing an in-placeALTER TABLE.线程正在计算
MyISAM表的键分布(例如,用于ANALYZE TABLE)。The thread is calculating aMyISAMtable key distributions (for example, forANALYZE TABLE).checking permissionschecking permissions该线程正在检查服务器是否具有执行该语句所需的权限。The thread is checking whether the server has the required privileges to execute the statement.
线程正在执行表检查操作。The thread is performing a table check operation.
该线程已经处理了一个命令,并正在准备释放内存并重置某些状态变量。The thread has processed one command and is preparing to free memory and reset certain state variables.
线程正在将已更改的表数据刷新到磁盘并关闭已使用的表。这应该是一个快速操作。如果不是,请确认你的磁盘未满且磁盘未被大量使用。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 enginecommitting alter table to storage engine服务器已完成就地
ALTER TABLE并正在提交结果。The server has finished an in-placeALTER TABLEand is committing the result.converting HEAP to ondiskconverting HEAP to ondisk线程正在将内部临时表从
MEMORY表转换为磁盘表。The thread is converting an internal temporary table from aMEMORYtable to an on-disk table.copy to tmp tablecopy to tmp table线程正在处理一个
ALTER TABLE语句。该状态发生在新结构的表已创建但行尚未复制到其中时。The thread is processing anALTER TABLEstatement. 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 tableCopying to group table如果语句具有不同的
ORDER BY和GROUP BY条件,则行将按组排序并复制到临时表中。If a statement has differentORDER BYandGROUP BYcriteria, the rows are sorted by group and copied to a temporary table.Copying to tmp tableCopying to tmp table服务器正在将数据复制到内存中的临时表。The server is copying to a temporary table in memory.
Copying to tmp table on diskCopying 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.
该线程正在处理
ALTER TABLE ... ENABLE KEYS用于MyISAM表。The thread is processingALTER TABLE ... ENABLE KEYSfor aMyISAMtable.Creating sort indexCreating sort index线程正在处理一个通过内部临时表解决的
SELECT。The thread is processing aSELECTthat is resolved using an internal temporary table.该线程正在创建表。这包括创建临时表。The thread is creating a table. This includes creation of temporary tables.
Creating tmp tableCreating 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 isCopying to tmp table on disk.deleting from main tabledeleting 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 tablesdeleting from reference tables服务器正在执行多表删除的第二部分,并从其他表中删除匹配的行。The server is executing the second part of a multiple-table delete and deleting the matched rows from the other tables.
该线程正在处理一个
ALTER TABLE ... DISCARD TABLESPACE或ALTER TABLE ... IMPORT TABLESPACE语句。The thread is processing anALTER TABLE ... DISCARD TABLESPACEorALTER TABLE ... IMPORT TABLESPACEstatement.这发生在
ALTER TABLE、CREATE VIEW、DELETE、INSERT、SELECT或UPDATE语句的清理之前和结束时。This occurs at the end but before the cleanup ofALTER TABLE,CREATE VIEW,DELETE,INSERT,SELECT, orUPDATEstatements.对于
end状态,可能正在发生以下操作:For theendstate, the following operations could be happening:将事件写入二进制日志Writing an event to the binary log
释放内存缓冲区,包括用于二进制大对象(BLOB)的缓冲区Freeing memory buffers, including for blobs
该线程已开始执行一条语句。The thread has begun executing a statement.
Execution of init_commandExecution of init_command线程正在执行
init_command系统变量中的语句。The thread is executing statements in the value of theinit_commandsystem variable.线程已经执行了一个命令。此状态通常会紧接着
cleaning up。The thread has executed a command. This state is usually followed bycleaning up.FULLTEXT initializationFULLTEXT initialization服务器正在准备执行自然语言全文搜索。The server is preparing to perform a natural-language full-text search.
这发生在
ALTER TABLE、DELETE、INSERT、SELECT或UPDATE语句初始化之前。服务器在此状态下执行的操作包括刷新二进制日志和InnoDB日志。This occurs before the initialization ofALTER TABLE,DELETE,INSERT,SELECT, orUPDATEstatements. Actions taken by the server in this state include flushing the binary log and theInnoDBlog.有人向线程发送了一个
KILL语句,下次线程检查终止标志时应当中止。该标志会在 MySQL 的每个主要循环中检查,但在某些情况下,线程完全终止可能仍需短时间。如果线程被其他线程锁定,一旦其他线程释放其锁定,终止将立即生效。Someone has sent aKILLstatement 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 tablesLocking system tables该线程正在尝试锁定系统表(例如,时区表或日志表)。The thread is trying to lock a system table (for example, a time zone or log table).
logging slow querylogging slow query该线程正在向慢查询日志写入一条语句。The thread is writing a statement to the slow-query log.
连接线程的初始状态,直到客户端成功通过身份验证。The initial state for a connection thread until the client has been authenticated successfully.
服务器正在启用或禁用表索引。The server is enabling or disabling a table index.
Opening system tablesOpening system tables该线程正在尝试打开一个系统表(例如,时区表或日志表)。The thread is trying to open a system table (for example, a time zone or log table).
线程正在尝试打开一个表。这个过程应该非常快,除非有某些因素阻止打开。例如,
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, anALTER TABLEor aLOCK TABLEstatement can prevent opening a table until the statement is finished. It is also worth checking that yourtable_open_cachevalue is large enough.对于系统表,则使用
Opening system tables状态。For system tables, theOpening system tablesstate is used instead.服务器正在为查询执行初始优化。The server is performing initial optimizations for a query.
这种状态发生在查询优化过程中。This state occurs during query optimization.
preparing for alter tablepreparing for alter table服务器正在准备执行就地
ALTER TABLE。The server is preparing to execute an in-placeALTER TABLE.Purging old relay logsPurging old relay logs线程正在删除不需要的中继日志文件。The thread is removing unneeded relay log files.
该状态发生在处理查询之后,但在
freeing items状态之前。This state occurs after processing a query but before thefreeing itemsstate.Receiving from clientReceiving from client服务器正在从客户端读取数据包。The server is reading a packet from the client.
Removing duplicatesRemoving duplicates该查询使用了
SELECT DISTINCT,MySQL 无法在早期阶段优化去重操作。因此,MySQL 需要额外的步骤在将结果发送给客户端之前删除所有重复的行。The query was usingSELECT DISTINCTin 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 tableremoving tmp table线程在处理
SELECT语句后正在删除内部临时表。如果没有创建临时表,则不会使用此状态。The thread is removing an internal temporary table after processing aSELECTstatement. This state is not used if no temporary table was created.该线程正在重命名一个表。The thread is renaming a table.
rename result tablerename result table该线程正在处理一个
ALTER TABLE语句,已经创建了新表,并正在将其重命名以替换原始表。The thread is processing anALTER TABLEstatement, has created the new table, and is renaming it to replace the original table.线程获取了表的锁,但在获取锁后注意到基础表结构发生了变化。它已经释放了锁,关闭了表,并试图重新打开它。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 sortingRepair by sorting修复代码正在使用排序来创建索引。The repair code is using a sort to create indexes.
该线程已完成对一个
MyISAM表的多线程修复。The thread has completed a multithreaded repair for aMyISAMtable.Repair with keycacheRepair with keycache修复代码正在通过键缓存逐个创建键。这比
Repair by sorting慢得多。The repair code is using creating keys one by one through the key cache. This is much slower thanRepair by sorting.该线程正在回滚事务。The thread is rolling back a transaction.
对于
MyISAM表操作,如修复或分析,线程正在将新的表状态保存到.MYI文件头。状态包括行数、AUTO_INCREMENT计数器以及键分布等信息。ForMyISAMtable operations such as repair or analysis, the thread is saving the new table state to the.MYIfile header. State includes information such as number of rows, theAUTO_INCREMENTcounter, and key distributions.Searching rows for updateSearching 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 theUPDATEis changing the index that is used to find the involved rows.Sending dataSending data该状态现在包含在
Executing状态中。This state is now included in theExecutingstate.Sending to clientSending to client服务器正在向客户端写入一个数据包。The server is writing a packet to the client.
线程正在开始一个
ALTER TABLE操作。The thread is beginning anALTER TABLEoperation.Sorting for groupSorting for group线程正在进行排序以满足
GROUP BY。The thread is doing a sort to satisfy aGROUP BY.Sorting for orderSorting for order线程正在进行排序以满足
ORDER BY。The thread is doing a sort to satisfy anORDER BY.该线程正在对索引页进行排序,以在
MyISAM表优化操作期间实现更高效的访问。The thread is sorting index pages for more efficient access during aMyISAMtable optimization operation.对于
SELECT语句,这类似于Creating sort index,但针对非临时表。For aSELECTstatement, this is similar toCreating sort index, but for nontemporary tables.语句执行开始时的第一个阶段。The first stage at the beginning of statement execution.
服务器正在计算统计信息以制定查询执行计划。如果一个线程长时间处于此状态,服务器很可能在执行其他工作时受磁盘限制。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.
线程已经调用了
mysql_lock_tables(),并且线程状态自那时起未被更新。这是一个非常通用的状态,可能由多种原因引起。The thread has calledmysql_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 whenInnoDBwaits for a table-level lock during execution ofLOCK TABLES. If this state is being caused by requests for external locks and you are not using multiple mysqld servers that are accessing the sameMyISAMtables, you can disable external system locks with the--skip-external-lockingoption. However, external locking is disabled by default, so it is likely that this option has no effect. ForSHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).对于系统表,使用
Locking system tables状态。For system tables, theLocking system tablesstate is used instead.线程正在准备开始更新表格。The thread is getting ready to start updating the table.
线程正在搜索要更新的行并正在更新它们。The thread is searching for rows to update and is updating them.
updating main tableupdating 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 tablesupdating reference tables服务器正在执行多表更新的第二部分,并更新来自其他表的匹配行。The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.
该线程将请求或正在等待通过
GET_LOCK()调用请求的建议锁。对于SHOW PROFILE,此状态意味着线程正在请求锁(而不是在等待锁)。The thread is going to request or is waiting for an advisory lock requested with aGET_LOCK()call. ForSHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).Waiting for commit lockWaiting for commit lockFLUSH TABLES WITH READ LOCK正在等待提交锁。FLUSH TABLES WITH READ LOCKis waiting for a commit lock.waiting for handler commitwaiting for handler commit该线程正在等待一个事务提交,以便与查询处理的其他部分协调。The thread is waiting for a transaction to commit versus other parts of query processing.
Waiting for tablesWaiting 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 usedFLUSH TABLESor one of the following statements on the table in question:FLUSH TABLES,tbl_nameALTER TABLE,RENAME TABLE,REPAIR TABLE,ANALYZE TABLE, orOPTIMIZE TABLE.Waiting for table flushWaiting for table flush该线程正在执行
FLUSH TABLES并且正在等待所有线程关闭它们的表,或者该线程收到通知表的底层结构已更改,需要重新打开表以获取新结构。但是,要重新打开表,它必须等待所有其他线程关闭相关表。The thread is executingFLUSH TABLESand 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 usedFLUSH TABLESor one of the following statements on the table in question:FLUSH TABLES,tbl_nameALTER TABLE,RENAME TABLE,REPAIR TABLE,ANALYZE TABLE, orOPTIMIZE TABLE.Waiting for lock_type lockWaiting forlock_typelock服务器正在等待获取
THR_LOCK锁或来自元数据锁子系统的锁,其中lock_type表示锁的类型。The server is waiting to acquire aTHR_LOCKlock or a lock from the metadata locking subsystem, wherelock_typeindicates the type of lock.此状态表示等待
THR_LOCK:This state indicates a wait for aTHR_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 lockWaiting for global read lockWaiting for global read lockWaiting for schema metadata lockWaiting for schema metadata lockWaiting for stored function metadata lockWaiting for stored function metadata lockWaiting for stored procedure metadata lockWaiting for stored procedure metadata lockWaiting for table metadata lockWaiting for table metadata lockWaiting 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 condWaiting on cond线程正在等待某个条件变为真值的一般状态。没有可用的具体状态信息。A generic state in which the thread is waiting for a condition to become true. No specific state information is available.
服务器正在向网络写入一个数据包。The server is writing a packet to the network.