>It's been up for a few days and runs fast/well, but twice now it has suddenly >locked up with NO activity at all - all of the Innodb thread slots have tasks >which seem stuck, and hundreds of other threads waiting - this goes on >forever, like 1-2 hours at CPU 100% idle, no queries executing, etc. until we >discovered FLUSH TABLES will fix it.
You may need to increase the value of the table_cache variable. You can check whether you need to increase the table cache by checking the Opened_tables status variable. If the value is very large or increases rapidly, even when you have not issued many FLUSH TABLES statements, you should increase the table cache size.
http://dev.mysql.com/doc/refman/5.1/en/table-cache.html