Friday, December 3, 2010

MySQL problem, Thread stack overrun: * bytes used of a * byte stack, and * bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack

Are you getting this problem when running custom SQL in phpmyadmin or in the mysql error log? Or maybe if you catch the exception in a programming language like ie php.

One exempel of a problem when requesting data from the database:

#1436 - Thread stack overrun: 5012 bytes used of a 131072 byte stack, and 128000 bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack.


The solution here is to specify a bigger stack as said. One way to do this is to edit your my.cnf file for mysql. You normally will do find the file in Linux at this location: /etc/my.cnf or: /etc/mysql/my.cnf
The location can wary, and sometimes you may not even have a my.cnf then you need to create one.

Open my.cnf in your preferred editor, like vim. And then change or add a line that are higher than the demanded stack size.
You'll be looking for a line like this in your cnf-file:


thread_stack = 192K


Change the thead_stack to a bigger size than what it's specified. If you can't find this line, add it.

After this you'll need to restart mysqld so the changes will apply.

"When the thread stack is too small, this limits the complexity of the SQL statements which the server can handle, the recursion depth of stored procedures, and other memory-consuming actions"

No comments:

Post a Comment