bensheldon / good_job

Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.
https://goodjob-demo.herokuapp.com/
MIT License
2.53k stars 190 forks source link

`#good_job_labels` retains values across job instances #1354

Closed mhgoldman closed 1 month ago

mhgoldman commented 1 month ago

Given the following job:

class TestJob < ApplicationJob
  include GoodJob::ActiveJobExtensions::Labels

  before_enqueue { |job| job.good_job_labels << Time.now.to_s }

  def perform
    puts "#{good_job_labels}"
  end
end

Each job I enqueue contains the labels of the job before:

TestJob.perform_later # => ["2024-05-22 01:42:36 +0000"]
TestJob.perform_later # => ["2024-05-22 01:42:36 +0000", "2024-05-22 01:42:40 +0000"]
TestJob.perform_later # => ["2024-05-22 01:42:36 +0000", "2024-05-22 01:42:40 +0000", "2024-05-22 01:42:41 +0000"]
bensheldon commented 1 month ago

ooh, thanks for the report. I think there needs to be a dup in here:

https://github.com/bensheldon/good_job/blob/e632cf3f60adb5b59d0b6338d4b109387b9bc0d5/lib/good_job/active_job_extensions/labels.rb#L11-L11

Let me try to make a quick repro test and fix.

bensheldon commented 1 month ago

Just released the fix for this: https://github.com/bensheldon/good_job/releases/tag/v3.29.2

mhgoldman commented 1 month ago

Fantastic. Many thanks for all your efforts!!