取消执行的语句被记录 slowlog
程序员文章站
2022-07-13 17:15:21
...
1.版本
1)操作系统
#cat /proc/version
Linux version 4.14.76-1.el7.rx.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)) #1 SMP Thu Oct 18 09:52:06 +06 2018
2)mysql数据库版本
[[email protected]][(none)]> select version();
+-----------+
| version() |
+-----------+
| 8.0.19 |
+-----------+
1 row in set (0.00 sec)
2.问题描述
2.1 问题发现
偶然发现一个很有意思的慢查日志,日志如下(日志中用户名,ip,表名做了处理):
# Time: 2021-03-10T23:34:50.091021+08:00
# [email protected]: dba_xxxx[dba_xxxx] @ [xx.xxx.x.xx] Id: 26233801
# Query_time: 2.839109 Lock_time: 0.000377 Rows_sent: 0 Rows_examined: 0
SET timestamp=1615390487;
SELECT id,create_time FROM t_xxxx order by id
LIMIT 0, 1000;
##这个表是一个业务表,肯定是不为空的,但是慢日志中Rows_sent 和 Rows_examined 都为0,这是怎么回事?咨询了当时执行这个sql的同事,他当时执行一会就取消了该sql。就是说mysql 慢日志中记录取消执行的sql
2.2 测试验证
1) 执行某个sql,然后中断执行
[email protected]][(none)]> use test_shao;
Database changed
[[email protected]][test_shao]> select count(*) from test_user;
^C^C -- query aborted
ERROR 1317 (70100): Query execution was interrupted
[[email protected]][test_shao]>
2) 查看慢日志
# Time: 2021-03-17T14:45:05.191215+08:00
# [email protected]: root[root] @ [127.0.0.1] Id: 49
# Query_time: 5.700274 Lock_time: 0.001084 Rows_sent: 0 Rows_examined: 0
SET timestamp=1615963499;
select count(*) from test_user;
##看来猜想是正确的,mysql会记录被中断执行的sql,但是 Rows_sent 和 Rows_examined 都为0