Mysql Error Code : 1436 Thread stack overrun

编程学习 2021-07-05 15:27www.dzhlxh.cn编程入门
I meet with the error while calling stored procedures from the MySql in my Mac system server. It similar as the description below

ERRNO: 256 
TEXT: SQLSTATE[HY000]: General error: 1436 Thread stack overrun: 4904 bytes used of a 131072 byte stack, and 128000 bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack. 

According to the MySQL manual “The default (192KB) is large enough for normal operation. If the thread stack size is too small, it limits the complexity of the SQL statements that the server can handle, the recursion depth of stored procedures, and other memory-consuming actions” .

To resolve this issue you need to change the default value of parameter 'thread_stack' in /etc/my.cnf  in your MySQL configuration file. I use the XAMPP for php/mysql development. 

Once you set this value you need to restart MySQL as this value cannot be set dynamically.

you maybe also encounter with the message when you try to modify the my.cnf

"Cannot open file for writing: Permission denied"

We will try to use the 'chmod' instruction to change permission as usually. I seldom take the concrete permission into consideration, so I use always use the 'chmod 777'. but it resulted in another errors when I use the phpmyadmin, another tools included in XAMPP, after running 'chmod 777'.

After googling it, I get this file (my.cnf) permissions has to be 600. I change its permission and it works well now.

bug info

报错信息:
java.sql.SQLException: Thread stack overrun: 5456 bytes used of a 131072 byte stack, and 128000 bytes needed. Use 'mysqld --thread_stack=#' to specify a bigger stack.

官方相应信息:

The default (192KB) is large enough for normal operation. If the thread stack size is too small, it limits the complexity of the SQL statements that the server can handle, the recursion depth of stored procedures, and other memory-consuming actions

可以使用

show variables where `variable_name` = 'thread_stack';

查询当前数据库的默认线程栈的大小,一般情况下都能正常使用,但是当查询语句或者存储过程复杂时会报Thread stack overrun错误,此时只要修改默认配置就可以。

解决

windows: 修改mysql安装目录下的my-small.ini或者my.ini设置为256k,或者更大,然后重启服务

[mysqld]
thread_stack = 256k
linux: 同样要修改配置文件,但是!!!,不是安装目录下的配置文件,是/etc/my.cnf,只有这个文件才能生效,然后重启服务service mysql restart

[mysqld]
thread_stack = 256k

其实针对32位系统,32G内存,一般设置为512K即可,据国外网站看到的,如果是64位的系统可以适当增加,其实够用就好了,没必须刚开始设置的就很大。

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板