当前位置:网站首页>pt-kill 查询中包含中文字符 导致工具失效的排查
pt-kill 查询中包含中文字符 导致工具失效的排查
2022-07-28 09:59:00 【二狗不要跑】
生产环境遇到几个YearningSQL平台触发的慢查询(该sql产生的笛卡尔积太大,出不来结果,研发在前端界面再次触发查询),最终把数据库的CPU拖高的情况。
DBA紧急介入后,根据mysql服务器上show full processlist抓取到相关sql,执行时间已经超过120s。先记录下现场,然后kill掉相关query。
query类似如下:
select
aa AS A列,
bb as B列
FROM sbtest.sbtest1
where aa = 'abcdefg'
order by update_time desc
LIMIT 100;对比了下后台操作日志,确认这就是研发同学在YearningSQL查询界面多次提交的query。
但是,我们几个月前就上线了pt-kill 定时任务,针对于YearningSQL平台的用户查询做了60秒的查询超时熔断。理论上即便出现这类慢sql也不会执行时间过长。
查了下pt-kill 的最近日志,发现里面有一些提示:
Wide character in print at pt-kill line 7373
翻下对应的代码段,如下部分:
根据上面的sql,基本可以判断是perl脚本执行过程中遇到中文字符处理失败导致的。
找到了原因,解决方法也很简单:
在pt-kill的文件头部,加2行代码:
use utf8;
use open ":encoding(utf8)",":std";另外对于一些复杂的查询,有些建议给到研发同学:
1、执行前建议先explain自行评估下
2、查询中,可以显式定义60秒超时时间,例如 SELECT /*+ MAX_EXECUTION_TIME(60000) */ * FROM t1 INNER JOIN t2 WHERE ... 【5.7及以上版本生效】
边栏推荐
- 8、数组中出现次数超过一半的数字
- 【云驻共创】华为云:MetaStudio数字内容生产线,让虚拟世界与现实世界无缝融合
- 管道、管程、管态的区别
- Kubernetes
- 13、哈希表——两个链表第一个公共节点
- ES (8.1) certification topic
- Cloudcompare & PCL matching point sampling consistency suppression
- B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
- 双指针技巧
- 21. 合并两个有序链表
猜你喜欢

JS promotion: the underlying principle of flat tiling

巧用ngx_lua做流量分组

ES (8.1) certification topic

What are the advantages of MRO purchasing website for industrial products? One article will help you understand

什么样的知识付费系统功能,更有利于平台与讲师发展?

初识SuperMap iDesktop

14、双指针——盛最多水的容器

小黑重新站起来看leetcode:653. 两数之和 IV - 输入 BST

【JS高级】js之函数、重载、匿名函数、作用域及作用域链_03

Skillfully use NGX_ Lua makes traffic grouping
随机推荐
指令系统超全知识点详解
7、二分法——寻找一组重复或者有序但是旋转的数组
海量数据TopN问题
建筑建材行业B2B电子商务网站方案:赋能建材企业转型升级,实现降本提效
【JZOF】14剪绳子
TCP Basics
IE兼容性问题处理
B2B e-commerce website scheme for building materials industry: enable the transformation and upgrading of building materials enterprises to achieve cost reduction and efficiency improvement
Boss: there are too many systems in the company. Can we realize account interworking?
初识SuperMap iDesktop
It's settled! On July 30!
管道、管程、管态的区别
Go json.Decoder Considered Harmful
Redis设计规范
Illustrate three mainstream enterprise architecture models (recommended collection!)
基于ModelArts续写最伟大的作品【玩转华为云】
记录一次idea中的父子项目修改project与module名称,亲测!
2021-10-13arx
jvm原理
(1)机器学习概念总结