MySQL数据库报“You are not owner of thread”错误的解决方法

背景

最近在做数据归档相关需求,最终方案采用存储过程进行归档,由应用服务去调度,在测试过程中出现以下错误,但是存储过程是正常执行成功

复制代码
### SQL: call proc_archive_table             (                 ?, ?,                 ?, ?,                 ?, ?,                 ?, ?             )
### Cause: java.sql.SQLException: You are not owner of thread 301928
; uncategorized SQLException; SQL state [HY000]; error code [1095]; You are not owner of thread 301928; nested exception is java.sql.SQLException: You are not owner of thread 301928
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:88)
Caused by: java.sql.SQLException: You are not owner of thread 301928
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
	at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370)
	at com.mysql.cj.jdbc.CallableStatement.execute(CallableStatement.java:845)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:483)

找到异常关键词后有点不解随即开始百度:You are not owner of thread 301928

大多都是在说权限不足导致的

例:MySQL数据库报"You are not owner of thread"错误的解决方法

但再三检查该用户权限后都无济于事,最终给到了root用户来进行测试也不行。。。

最后在同事的帮助指引下进行抓包查看,贴下正常与异常报文

异常报文在 调度存储过程后 5s 左右发起了一个Login Request的报文,随即 发送了一个 Kill 请求,继而响应:You are not owner of thread 301928

以此为突破点,回想系统的配置参数:德鲁伊: query-timeout:5s,随即便调大了此参数重新进行测试, 缤果, 没问题了。。。百思不得其解

结语

因此归档任务执行会非常耗时,本着不影响系统的原则 在对应 select 标签上增加 timeout 参数进行单独控制此 存储过程的执行超时时间

相关推荐
IT北辰1 小时前
用Python+MySQL实战解锁企业财务数据分析
python·mysql·数据分析
努力的小雨2 小时前
还在为调试提示词头疼?一个案例教你轻松上手!
后端
魔都吴所谓2 小时前
【go】语言的匿名变量如何定义与使用
开发语言·后端·golang
陈佬昔没带相机3 小时前
围观前后端对接的 TypeScript 最佳实践,我们缺什么?
前端·后端·api
AWS官方合作商4 小时前
Amazon RDS for MySQL成本优化:RDS缓存降本实战
数据库·mysql·aws
Livingbody4 小时前
大模型微调数据集加载和分析
后端
Livingbody4 小时前
第一次免费使用A800显卡80GB显存微调Ernie大模型
后端
Goboy5 小时前
Java 使用 FileOutputStream 写 Excel 文件不落盘?
后端·面试·架构
Goboy5 小时前
讲了八百遍,你还是没有理解CAS
后端·面试·架构
程序猿小D6 小时前
Java项目:基于SSM框架实现的校园活动资讯网管理系统【ssm+B/S架构+源码+数据库+毕业论文+远程部署】
java·数据库·mysql·spring·毕业设计·ssm框架·校园活动