mysql 突然报错 1878 Temporary file write failure

报错内容: 

message: "\n### Error querying database. 
Cause: java.sql.SQLException: Temporary file write failure.\n### The error may exist in URL
 [jar:file:/home/krsc/apps/whpcomp/whpcomp-admin-1.0-SNAPSHOT.jar!/BOOT-INF/lib/whpcomp-oem-application-1.0-SNAPSHOT.jar!/mapper/whpcomp/user/UserCertificateMapper.xml]\n### 
 The error may involve com.kx.whpcomp.oem.application.user.dao.mapper.UserCertificateMapper.getRYZJGQ-Inline\n### The error occurred while setting parameters\n### 
 SQL: SELECT   count(1)   FROM   (   SELECT   c1.*,   datediff(c1.valid_date,NOW()) xc   from   (SELECT *,row_number() over(partition by user_id,certificate_type order by valid_date desc) as rn1 FROM t_xxx_certificate   where valid_date is not null AND certificate_type =?) c1  
 left join t_user c2 on c1.user_id = c2.id   left join t_user_role cc on c1.user_id =  cc.user_id   left join t_role ccc on cc.role_id = ccc.id   WHERE   rn1=1   AND c2.status=0        AND c1.department_id = ?        ) t   where    t.xc <= 30\n### 
 Cause: java.sql.SQLException: Temporary file write failure.\n; uncategorized SQLException; SQL state [HY000]; error code [1878]; Temporary file write failure.; nested exception is java.sql.SQLException: Temporary file write failure."

问题排查:
1. 首先测试环境检验此功能是否正常使用 发现正常;

2. 查看sql是否可以正常运行(线上线下都正常)

3. 仔细看异常信息发现java.sql.SQLException这个错误应该是数据库的错误(不确定)

4. 百度了一下mybatis 1878 Temporary file write failure 发现没有此错误,只有mysql有(基本可确定不是mybatis的问题)

5. 百度 mysql 1878 Temporary file write failure 发现 错误原因;

错误原因:

在sql执行表关联时,会创建临时表,当临时空间不够,导致临时文件写入失败

解决办法:

查看创建临时表的空间join_buffer:

show VARIABLES like '%join_buffer%';

 join_buffer_size 默认值 256k(262144)

修改join_buffer_size:

set SESSION join_buffer_size = 1024*1024*1024;

 

 再次检验发现 功能恢复正常;

 

 原因分析借鉴:

【已解决】Temporary file write failure_KP的博客-CSDN博客

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值