Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Sidekiq using same job id for different jobs

$
0
0

Brief description:

For this Ruby on Rails application, I'm using sidekiq 5.2 + redis 4.1.4 for job scheduling. However, for some reason, jobs that should be different get all scheduled with the same job_id and job_provider_id.

Deatails

I have an ApplicationRecord class called Calendar with a method that gets called after an entity of type "Calendar" has been created. The method schedules the execution of a job, using the id of the calendar as a parameter.

class Calendar < ApplicationRecord    after_create :program_job    def program_job        job = ActivateCalendarJob.set(          wait_until: self.start_date,        ).perform_later(self.id)        self.update(          status: 'queued',          job_id: job.job_id,          job_provider_id: job.provider_job_id        )    endend

As you can see in the code above, I'm saving the job_id and job_provider_id in the calendar entity. The problem here is that if multiple calendars are created, only one job gets scheduled in sidekiq, and when reviewing each calendar entity they all have the same job_id and job_provider_id value saved in the Database. This shouldn't happen, however, as they all schedule a job with different params (a different calendar ID), and they all are created at different dates.

Any knowledge as to why this happens is greatly appreciated.

Both the development.rb and production.rb files have sidekiq as queue adapter:

Rails.application.configure do    config.active_job.queue_adapter = :sidekiqend

Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>