This project is archived and is in readonly mode.

#5027 needs-more-info
Garrett Bjerkhoel

_request_and_response.erb and diagnostics.erb take an increasingly long time to render in development with multiple SHOW TABLES calls

Reported by Garrett Bjerkhoel | July 1st, 2010 @ 02:36 PM | in 3.0.6

In Rails master whenever an exception is raised, it takes a rough 30 seconds for the page to render completely with a number of SHOW TABLES MySQL queries.

Started GET "/" for 127.0.0.1 at Thu Jul 01 09:26:36 -0400 2010
  SQL (1.6ms)  describe `approvals_users`
  SQL (14.1ms)  describe `clients_users`
  SQL (1.4ms)  describe `agencies_users`
  SQL (1.3ms)  describe `clients_users`
  SQL (1.2ms)  describe `approvals_users`
  SQL (1.4ms)  describe `permissions_users`
  Processing by DashboardController#show as HTML
  SQL (1.4ms)  describe `agencies_users`
  Agency Load (0.4ms)  SELECT `agencies`.* FROM `agencies` WHERE (`agencies`.`subdomain` = 'test') LIMIT 1
  Plan Load (0.4ms)  SELECT `plans`.`id`, `plans`.`name`, `plans`.`price`, `plans`.`client_limit`, `plans`.`allow_hosted_domain`, `plans`.`created_at`, `plans`.`updated_at`, `plans`.`email_access`, `plans`.`max_file_size`, `plans`.`is_secure`, `plans`.`create_templates`, `plans`.`token`, `plans`.`file_types` FROM `plans` WHERE (`plans`.`id` = 3) LIMIT 1
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
  SQL (1.4ms)  describe `permissions_users`
  Permission Load (0.5ms)  SELECT permissions.* FROM permissions INNER JOIN permissions_users ON permissions.id = permissions_users.permission_id WHERE permissions_users.user_id = 1 AND permissions_users.agency_id = 1 LIMIT 1
  Client Load (0.5ms)  SELECT clients.* FROM clients INNER JOIN clients_users ON clients.id = clients_users.client_id WHERE clients_users.agency_id = 1 AND clients_users.user_id = 1 ORDER BY clients.name ASC
  Project Load (0.5ms)  SELECT `projects`.`id`, `projects`.`client_id`, `projects`.`name`, `projects`.`slug`, `projects`.`description`, `projects`.`due_at`, `projects`.`position`, `projects`.`created_at`, `projects`.`updated_at`, `projects`.`is_public`, `projects`.`public_key`, `projects`.`pages_count` FROM `projects` WHERE (`projects`.client_id = 93) ORDER BY position ASC, created_at ASC
  Page Load (0.7ms)  SELECT `pages`.* FROM `pages` WHERE (`pages`.project_id = 28) ORDER BY pages.position ASC, pages.created_at ASC, id DESC LIMIT 1
  Revision Load (0.5ms)  SELECT `revisions`.`id`, `revisions`.`user_id`, `revisions`.`page_id`, `revisions`.`version`, `revisions`.`asset_file_name`, `revisions`.`asset_file_size`, `revisions`.`asset_file_type`, `revisions`.`asset_updated_at`, `revisions`.`created_at`, `revisions`.`updated_at`, `revisions`.`comments_count`, `revisions`.`agency_id`, `revisions`.`asset_stored`, `revisions`.`panda_id`, `revisions`.`type` FROM `revisions` WHERE (`revisions`.page_id = 1) ORDER BY revisions.version DESC LIMIT 1
Rendered dashboard/partials/_project.html.haml (61.6ms)
Rendered dashboard/partials/_client.html.haml (74.9ms)
  SQL (0.9ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
Rendered dashboard/show.html.haml within layouts/application (21656.9ms)
Completed   in 21781ms

ActionView::Template::Error (undefined local variable or method `throw_error' for #<#<Class:0x106635770>:0x1066334e8>):
    12:   .title_bar
    13:     %h4 Recent Activity
    14:   .stream
    15:     = throw_error
    16:     - cache [current_agency, current_user, 'feeds'] do
    17:       - feed_list = Feed.list
    18:       - feed_list[:items].each do |item, feed|
  app/views/dashboard/show.html.haml:15:in `_app_views_dashboard_show_html_haml__665120934_2201062920_0'
  app/controllers/dashboard_controller.rb:6:in `show'

Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-21957b72ea394c679d9b17e75b570cc99596322d/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.4ms)
  SQL (1.1ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (1.0ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (0.7ms)  SHOW TABLES
  SQL (0.9ms)  SHOW TABLES
  SQL (0.8ms)  SHOW TABLES
Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-21957b72ea394c679d9b17e75b570cc99596322d/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (17415.2ms)
Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-21957b72ea394c679d9b17e75b570cc99596322d/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (17738.5ms)

This has happened for the following exceptions and more:

  • NoMethodError
  • ActiveRecord::RecordNotFound
  • ActionView::Template::Error

Although there are a few exceptions that fail and render immediately, like ActionController::UnknownAction. Attached is the stack trace.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper July 1st, 2010 @ 05:47 PM

    • State changed from “new” to “open”
    • Milestone cleared.
    • Importance changed from “” to “High”
  • Neeraj Singh

    Neeraj Singh July 1st, 2010 @ 06:27 PM

    • Tag changed from activerecord rails3, exception to activerecord rails3, exception, rails3

    I created a brand new rails app and added a single line at the top of index page.

    <% raise 'boom' %>
    

    I see my exception instantly. Here is my log

    Started GET "/users" for 127.0.0.1 at Thu Jul 01 13:23:24 -0400 2010
      Processing by UsersController#index as HTML
      SQL (0.8ms)   SELECT name
     FROM sqlite_master
     WHERE type = 'table' AND NOT name = 'sqlite_sequence'
    
      User Load (0.2ms)  SELECT "users".* FROM "users"
    Rendered users/index.html.erb within layouts/application (4.0ms)
    Completed   in 38ms
    
    ActionView::Template::Error (boom):
        1: <% raise 'boom' %>
        2: 
        3: <h1>Listing users</h1>
        4: 
      app/views/users/index.html.erb:1:in `_app_views_users_index_html_erb___518242468_2158308900_0'
      app/controllers/users_controller.rb:7:in `index'
    
    Rendered /Users/nsingh/dev/working/rails_tickets/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
    Rendered /Users/nsingh/dev/working/rails_tickets/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (3.9ms)
    Rendered /Users/nsingh/dev/working/rails_tickets/rails/actionpack/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (9.6ms)
    

    You are using haml. Can you try without haml although I don't expect haml to be an issue?

    Could it be possible that some other plugin/gem is interfering. Could you please list all gems/plugins you are using in your app?

    thanks

  • Garrett Bjerkhoel

    Garrett Bjerkhoel July 1st, 2010 @ 06:45 PM

    These errors are happening even before I hit the views sometimes; Builder/xml, within controllers, etc.

    I thought maybe the Hoptoad Gem might have something to do with this because that's its job to report errors, so I took that out and it still takes increasingly long to render any sort of exception.

    Started POST "/api/v1/agencies.xml" for 127.0.0.1 at Thu Jul 01 13:34:38 -0400 2010
      SQL (1.6ms)  describe `approvals_users`
      SQL (1.8ms)  describe `clients_users`
      SQL (1.5ms)  describe `agencies_users`
      SQL (1.3ms)  describe `clients_users`
      SQL (1.2ms)  describe `approvals_users`
      SQL (2.3ms)  describe `permissions_users`
      Processing by Api::V1::AgenciesController#create as XML
      Parameters: {"api_key"=>"123132"}
      SQL (1.5ms)  describe `agencies_users`
      Agency Load (1.9ms)  SELECT `agencies`.* FROM `agencies` WHERE (`agencies`.`api_key` = '123132') LIMIT 1
    Completed   in 37ms
    
    ActiveRecord::RecordNotFound (Couldn't find Agency with api_key = 123132):
      app/models/agency.rb:58:in `find_by_domain'
      app/controllers/api_controller.rb:32:in `current_agency'
      app/controllers/api_controller.rb:94:in `run_api_validations'
    
    Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.5ms)
    Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (18154.3ms)
    Rendered /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (18542.1ms)
    

    Stacktrace:

    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/relation/finder_methods.rb:230:in `find_by_attributes'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/base.rb:1036:in `send'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/base.rb:1036:in `method_missing'
    app/models/agency.rb:58:in `find_by_domain'
    app/controllers/api_controller.rb:32:in `current_agency'
    app/controllers/api_controller.rb:94:in `run_api_validations'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:430:in `_run__353673824__process_action__1623385099__callbacks'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:404:in `send'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:404:in `_run_process_action_callbacks'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:93:in `send'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:93:in `run_callbacks'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/abstract_controller/callbacks.rb:17:in `process_action'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/notifications.rb:47:in `__send__'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/notifications.rb:47:in `instrument'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal/instrumentation.rb:28:in `process_action'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal/rescue.rb:8:in `process_action'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/abstract_controller/base.rb:105:in `process'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/abstract_controller/rendering.rb:40:in `process'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal.rb:133:in `dispatch'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_controller/metal.rb:173:in `action'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/routing/route_set.rb:29:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/routing/route_set.rb:29:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/route_set.rb:148:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/code_generation.rb:89:in `recognize'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/code_generation.rb:66:in `optimized_each'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/code_generation.rb:88:in `recognize'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/vendor/rack-mount-0.6.6.pre/rack/mount/route_set.rb:139:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/routing/route_set.rb:486:in `call'
    vendor/plugins/rack_openid/lib/rack/openid.rb:98:in `call'
    hoptoad_notifier (2.3.0) lib/hoptoad_notifier/rack.rb:27:in `call'
    haml (3.0.13) lib/sass/plugin/rack.rb:41:in `call'
    warden (0.10.7) lib/warden/manager.rb:35:in `call'
    warden (0.10.7) lib/warden/manager.rb:34:in `catch'
    warden (0.10.7) lib/warden/manager.rb:34:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/head.rb:14:in `call'
    rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/flash.rb:177:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb:144:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/cookies.rb:268:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/query_cache.rb:32:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/query_cache.rb:12:in `cache'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/query_cache.rb:31:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:367:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/callbacks.rb:46:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/activesupport/lib/active_support/callbacks.rb:410:in `_run_call_callbacks'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
    rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:48:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/railties/lib/rails/rack/logger.rb:13:in `call'
    rack (1.2.1) lib/rack/runtime.rb:17:in `call'
    rack (1.2.1) lib/rack/lock.rb:11:in `call'
    rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
    rack (1.2.1) lib/rack/lock.rb:11:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/actionpack/lib/action_dispatch/middleware/static.rb:30:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/railties/lib/rails/application.rb:162:in `call'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/railties/lib/rails/application.rb:77:in `send'
    /Users/garrett/.bundle/ruby/1.8/bundler/gems/rails-07b08721a226ff01f983e61d99ab4da96e296c97-53b34e84762b7f2d6b641f99dadbb1eab42907ab/railties/lib/rails/application.rb:77:in `method_missing'
    passenger (2.2.11) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    passenger (2.2.11) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    passenger (2.2.11) lib/phusion_passenger/rack/application_spawner.rb:118:in `run'
    passenger (2.2.11) lib/phusion_passenger/rack/application_spawner.rb:65:in `spawn_application'
    passenger (2.2.11) lib/phusion_passenger/utils.rb:184:in `safe_fork'
    passenger (2.2.11) lib/phusion_passenger/rack/application_spawner.rb:58:in `spawn_application'
    passenger (2.2.11) lib/phusion_passenger/rack/application_spawner.rb:41:in `spawn_application'
    passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:159:in `spawn_application'
    passenger (2.2.11) lib/phusion_passenger/spawn_manager.rb:287:in `handle_spawn_application'
    passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.11) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    passenger (2.2.11) bin/passenger-spawn-server:61
    

    Here is my Gemfile:

    source 'http://gemcutter.org'
    
    # Core
    # gem 'rails', '3.0.0.beta4'
    gem 'rails', :git => 'http://github.com/rails/rails.git'
    gem 'sinatra'
    gem 'mysql'
    gem 'bundler'
    gem 'memcache-client'
    gem 'system_timer'
    gem 'mime-types', :require => 'mime/types'
    gem 'json'
    gem 'haml', '~> 3.0.12'
    gem 'bcrypt-ruby', :require => 'bcrypt'
    
    # Users
    gem 'warden'
    gem 'ruby-openid', :require => 'openid'
    gem 'canable'
    gem 'devise', '1.1.rc2'
    
    # Paperclip
    gem 'aws-s3', :require => 'aws/s3'
    gem 'paperclip', :git => 'git://github.com/dewski/paperclip.git', :branch => 'rails3'
    gem 'delayed_job', :git => 'git://github.com/dewski/delayed_job.git'
    
    group :development do
      gem 'termios'
      gem 'faker'
    end
    
    group :test do
      gem 'webrat'
      gem 'hpricot'
      gem 'mocha', :require => false
    end
    
  • Jeremy Kemper
  • gnufied

    gnufied September 22nd, 2010 @ 04:02 PM

    Can you attach a minimum reproducible case, which we can run and reproduce the problem? For freshly minted Rails3 application, I can't reproduce your problem.

  • David Trasbo

    David Trasbo September 23rd, 2010 @ 08:44 AM

    • State changed from “open” to “needs-more-info”

    We need a way of re-producing this from a fresh Rails 3 app.

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
  • Ryan Bigg

    Ryan Bigg October 16th, 2010 @ 02:42 AM

    • Tag cleared.

    Automatic cleanup of spam.

  • Evgeniy Dolzhenko

    Evgeniy Dolzhenko November 8th, 2010 @ 03:16 PM

    The problem is actually pretty subtle and manifests whenever you have some object with huge inspect output in your request.env.

    For example I have an app with a lot of routes and Devise installed. Devise adds Warden middleware which is always present in request.env and which holds references to ActionDispatch::Routing::RouteSet. The inspect output of ActionDispatch::Routing::RouteSet is huge when you have many routes (I get about ~3Mb diagnostics.erb output on that project).

    One solution would be just to truncate output for every key in the debug_hash method of _request_and_response.erb partial.

  • Santiago Pastorino
  • Nicolas Blanco

    Nicolas Blanco January 3rd, 2011 @ 02:48 PM

    I confirm this problem and Evgeniy Dolzhenko explanation.

    On my application, the template (_request_and_response.erb) takes 10 seconds to render. By disabling the debug_hash method, the rendering time goes down to less than 1 sec!

    I confirm that request.env is very big and I agree with truncating its values.

    It's not possible to inject megabytes of data in a single page as it even freezes the browser sometimes.

    Do you see another clean solution than truncating?

  • Nicolas Blanco

    Nicolas Blanco January 3rd, 2011 @ 03:52 PM

    Some more investigation on my request.env object, here are the biggest keys :

    warden: 2009703 bytes
    action_controller.instance: 5985405 bytes
    action_dispatch.remote_ip: 1999023 bytes

    If this normal?

  • Santiago Pastorino
  • Santiago Pastorino

    Santiago Pastorino February 27th, 2011 @ 03:15 AM

    • Milestone changed from 3.0.5 to 3.0.6
  • jay

    jay March 7th, 2011 @ 11:07 PM

    Attached is a patch that adds configurable options for both session and environment dumping on ActionDispatch error pages. These options have been added to the ActionDispatch Railtie and are called dump_session_on_error and dump_environment_on_error respectively. By default I've set the options to dump sessions but not the environment on error, since the session dump generally seems to be small while the environment dump can become huge as you add things like routes and plugins and extensions that like to add instance variables to the controller and such.

    I rarely ever find myself looking at the environment dump, so I'm not really going to miss it if it's gone by default, but it's nice being able to turn it back on again for the once-in-a-blue-moon that I would ever need to use it.

    This might not be as pretty of a solution as truncating the values in the environment hash and such, but it's a quick fix for something that I doubt too many people really pay attention to anyways. I haven't included any tests in the patch as I'm not sure how to go about testing configuration options and templates like this, but I can add them if necessary and if anyone has any hints.

  • jay

    jay March 8th, 2011 @ 08:06 PM

    I just realized that the patch above was against 3-0-stable, so here's a patch against master, too.

  • Andy

    Andy March 12th, 2011 @ 07:14 AM

    I'm seeing what I think is the same problem as the original poster. I find that some exceptions end up making a bunch of slow SHOW TABLES queries when they are being stringified. I have an almost vanilla rail 3.0.5 app that can reproduce the problem here: https://github.com/ajh/show_tables

    See the README for how to repro it.

    I've also found people talking about what seems to be the same issue here: http://stackoverflow.com/questions/3114993/exception-pages-in-devel...

  • Andy

    Andy March 12th, 2011 @ 05:24 PM

    The key part of the backtraces that I'm seeing is this (see https://github.com/ajh/show_tables/blob/master/README for a full backtrace):

    /home/ajh/.rvm/gems/ruby-1.8.7-p302@rails3/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:432:in `tables'
    /home/ajh/.rvm/gems/ruby-1.8.7-p302@rails3/gems/activerecord-3.0.5/lib/active_record/connection_adapters/abstract/schema_statements.rb:21:in `table_exists?'
    /home/ajh/.rvm/gems/ruby-1.8.7-p302@rails3/gems/activerecord-3.0.5/lib/active_record/base.rb:673:in `table_exists?'
    /home/ajh/.rvm/gems/ruby-1.8.7-p302@rails3/gems/activerecord-3.0.5/lib/active_record/base.rb:795:in `inspect' 
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `to_str'
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `to_s'                     
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `inspect'
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `to_str'                   
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `to_s'
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36:in `message'
    

    A raised exception's #message method is called, and as that's being evaluated somehow an ActiveRecord::Base class's inspect method gets fired.

    I've followed this code path in a debugger and I don't see the call to the ActiveRecord::Base.inspect method, the debugger just ends up inside that method. After setting a break point at the bottom line in the above backtrace, I can examine the exception like so:

    Breakpoint 2 at /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36
    /home/ajh/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/test/unit/error.rb:36
    "#{@exception.class.name}: #{@exception.message}"
    (rdb:1) irb
    ruby-1.8.7-p302 :001 > @exception.class
       => NoMethodError
    ruby-1.8.7-p302 :005 >   @exception.class.included_modules
       => [ActiveSupport::Dependencies::Blamable, Base64::Deprecated, Base64, ActiveSupport::Dependencies::Loadable, PP::ObjectMixin, Kernel]
    

    I've skimmed through the included modules and haven't seen anything that might call ActiveRecord::Base.inspect.

  • Andy

    Andy March 12th, 2011 @ 05:34 PM

    By the way, about the patches above and Evgeniy Dolzhenko's explanation. I don't doubt that fixes a real issue, but I don't think it explains Garrett's original problem where he is seeing a bunch of 'SHOW TABLES' queries being run.

  • Jonathan Monahan

    Jonathan Monahan March 14th, 2011 @ 04:00 PM

    FWIW, we had a similar problem on Rails 2.2.x and fixed it by monkey patching ActiveRecord::Base.inspect:

    module ActiveRecord
      class Base
        def self.inspect
          if self == Base
            super
          elsif abstract_class?
            "#{super}(abstract)" 
          else
            begin
              attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
              "#{super}(#{attr_list})" 
            rescue Exception => e
              # Any exception is likely to be caused by the table not existing!
              "#{super}(Table doesn't exist)"
            end
          end
        end
      end
    end
    

    The original code relied on table_exists? which causes a SHOW TABLES query without any caching. I decided that if you call table_exists? then you probably wanted to explicitly check if the table exists, but for inspect it would be OK to just rely on columns failing.

    I don't know if this is helpful on Rails 3 or not - we're not there yet.

    Cheers,

    Jonathan.
    
  • Jamie Wilkinson

    Jamie Wilkinson April 7th, 2011 @ 01:37 AM

    Bump, this is still a huge & pervasive issue -- you can balloon error pages to 2.5MB just by adding omniauth to a vanilla Rails app. There's a healthy discussion here, including some .inspect monkeypatches:

    http://stackoverflow.com/questions/3114993/exception-pages-in-devel...

  • Raphael Sofaer

    Raphael Sofaer April 7th, 2011 @ 06:36 PM

    Any one of the @response, @request, and @_env instance variables in a controller object have inspects that are so enormous that they are useless. The problem is really that inspecting the env hash inspects the controller, which has the env hash as an instance variable, and has other instance variables which have the env hash as an instance variable.

  • Adam Bair

    Adam Bair April 28th, 2011 @ 04:28 AM

    Bump +1 - ran into this today using Rails v3.0.6 and pow. Ended up using the "SmallInspect" mixin from the stackoverflow post above after spending waay to much time on it. This reduces the time from 45 seconds on exception to around 5 though it does NOT solve the tons of SHOW_TABLE messages flying by in the logfile.

  • Adam Bair

    Adam Bair April 28th, 2011 @ 03:37 PM

    For the SHOW_TABLES issue one thing you might want to check is to see if you have any route constraints. We noticed that we, Ping - a coworker and myself, could stop the tables from showing up by overriding the inspect method on the model on the constraint. In our case it was the Account model. We did something like this:

    def self.inspect

    ['id','name', 'domain', 'subdomain'].each { |c| "#{c.name}: #{c.type}" } * ', '
    

    end

    I know that this place is defunct but I wanted to add this here just in case it could help someone.

  • Adam Bair

    Adam Bair April 28th, 2011 @ 03:38 PM

    def self.inspect

      ['id','name', 'domain', 'subdomain'].each { |c| "#{c.name}: #{c.type}" } * ', '
    end
    

    Is what I meant to say.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages