SHOW PROCESSLIST的各个状态说明

本文涉及的产品
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
简介:

SHOW PROCESSLIST显示哪些线程正在运行。

如果您有SUPER权限,您可以看到所有线程。否则,您只能看到您自己的线程(也就是,与您正在使用的MySQL账户相关的线程)。

如果您不使用FULL关键词,则只显示每个查询的前100个字符。


本语句报告TCP/IP连接的主机名称(采用host_name:client_port格式),以方便地判定哪个客户端正在做什么。


如果您得到“too many connections”错误信息,并且想要了解正在发生的情况,本语句是非常有用的。mysql保留一个额外的连接,让拥有SUPER权限的 账户使用,以确保管理员能够随时连接和检查系统(假设您没有把此权限给予所有的用户)。


官方说明: https://dev.mysql.com/doc/refman/5.7/en/general-thread-states.html


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.

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

  •  converting HEAP to MyISAM

    The thread is converting an internal temporary table from a MEMORY table to an on-disk MyISAM 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. See Section 25.11.5, “Performance Schema Stage Event Tables”.

  •  Copying to group table

    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

    The server is copying to a temporary table in memory.

  •  altering table

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

  •  Copying to tmp table on disk

    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.

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

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

  •  end

    This occurs at the end but before the cleanup of ALTER TABLECREATE VIEWDELETEINSERTSELECT, or UPDATE statements.

  •  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. Some freeing of items done during this state involves the query cache. 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 TABLEDELETEINSERTSELECT, or UPDATE statements. Actions taken by the server in this state include flushing the binary log, the InnoDB log, and some query cache cleanup operations.

    For the end state, the following operations could be happening:

    • Removing query cache entries after data in a table is changed

    • Writing an event to the binary log

    • Freeing memory buffers, including for blobs

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

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

  •  NULL

    This state is used for the SHOW PROCESSLIST state.

  •  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 TABLEstatement can prevent opening a table until the statement is finished. It is also worth checking that your table_open_cache value is large enough.

  •  optimizing

    The server is performing initial optimizations for a query.

  •  preparing

    This state occurs during query optimization.

  •  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. This state is called Reading from net prior to MySQL 5.7.8.

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

  •  preparing for alter table

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

  •  Repair done

    The thread has completed a multi-threaded 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 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.

  •  Sending to client

    The server is writing a packet to the client. This state is called Writing to net prior to MySQL 5.7.8.

  •  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 access during a MyISAM table optimization operation.

  •  Sorting result

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

  •  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 will have no effect. For SHOW PROFILE, this state means the thread is requesting the lock (not waiting for it).

  •  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 global read lock

    FLUSH TABLES WITH READ LOCK is waiting for a global read lock or the global read_only system variable is being set.

  •  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_nameALTER TABLERENAME TABLEREPAIR TABLEANALYZE 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_nameALTER TABLERENAME TABLEREPAIR TABLEANALYZE 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:

    These states indicate a wait for a 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 25.11.12, “Performance Schema Lock Tables”.

    • 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 for table level 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. This state is called Sending to client as of MySQL 5.7.8.










本文转自 lirulei90 51CTO博客,原文链接:http://blog.51cto.com/lee90/1944678,如需转载请自行联系原作者
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
目录
相关文章
|
SQL 存储 数据挖掘
大模型与数据分析:探索Text-to-SQL(下)
大模型与数据分析:探索Text-to-SQL(下)
1359 4
|
缓存 算法 网络协议
公众号JSSDK获取signature签名,史上最全,没有之一
公众号JSSDK获取signature签名,史上最全,没有之一
929 0
|
数据采集 关系型数据库 MySQL
python-协程(async、await关键字与asyncio)
python-协程(async、await关键字与asyncio)
1676 0
|
9月前
|
Kubernetes Docker 容器
Kubernetes与Docker参数对照:理解Pod中的command、args与Dockerfile中的CMD、ENTRYPOINT。
需要明确的是,理解这些都需要对Docker和Kubernetes有一定深度的理解,才能把握二者的区别和联系。虽然它们都是容器技术的二个重要组成部分,但各有其特性和适用场景,理解它们的本质和工作方式,才能更好的使用这些工具,将各自的优点整合到生产环境中,实现软件的快速开发和部署。
369 25
|
5月前
|
运维 数据可视化 测试技术
从混乱到清晰:API开发追踪工具实用技巧与工具配置完整拆解
API开发追踪工具是提升团队协作效率、实现接口全流程管理的关键。它整合任务看板、文档同步、版本控制与多角色协作,助力前后端及第三方高效对接。本文详解其核心功能、选型建议与落地实践,助你打造透明、规范的API协作体系。
|
6月前
|
监控 数据可视化 测试技术
API性能监控:关键指标与实用工具
监控API接口性能对保障其稳定性和效率至关重要。常用方法包括:关注响应时间、吞吐量、正常运行时间、错误率及资源使用率等关键指标;通过日志分析、性能监控工具(如New Relic、Datadog APM)、实时警报和用户行为分析优化性能;借助压力测试评估负载能力。推荐工具如Assertible、SmartBear、Moesif等,可简化监控流程并提供详细报告。综合运用这些方法与工具,能有效确保API的高效稳定运行。
925 1
|
4月前
|
存储 人工智能 Serverless
AI Agent 运行时相比传统应用有什么不同:百家企业 AI 实践观察(二)
本文深入探讨了AI Agent运行时的核心挑战及解决方案,分析了AI Agent从理论走向实践过程中所面临的动态推理、资源成本与安全风险等问题,并详细介绍了阿里云函数计算FC如何作为AI Agent运行时及沙箱环境(Sandbox),有效应对脉冲式计算需求、突发性负载、数据隔离与会话亲和性等挑战。同时,文章结合典型场景,展示了函数计算FC在编码式与流程式AI Agent构建中的优势,涵盖Chat AI Agent、营销素材组装、仿真训练等应用,为AI Agent的高效、安全运行提供了完整的技术路径。
548 2
|
8月前
|
存储 分布式计算 调度
Flink Shuffle 技术演进之路
本文由阿里云智能Flink团队郭伟杰与哔哩哔哩蒋晓峰在Flink Forward Asia 2024上的分享整理而成,聚焦Flink Shuffle技术的演进与未来规划。内容涵盖低延迟的Pipelined Shuffle、高吞吐的Blocking Shuffle、流批一体的Hybrid Shuffle三大模式及其应用场景,并探讨了Flink与Apache Celeborn的整合、性能优化及长期发展路线图。通过Hybrid Shuffle等创新技术,Flink实现了资源调度灵活性与高性能的平衡,为流批一体化计算提供了强大支持。未来,社区将进一步优化Shuffle机制,提升系统智能化与易用性。
495 14
Flink Shuffle 技术演进之路
|
Prometheus 监控 Kubernetes
免费的集群管理软件有哪些?5款主流推荐
集群管理是对多台服务器或计算节点进行协调、调度和维护的过程,核心在于资源分配、负载均衡、监控和故障恢复。常见的集群管理软件包括板栗看板、Kubernetes Dashboard、Zabbix、Prometheus + Grafana 和 Nagios Core。这些软件各有特色,适用于不同的需求场景,如项目管理、容器编排、实时监控等。选择合适的集群管理工具,可以提升团队效率,降低运营成本,确保系统稳定运行。
3349 4
|
NoSQL 数据可视化 Linux
redis学习四、可视化操作工具链接 centos redis,付费Redis Desktop Manager和免费Another Redis DeskTop Manager下载、安装
本文介绍了Redis的两个可视化管理工具:付费的Redis Desktop Manager和免费的Another Redis DeskTop Manager,包括它们的下载、安装和使用方法,以及在使用Another Redis DeskTop Manager连接Redis时可能遇到的问题和解决方案。
1813 1
redis学习四、可视化操作工具链接 centos redis,付费Redis Desktop Manager和免费Another Redis DeskTop Manager下载、安装

热门文章

最新文章