good_job 4.24.0 → 4.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,11 @@ module GoodJob
13
13
  end
14
14
 
15
15
  def batch
16
- @_batch ||= CurrentThread.job&.batch&.to_batch if CurrentThread.job.present? && CurrentThread.job.active_job_id == job_id
16
+ current_job = CurrentThread.job
17
+ return @_batch unless current_job && current_job.active_job_id == job_id
18
+
19
+ @_batch = nil if @_batch&.id != current_job.batch_id
20
+ @_batch ||= current_job.reload_batch&.to_batch
17
21
  end
18
22
  alias batch? batch
19
23
  end
@@ -7,8 +7,9 @@ module GoodJob
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  included do
10
- around_perform do |_job, block|
11
- raise InterruptError, "Interrupted after starting perform at '#{CurrentThread.execution_interrupted}'" if CurrentThread.execution_interrupted.present?
10
+ around_perform do |job, block|
11
+ interrupted_at = CurrentThread.execution_interrupted
12
+ raise InterruptError, "Interrupted after starting perform at '#{interrupted_at}'" if interrupted_at.present? && CurrentThread.active_job_id == job.job_id
12
13
 
13
14
  block.call
14
15
  end
data/lib/good_job/bulk.rb CHANGED
@@ -97,6 +97,7 @@ module GoodJob
97
97
  job.respond_to?(:good_job_enqueue_concurrency_controlled?) && job.good_job_enqueue_concurrency_controlled?
98
98
  end
99
99
  adapter.enqueue_all(bulkable_jobs) if bulkable_jobs.any?
100
+ ActiveSupport::Notifications.instrument("enqueue_jobs_individually.good_job", { jobs: unbulkable_jobs }) if unbulkable_jobs.any?
100
101
  else
101
102
  unbulkable_jobs = jobs
102
103
  end
@@ -541,6 +541,20 @@ module GoodJob
541
541
  (options[:dequeue_query_sort] || rails_config[:dequeue_query_sort] || :created_at).to_sym
542
542
  end
543
543
 
544
+ # Emits a deprecation warning when +dequeue_query_sort+ has not been
545
+ # explicitly configured, because the default will change from +:created_at+
546
+ # to +:scheduled_at+ (and the option will be removed) in the next major version.
547
+ # @return [void]
548
+ def warn_dequeue_query_sort_default
549
+ return unless options[:dequeue_query_sort].nil? && rails_config[:dequeue_query_sort].nil?
550
+
551
+ GoodJob.deprecator.warn(<<~MSG.squish)
552
+ GoodJob will dequeue jobs ordered by `scheduled_at` instead of `created_at` in the next major version,
553
+ and the `dequeue_query_sort` option will be removed. Opt in to the new behavior now and silence this
554
+ warning by setting `config.good_job.dequeue_query_sort = :scheduled_at`.
555
+ MSG
556
+ end
557
+
544
558
  # Resolves lazily memoized values so the configuration can be frozen.
545
559
  # @return [self]
546
560
  def prepare_for_sharing
@@ -48,6 +48,8 @@ module GoodJob
48
48
  GoodJob.on_thread_error = rails_config[:on_thread_error] if rails_config.key?(:on_thread_error)
49
49
  GoodJob.preserve_job_records = rails_config[:preserve_job_records] if rails_config.key?(:preserve_job_records)
50
50
  GoodJob.retry_on_unhandled_error = rails_config[:retry_on_unhandled_error] if rails_config.key?(:retry_on_unhandled_error)
51
+
52
+ GoodJob.configuration.warn_dequeue_query_sort_default
51
53
  end
52
54
  end
53
55
 
@@ -254,6 +254,15 @@ module GoodJob
254
254
  end
255
255
  end
256
256
 
257
+ # @!macro notification_responder
258
+ def enqueue_jobs_individually(event)
259
+ jobs = event.payload[:jobs]
260
+
261
+ info do
262
+ "Enqueuing #{jobs.size} #{'job'.pluralize(jobs.size)} with enqueue concurrency limits individually instead of in bulk: #{jobs.map { |job| job.class.name }.uniq.join(', ')}"
263
+ end
264
+ end
265
+
257
266
  # @!macro notification_responder
258
267
  def systemd_watchdog_start(event)
259
268
  interval = event.payload[:interval]
@@ -3,7 +3,7 @@
3
3
 
4
4
  module GoodJob
5
5
  # GoodJob gem version.
6
- VERSION = '4.24.0'
6
+ VERSION = '4.24.2'
7
7
 
8
8
  # GoodJob version as Gem::Version object
9
9
  GEM_VERSION = Gem::Version.new(VERSION)