good_job 3.30.0 → 4.0.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 +46 -0
- data/README.md +22 -0
- data/app/charts/good_job/scheduled_by_queue_chart.rb +2 -2
- data/app/controllers/good_job/cron_entries_controller.rb +0 -8
- data/app/controllers/good_job/metrics_controller.rb +1 -1
- data/app/controllers/good_job/performance_controller.rb +19 -0
- data/app/filters/good_job/base_filter.rb +1 -1
- data/app/helpers/good_job/application_helper.rb +1 -0
- data/app/models/concerns/good_job/error_events.rb +2 -2
- data/app/models/concerns/good_job/filterable.rb +1 -1
- data/app/models/good_job/base_execution.rb +544 -50
- data/app/models/good_job/cron_entry.rb +0 -2
- data/app/models/good_job/discrete_execution.rb +1 -26
- data/app/models/good_job/execution.rb +3 -609
- data/app/models/good_job/job.rb +37 -116
- data/app/models/good_job/process.rb +7 -20
- data/app/views/good_job/batches/index.html.erb +11 -15
- data/app/views/good_job/jobs/_executions.erb +1 -1
- data/app/views/good_job/jobs/_table.erb +1 -1
- data/app/views/good_job/jobs/show.html.erb +1 -8
- data/app/views/good_job/performance/index.html.erb +43 -0
- data/app/views/good_job/shared/_navbar.erb +5 -0
- data/config/locales/de.yml +10 -2
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +10 -2
- data/config/locales/fr.yml +10 -2
- data/config/locales/it.yml +10 -2
- data/config/locales/ja.yml +10 -2
- data/config/locales/ko.yml +10 -2
- data/config/locales/nl.yml +10 -2
- data/config/locales/pt-BR.yml +10 -2
- data/config/locales/ru.yml +10 -2
- data/config/locales/tr.yml +10 -2
- data/config/locales/uk.yml +10 -2
- data/config/routes.rb +2 -0
- data/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb +65 -3
- data/lib/good_job/active_job_extensions/batches.rb +1 -1
- data/lib/good_job/active_job_extensions/concurrency.rb +10 -10
- data/lib/good_job/adapter.rb +13 -24
- data/lib/good_job/configuration.rb +5 -1
- data/lib/good_job/current_thread.rb +6 -6
- data/lib/good_job/job_performer.rb +2 -2
- data/lib/good_job/log_subscriber.rb +2 -10
- data/lib/good_job/notifier.rb +3 -3
- data/lib/good_job/version.rb +1 -1
- data/lib/good_job.rb +22 -21
- metadata +18 -30
- data/lib/generators/good_job/templates/update/migrations/02_create_good_job_settings.rb.erb +0 -20
- data/lib/generators/good_job/templates/update/migrations/03_create_index_good_jobs_jobs_on_priority_created_at_when_unfinished.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/04_create_good_job_batches.rb.erb +0 -35
- data/lib/generators/good_job/templates/update/migrations/05_create_good_job_executions.rb.erb +0 -33
- data/lib/generators/good_job/templates/update/migrations/06_create_good_jobs_error_event.rb.erb +0 -16
- data/lib/generators/good_job/templates/update/migrations/07_recreate_good_job_cron_indexes_with_conditional.rb.erb +0 -45
- data/lib/generators/good_job/templates/update/migrations/08_create_good_job_labels.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/09_create_good_job_labels_index.rb.erb +0 -22
- data/lib/generators/good_job/templates/update/migrations/10_remove_good_job_active_id_index.rb.erb +0 -21
- data/lib/generators/good_job/templates/update/migrations/11_create_index_good_job_jobs_for_candidate_lookup.rb.erb +0 -19
- data/lib/generators/good_job/templates/update/migrations/12_create_good_job_execution_error_backtrace.rb.erb +0 -15
- data/lib/generators/good_job/templates/update/migrations/13_create_good_job_process_lock_ids.rb.erb +0 -17
- data/lib/generators/good_job/templates/update/migrations/14_create_good_job_process_lock_indexes.rb.erb +0 -37
- data/lib/generators/good_job/templates/update/migrations/15_create_good_job_execution_duration.rb.erb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5725006ff1eae761677d25b8f89d55903532b80c6850a8a58ad6506823316763
|
4
|
+
data.tar.gz: fe91ce725bd86202334c86c308443a3c5e5b0c71b680be4d5086b87b0349fe8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96ca288be634ed11773a66da6e3cad2f60c6cf8736cd33b41f5ce85681160d3a26e283f63f15914e480b5e8587b257ba95e9baed8f08c08c084c28c961320a29
|
7
|
+
data.tar.gz: d7d6fee108acbfd3743a6520b9f6283bb3cb999a7ce51f87c4d3ae80864d8b0cfe1e34bbb0517c42c8b807145dae315f60f8907bbc601d2aade905b8ff37fa53
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,51 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v4.0.1](https://github.com/bensheldon/good_job/tree/v4.0.1) (2024-07-08)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.0.0...v4.0.1)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- Actually change `smaller_number_is_higher_priority` for v4 [\#1402](https://github.com/bensheldon/good_job/pull/1402) ([Earlopain](https://github.com/Earlopain))
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Bump prism/rbi dev dependency [\#1403](https://github.com/bensheldon/good_job/pull/1403) ([Earlopain](https://github.com/Earlopain))
|
14
|
+
- Use index action for the performance controller [\#1398](https://github.com/bensheldon/good_job/pull/1398) ([Earlopain](https://github.com/Earlopain))
|
15
|
+
|
16
|
+
## [v4.0.0](https://github.com/bensheldon/good_job/tree/v4.0.0) (2024-07-07)
|
17
|
+
|
18
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.99.0...v4.0.0)
|
19
|
+
|
20
|
+
**Implemented enhancements:**
|
21
|
+
|
22
|
+
- Release GoodJob v4 [\#1394](https://github.com/bensheldon/good_job/pull/1394) ([bensheldon](https://github.com/bensheldon))
|
23
|
+
|
24
|
+
## [v3.99.0](https://github.com/bensheldon/good_job/tree/v3.99.0) (2024-07-07)
|
25
|
+
|
26
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.30.1...v3.99.0)
|
27
|
+
|
28
|
+
**Merged pull requests:**
|
29
|
+
|
30
|
+
- Remove deprecation silencers for v3.99 release [\#1395](https://github.com/bensheldon/good_job/pull/1395) ([bensheldon](https://github.com/bensheldon))
|
31
|
+
- Add instructions and `GoodJob.v4_ready?` for upgrading to v4 [\#1356](https://github.com/bensheldon/good_job/pull/1356) ([bensheldon](https://github.com/bensheldon))
|
32
|
+
|
33
|
+
## [v3.30.1](https://github.com/bensheldon/good_job/tree/v3.30.1) (2024-07-06)
|
34
|
+
|
35
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.30.0...v3.30.1)
|
36
|
+
|
37
|
+
**Fixed bugs:**
|
38
|
+
|
39
|
+
- Fix Performance table formatting, change url from `performances` to singular `performance` [\#1393](https://github.com/bensheldon/good_job/pull/1393) ([bensheldon](https://github.com/bensheldon))
|
40
|
+
- Add a version check for Rails whether to use pg interval or calculate float [\#1389](https://github.com/bensheldon/good_job/pull/1389) ([bensheldon](https://github.com/bensheldon))
|
41
|
+
|
42
|
+
**Merged pull requests:**
|
43
|
+
|
44
|
+
- Add missing newline after frozen string literal for migrations [\#1392](https://github.com/bensheldon/good_job/pull/1392) ([Earlopain](https://github.com/Earlopain))
|
45
|
+
- Temporarily remove JRuby builds [\#1391](https://github.com/bensheldon/good_job/pull/1391) ([bensheldon](https://github.com/bensheldon))
|
46
|
+
- Add initial Performance panel to dashboard [\#1388](https://github.com/bensheldon/good_job/pull/1388) ([bensheldon](https://github.com/bensheldon))
|
47
|
+
- Move job execution logic from Execution to BaseExecution to simplify v4 changes [\#1357](https://github.com/bensheldon/good_job/pull/1357) ([bensheldon](https://github.com/bensheldon))
|
48
|
+
|
3
49
|
## [v3.30.0](https://github.com/bensheldon/good_job/tree/v3.30.0) (2024-07-05)
|
4
50
|
|
5
51
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v3.29.5...v3.30.0)
|
data/README.md
CHANGED
@@ -53,6 +53,7 @@ For more of the story of GoodJob, read the [introductory blog post](https://isla
|
|
53
53
|
- [Batches](#batches)
|
54
54
|
- [Updating](#updating)
|
55
55
|
- [Upgrading minor versions](#upgrading-minor-versions)
|
56
|
+
- [Upgrading v3 to v4](#upgrading-v3-to-v4)
|
56
57
|
- [Upgrading v2 to v3](#upgrading-v2-to-v3)
|
57
58
|
- [Upgrading v1 to v2](#upgrading-v1-to-v2)
|
58
59
|
- [Go deeper](#go-deeper)
|
@@ -873,6 +874,27 @@ To perform upgrades to the GoodJob database tables:
|
|
873
874
|
1. Commit the migration files and resulting `db/schema.rb` changes.
|
874
875
|
1. Deploy the code, run the migrations against the production database, and restart server/worker processes.
|
875
876
|
|
877
|
+
#### Upgrading v3 to v4
|
878
|
+
|
879
|
+
GoodJob v4 changes how job and job execution records are stored in the database; moving from job and executions being commingled in the `good_jobs` table to separately and discretely storing job executions in `good_job_executions`. To safely upgrade, all unfinished jobs must use the new format. This change was introduced in GoodJob [v3.15.4 (April 2023)](https://github.com/bensheldon/good_job/releases/tag/v3.15.4), so your application is likely ready-to-upgrade already if you have kept up with GoodJob updates.
|
880
|
+
|
881
|
+
To upgrade:
|
882
|
+
|
883
|
+
1. Upgrade to v3.99.x, following the minor version upgrade process, running any remaining database migrations (rails g good_job:update) and addressing deprecation warnings.
|
884
|
+
1. Check if your application is safe to upgrade to the new job record format by running either:
|
885
|
+
- In a production console, run `GoodJob.v4_ready?` which should return `true` when safely upgradable.
|
886
|
+
- Or, when connected to the production database verify that `SELECT COUNT(*) FROM "good_jobs" WHERE finished_at IS NULL AND is_discrete IS NOT TRUE` returns `0`
|
887
|
+
|
888
|
+
If not all unfinished jobs are stored in the new format, either wait to upgrade until those jobs finish or discard them. Not waiting could prevent those jobs from successfully running when upgrading to v4.
|
889
|
+
1. Upgrade from v3.99.x to v4.x.
|
890
|
+
|
891
|
+
Notable changes:
|
892
|
+
|
893
|
+
- Only supports Rails 6.1+, CRuby 3.0+ and JRuby 9.4+, Postgres 12+. Rails 6.0 is no longer supported. CRuby 2.6 and 2.7 are no longer supported. JRuby 9.3 is no longer supported.
|
894
|
+
- Changes job `priority` to give smaller numbers higher priority (default: `0`), in accordance with Active Job's definition of priority.
|
895
|
+
- Enqueues and executes jobs via the `GoodJob::Job` model instead of `GoodJob::Execution`
|
896
|
+
- Setting `config.good_job.cleanup_interval_jobs`, `GOOD_JOB_CLEANUP_INTERVAL_JOBS`, `config.good_job.cleanup_interval_seconds`, or `GOOD_JOB_CLEANUP_INTERVAL_SECONDS` to `nil` or `""` no longer disables count- or time-based cleanups. Set to `false` to disable, or `-1` to run a cleanup after every job execution.
|
897
|
+
|
876
898
|
#### Upgrading v2 to v3
|
877
899
|
|
878
900
|
GoodJob v3 is operationally identical to v2; upgrading to GoodJob v3 should be simple. If you are already using `>= v2.9+` no other changes are necessary.
|
@@ -11,7 +11,7 @@ module GoodJob
|
|
11
11
|
start_time = end_time - 1.day
|
12
12
|
table_name = GoodJob::Job.table_name
|
13
13
|
|
14
|
-
count_query = Arel.sql(GoodJob::
|
14
|
+
count_query = Arel.sql(GoodJob::Job.pg_or_jdbc_query(<<~SQL.squish))
|
15
15
|
SELECT *
|
16
16
|
FROM generate_series(
|
17
17
|
date_trunc('hour', $1::timestamp),
|
@@ -35,7 +35,7 @@ module GoodJob
|
|
35
35
|
ActiveRecord::Relation::QueryAttribute.new('start_time', start_time, ActiveRecord::Type::DateTime.new),
|
36
36
|
ActiveRecord::Relation::QueryAttribute.new('end_time', end_time, ActiveRecord::Type::DateTime.new),
|
37
37
|
]
|
38
|
-
executions_data = GoodJob::
|
38
|
+
executions_data = GoodJob::Job.connection.exec_query(GoodJob::Job.pg_or_jdbc_query(count_query), "GoodJob Dashboard Chart", binds)
|
39
39
|
|
40
40
|
queue_names = executions_data.reject { |d| d['count'].nil? }.map { |d| d['queue_name'] || BaseFilter::EMPTY }.uniq
|
41
41
|
labels = []
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module GoodJob
|
4
4
|
class CronEntriesController < GoodJob::ApplicationController
|
5
|
-
before_action :check_settings_migration!, only: [:enable, :disable]
|
6
|
-
|
7
5
|
def index
|
8
6
|
@cron_entries = CronEntry.all
|
9
7
|
end
|
@@ -30,11 +28,5 @@ module GoodJob
|
|
30
28
|
@cron_entry.disable
|
31
29
|
redirect_back(fallback_location: cron_entries_path, notice: t(".notice"))
|
32
30
|
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def check_settings_migration!
|
37
|
-
redirect_back(fallback_location: cron_entries_path, alert: t("good_job.cron_entries.pending_migrations")) unless GoodJob::Setting.migrated?
|
38
|
-
end
|
39
31
|
end
|
40
32
|
end
|
@@ -4,7 +4,7 @@ module GoodJob
|
|
4
4
|
class MetricsController < ApplicationController
|
5
5
|
def primary_nav
|
6
6
|
jobs_count = GoodJob::Job.count
|
7
|
-
batches_count = GoodJob::BatchRecord.
|
7
|
+
batches_count = GoodJob::BatchRecord.all.size
|
8
8
|
cron_entries_count = GoodJob::CronEntry.all.size
|
9
9
|
processes_count = GoodJob::Process.active.count
|
10
10
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GoodJob
|
4
|
+
class PerformanceController < ApplicationController
|
5
|
+
def index
|
6
|
+
@performances = GoodJob::DiscreteExecution
|
7
|
+
.where.not(job_class: nil)
|
8
|
+
.group(:job_class)
|
9
|
+
.select("
|
10
|
+
job_class,
|
11
|
+
COUNT(*) AS executions_count,
|
12
|
+
AVG(duration) AS avg_duration,
|
13
|
+
MIN(duration) AS min_duration,
|
14
|
+
MAX(duration) AS max_duration
|
15
|
+
")
|
16
|
+
.order("job_class")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -27,7 +27,7 @@ module GoodJob
|
|
27
27
|
def error_event
|
28
28
|
return unless self.class.columns_hash['error_event']
|
29
29
|
|
30
|
-
enum =
|
30
|
+
enum = read_attribute(:error_event)
|
31
31
|
return unless enum
|
32
32
|
|
33
33
|
ERROR_EVENT_ENUMS.key(enum)
|
@@ -39,7 +39,7 @@ module GoodJob
|
|
39
39
|
enum = ERROR_EVENT_ENUMS[event]
|
40
40
|
raise(ArgumentError, "Invalid error_event: #{event}") if event && !enum
|
41
41
|
|
42
|
-
|
42
|
+
write_attribute(:error_event, enum)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -35,7 +35,7 @@ module GoodJob
|
|
35
35
|
next if query.blank?
|
36
36
|
|
37
37
|
# TODO: turn this into proper bind parameters in Arel
|
38
|
-
tsvector = "(to_tsvector('english', id::text) || to_tsvector('english', COALESCE(active_job_id::text, '')) || to_tsvector('english', serialized_params) || to_tsvector('english', COALESCE(error, ''))
|
38
|
+
tsvector = "(to_tsvector('english', id::text) || to_tsvector('english', COALESCE(active_job_id::text, '')) || to_tsvector('english', serialized_params) || to_tsvector('english', COALESCE(error, '')) || to_tsvector('english', COALESCE(array_to_string(labels, ' '), '')))"
|
39
39
|
to_tsquery_function = database_supports_websearch_to_tsquery? ? 'websearch_to_tsquery' : 'plainto_tsquery'
|
40
40
|
where("#{tsvector} @@ #{to_tsquery_function}(?)", query)
|
41
41
|
.order(sanitize_sql_for_order([Arel.sql("ts_rank(#{tsvector}, #{to_tsquery_function}(?))"), query]) => 'DESC')
|