Shopify / identity_cache

IdentityCache is a blob level caching solution to plug into Active Record. Don't #find, #fetch!
http://shopify.github.io/identity_cache
MIT License
1.92k stars 173 forks source link

IdentityCache in combination with module causes "undefined method `all'" #298

Open edwardmp opened 7 years ago

edwardmp commented 7 years ago

Hi,

Thanks for developing this, it's neat (when it works ;)).

Recently I encountered a rather peculiar bug that I eventually traced down to IdentityCache. At one point my code looked like this:

class Card < Identifiable
  cache_index :card, unique: :true

  belongs_to :employee, inverse_of: :cards
  cache_belongs_to :employee
  validates_associated :employee
  validates :employee, presence: true
end

class PlateOwner < ApplicationRecord
  self.abstract_class = true
  include IdentityCache
  acts_as_paranoid
end

class Numberplate < Identifiable
  cache_index :plate, unique: :true

  belongs_to :plate_owner, -> { with_deleted }, polymorphic: true, inverse_of: :numberplates
  cache_belongs_to :plate_owner
  validates_associated :plate_owner
  validates :plate_owner, presence: true
end

I then refactored it to use concerns rather than using inheritance for identifiable. After the refactor, my code looked like this:

class Card < ApplicationRecord
  include Identifiable
  cache_index :card, unique: :true

  belongs_to :employee, inverse_of: :cards
  cache_belongs_to :employee
  validates_associated :employee
  validates :employee, presence: true
end

module Identifiable
  extend ActiveSupport::Concern

  included do
    include IdentityCache
    acts_as_paranoid

    has_many :events, as: :identifiable, inverse_of: :identifiable
    cache_has_many :events, embed: true
  end

  module ClassMethods
  end
end

class Numberplate < ApplicationRecord
  include Identifiable

  cache_index :plate, unique: :true

  belongs_to :plate_owner, -> { with_deleted }, polymorphic: true, inverse_of: :numberplates
  cache_belongs_to :plate_owner
  validates_associated :plate_owner
  validates :plate_owner, presence: true
end

Then things went south. I started to get very weird errors like undefined methodall' for Identifiable:Module` when saving a new Card for instance. Here's a stack trace:

app/controllers/cards_controller.rb:34:in `block in create'
app/controllers/cards_controller.rb:33:in `create'
app/controllers/application_controller.rb:22:in `block in identity_cache_memoization'
app/controllers/application_controller.rb:22:in `identity_cache_memoization'

It took quite some time to pinpoint the issue being caused by IdentityCache in combination with the new module. I'm not sure what's actually causing it, but no longer including identity cache in my code solves the problem for me.

samratjp commented 7 years ago

@edwardmp did you ever end up giving this another shot by chance? What version were you using?

I just experienced a similar issue with v0.3.2 (Ruby 2.2.0 + Rails 4.2.7.1) with memoization + a lookup method from a concern.

The input for the method that triggered this trace was 'd60f9b'. Fwiw, I've had this code running in prod for months now and was surprised to see it break today and tracing through my logs found the exception trace attached below.

I'm not even sure if this an issue anymore - so if any of the contributors seeing this know anything about this, please chime in / happy to help test. Unfortunately, I don't have any repro steps on this.

I'm gonna go ahead and upgrade to the latest version and add an exception handler for now with exception notifications to monitor.

I just wanted to report this issue here for posterity if anyone else would find it useful to debug or share any insights.

The concern/module where it broke:

module FriendlyFetch
  extend ActiveSupport::Concern

  included do
    cache_index :slug, unique: true
  end

  module ClassMethods
    def friendly_fetch(lookup)
      found_item = fetch_by_slug(lookup) if lookup.to_s.match(/\D/) # It's a slug
      return found_item if found_item.present?
      found_item = find(lookup)
      # else It's an id or past used slug
      lookup_param = found_item.present? ? found_item.try(:id) : lookup
      found_item = fetch(lookup_param)
    end
  end
end

The exception trace

vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/query_api.rb:129:in `record_from_coder': undefined method `[]' for true:TrueClass (NoMethodError)
    from vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/query_api.rb:28:in `block in fetch_by_id'
    from vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/query_api.rb:210:in `require_if_necessary'
    from vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/query_api.rb:25:in `fetch_by_id'
    from vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/configuration_dsl.rb:55:in `fetch_by_slug'
    from app/concerns/friendly_fetch.rb:10:in `friendly_fetch'
    from app/controllers/makes_controller.rb:90:in `find_make'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:145:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:145:in `block in halting_and_conditional'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `block in call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `each'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:504:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:298:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:298:in `block in halting_and_conditional'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `block in around'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:498:in `block (2 levels) in around'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:313:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:313:in `block (2 levels) in halting'
    from app/controllers/application_controller.rb:30:in `block in identity_cache_memoization'
    from vendor/bundle/ruby/2.2.0/gems/identity_cache-0.3.2/lib/identity_cache/memoized_cache_proxy.rb:26:in `with_memoization'
    from app/controllers/application_controller.rb:30:in `identity_cache_memoization'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:312:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:312:in `block in halting'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:497:in `block in around'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:505:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/abstract_controller/callbacks.rb:19:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/rescue.rb:29:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `block in instrument'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:164:in `instrument'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/scout_apm-2.1.13/lib/scout_apm/instruments/action_controller_rails_3_rails4.rb:79:in `process_action'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/abstract_controller/base.rb:137:in `process'
    from vendor/bundle/ruby/2.2.0/gems/actionview-4.2.7.1/lib/action_view/rendering.rb:30:in `process'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb:196:in `dispatch'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_controller/metal.rb:237:in `block in action'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:74:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:43:in `serve'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:43:in `block in serve'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:30:in `each'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/journey/router.rb:30:in `serve'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/routing/route_set.rb:817:in `call'
    from vendor/bundle/ruby/2.2.0/gems/scout_apm-2.1.13/lib/scout_apm/instruments/rails_router.rb:23:in `call_with_scout_instruments'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/apipie-rails-0.3.7/lib/apipie/static_dispatcher.rb:65:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/scout_apm-2.1.13/lib/scout_apm/middleware.rb:15:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:186:in `call!'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/strategy.rb:164:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/omniauth-1.2.2/lib/omniauth/builder.rb:59:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/rack/agent_hooks.rb:30:in `traced_call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/rack/browser_monitoring.rb:32:in `traced_call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/apipie-rails-0.3.7/lib/apipie/extractor/recorder.rb:132:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:35:in `block in call'
    from vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `catch'
    from vendor/bundle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/manager.rb:34:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/etag.rb:24:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/conditionalget.rb:25:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/flash.rb:260:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/cookies.rb:560:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/bundler/gems/fastly-rails-306dfc8944e9/lib/fastly-rails/rack/remove_set_cookie_header.rb:9:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from config/initializers/set_cache_control_private.rb:8:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/query_cache.rb:36:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.7.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:88:in `__run_callbacks__'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/rack/logger.rb:38:in `call_app'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/rack/logger.rb:20:in `block in call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb:68:in `block in tagged'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb:26:in `tagged'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/tagged_logging.rb:68:in `tagged'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/rack/logger.rb:20:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/request_store-1.3.1/lib/request_store/middleware.rb:9:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/request_id.rb:21:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/methodoverride.rb:22:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/runtime.rb:18:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.7.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/static.rb:120:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/skip_binary.rb:19:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/deflater.rb:35:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/heroku-deflater-0.5.3/lib/heroku-deflater/serve_zipped_assets.rb:50:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/rack-1.6.4/lib/rack/sendfile.rb:113:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/ssl.rb:24:in `call'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/scout_apm-2.1.13/lib/scout_apm/instruments/middleware_summary.rb:52:in `call'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/engine.rb:518:in `call'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/application.rb:165:in `call'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `public_send'
    from vendor/bundle/ruby/2.2.0/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `method_missing'
    from vendor/bundle/ruby/2.2.0/gems/newrelic_rpm-3.17.0.325/lib/new_relic/agent/instrumentation/middleware_tracing.rb:96:in `call'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/configuration.rb:78:in `call'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/server.rb:541:in `handle_request'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/server.rb:388:in `process_client'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/server.rb:270:in `block in run'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/thread_pool.rb:106:in `call'
    from vendor/bundle/ruby/2.2.0/gems/puma-2.14.0/lib/puma/thread_pool.rb:106:in `block in spawn_thread'
edwardmp commented 7 years ago

@samratjp No eventually I stopped using IdentityCache. Not necessarily because of this issue, but because I found this way of caching to unelegant/introducing technical debt.

According to my Gemfile.lock I would have been using IdentityCache 0.3.2 at the time, but I used it with Rails 5.0.0.1 and Ruby 2.3.0