Skip to content

Fanout.rb thread variable is sometimes nil #21873

@frobichaud

Description

@frobichaud

Hi,
we're seeing many occurrences of
"NoMethodError undefined method `pop' for nil:NilClass" on fanout.rb. We don't have reproducible steps, we're running in a multithreaded production environment. The Thread[:_timestack] variable is nil.

See below for the stacktrace.

NoMethodError undefined method `pop' for nil:NilClass
gems/activesupport-4.2.2/lib/active_support/notifications/fanout.rb:126 finish
          def finish(name, id, payload)
            timestack = Thread.current[:_timestack]
            started = timestack.pop
            @delegate.call(name, started, Time.now, id, payload)
          end
        end
gems/activesupport-4.2.2/lib/active_support/notifications/fanout.rb:46block in finish
gems/activesupport-4.2.2/lib/active_support/notifications/fanout.rb:46each
gems/activesupport-4.2.2/lib/active_support/notifications/fanout.rb:46finish
gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:36finish
gems/activesupport-4.2.2/lib/active_support/notifications/instrumenter.rb:25instrument
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:467log
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:299execute
gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:231execute
gems/activerecord-4.2.2/lib/active_record/connection_adapters/mysql2_adapter.rb:235exec_query
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:347select
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:32select_all
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:68block in select_all
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:83cache_sql
gems/activerecord-4.2.2/lib/active_record/connection_adapters/abstract/query_cache.rb:68select_all
gems/activerecord-4.2.2/lib/active_record/relation/calculations.rb:264execute_simple_calculation
gems/activerecord-4.2.2/lib/active_record/relation/calculations.rb:221perform_calculation
gems/activerecord-4.2.2/lib/active_record/relation/calculations.rb:127calculate
gems/activerecord-4.2.2/lib/active_record/relation/calculations.rb:125calculate
gems/activerecord-4.2.2/lib/active_record/relation/calculations.rb:42count
gems/will_paginate-3.0.7/lib/will_paginate/active_record.rb:97count
gems/will_paginate-3.0.7/lib/will_paginate/active_record.rb:95count
gems/will_paginate-3.0.7/lib/will_paginate/active_record.rb:113empty?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions