lib/rocket_job/plugins/singleton.rb in rocketjob-5.0.0.beta4 vs lib/rocket_job/plugins/singleton.rb in rocketjob-5.0.0.rc1

- old
+ new

@@ -10,10 +10,12 @@ validate :rocket_job_singleton_check end # Returns [true|false] whether another instance of this job is already active def rocket_job_singleton_active? - self.class.where(:state.in => %i[running queued], :id.ne => id).exists? + self.class.with(read: {mode: :primary}) do |conn| + conn.where(:state.in => %i[running queued], :id.ne => id).exists? + end end private # Validation prevents a new job from being saved while one is already running