【 TiDB 使用环境】生产环境
【 TiDB 版本】v5.3.2
【遇到的问题】一个非常奇怪的现象,数据库这边运行一个sql,结果能够查出来,但是 session 一直处于query状态,kill tidb ID也不生效。也只有这个sql 是这样的情况。
通过cluster_processlist 查看,这个session的query time一直在增加,可实际上,结果已经返回:
我通过mysql 客户端执行该条sql,也是同样的,sql执行完毕,结果已经返回,但是session一直存在,即使关闭mysql客户端也同样一直存在,登陆到对应 tidb 节点去kill ,杀不掉,然后发现kill 在 v5.4以前有bug,目前唯一的解决办法是重启对应的 tidb-server。
sql:
select *
from (SELECT
wde.weight_time,
wde.review_end_time,
wt.sign_ask,
wdst.goodcount,
wd.pack_no,
wde.handover_time,
CONCAT(
IFNULL(service_province, ""),
IFNULL(service_city, ""),
IFNULL(service_district, ""),
IFNULL(service_street, "")
) receive_address,
wt.trans_ask
FROM wd
left JOIN wt
ON wd.do_id = wt.order_id
left JOIN wde
ON wd.do_id = wde.do_id
left JOIN wdst ON wd.do_id = wdst.orderid
WHERE 1 = 1
AND house_id = '3401001'
AND partner_id = 'test'
AND create_time >= '2022-09-01 00:00:00.0'
AND create_time <= '2022-09-12 00:00:00.0'
AND cust_id_list IN (
'12345678',
'22345678',
'32345678',
'42345678'
)) t
order by create_time desc
limit 80000, 200;
目前改写sql为则恢复正常:
SELECT
*
FROM
(
SELECT
wde.weight_time,
wde.review_end_time,
wt.sign_ask,
wdst.goodcount,
wd.pack_no,
wde.handover_time,
CONCAT(
IFNULL(service_province, ""),
IFNULL(service_city, ""),
IFNULL(service_district, ""),
IFNULL(service_street, "")
) receive_address,
wt.trans_ask
FROM
(
SELECT * FROM wd WHERE
1 = 1
AND house_id = '3401001'
AND partner_id = 'test'
AND create_time >= '2022-09-01 00:00:00.0'
AND create_time <= '2022-09-12 00:00:00.0'
AND cust_id_list IN (
'12345678',
'22345678',
'32345678',
'42345678'
)
ORDER BY
create_time DESC
LIMIT
80000, 200
) wd
LEFT JOIN wt ON wd.do_id = wt.order_id
LEFT JOIN wde ON wd.do_id = wde.do_id
LEFT JOIN wdst ON wd.do_id = wdst.orderid
) t
所以想知道造成这种现象的原因是什么?
附上Clinic诊断数据: