10bet网址
MySQL 8.0 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

8.14.3 General Thread States

The following list describes threadStatevalues 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-placeALTER TABLE.

  • Analyzing

    The thread is calculating aMyISAMtable key distributions (for example, forANALYZE 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.

  • converting HEAP to ondisk

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

  • copy to tmp 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.

    For a thread in this state, the Performance Schema can be used to obtain about the progress of the copy operation. SeeSection 27.12.5, “Performance Schema Stage Event Tables”.

  • Copying to group table

    If a statement has differentORDER BYandGROUP BYcriteria, 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 (seeSection 8.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

    The thread is processingALTER TABLE ... ENABLE KEYSfor aMyISAMtable.

  • Creating sort index

    The thread is processing aSELECTthat 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 isCopying to tmp table on disk.

  • committing alter table to storage engine

    The server has finished an in-placeALTER TABLEand is committing the result.

  • 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 anALTER TABLE ... DISCARD TABLESPACEorALTER TABLE ... IMPORT TABLESPACEstatement.

  • end

    This occurs at the end but before the cleanup ofALTER TABLE,CREATE VIEW,DELETE,INSERT,SELECT, orUPDATEstatements.

    For theendstate, the following operations could be happening:

    • Writing an event to the binary log

    • Freeing memory buffers, including for blobs

  • executing

    The thread has begun executing a statement.

  • Execution of init_command

    The thread is executing statements in the value of theinit_commandsystem variable.

  • freeing items

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

  • FULLTEXT initialization

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

  • init

    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.

  • Killed

    Someone has sent aKILL声明下t线程和它应该中止ime 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

    线程试图锁定系统表(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, 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.

    For system tables, theOpening system tablesstate is used instead.

  • optimizing

    The server is performing initial optimizations for a query.

  • preparing

    This state occurs during query optimization.

  • 清除旧的relay logs

    The thread is removing unneeded relay log files.

  • query end

    This state occurs after processing a query but before thefreeing itemsstate.

  • Receiving from client

    The server is reading a packet from the client.

  • Removing duplicates

    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 table

    The thread is removing an internal temporary table after processing aSELECTstatement. 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 anALTER TABLEstatement, 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.

  • preparing for alter table

    The server is preparing to execute an in-placeALTER TABLE.

  • Repair done

    The thread has completed a multithreaded repair for aMyISAMtable.

  • Repair with keycache

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

  • Rolling back

    The thread is rolling back a transaction.

  • Saving state

    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 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 data

    Prior to MySQL 8.0.17: The thread is reading and processing rows for aSELECTstatement, 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 theExecutingstate.

  • Sending to client

    The server is writing a packet to the client.

  • setup

    The thread is beginning anALTER TABLEoperation.

  • Sorting for group

    The thread is doing a sort to satisfy aGROUP BY.

  • Sorting for order

    The thread is doing a sort to satisfy anORDER BY.

  • Sorting index

    The thread is sorting index pages for more efficient access during aMyISAMtable optimization operation.

  • Sorting result

    For aSELECTstatement, this is similar toCreating 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 calledmysql_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 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 multiplemysqldservers 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).

    For system tables, theLocking system tablesstate 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 aGET_LOCK()call. ForSHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).

  • User sleep

    The thread has invoked aSLEEP()call.

  • Waiting for commit lock

    FLUSH TABLES WITH READ LOCKis 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 usedFLUSH TABLESor one of the following statements on the table in question:FLUSH TABLEStbl_name,ALTER TABLE,RENAME TABLE,REPAIR TABLE,ANALYZE TABLE, orOPTIMIZE TABLE.

  • Waiting for table flush

    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.

    This notification takes place if another thread has usedFLUSH TABLESor one of the following statements on the table in question:FLUSH TABLEStbl_name,ALTER TABLE,RENAME TABLE,REPAIR TABLE,ANALYZE TABLE, orOPTIMIZE TABLE.

  • Waiting forlock_typelock

    The server is waiting to acquire aTHR_LOCKlock or a lock from the metadata locking subsystem, wherelock_typeindicates the type of lock.

    This state indicates a wait for aTHR_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

    For information about table lock indicators, seeSection 8.11.1, “Internal Locking Methods”. For information about metadata locking, seeSection 8.11.4, “Metadata Locking”. To see which locks are blocking lock requests, use the Performance Schema lock tables described atSection 27.12.13, “Performance Schema Lock Tables”.

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