Crazy Error
I just updated some rails webpages to 4.2.4. On one system, I didn’t have any trouble. But on the other one, things worked fine on my laptop, but gave all sorts of random errors on my production system. I started keeping a list to see if I could figure out what was going on. Here are some of the errors that I was seeing.
Assigning rec to a user D, [2015-09-16T13:19:32.760059 #9687] DEBUG -- : Applicant Load (0.5ms) SELECT `applicants`.* FROM `applicants` WHERE `applicants`.`id` = ? LIMIT 1 [["id", 1]] E, [2015-09-16T13:19:32.760913 #9687] ERROR -- : Mysql::Error: : SELECT `applicants`.* FROM `applicants` WHERE `applicants`.`id` = ? LIMIT 1 I, [2015-09-16T13:19:32.763318 #9687] INFO -- : Completed 500 Internal Server Error in 34ms (ActiveRecord: 4.4ms) F, [2015-09-16T13:19:32.765518 #9687] FATAL -- : ActiveRecord::StatementInvalid (Mysql::Error: : SELECT `applicants`.* FROM `applicants` WHERE `applicants`.`id` = ? LIMIT 1): app/controllers/reference_documents_controller.rb:44:in `update' Clicked on Admin D, [2015-09-16T13:20:57.053182 #9687] DEBUG -- : SQL (0.4ms) UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ? [["last_request_at", "2015-09-16 18:20:57"], ["updated_at", "2015-09-16 18:20:57"], ["id", 2]] E, [2015-09-16T13:20:57.053291 #9687] ERROR -- : Mysql::Error: : UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ? D, [2015-09-16T13:20:57.053591 #9687] DEBUG -- : (0.1ms) ROLLBACK I, [2015-09-16T13:20:57.053942 #9687] INFO -- : Completed 500 Internal Server Error in 8ms (ActiveRecord: 1.2ms) F, [2015-09-16T13:20:57.055476 #9687] FATAL -- : ActiveRecord::StatementInvalid (Mysql::Error: : UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ?): app/controllers/application_controller.rb:15:in `current_user_session' app/controllers/application_controller.rb:20:in `current_user' Clicked on Applicants D, [2015-09-16T13:21:27.031430 #9687] DEBUG -- : (0.3ms) SELECT `reference_documents`.`firstname`, `reference_documents`.`lastname` FROM `reference_documents` WHERE `reference_documents`.`applicant_id` = ? [["applicant_id", 1]] E, [2015-09-16T13:21:27.031532 #9687] ERROR -- : Mysql::Error: : SELECT `reference_documents`.`firstname`, `reference_documents`.`lastname` FROM `reference_documents` WHERE `reference_documents`.`applicant_id` = ? I, [2015-09-16T13:21:27.032374 #9687] INFO -- : Rendered applicants/index.html.erb within layouts/application (7.1ms) I, [2015-09-16T13:21:27.032567 #9687] INFO -- : Completed 500 Internal Server Error in 27ms (ActiveRecord: 12.1ms) F, [2015-09-16T13:21:27.034208 #9687] FATAL -- : ActionView::Template::Error (Mysql::Error: : SELECT `reference_documents`.`firstname`, `reference_documents`.`lastname` FROM `reference_documents` WHERE `reference_documents`.`applicant_id` = ?): Clicked on Upload Recommendation D, [2015-09-16T13:22:25.859508 #9687] DEBUG -- : SQL (0.3ms) UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ? [["last_request_at", "2015-09-16 18:22:25"], ["updated_at", "2015-09-16 18:22:25"], ["id", 2]] E, [2015-09-16T13:22:25.859610 #9687] ERROR -- : Mysql::Error: : UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ? D, [2015-09-16T13:22:25.859970 #9687] DEBUG -- : (0.1ms) ROLLBACK I, [2015-09-16T13:22:25.860197 #9687] INFO -- : Completed 500 Internal Server Error in 6ms (ActiveRecord: 1.0ms) F, [2015-09-16T13:22:25.861710 #9687] FATAL -- : ActiveRecord::StatementInvalid (Mysql::Error: : UPDATE `users` SET `last_request_at` = ?, `updated_at` = ? WHERE `users`.`id` = ?): app/controllers/application_controller.rb:15:in `current_user_session' app/controllers/application_controller.rb:20:in `current_user'
I had run rake rails:update to get to these pages and thought that perhaps I had screwed something up during the update. So I basically rewrote the entire app from scratch and I still got the above random errors. All I knew was that it was something to do with mysql.
Finally, I looked at another app that does pretty much the same thing, but for a different group. When I closely examined the Gemfile.lock files, I realized that the working app was using the mysql2 gem (0.3.20) and the app with random errors was using the mysql gem (2.9.1). I then changed to the mysql2 0.3.20 gem and changed my database.yml file to reflect that. My random errors seem to have gone away, but I’m still testing.
Did a bit of looking around and found that I should have never used the mysql gem. It hasn’t been updated in years. I guess I didn’t realize that I had been using this app for that many years. Anyway, now I know to stick with mysql2.