Philipe
Philipe

Reputation: 21

Ruby on Rails Sidekiq Worker doesn't complete process, but no error is shown - Processing 30,000+ records in batches

I’m facing an issue with a Sidekiq worker that processes a large number of records in batches, but it’s not completing the process correctly. The worker starts executing, but never reaches the "finished" log, and although there is no explicit error, the process doesn’t complete as expected.

Here’s a summary of what’s happening:

Code:

 # frozen_string_literal: true

 module HeroIntake
  class ReproveWorker
    include Sidekiq::Worker

    sidekiq_options queue: 'low', retry: 1

    def perform
      Rails.logger.info "HeroIntake::ReproveWorker started for: #{HeroProfile.analyze.count} at: #{Time.current}"

      HeroProfile.analyze.where(analyzed_at: nil).find_each(batch_size: 10) do |hero_profile|
        begin
          Rails.logger.info "HeroIntake::ReproveWorker Processing hero profile with ID: #{hero_profile.inspect}"
          Hero::Profile::Reprove.call(hero_profile)
          hero_profile.update_column(:analyzed_at, Time.current)
        rescue StandardError => e
          Honeybadger.notify(error_class: e, error_message: 'HeroIntake::ReproveWorker Error while processing hero rejection')
          Rails.logger.error "HeroIntake::ReproveWorker Error processing hero profile: #{e.message}  ||  #{hero_profile.inspect}"
        end
      end

      Rails.logger.info "HeroIntake::ReproveWorker finished at: #{Time.current}"
    rescue StandardError => e
      Honeybadger.notify(error_class: e, error_message: 'HeroIntake::ReproveWorker Error while processing the worker')
      Rails.logger.error "HeroIntake::ReproveWorker Error: #{e.message}"
    end
  end
end

Observed Behavior:

What I’ve Tried:

Questions:

Ruby version: 2.3.8
Rails: gem 'rails', '4.2.11'
Environment: Production
sidekiq gem:

Upvotes: 0

Views: 109

Answers (0)

Related Questions