Rechercher dans le manuel MySQL
8.14.2 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.
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.
The thread is calculating a
MyISAM
table key distributions (for example, forANALYZE TABLE
).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.
The thread is converting an internal temporary table from a
MEMORY
table to an on-disk 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. See Section 26.12.5, “Performance Schema Stage Event Tables”.
If a statement has different
ORDER BY
andGROUP BY
criteria, the rows are sorted by group and copied to a temporary table.The server is copying to a temporary table in memory.
The server is in the process of executing an in-place
ALTER TABLE
.The server is copying to a temporary table on disk. The temporary result set has become too large (see Section 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.
The thread is processing
ALTER TABLE ... ENABLE KEYS
for aMyISAM
table.The thread is processing a
SELECT
that is resolved using an internal temporary table.The thread is creating a table. This includes creation of temporary tables.
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 will be
Copying to tmp table on disk
.committing alter table to storage engine
The server has finished an in-place
ALTER TABLE
and is committing the result.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.
The thread is processing an
ALTER TABLE ... DISCARD TABLESPACE
orALTER TABLE ... IMPORT TABLESPACE
statement.This occurs at the end but before the cleanup of
ALTER TABLE
,CREATE VIEW
,DELETE
,INSERT
,SELECT
, orUPDATE
statements.The thread has begun executing a statement.
The thread is executing statements in the value of the
init_command
system variable.The thread has executed a command. This state is usually followed by
cleaning up
.The server is preparing to perform a natural-language full-text search.
This occurs before the initialization of
ALTER TABLE
,DELETE
,INSERT
,SELECT
, orUPDATE
statements. Actions taken by the server in this state include flushing the binary log and theInnoDB
log.For the
end
state, the following operations could be happening:Writing an event to the binary log
Freeing memory buffers, including for blobs
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.The thread is trying to lock a system table (for example, a time zone or log table).
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.
This state is used for the
SHOW PROCESSLIST
state.The thread is trying to open a system table (for example, a time zone or log table).
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 aLOCK TABLE
statement can prevent opening a table until the statement is finished. It is also worth checking that yourtable_open_cache
value is large enough.For system tables, the
Opening system tables
state is used instead.The server is performing initial optimizations for a query.
This state occurs during query optimization.
The thread is removing unneeded relay log files.
This state occurs after processing a query but before the
freeing items
state.The server is reading a packet from the client.
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.The thread is removing an internal temporary table after processing a
SELECT
statement. This state is not used if no temporary table was created.The thread is renaming a table.
The thread is processing an
ALTER TABLE
statement, 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.
The repair code is using a sort to create indexes.
The server is preparing to execute an in-place
ALTER TABLE
.The thread has completed a multithreaded repair for a
MyISAM
table.The repair code is using creating keys one by one through the key cache. This is much slower than
Repair by sorting
.The thread is rolling back a transaction.
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, theAUTO_INCREMENT
counter, and key distributions.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 data
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.The server is writing a packet to the client.
The thread is beginning an
ALTER TABLE
operation.The thread is doing a sort to satisfy a
GROUP BY
.The thread is doing a sort to satisfy an
ORDER BY
.The thread is sorting index pages for more efficient access during a
MyISAM
table optimization operation.For a
SELECT
statement, this is similar toCreating sort index
, but for nontemporary tables.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.
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 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 sameMyISAM
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 will have no effect. ForSHOW 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.The thread is getting ready to start updating the table.
The thread is searching for rows to update and is updating them.
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.
The server is executing the second part of a multiple-table update and updating the matched rows from the other tables.
The thread is going to request or is waiting for an advisory lock requested with a
GET_LOCK()
call. ForSHOW PROFILE
, this state means the thread is requesting the lock (not waiting for it).The thread has invoked a
SLEEP()
call.FLUSH TABLES WITH READ LOCK
is waiting for a commit lock.FLUSH TABLES WITH READ LOCK
is waiting for a global read lock or the globalread_only
system variable is being set.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
, orOPTIMIZE TABLE
.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
, orOPTIMIZE TABLE
.The server is waiting to acquire a
THR_LOCK
lock or a lock from the metadata locking subsystem, wherelock_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
For information about table lock indicators, see Section 8.11.1, “Internal Locking Methods”. For information about metadata locking, see Section 8.11.4, “Metadata Locking”. To see which locks are blocking lock requests, use the Performance Schema lock tables described at Section 26.12.12, “Performance Schema Lock Tables”.
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.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-general-thread-states.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.