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 参数进行单独控制此 存储过程的执行超时时间

相关推荐
chat2tomorrow4 分钟前
数据采集平台的起源与演进:从ETL到数据复制
大数据·数据库·数据仓库·mysql·低代码·postgresql·etl
考虑考虑7 分钟前
Postgerssql格式化时间
数据库·后端·postgresql
依稀i12310 分钟前
Spring Boot + MySQL 创建超级管理员
spring boot·mysql
Chan1620 分钟前
【智能协同云图库】基于统一接口架构构建多维度分析功能、结合 ECharts 可视化与权限校验实现用户 / 管理员图库统计、通过 SQL 优化与流式处理提升数据
java·spring boot·后端·sql·spring·intellij-idea·echarts
库库林_沙琪马39 分钟前
REST接口幂等设计深度解析
spring boot·后端
IT_陈寒42 分钟前
Redis性能提升50%的7个关键优化策略,90%开发者都不知道第5点!
前端·人工智能·后端
驾驭人生1 小时前
Asp .Net Core 系列:Asp .Net Core 集成 Hangfire+MySQL
数据库·mysql·.netcore
智商偏低1 小时前
ASP.NET Core 身份验证概述
后端·asp.net
冷冷的菜哥1 小时前
ASP.NET Core使用MailKit发送邮件
后端·c#·asp.net·发送邮件·mailkit
xhbh6661 小时前
不止是DELETE:MySQL多表关联删除的JOIN语法实战详解
数据库·mysql·程序员·mysql删除语句