Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Active Record running all queries twice

Have no idea why this is happening in production:

Update this is from the rails console:

User.all
  User Load (0.5ms)  SELECT "users".* FROM "users"
  User Load (0.5ms)  SELECT "users".* FROM "users"
2.0.0-p451 :005 > User.first.destroy
  User Load (0.6ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
  User Load (0.6ms)  SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
   (0.2ms)  BEGIN
   (0.2ms)  BEGIN
  Discussion Load (60.4ms)  SELECT DISTINCT "discussions".* FROM "discussions" INNER JOIN "followers" ON "discussions"."id" = "followers"."discussion_id" WHERE "followers"."user_id" = $1  [["user_id", 1]]
  Discussion Load (60.4ms)  SELECT DISTINCT "discussions".* FROM "discussions" INNER JOIN "followers" ON "discussions"."id" = "followers"."discussion_id" WHERE "followers"."user_id" = $1  [["user_id", 1]]
  Reply Load (0.8ms)  SELECT "replies".* FROM "replies" WHERE "replies"."user_id" = $1  [["user_id", 1]]
  Reply Load (0.8ms)  SELECT "replies".* FROM "replies" WHERE "replies"."user_id" = $1  [["user_id", 1]]
  SQL (0.4ms)  DELETE FROM "users" WHERE "users"."id" = $1  [["id", 1]]
  SQL (0.4ms)  DELETE FROM "users" WHERE "users"."id" = $1  [["id", 1]]
   (0.5ms)  COMMIT
   (0.5ms)  COMMIT

My production settings:

  config.cache_classes = false
  config.eager_load = false
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  config.action_mailer.default_url_options = { host: 'xxx' }
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :authentication => :plain,
    :address => "xxx",
    :port => xxx,
    :domain => "xxx",
    :user_name => "xxx",
    :password => "xxx"
  }


  config.active_support.deprecation = :log
  config.active_record.migration_error = :page_load
  config.serve_static_assets = :false
  config.log_level = :debug
  config.assets.debug = true

Hoping there's some common gotcha? Really odd isn't it?

like image 432
Starkers Avatar asked May 06 '14 19:05

Starkers


1 Answers

I've had a similar problem, turned out it was a bug in rails_12factor gem I installed for heroku. Just set it as a production gem in Gemfile

gem 'rails_12factor', group: :production
like image 85
Morozov Avatar answered Sep 21 '22 06:09

Morozov