代码改变世界

Failed to write to mysql.slow_log

2021-12-08 23:26  潇湘隐者  阅读(568)  评论(0编辑  收藏  举报

 

   最近将一MySQL数据库的系统变量log_output从file调整为table后,偶尔会收到告警邮件,告警邮件内容为:

 

Failed to write to mysql.slow_log

 

查了一下这个问题,发现居然是一个Bug,其实出现这个错误是因为慢查询的SQL语句太长,导致插入mysql.slow_log系统表时超过字段的长度,所以在错误日志当中出现"Failed to write to mysql.slow_log"信息。官方文档的Bug信息为Bug #37132 Logging to slow_log table fails with very slow queries。 摘抄其中一段描述内容如下:

 

Fixed in 8.0.17.

Logging to the mysql.slow_log system table could fail when values

were to large for table columns. Now logging proceeds on a

best-effort basis, writing what information can be provided.

Otherwise, the row is discarded and a message is written to the error log.

 

这个Bug直到MySQL 8.0.17才被Fix掉,在这之前从未碰到过,第一次遇到也颇感意外,遇到了就记录一下!

 

参考资料:

https://bugs.mysql.com/bug.php?id=37132