good_job 3.29.5 → 3.30.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26e3887930fc0f923edca0286d1d6c2fff51466f5b395eb122a56f6dd4ec9171
4
- data.tar.gz: 79a670cab496050ddf9cee105be9eab503a4d18f4786ac4a5b04dd3f93e3814a
3
+ metadata.gz: 7a62f9aed6b7846a54575fc79d8bb6e164f4236a0e1089eeaf2d2d7ded5e2561
4
+ data.tar.gz: cf93bd4a95f4cbd143442ecb5e4d3a1eff77cdecd9e703ee711ea22d2aba2b4e
5
5
  SHA512:
6
- metadata.gz: a8f938f53fc9d1e2334b25fb9311f30abffa47fe26b9968d1d7de5f354337c1aeca217cf70fcfc2e5ab15ceba992f9a4edbc7430d5b09733a90221a970fbdebc
7
- data.tar.gz: ad97c2abf1d88cab58898f983991e599b8b55e2f20cc5931b0b2d7ee08292ca9c20652452ebbf853a3f09e96c2134dd7167f158c5a0629390d94c48383a2b436
6
+ metadata.gz: aca712916a3b886d92ae128ee6f238a20a6af8d13bfba3b33b4064820fcbe3317f077fb6a4eac39377f14dcfb10078f0e2ed4c21f81ad9422e59769982aa6d8c
7
+ data.tar.gz: 2adc01f26ea9e2155073224a1cf9a42049c63f67c7bb5ffc87f07c1dd95f30cbbd958b15f9b50e0bbf645e132b331f592c9aa6cf182b110484bc807f6b024ef2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v3.30.0](https://github.com/bensheldon/good_job/tree/v3.30.0) (2024-07-05)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.29.5...v3.30.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Added GoodJob::DiscreteExecution\#duration column [\#1374](https://github.com/bensheldon/good_job/pull/1374) ([SebouChu](https://github.com/SebouChu))
10
+
11
+ **Closed issues:**
12
+
13
+ - Job retried infinitely [\#1384](https://github.com/bensheldon/good_job/issues/1384)
14
+
15
+ **Merged pull requests:**
16
+
17
+ - Use newer syntax in documentation for `wait` config on `retry` [\#1380](https://github.com/bensheldon/good_job/pull/1380) ([benoittgt](https://github.com/benoittgt))
18
+
3
19
  ## [v3.29.5](https://github.com/bensheldon/good_job/tree/v3.29.5) (2024-06-24)
4
20
 
5
21
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v3.29.4...v3.29.5)
data/README.md CHANGED
@@ -933,7 +933,7 @@ Active Job can be configured to retry an infinite number of times, with a polyno
933
933
 
934
934
  ```ruby
935
935
  class ApplicationJob < ActiveJob::Base
936
- retry_on StandardError, wait: :exponentially_longer, attempts: Float::INFINITY
936
+ retry_on StandardError, wait: :polynomially_longer, attempts: Float::INFINITY
937
937
  # ...
938
938
  end
939
939
  ```
@@ -953,7 +953,7 @@ When using `retry_on` with an infinite number of retries, exceptions will never
953
953
 
954
954
  ```ruby
955
955
  class ApplicationJob < ActiveJob::Base
956
- retry_on StandardError, wait: :exponentially_longer, attempts: Float::INFINITY
956
+ retry_on StandardError, wait: :polynomially_longer, attempts: Float::INFINITY
957
957
 
958
958
  retry_on SpecialError, attempts: 5 do |_job, exception|
959
959
  Rails.error.report(exception)
@@ -979,7 +979,7 @@ You can use an initializer to configure `ActionMailer::MailDeliveryJob`, for exa
979
979
 
980
980
  ```ruby
981
981
  # config/initializers/good_job.rb
982
- ActionMailer::MailDeliveryJob.retry_on StandardError, wait: :exponentially_longer, attempts: Float::INFINITY
982
+ ActionMailer::MailDeliveryJob.retry_on StandardError, wait: :polynomially_longer, attempts: Float::INFINITY
983
983
 
984
984
  # With Sentry (or Bugsnag, Airbrake, Honeybadger, etc.)
985
985
  ActionMailer::MailDeliveryJob.around_perform do |_job, block|
@@ -28,6 +28,13 @@ module GoodJob # :nodoc:
28
28
  false
29
29
  end
30
30
 
31
+ def self.monotonic_duration_migrated?
32
+ return true if columns_hash["duration"].present?
33
+
34
+ migration_pending_warning!
35
+ false
36
+ end
37
+
31
38
  def number
32
39
  serialized_params.fetch('executions', 0) + 1
33
40
  end
@@ -37,9 +44,13 @@ module GoodJob # :nodoc:
37
44
  created_at - scheduled_at
38
45
  end
39
46
 
40
- # Time between when this job started and finished
47
+ # Monotonic time between when this job started and finished
41
48
  def runtime_latency
42
- (finished_at || Time.current) - performed_at if performed_at
49
+ if self.class.monotonic_duration_migrated?
50
+ duration
51
+ elsif performed_at
52
+ (finished_at || Time.current) - performed_at
53
+ end
43
54
  end
44
55
 
45
56
  def last_status_at
@@ -372,6 +372,7 @@ module GoodJob
372
372
  raise PreviouslyPerformedError, 'Cannot perform a job that has already been performed' if finished_at
373
373
 
374
374
  job_performed_at = Time.current
375
+ monotonic_start = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
375
376
  discrete_execution = nil
376
377
  result = GoodJob::CurrentThread.within do |current_thread|
377
378
  current_thread.reset
@@ -385,12 +386,14 @@ module GoodJob
385
386
  interrupt_error_string = self.class.format_error(GoodJob::InterruptError.new("Interrupted after starting perform at '#{existing_performed_at}'"))
386
387
  self.error = interrupt_error_string
387
388
  self.error_event = ERROR_EVENT_INTERRUPTED if self.class.error_event_migrated?
389
+ monotonic_duration = (::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - monotonic_start).seconds
388
390
 
389
391
  discrete_execution_attrs = {
390
392
  error: interrupt_error_string,
391
393
  finished_at: job_performed_at,
392
394
  }
393
395
  discrete_execution_attrs[:error_event] = GoodJob::ErrorEvents::ERROR_EVENT_ENUMS[GoodJob::ErrorEvents::ERROR_EVENT_INTERRUPTED] if self.class.error_event_migrated?
396
+ discrete_execution_attrs[:duration] = monotonic_duration if GoodJob::DiscreteExecution.monotonic_duration_migrated?
394
397
  discrete_executions.where(finished_at: nil).where.not(performed_at: nil).update_all(discrete_execution_attrs) # rubocop:disable Rails/SkipsModelValidations
395
398
  end
396
399
  end
@@ -494,8 +497,12 @@ module GoodJob
494
497
  job_attributes.delete(:error_event) unless self.class.error_event_migrated?
495
498
 
496
499
  job_finished_at = Time.current
500
+ monotonic_duration = (::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - monotonic_start).seconds
497
501
  job_attributes[:finished_at] = job_finished_at
498
- discrete_execution.finished_at = job_finished_at if discrete_execution
502
+ if discrete_execution
503
+ discrete_execution.finished_at = job_finished_at
504
+ discrete_execution.duration = monotonic_duration if GoodJob::DiscreteExecution.monotonic_duration_migrated?
505
+ end
499
506
 
500
507
  retry_unhandled_error = result.unhandled_error && GoodJob.retry_on_unhandled_error
501
508
  reenqueued = result.retried? || retried_good_job_id.present? || retry_unhandled_error
@@ -61,6 +61,7 @@ class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %>
61
61
  t.integer :error_event, limit: 2
62
62
  t.text :error_backtrace, array: true
63
63
  t.uuid :process_id
64
+ t.interval :duration
64
65
  end
65
66
 
66
67
  create_table :good_job_processes, id: :uuid do |t|
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CreateGoodJobExecutionDuration < ActiveRecord::Migration<%= migration_version %>
4
+ def change
5
+ reversible do |dir|
6
+ dir.up do
7
+ # Ensure this incremental update migration is idempotent
8
+ # with monolithic install migration.
9
+ return if connection.column_exists?(:good_job_executions, :duration)
10
+ end
11
+ end
12
+
13
+ add_column :good_job_executions, :duration, :interval
14
+ end
15
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module GoodJob
4
4
  # GoodJob gem version.
5
- VERSION = '3.29.5'
5
+ VERSION = '3.30.0'
6
6
 
7
7
  # GoodJob version as Gem::Version object
8
8
  GEM_VERSION = Gem::Version.new(VERSION)
data/lib/good_job.rb CHANGED
@@ -286,8 +286,8 @@ module GoodJob
286
286
  # @return [Boolean]
287
287
  def self.migrated?
288
288
  # Always update with the most recent migration check
289
- GoodJob::Execution.reset_column_information
290
- GoodJob::Execution.process_lock_migrated?
289
+ GoodJob::DiscreteExecution.reset_column_information
290
+ GoodJob::DiscreteExecution.monotonic_duration_migrated?
291
291
  end
292
292
 
293
293
  ActiveSupport.run_load_hooks(:good_job, self)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: good_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.29.5
4
+ version: 3.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
11
+ date: 2024-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -362,6 +362,7 @@ files:
362
362
  - lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb
363
363
  - lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb
364
364
  - lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb
365
+ - lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb
365
366
  - lib/generators/good_job/update_generator.rb
366
367
  - lib/good_job.rb
367
368
  - lib/good_job/active_job_extensions/batches.rb