-
Notifications
You must be signed in to change notification settings - Fork 111
ps_setup_disable_thread()
xiaoboluo768 edited this page Jun 9, 2020
·
2 revisions
-
禁用指定线程的检测功能,通过修改performance_schema.threads表,调用时传入值作为processlist_id字段值(或者是show processlist;输出的id字段值),修改instrumented字段为NO实现,返回一个被关闭的线程数量(已经处于关闭状态的线程不会计数,因为是使用ROW_COUNT()函数作为返回值,该函数只记录发生变更的行)
-
参数:
- in_connection_id BIGINT:连接ID(进程ID),为performance_schema.theads表的PROCESSLIST_ID列或SHOW PROCESSLIST输出的id列值
-
定义语句
DROP PROCEDURE IF EXISTS ps_setup_disable_thread;
DELIMITER $$
CREATE DEFINER='root'@'localhost' PROCEDURE ps_setup_disable_thread (
IN in_connection_id BIGINT
)
COMMENT '
Description
-----------
Disable the given connection/thread in Performance Schema.
Parameters
-----------
in_connection_id (BIGINT):
The connection ID (PROCESSLIST_ID from performance_schema.threads
or the ID shown within SHOW PROCESSLIST)
Example
-----------
mysql> CALL sys.ps_setup_disable_thread(3);
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.01 sec)
To disable the current connection:
mysql> CALL sys.ps_setup_disable_thread(CONNECTION_ID());
+-------------------+
| summary |
+-------------------+
| Disabled 1 thread |
+-------------------+
1 row in set (0.00 sec)
'
SQL SECURITY INVOKER
NOT DETERMINISTIC
MODIFIES SQL DATA
BEGIN
UPDATE performance_schema.threads
SET instrumented = 'NO'
WHERE processlist_id = in_connection_id;
SELECT CONCAT('Disabled ', @rows := ROW_COUNT(), ' thread', IF(@rows != 1, 's', '')) AS summary;
END$$
DELIMITER ;
上一篇: ps_setup_disable_instrument()存储过程 | 下一篇: ps_setup_enable_background_threads()存储过程
- 验证、测试、整理:罗小波
- QQ:309969177
- 提示:本系列文章的主体结构遵循Oracle MySQL 官方 5.7 手册中,关于information_schema、mysql schema、performance_schema、sys schema的章节结构体系,并额外添加了一些验证、测试数据。鉴于本人精力和能力有限,难免出现一些纰漏,欢迎大家踊跃指正!