Rails Version: 2.3.8
Many times during the day, my application seems to accidentally return 500 errors with the corresponding entry in the production log:
ActiveRecord::StatementInvalid (Mysql::Error: Lock wait timeout exceeded; try restarting transaction: INSERT INTO `forum_posts` (`forum_topic_id`, `created_at`, `body`, `ancestry`, `updated_at`, `quote_limit`, `user_id`, `ancestry_depth`, `quote_root`) VALUES(1224783, '2011-01-24 19:18:38', 'Post body', '1285704', '2011-01-24 19:18:38', 1, 57931, 1, 1))
Checking the MySQL slow query log shows this entry as:
SET insert_id=0;
INSERT INTO `forum_posts` (`forum_topic_id`, `created_at`, `body`, `ancestry`, `updated_at`, `quote_limit`, `user_id`, `ancestry_depth`, `quote_root`) VALUES(1224783, '2011-01-24 19:18:38', 'Post body', '1285704', '2011-01-24 19:18:38', 1, 57931, 1, 1);
According to the Rails log, ActiveRecord returned an error due to a timeout waiting for a lock. It seems that the long-term nature of this simple request also offers. The fact is that nowhere is the slow query log able to find the actual query, which should take a lot of time to process - they are all similar to the above example. In addition, in the same journal, no record has a value Lock_timegreater than 0.
- , ? , , , .
.