【MySQL】mysqldump Error 3024: Query execution was interrupted

数据库版本:MySQL 5.7.16

mysqldump完整报错:
mysqldump: Error: Query execution was interrupted, maximum statement execution time exceeded when trying to dump tablespaces 
mysqldump: Error 3024: Query execution was interrupted, maximum statement execution time exceeded when dumping table `$tb_name` at row: 25002

在SELECT时也有可能报该错:
ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded

检查bug库,发现同样问题:
https://bugs.mysql.com/bug.php?id=83339

原因是max_execution_time设置过小导致。


复现:
将max_execution_time设置成很小的值,执行mysqldump(本质也是执行SELECT)或者SELECT语句:

  1. [17:23:01] root@localhost [(none)]SET GLOBAL max_execution_time=10;
  2. Query OK, 0 rows affected (0.00 sec)

  3. [17:23:11] root@localhost [(none)]> SELECT * FROM test.t1 LIMIT 100000;
  4. ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded

  5. mysqldump -uxxx -pxxx -S -A > /tmp/a.sql
  6. mysqldump: Error 3024: Query execution was interrupted, maximum statement execution time exceeded when dumping table `$tb_name` at row: 0



解决办法:
① 通过hints,增大N值(文档说,在hints用法中,将N改为0为无限制,但我测下来不生效,可设置成一个较大值如999999解决)
SELECT /*+ MAX_EXECUTION_TIME(N) */ * FROM t1 LIMIT 100000;

② 修改max_execution_time值,将该值设置为较大一个值,或设置为0(不限制)



相关参数:
max_execution_time
该参数5.7.8被添加,单位为ms,动态参数,默认为0。
设置为0时意味着SELECT超时不被设置(不限制超时时间)。
不作用于存储过程中的SELECT语句,并且只作用于只读的SELECT,比如INSERT ... SELECT ... 是不被作用的。








个人感觉,这个参数的添加,本意是用于干掉执行时间过长的SELECT语句,
但这个参数可以被mysqldump所触发,感觉是一个很鸡肋的参数。
最后看了一下,该实例备份失败,这个参数的确被人配置成了60……



作者微信公众号(持续更新)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29773961/viewspace-2150443/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29773961/viewspace-2150443/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值