Skip to content

NoMethodError: undefined method 'heartbeat' for nil in Solid Queue heartbeat process #693

@ohbarye

Description

@ohbarye

Summary

A NoMethodError occurs when the heartbeat method is called on a nil object in Solid Queue's heartbeat process.

Environment

  • Ruby: 3.4.7
  • Rails: 8.1.1
  • Solid Queue: 1.2.4
  • Execution Environment: AWS ECS Fargate (ARM64, Linux)

Solid Queue Configuration

config/queue.yml:

default: &default
  dispatchers:
    - polling_interval: 1
      batch_size: 500
  workers:
    - queues: "*"
      threads: 3
      processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %>
      polling_interval: 0.1

Error Details

Stack Trace

NoMethodError: undefined method 'heartbeat' for nil (NoMethodError)

        process.heartbeat
               ^^^^^^^^^^
    from solid_queue/processes/registrable.rb:57:in 'heartbeat'
    from solid_queue/processes/registrable.rb:42:in 'block (2 levels) in SolidQueue::Processes::Registrable#launch_heartbeat'
    from active_support/execution_wrapper.rb:91:in 'ActiveSupport::ExecutionWrapper.wrap'
    from solid_queue/app_executor.rb:7:in 'wrap_in_app_executor'
    from solid_queue/processes/registrable.rb:42:in 'block in SolidQueue::Processes::Registrable#launch_heartbeat'
    from concurrent/executor/safe_task_executor.rb:24:in 'block in Concurrent::SafeTaskExecutor#execute'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'block in Concurrent::Synchronization::MutexLockableObject#synchronize'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'synchronize'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'synchronize'
    from concurrent/executor/safe_task_executor.rb:22:in 'execute'
    from concurrent/timer_task.rb:339:in 'execute_task'
    from concurrent/executor/safe_task_executor.rb:24:in 'block in Concurrent::SafeTaskExecutor#execute'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'block in Concurrent::Synchronization::MutexLockableObject#synchronize'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'synchronize'
    from concurrent/synchronization/mutex_lockable_object.rb:48:in 'synchronize'
    from concurrent/executor/safe_task_executor.rb:22:in 'execute'
    from concurrent/ivar.rb:170:in 'safe_execute'
    from concurrent/scheduled_task.rb:298:in 'process_task'
    from concurrent/executor/timer_set.rb:166:in 'block (2 levels) in Concurrent::TimerSet#process_tasks'
    from new_relic/agent/tracer.rb:434:in 'block (2 levels) in NewRelic::Agent::Tracer.thread_block_with_current_transaction'
    from new_relic/agent/tracer.rb:357:in 'NewRelic::Agent::Tracer.capture_segment_error'
    from new_relic/agent/tracer.rb:433:in 'block in NewRelic::Agent::Tracer.thread_block_with_current_transaction'
    from concurrent/executor/ruby_thread_pool_executor.rb:359:in 'run_task'
    from concurrent/executor/ruby_thread_pool_executor.rb:350:in 'block (3 levels) in Concurrent::RubyThreadPoolExecutor::Worker#create_worker'
    from <internal:kernel>:168:in 'loop'
    from concurrent/executor/ruby_thread_pool_executor.rb:341:in 'block (2 levels) in Concurrent::RubyThreadPoolExecutor::Worker#create_worker'
    from concurrent/executor/ruby_thread_pool_executor.rb:340:in 'catch'
    from concurrent/executor/ruby_thread_pool_executor.rb:340:in 'block in Concurrent::RubyThreadPoolExecutor::Worker#create_worker'
    from new_relic/agent/tracer.rb:434:in 'block (2 levels) in NewRelic::Agent::Tracer.thread_block_with_current_transaction'
    from new_relic/agent/tracer.rb:357:in 'NewRelic::Agent::Tracer.capture_segment_error'
    from new_relic/agent/tracer.rb:433:in 'block in NewRelic::Agent::Tracer.thread_block_with_current_transaction'

Expected Behavior

The heartbeat method should be called successfully, updating the process heartbeat.

Actual Behavior

The heartbeat method is called on a nil process object, causing a NoMethodError.

Steps to Reproduce

We have not been able to identify specific reproduction conditions. The error may occur hours (or days) after the process starts, or it may not occur at all. There is no consistent reproduction path.

Workaround

Restarting the process temporarily resolves the issue. However, this does not address the root cause.

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