good_job 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb +2 -0
- data/lib/generators/good_job/templates/update/migrations/04_index_good_job_jobs_on_finished_at.rb.erb +25 -0
- data/lib/good_job/active_job_job.rb +9 -3
- data/lib/good_job/adapter.rb +1 -1
- data/lib/good_job/execution.rb +2 -0
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +4 -2
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bca3de7432f33744351456a803dcbb74f73c0228f824dad035b51565c711e529
|
4
|
+
data.tar.gz: 0e0b3d2959f2db50c00d61a49ccad52be73711ac8e07cfd7cfffb186923fb5b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad760ae64fe74a08943013b9359e675bf46ad366cb9a688937a182e2fc8b6abd336fa8b8408cc61e22cf7c3ab713d0fa9e0a6ae973196d653e5c763818ef1672
|
7
|
+
data.tar.gz: 630f2765587b5b675eaf1e33b6c5b39a83ada8980a0638011e2cc71f4ce963d6f6287db5d50a9c5efb3d1ba7c1402e7ef1f2beb11369ad981a6046c8e4491f30
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.8.1](https://github.com/bensheldon/good_job/tree/v2.8.1) (2022-01-03)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.8.0...v2.8.1)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- Add indexes to `good_jobs.finished_at` and have `GoodJob.cleanup_preserved_jobs` delete all executions for a given job [\#477](https://github.com/bensheldon/good_job/pull/477) ([bensheldon](https://github.com/bensheldon))
|
10
|
+
|
11
|
+
**Closed issues:**
|
12
|
+
|
13
|
+
- finished\_at should be indexed and clean up should clean up all of a job's executions [\#476](https://github.com/bensheldon/good_job/issues/476)
|
14
|
+
|
15
|
+
**Merged pull requests:**
|
16
|
+
|
17
|
+
- Update development Ruby \(2.7.5\) and Rails \(6.1.4.4\) versions [\#475](https://github.com/bensheldon/good_job/pull/475) ([bensheldon](https://github.com/bensheldon))
|
18
|
+
- Clean up server integration tests [\#474](https://github.com/bensheldon/good_job/pull/474) ([bensheldon](https://github.com/bensheldon))
|
19
|
+
|
3
20
|
## [v2.8.0](https://github.com/bensheldon/good_job/tree/v2.8.0) (2021-12-31)
|
4
21
|
|
5
22
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v2.7.4...v2.8.0)
|
@@ -32,5 +32,7 @@ class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %>
|
|
32
32
|
add_index :good_jobs, :concurrency_key, where: "(finished_at IS NULL)", name: :index_good_jobs_on_concurrency_key_when_unfinished
|
33
33
|
add_index :good_jobs, [:cron_key, :created_at], name: :index_good_jobs_on_cron_key_and_created_at
|
34
34
|
add_index :good_jobs, [:cron_key, :cron_at], name: :index_good_jobs_on_cron_key_and_cron_at, unique: true
|
35
|
+
add_index :good_jobs, [:active_job_id], name: :index_good_jobs_on_active_job_id
|
36
|
+
add_index :good_jobs, [:finished_at], where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL", name: :index_good_jobs_jobs_on_finished_at
|
35
37
|
end
|
36
38
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class IndexGoodJobJobsOnFinishedAt < ActiveRecord::Migration<%= migration_version %>
|
3
|
+
disable_ddl_transaction!
|
4
|
+
|
5
|
+
def change
|
6
|
+
reversible do |dir|
|
7
|
+
dir.up do
|
8
|
+
# Ensure this incremental update migration is idempotent
|
9
|
+
# with monolithic install migration.
|
10
|
+
return if connection.index_name_exists?(:good_jobs, :index_good_jobs_on_active_job_id)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :good_jobs,
|
15
|
+
[:active_job_id],
|
16
|
+
name: :index_good_jobs_on_active_job_id,
|
17
|
+
algorithm: :concurrently
|
18
|
+
|
19
|
+
add_index :good_jobs,
|
20
|
+
[:finished_at],
|
21
|
+
where: "retried_good_job_id IS NULL AND finished_at IS NOT NULL",
|
22
|
+
name: :index_good_jobs_jobs_on_finished_at,
|
23
|
+
algorithm: :concurrently
|
24
|
+
end
|
25
|
+
end
|
@@ -19,7 +19,7 @@ module GoodJob
|
|
19
19
|
self.primary_key = 'active_job_id'
|
20
20
|
self.advisory_lockable_column = 'active_job_id'
|
21
21
|
|
22
|
-
has_many :executions, -> { order(created_at: :asc) }, class_name: 'GoodJob::Execution', foreign_key: 'active_job_id'
|
22
|
+
has_many :executions, -> { order(created_at: :asc) }, class_name: 'GoodJob::Execution', foreign_key: 'active_job_id', inverse_of: :job
|
23
23
|
|
24
24
|
# Only the most-recent unretried execution represents a "Job"
|
25
25
|
default_scope { where(retried_good_job_id: nil) }
|
@@ -27,11 +27,17 @@ module GoodJob
|
|
27
27
|
# Get Jobs with given class name
|
28
28
|
# @!method job_class
|
29
29
|
# @!scope class
|
30
|
-
# @param string [String]
|
31
|
-
# Execution class name
|
30
|
+
# @param string [String] Execution class name
|
32
31
|
# @return [ActiveRecord::Relation]
|
33
32
|
scope :job_class, ->(job_class) { where("serialized_params->>'job_class' = ?", job_class) }
|
34
33
|
|
34
|
+
# Get Jobs finished before the given timestamp.
|
35
|
+
# @!method finished_before(timestamp)
|
36
|
+
# @!scope class
|
37
|
+
# @param timestamp (DateTime, Time)
|
38
|
+
# @return [ActiveRecord::Relation]
|
39
|
+
scope :finished_before, ->(timestamp) { where(arel_table['finished_at'].lteq(timestamp)) }
|
40
|
+
|
35
41
|
# First execution will run in the future
|
36
42
|
scope :scheduled, -> { where(finished_at: nil).where('COALESCE(scheduled_at, created_at) > ?', DateTime.current).where("(serialized_params->>'executions')::integer < 2") }
|
37
43
|
# Execution errored, will run in the future
|
data/lib/good_job/adapter.rb
CHANGED
@@ -149,7 +149,7 @@ module GoodJob
|
|
149
149
|
def in_server_process?
|
150
150
|
return @_in_server_process if defined? @_in_server_process
|
151
151
|
|
152
|
-
@_in_server_process = Rails.const_defined?(
|
152
|
+
@_in_server_process = Rails.const_defined?(:Server) ||
|
153
153
|
caller.grep(%r{config.ru}).any? || # EXAMPLE: config.ru:3:in `block in <main>' OR config.ru:3:in `new_from_string'
|
154
154
|
caller.grep(%{/rack/handler/}).any? || # EXAMPLE: iodine-0.7.44/lib/rack/handler/iodine.rb:13:in `start'
|
155
155
|
(Concurrent.on_jruby? && caller.grep(%r{jruby/rack/rails_booter}).any?) # EXAMPLE: uri:classloader:/jruby/rack/rails_booter.rb:83:in `load_environment'
|
data/lib/good_job/execution.rb
CHANGED
@@ -51,6 +51,8 @@ module GoodJob
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
belongs_to :job, class_name: 'GoodJob::ActiveJobJob', foreign_key: 'active_job_id', primary_key: 'active_job_id', optional: true, inverse_of: :executions
|
55
|
+
|
54
56
|
# Get Jobs with given ActiveJob ID
|
55
57
|
# @!method active_job_id
|
56
58
|
# @!scope class
|
data/lib/good_job/version.rb
CHANGED
data/lib/good_job.rb
CHANGED
@@ -138,9 +138,11 @@ module GoodJob
|
|
138
138
|
timestamp = Time.current - older_than
|
139
139
|
|
140
140
|
ActiveSupport::Notifications.instrument("cleanup_preserved_jobs.good_job", { older_than: older_than, timestamp: timestamp }) do |payload|
|
141
|
-
|
141
|
+
old_jobs = GoodJob::ActiveJobJob.where('finished_at <= ?', timestamp)
|
142
|
+
old_jobs_count = old_jobs.count
|
142
143
|
|
143
|
-
|
144
|
+
GoodJob::Execution.where(job: old_jobs).delete_all
|
145
|
+
payload[:deleted_records_count] = old_jobs_count
|
144
146
|
end
|
145
147
|
end
|
146
148
|
|
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: 2.8.
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sheldon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -405,6 +405,7 @@ files:
|
|
405
405
|
- lib/generators/good_job/templates/update/migrations/02_add_cron_at_to_good_jobs.rb.erb
|
406
406
|
- lib/generators/good_job/templates/update/migrations/03_add_cron_key_cron_at_index_to_good_jobs.rb.erb
|
407
407
|
- lib/generators/good_job/templates/update/migrations/04_create_good_job_processes.rb.erb
|
408
|
+
- lib/generators/good_job/templates/update/migrations/04_index_good_job_jobs_on_finished_at.rb.erb
|
408
409
|
- lib/generators/good_job/update_generator.rb
|
409
410
|
- lib/good_job.rb
|
410
411
|
- lib/good_job/active_job_extensions.rb
|
@@ -445,6 +446,7 @@ metadata:
|
|
445
446
|
documentation_uri: https://rdoc.info/github/bensheldon/good_job
|
446
447
|
homepage_uri: https://github.com/bensheldon/good_job
|
447
448
|
source_code_uri: https://github.com/bensheldon/good_job
|
449
|
+
rubygems_mfa_required: 'true'
|
448
450
|
post_install_message:
|
449
451
|
rdoc_options:
|
450
452
|
- "--title"
|
@@ -468,7 +470,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
468
470
|
- !ruby/object:Gem::Version
|
469
471
|
version: '0'
|
470
472
|
requirements: []
|
471
|
-
rubygems_version: 3.
|
473
|
+
rubygems_version: 3.1.6
|
472
474
|
signing_key:
|
473
475
|
specification_version: 4
|
474
476
|
summary: A multithreaded, Postgres-based ActiveJob backend for Ruby on Rails
|