I'm having issues with my MySQL backend for my Rails app.
Basically every time I deploy, I start getting weird exceptions like
ActiveRecord::StatementInvalid: Mysql2::Error:
NoMethodError: undefined method `fields' for nil:NilClass
ActiveModel::MissingAttributeError: missing attribute: created_at
ActiveRecord::StatementInvalid: Mysql2::Error: Lost connection to MySQL server during query
ActiveRecord::UnknownPrimaryKey: Unknown primary key for table users in model User.
RuntimeError: Session collision on '"017fab6b21d2ef20d30e6119f7bf...."'
I'm not sure if this is happening because of sudden load, which my MySQL instance isn't able to take, but it happens 99% when I restart the app after a deploy.
What could be causing this? I have Rails 3.2.6, Ubuntu 12.04, MySQL 5.1.63
I was having a similar problem in the recent weeks, and had no idea where it came from. Yesterday I tweaked unicorn configuration (our server is running on Debian + unicorn + MySQL), changed number of workers to 4, and limit number of concurrent connections per worker to 2 (in config/database.yml). This morning I find the problem gone, no more random exception like this happens. So I guess it was because too much concurrent connections made MySQL unstable.
I've just posted on my blog about it. Hope this can help you as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With