MYSQL Out of Memory and Table Crashing

memoryMySQL

A specific table in my database keeps crashing. I suspect it to be a bad buffer setting in the my.conf file, because it shows this error before crashing (most of the time it needs to be repaired):

18:26:59 [ERROR] /usr/libexec/mysqld: Incorrect key file for table './myDB/myTable.MYI'; try to repair it
18:54:57 [ERROR] /usr/libexec/mysqld: Out of memory (Needed 59542644 bytes) 141020  
18:54:57 [ERROR] /usr/libexec/mysqld: Sort aborted

I don't think it is hard disk related, since tmpdir is set to /tmp/ and has around 48 GB of free disk space.

Input

mysql> SHOW VARIABLES LIKE 'tmpdir';

Output

tmpdir         /tmp/  

Here is a look at the my.conf settings. Take special note of the parameter sort_buffer_size which has been set way to high. However, I'm unsure if it will produce this kind of error when set too high. This machine runs Ubuntu with 8 GB RAM.

[mysqld]
max_connections         = 1500
back_log                = 50
skip-locking
key_buffer              = 819M
max_allowed_packet      = 16M
table_cache             = 512 
sort_buffer_size        = 2048M
read_buffer_size        = 16M
read_rnd_buffer_size    = 8M
myisam_sort_buffer_size = 64M
thread_cache_size       = 16
query_cache_size        = 16M
thread_concurrency      = 8
max_heap_table_size     = 512M
wait_timeout            = 60
interactive_timeout     = 60

Any thoughts on this issue?

Best Answer

Set in config file this line

max_sort_length=8M

And happy day!