Identify the reason for "[ERROR] ... Sort aborted"

Hello Forum,
i did not find a answer in the search section, so i creating this new topic.

We are having a lot of mysql 5.0.85 server for our customers, most of all running good and unremarkable.

Sometimes a mysql server gets high load and i see in /var/log/mysqld.err entries like these:

100210 21:22:42 [ERROR] /usr/libexec/mysqld: Sort aborted100210 21:23:10 [ERROR] /usr/libexec/mysqld: Sort aborted100210 21:28:56 [ERROR] /usr/libexec/mysqld: Sort aborted

All other mysql logging is disabled, the server host today 2336 different databases.

Can i enable a partially logging to find the database and/or reason for “Sort aborted”?

Thank you in advance,

Some details about the server:

Intel® Core™2 Quad CPU Q6600 @ 2.40GHzMem: 3986980Part of /etc/my.cnfmax_connections=2000key_buffer = 254Mmax_allowed_packet = 16Mtable_cache = 8048sort_buffer_size = 64Mread_buffer_size = 32Mread_rnd_buffer_size = 32Mmyisam_sort_buffer_size = 64Mthread_cache = 1024query_cache_size = 512M# Try number of CPU’s*2 for thread_concurrencythread_concurrency = 8mysqlreport:MySQL 5.0.85 uptime 6 9:35:44 Wed Feb 10 22:05:48 2010__ SELECT and Sort __________________________Scan 14.18M 25.7/s %SELECT: 23.51Range 5.33M 9.6/s 8.84Full join 589.47k 1.1/s 0.98Range check 1.07k 0.0/s 0.00Full rng join 63.58k 0.1/s 0.11Sort scan 11.20M 20.3/sSort range 5.06M 9.1/sSort mrg pass 2 0.0/s Bytes _______________________________________Sent 3.40T 6.2M/sReceived 38.96G 70.5k/s

I don’t think there is a way to log the query that causes those errors. But I think you can find the queries by sniffing TCP traffic with mk-query-digest or wireshark.