good_job 4.19.0 → 4.19.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +64 -9
- data/README.md +4 -4
- data/app/models/concerns/good_job/advisory_lockable.rb +12 -4
- data/app/models/good_job/batch.rb +6 -0
- data/app/models/good_job/job.rb +7 -6
- data/config/brakeman.ignore +3 -3
- data/lib/good_job/active_job_extensions/concurrency.rb +8 -2
- data/lib/good_job/configuration.rb +1 -4
- data/lib/good_job/log_subscriber.rb +22 -0
- data/lib/good_job/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6ad85ff0a870b41065fedac7c97b85f06606227b8a508851d775fabf90d2cc44
|
|
4
|
+
data.tar.gz: b4060b5afd727017bc337833d5c3d152f8f08465077edc42cbba9f929da72452
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a6f6a889caf1e0566fb98b18603fabcfde6f2499cffc96d9ddec3eb3fd15e1049d32d2e16a0c42284410d43bd6bb849b57f5e54ac3dea989a1e9eba929a42034
|
|
7
|
+
data.tar.gz: f671e1ee8a746c4f771339d4f5afdd2da089e16934129462890645b44ebd013f13568feb1e278df06fb84ce49a1020e43f0813c481da60e16008d7b7944c05cf
|
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [v4.19.2](https://github.com/bensheldon/good_job/tree/v4.19.2) (2026-07-20)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.19.1...v4.19.2)
|
|
6
|
+
|
|
7
|
+
**Fixed bugs:**
|
|
8
|
+
|
|
9
|
+
- Resolve connection pool at call time in the `adapter_class` shim [\#1798](https://github.com/bensheldon/good_job/pull/1798) ([DaisyOli](https://github.com/DaisyOli))
|
|
10
|
+
- Add GoodJob::Batch.where\(id:\) for GlobalID::Locator.fetch [\#1792](https://github.com/bensheldon/good_job/pull/1792) ([bensheldon](https://github.com/bensheldon))
|
|
11
|
+
- Preserve created\_at when a job is retried [\#1789](https://github.com/bensheldon/good_job/pull/1789) ([ollym](https://github.com/ollym))
|
|
12
|
+
|
|
13
|
+
**Closed issues:**
|
|
14
|
+
|
|
15
|
+
- Memoized `adapter_class` proxy captures the pre-fork connection pool, crashing the Notifier in forked Puma workers \(Rails \< 7.2 + `preload_app!`\) [\#1797](https://github.com/bensheldon/good_job/issues/1797)
|
|
16
|
+
- created\_at is reset every time a job is retried [\#1788](https://github.com/bensheldon/good_job/issues/1788)
|
|
17
|
+
|
|
18
|
+
**Merged pull requests:**
|
|
19
|
+
|
|
20
|
+
- Fix JRuby CI failure installing `rbs` gem [\#1794](https://github.com/bensheldon/good_job/pull/1794) ([bensheldon](https://github.com/bensheldon))
|
|
21
|
+
- Fix flaky scheduled\_at precision comparison in adapter\_spec [\#1793](https://github.com/bensheldon/good_job/pull/1793) ([bensheldon](https://github.com/bensheldon))
|
|
22
|
+
- Remove inline\_execution\_respects\_schedule config [\#1791](https://github.com/bensheldon/good_job/pull/1791) ([bensheldon](https://github.com/bensheldon))
|
|
23
|
+
- Bump actions/checkout from 6 to 7 [\#1787](https://github.com/bensheldon/good_job/pull/1787) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
24
|
+
|
|
25
|
+
## [v4.19.1](https://github.com/bensheldon/good_job/tree/v4.19.1) (2026-06-25)
|
|
26
|
+
|
|
27
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.19.0...v4.19.1)
|
|
28
|
+
|
|
29
|
+
**Fixed bugs:**
|
|
30
|
+
|
|
31
|
+
- Support Rails Edge version of Arel::Table [\#1783](https://github.com/bensheldon/good_job/pull/1783) ([luizkowalski](https://github.com/luizkowalski))
|
|
32
|
+
- Emit ActiveSupport::Notifications for concurrency-aborted enqueues [\#1779](https://github.com/bensheldon/good_job/pull/1779) ([bdewater-thatch](https://github.com/bdewater-thatch))
|
|
33
|
+
|
|
34
|
+
**Closed issues:**
|
|
35
|
+
|
|
36
|
+
- The probe server doesn't handle SIGINT/SIGTERM [\#1632](https://github.com/bensheldon/good_job/issues/1632)
|
|
37
|
+
|
|
3
38
|
## [v4.19.0](https://github.com/bensheldon/good_job/tree/v4.19.0) (2026-05-27)
|
|
4
39
|
|
|
5
|
-
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.18.
|
|
40
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.18.3...v4.19.0)
|
|
6
41
|
|
|
7
42
|
**Implemented enhancements:**
|
|
8
43
|
|
|
@@ -18,6 +53,17 @@
|
|
|
18
53
|
- Make execution state completely Fiber-safe via Rails isolated execution state [\#1765](https://github.com/bensheldon/good_job/pull/1765) ([ollym](https://github.com/ollym))
|
|
19
54
|
- Handle nil updated\_at in stale? method [\#1764](https://github.com/bensheldon/good_job/pull/1764) ([gavinballard](https://github.com/gavinballard))
|
|
20
55
|
|
|
56
|
+
**Merged pull requests:**
|
|
57
|
+
|
|
58
|
+
- Prune CI test matrix to boundary Ruby versions per Rails version [\#1777](https://github.com/bensheldon/good_job/pull/1777) ([bensheldon](https://github.com/bensheldon))
|
|
59
|
+
- Refactor Concurrency::Rule to use explicit ivars instead of options hash [\#1776](https://github.com/bensheldon/good_job/pull/1776) ([bensheldon](https://github.com/bensheldon))
|
|
60
|
+
- Fix typo in README.md [\#1773](https://github.com/bensheldon/good_job/pull/1773) ([NobodysNightmare](https://github.com/NobodysNightmare))
|
|
61
|
+
- Use explicit keyword arguments for concurrency controls [\#1770](https://github.com/bensheldon/good_job/pull/1770) ([bdewater-thatch](https://github.com/bdewater-thatch))
|
|
62
|
+
|
|
63
|
+
## [v4.18.3](https://github.com/bensheldon/good_job/tree/v4.18.3) (2026-05-27)
|
|
64
|
+
|
|
65
|
+
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.18.2...v4.18.3)
|
|
66
|
+
|
|
21
67
|
**Closed issues:**
|
|
22
68
|
|
|
23
69
|
- enable\_pauses ENV var check has singular/plural mismatch [\#1771](https://github.com/bensheldon/good_job/issues/1771)
|
|
@@ -27,13 +73,6 @@
|
|
|
27
73
|
- Job runner process enters a loop on create\_listen\_task - stale check fails [\#1649](https://github.com/bensheldon/good_job/issues/1649)
|
|
28
74
|
- Set a default queue\_select\_limit [\#1596](https://github.com/bensheldon/good_job/issues/1596)
|
|
29
75
|
|
|
30
|
-
**Merged pull requests:**
|
|
31
|
-
|
|
32
|
-
- Prune CI test matrix to boundary Ruby versions per Rails version [\#1777](https://github.com/bensheldon/good_job/pull/1777) ([bensheldon](https://github.com/bensheldon))
|
|
33
|
-
- Refactor Concurrency::Rule to use explicit ivars instead of options hash [\#1776](https://github.com/bensheldon/good_job/pull/1776) ([bensheldon](https://github.com/bensheldon))
|
|
34
|
-
- Fix typo in README.md [\#1773](https://github.com/bensheldon/good_job/pull/1773) ([NobodysNightmare](https://github.com/NobodysNightmare))
|
|
35
|
-
- Use explicit keyword arguments for concurrency controls [\#1770](https://github.com/bensheldon/good_job/pull/1770) ([bdewater-thatch](https://github.com/bdewater-thatch))
|
|
36
|
-
|
|
37
76
|
## [v4.18.2](https://github.com/bensheldon/good_job/tree/v4.18.2) (2026-04-20)
|
|
38
77
|
|
|
39
78
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.18.1...v4.18.2)
|
|
@@ -117,6 +156,10 @@
|
|
|
117
156
|
|
|
118
157
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.16.0...v4.17.0)
|
|
119
158
|
|
|
159
|
+
**Implemented enhancements:**
|
|
160
|
+
|
|
161
|
+
- Introduce advisory lock key customization support methods [\#1722](https://github.com/bensheldon/good_job/pull/1722) ([amkisko](https://github.com/amkisko))
|
|
162
|
+
|
|
120
163
|
**Merged pull requests:**
|
|
121
164
|
|
|
122
165
|
- Convert UI JavaScript modules to Stimulus controllers [\#1743](https://github.com/bensheldon/good_job/pull/1743) ([bensheldon](https://github.com/bensheldon))
|
|
@@ -132,6 +175,11 @@
|
|
|
132
175
|
- Allow filtering by label on dashboard [\#1739](https://github.com/bensheldon/good_job/pull/1739) ([bensheldon](https://github.com/bensheldon))
|
|
133
176
|
- Allow multiple concurrency rules per job via labels [\#1700](https://github.com/bensheldon/good_job/pull/1700) ([bscofield](https://github.com/bscofield))
|
|
134
177
|
|
|
178
|
+
**Fixed bugs:**
|
|
179
|
+
|
|
180
|
+
- Fix advisory lock connection stickiness in block contexts [\#1736](https://github.com/bensheldon/good_job/pull/1736) ([bensheldon](https://github.com/bensheldon))
|
|
181
|
+
- Add JRuby 10 to testing matrix [\#1559](https://github.com/bensheldon/good_job/pull/1559) ([bensheldon](https://github.com/bensheldon))
|
|
182
|
+
|
|
135
183
|
**Closed issues:**
|
|
136
184
|
|
|
137
185
|
- Job duration misreported if interrupted [\#1723](https://github.com/bensheldon/good_job/issues/1723)
|
|
@@ -141,6 +189,7 @@
|
|
|
141
189
|
- Use annotated git tag in release script [\#1741](https://github.com/bensheldon/good_job/pull/1741) ([bensheldon](https://github.com/bensheldon))
|
|
142
190
|
- Double single-thread scheduler integration test timeout on JRuby [\#1738](https://github.com/bensheldon/good_job/pull/1738) ([bensheldon](https://github.com/bensheldon))
|
|
143
191
|
- Fix JRuby test flakes for scheduler timeout and interrupted execution duration [\#1737](https://github.com/bensheldon/good_job/pull/1737) ([bensheldon](https://github.com/bensheldon))
|
|
192
|
+
- Count Advisory Locks and refactor advisory lock lifecycle [\#1735](https://github.com/bensheldon/good_job/pull/1735) ([bensheldon](https://github.com/bensheldon))
|
|
144
193
|
- Show interrupted execution recovery duration in dashboard [\#1733](https://github.com/bensheldon/good_job/pull/1733) ([bensheldon](https://github.com/bensheldon))
|
|
145
194
|
- chore: use `merge` to avoid mutate the query object [\#1717](https://github.com/bensheldon/good_job/pull/1717) ([luizkowalski](https://github.com/luizkowalski))
|
|
146
195
|
|
|
@@ -156,6 +205,7 @@
|
|
|
156
205
|
|
|
157
206
|
**Merged pull requests:**
|
|
158
207
|
|
|
208
|
+
- Fix JRuby in development lockfile, with test [\#1734](https://github.com/bensheldon/good_job/pull/1734) ([bensheldon](https://github.com/bensheldon))
|
|
159
209
|
- Add herb to linter [\#1732](https://github.com/bensheldon/good_job/pull/1732) ([bensheldon](https://github.com/bensheldon))
|
|
160
210
|
- Update development dependencies; apply Rubocop to\_h lints [\#1728](https://github.com/bensheldon/good_job/pull/1728) ([bensheldon](https://github.com/bensheldon))
|
|
161
211
|
|
|
@@ -217,6 +267,7 @@
|
|
|
217
267
|
|
|
218
268
|
**Fixed bugs:**
|
|
219
269
|
|
|
270
|
+
- Check for graceful shutdown inside job cleanup loops [\#1711](https://github.com/bensheldon/good_job/pull/1711) ([bdewater-thatch](https://github.com/bdewater-thatch))
|
|
220
271
|
- Add title to Good Job Dashboard layout [\#1701](https://github.com/bensheldon/good_job/pull/1701) ([mockdeep](https://github.com/mockdeep))
|
|
221
272
|
|
|
222
273
|
**Closed issues:**
|
|
@@ -312,6 +363,7 @@
|
|
|
312
363
|
**Merged pull requests:**
|
|
313
364
|
|
|
314
365
|
- Update sorbet/tapioca [\#1681](https://github.com/bensheldon/good_job/pull/1681) ([bensheldon](https://github.com/bensheldon))
|
|
366
|
+
- Remove obsolete property from tests [\#1676](https://github.com/bensheldon/good_job/pull/1676) ([RDIL](https://github.com/RDIL))
|
|
315
367
|
- Bump actions/checkout from 4 to 5 [\#1673](https://github.com/bensheldon/good_job/pull/1673) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
316
368
|
|
|
317
369
|
## [v4.11.2](https://github.com/bensheldon/good_job/tree/v4.11.2) (2025-08-06)
|
|
@@ -434,6 +486,10 @@
|
|
|
434
486
|
|
|
435
487
|
[Full Changelog](https://github.com/bensheldon/good_job/compare/v4.9.0...v4.9.1)
|
|
436
488
|
|
|
489
|
+
**Implemented enhancements:**
|
|
490
|
+
|
|
491
|
+
- Order Dashboard jobs in more "natural" order [\#1604](https://github.com/bensheldon/good_job/pull/1604) ([francois](https://github.com/francois))
|
|
492
|
+
|
|
437
493
|
**Fixed bugs:**
|
|
438
494
|
|
|
439
495
|
- \[dashboard\] Scheduled tasks are shown "backwards" [\#1580](https://github.com/bensheldon/good_job/issues/1580)
|
|
@@ -1919,7 +1975,6 @@
|
|
|
1919
1975
|
- In tests, directly use `connection.truncate_tables` instead of `ActiveRecord::Tasks::DatabaseTasks.truncate_all` [\#918](https://github.com/bensheldon/good_job/pull/918) ([bensheldon](https://github.com/bensheldon))
|
|
1920
1976
|
- Use `GoodJob.capsule` in CLI instead of creating a new Capsule [\#916](https://github.com/bensheldon/good_job/pull/916) ([bensheldon](https://github.com/bensheldon))
|
|
1921
1977
|
- Fix lint: missing fr and nl translations; readme whitespace [\#914](https://github.com/bensheldon/good_job/pull/914) ([bensheldon](https://github.com/bensheldon))
|
|
1922
|
-
- Switches from Chrome to Chromium to support Apple M1/Arm CPUs [\#910](https://github.com/bensheldon/good_job/pull/910) ([ckdake](https://github.com/ckdake))
|
|
1923
1978
|
- Bump erb\_lint from 0.3.1 to 0.4.0 [\#906](https://github.com/bensheldon/good_job/pull/906) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
1924
1979
|
|
|
1925
1980
|
## [v3.15.0](https://github.com/bensheldon/good_job/tree/v3.15.0) (2023-04-02)
|
data/README.md
CHANGED
|
@@ -315,7 +315,6 @@ Available configuration options are:
|
|
|
315
315
|
- `cleanup_preserved_jobs_before_seconds_ago` (integer) number of seconds to preserve jobs when using the `$ good_job cleanup_preserved_jobs` CLI command or calling `GoodJob.cleanup_preserved_jobs`. Defaults to `1209600` (14 days). Can also be set with the environment variable `GOOD_JOB_CLEANUP_PRESERVED_JOBS_BEFORE_SECONDS_AGO`.
|
|
316
316
|
- `cleanup_interval_jobs` (integer) Number of jobs a Scheduler will execute before cleaning up preserved jobs. Defaults to `1000`. Disable with `false`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_JOBS` and disabled with `0`).
|
|
317
317
|
- `cleanup_interval_seconds` (integer) Number of seconds a Scheduler will wait before cleaning up preserved jobs. Defaults to `600` (10 minutes). Disable with `false`. Can also be set with the environment variable `GOOD_JOB_CLEANUP_INTERVAL_SECONDS` and disabled with `0`).
|
|
318
|
-
- `inline_execution_respects_schedule` (boolean) Opt-in to future behavior of inline execution respecting scheduled jobs. Defaults to `false`.
|
|
319
318
|
- `logger` ([Rails Logger](https://api.rubyonrails.org/classes/ActiveSupport/Logger.html)) lets you set a custom logger for GoodJob. It should be an instance of a Rails `Logger` (Default: `Rails.logger`).
|
|
320
319
|
- `preserve_job_records` (boolean, symbol, or lambda) keeps job records in your database even after jobs are completed. If set to `true`, all job records are preserved. If set to `:on_unhandled_error`, only jobs that finished with an unhandled error are preserved. If set to a lambda, the lambda will be called with the error_event (e.g., `:discarded`, `:retry_stopped`, or `:unhandled`) and should return a boolean indicating whether to preserve the job. (Default: `true`)
|
|
321
320
|
- `advisory_lock_heartbeat` (boolean) whether to use an advisory lock for the purpose of determining whether an execeution process is active. (Default `true` in Development; `false` in other environments)
|
|
@@ -339,6 +338,9 @@ Available configuration options are:
|
|
|
339
338
|
```
|
|
340
339
|
|
|
341
340
|
- `enable_pauses` (boolean) whether job processing can be paused. Defaults to `false`. You can also set this with the environment variable `GOOD_JOB_ENABLE_PAUSES`.
|
|
341
|
+
- `dequeue_query_sort` (symbol) sets the sort order used when querying for the next job(s) to execute. Defaults to `:created_at`. It can be any one of:
|
|
342
|
+
- `:created_at` sorts by priority, then job creation order. This is the default, but no longer best matches GoodJob's contemporary data model.
|
|
343
|
+
- `:scheduled_at` sorts by priority, then `scheduled_at`, then `id`, which better matches GoodJob's contemporary data model. This will become the default/only behavior in a future major release.
|
|
342
344
|
|
|
343
345
|
By default, GoodJob configures the following execution modes per environment:
|
|
344
346
|
|
|
@@ -1505,9 +1507,7 @@ It is also possible to manually trigger a cleanup of preserved job records:
|
|
|
1505
1507
|
|
|
1506
1508
|
By default, GoodJob uses its inline adapter in the test environment; the inline adapter is designed for the test environment. When enqueuing a job with GoodJob's inline adapter, the job will be executed immediately on the current thread; unhandled exceptions will be raised.
|
|
1507
1509
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
To opt into this behavior immediately set: `config.good_job.inline_execution_respects_schedule = true`
|
|
1510
|
+
The inline adapter respects scheduled jobs: jobs scheduled for the future are enqueued in the database rather than executed immediately.
|
|
1511
1511
|
|
|
1512
1512
|
To perform jobs inline at any time, use `GoodJob.perform_inline`. For example, using time helpers within an integration test:
|
|
1513
1513
|
|
|
@@ -207,6 +207,7 @@ module GoodJob
|
|
|
207
207
|
end
|
|
208
208
|
|
|
209
209
|
ADVISORY_LOCK_COUNTS = AdvisoryLockCounter.new
|
|
210
|
+
AREL_TABLE_NEW_KWARGS = Arel::Table.instance_method(:initialize).parameters.any? { |type, name| type == :key && name == :name }
|
|
210
211
|
|
|
211
212
|
included do
|
|
212
213
|
# Default column to be used when creating Advisory Locks
|
|
@@ -224,10 +225,10 @@ module GoodJob
|
|
|
224
225
|
unless respond_to?(:adapter_class)
|
|
225
226
|
define_singleton_method(:adapter_class) do
|
|
226
227
|
@_adapter_class ||= begin
|
|
227
|
-
|
|
228
|
+
klass = self
|
|
228
229
|
proxy = Object.new
|
|
229
|
-
proxy.define_singleton_method(:quote_table_name) { |name|
|
|
230
|
-
proxy.define_singleton_method(:quote_column_name) { |name|
|
|
230
|
+
proxy.define_singleton_method(:quote_table_name) { |name| klass.connection_pool.with_connection { |c| c.quote_table_name(name) } }
|
|
231
|
+
proxy.define_singleton_method(:quote_column_name) { |name| klass.connection_pool.with_connection { |c| c.quote_column_name(name) } }
|
|
231
232
|
proxy
|
|
232
233
|
end
|
|
233
234
|
end
|
|
@@ -357,7 +358,7 @@ module GoodJob
|
|
|
357
358
|
primary_key_for_select = primary_key.to_sym
|
|
358
359
|
column_for_select = column.to_sym
|
|
359
360
|
|
|
360
|
-
cte_table =
|
|
361
|
+
cte_table = arel_table_for(:rows)
|
|
361
362
|
cte_query = original_query.except(:limit)
|
|
362
363
|
cte_query = if primary_key_for_select == column_for_select
|
|
363
364
|
cte_query.select(primary_key_for_select)
|
|
@@ -485,6 +486,13 @@ module GoodJob
|
|
|
485
486
|
|
|
486
487
|
private
|
|
487
488
|
|
|
489
|
+
# Arel::Table.new has different parameters depending on Rails version.
|
|
490
|
+
# New version expects keyword arguments for the name while the old version expects a positional argument.
|
|
491
|
+
# This method creates a new Arel::Table instance with the correct parameters.
|
|
492
|
+
def arel_table_for(name)
|
|
493
|
+
AREL_TABLE_NEW_KWARGS ? Arel::Table.new(name: name) : Arel::Table.new(name)
|
|
494
|
+
end
|
|
495
|
+
|
|
488
496
|
# Executes a single pg_advisory_unlock call and updates bookkeeping.
|
|
489
497
|
# Used by {.advisory_unlock_key} and {.advisory_unlock_key!} to avoid
|
|
490
498
|
# mutual recursion when CTE-aware cleanup is needed.
|
|
@@ -197,6 +197,12 @@ module GoodJob
|
|
|
197
197
|
new _record: BatchRecord.find(id)
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
+
# Required by GlobalID::Locator.fetch/locate_many, which query with
|
|
201
|
+
# `ignore_missing: true` and thus call `.where(id: ids)` instead of `.find(id)`.
|
|
202
|
+
def self.where(id:)
|
|
203
|
+
BatchRecord.where(id: id).map { |record| new(_record: record) }
|
|
204
|
+
end
|
|
205
|
+
|
|
200
206
|
# Helper method to enqueue jobs and assign them to a batch
|
|
201
207
|
def self.within_thread(batch_id: nil, batch_callback_id: nil)
|
|
202
208
|
original_batch_id = current_batch_id
|
data/app/models/good_job/job.rb
CHANGED
|
@@ -327,8 +327,11 @@ module GoodJob
|
|
|
327
327
|
new(**enqueue_args(active_job, scheduled_at: scheduled_at))
|
|
328
328
|
end
|
|
329
329
|
|
|
330
|
-
# Construct arguments for GoodJob::
|
|
330
|
+
# Construct arguments for GoodJob::Job from an ActiveJob instance.
|
|
331
331
|
def self.enqueue_args(active_job, scheduled_at: nil)
|
|
332
|
+
reenqueued_current_job = CurrentThread.active_job_id && CurrentThread.active_job_id == active_job.job_id
|
|
333
|
+
current_job = CurrentThread.job
|
|
334
|
+
|
|
332
335
|
execution_args = {
|
|
333
336
|
id: active_job.job_id,
|
|
334
337
|
active_job_id: active_job.job_id,
|
|
@@ -336,15 +339,16 @@ module GoodJob
|
|
|
336
339
|
queue_name: active_job.queue_name.presence || DEFAULT_QUEUE_NAME,
|
|
337
340
|
priority: active_job.priority || DEFAULT_PRIORITY,
|
|
338
341
|
serialized_params: active_job.serialize,
|
|
339
|
-
created_at: Time.current,
|
|
340
342
|
}
|
|
341
343
|
|
|
344
|
+
now = Time.current
|
|
345
|
+
execution_args[:created_at] = now if !reenqueued_current_job || GoodJob.configuration.dequeue_query_sort == :created_at
|
|
342
346
|
execution_args[:scheduled_at] = if scheduled_at
|
|
343
347
|
scheduled_at
|
|
344
348
|
elsif active_job.scheduled_at
|
|
345
349
|
Time.zone.at(active_job.scheduled_at)
|
|
346
350
|
else
|
|
347
|
-
|
|
351
|
+
now
|
|
348
352
|
end
|
|
349
353
|
|
|
350
354
|
execution_args[:concurrency_key] = active_job.good_job_concurrency_key if active_job.respond_to?(:good_job_concurrency_key)
|
|
@@ -356,9 +360,6 @@ module GoodJob
|
|
|
356
360
|
execution_args[:labels] = labels
|
|
357
361
|
end
|
|
358
362
|
|
|
359
|
-
reenqueued_current_job = CurrentThread.active_job_id && CurrentThread.active_job_id == active_job.job_id
|
|
360
|
-
current_job = CurrentThread.job
|
|
361
|
-
|
|
362
363
|
if reenqueued_current_job
|
|
363
364
|
execution_args[:batch_id] = current_job.batch_id
|
|
364
365
|
execution_args[:batch_callback_id] = current_job.batch_callback_id
|
data/config/brakeman.ignore
CHANGED
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
{
|
|
67
67
|
"warning_type": "Dangerous Eval",
|
|
68
68
|
"warning_code": 13,
|
|
69
|
-
"fingerprint": "
|
|
69
|
+
"fingerprint": "c01ff32ee40cc694540aaa76e3fdab8f330babd9d6dbf2564c32aef1cfd877fa",
|
|
70
70
|
"check_name": "Evaluation",
|
|
71
71
|
"message": "Dynamic string evaluated as code",
|
|
72
72
|
"file": "lib/good_job/log_subscriber.rb",
|
|
73
|
-
"line":
|
|
73
|
+
"line": 278,
|
|
74
74
|
"link": "https://brakemanscanner.org/docs/warning_types/dangerous_eval/",
|
|
75
|
-
"code": "class_eval(\" def #{level}(progname = nil, tags: [], &block) # def info(progname = nil, tags: [], &block)\\n return unless logger # return unless logger\\n #\\n tag_logger(*tags) do # tag_logger(*tags) do\\n logger.#{level}(progname, &block) # logger.info(progname, &block)\\n end # end\\n end #\\n\", \"lib/good_job/log_subscriber.rb\", (
|
|
75
|
+
"code": "class_eval(\" def #{level}(progname = nil, tags: [], &block) # def info(progname = nil, tags: [], &block)\\n return unless logger # return unless logger\\n #\\n tag_logger(*tags) do # tag_logger(*tags) do\\n logger.#{level}(progname, &block) # logger.info(progname, &block)\\n end # end\\n end #\\n\", \"lib/good_job/log_subscriber.rb\", (278 + 1))",
|
|
76
76
|
"render_path": null,
|
|
77
77
|
"location": {
|
|
78
78
|
"type": "method",
|
|
@@ -120,7 +120,10 @@ module GoodJob
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
if (enqueue_concurrency + 1) > limit
|
|
123
|
-
|
|
123
|
+
ActiveSupport::Notifications.instrument(
|
|
124
|
+
"enqueue_concurrency_limit_exceeded.good_job",
|
|
125
|
+
{ job: job, key: key, limit: limit }
|
|
126
|
+
)
|
|
124
127
|
exceeded = :limit
|
|
125
128
|
next
|
|
126
129
|
end
|
|
@@ -134,7 +137,10 @@ module GoodJob
|
|
|
134
137
|
.count
|
|
135
138
|
|
|
136
139
|
if (enqueued_within_period + 1) > throttle_limit
|
|
137
|
-
|
|
140
|
+
ActiveSupport::Notifications.instrument(
|
|
141
|
+
"enqueue_concurrency_throttle_exceeded.good_job",
|
|
142
|
+
{ job: job, key: key, limit: throttle_limit }
|
|
143
|
+
)
|
|
138
144
|
exceeded = :throttle
|
|
139
145
|
next
|
|
140
146
|
end
|
|
@@ -177,10 +177,6 @@ module GoodJob
|
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
179
|
|
|
180
|
-
def inline_execution_respects_schedule?
|
|
181
|
-
!!rails_config[:inline_execution_respects_schedule]
|
|
182
|
-
end
|
|
183
|
-
|
|
184
180
|
# The maximum number of future-scheduled jobs to store in memory.
|
|
185
181
|
# Storing future-scheduled jobs in memory reduces execution latency
|
|
186
182
|
# at the cost of increased memory usage. 10,000 stored jobs = ~20MB.
|
|
@@ -439,6 +435,7 @@ module GoodJob
|
|
|
439
435
|
Rails.env.development?
|
|
440
436
|
end
|
|
441
437
|
|
|
438
|
+
# TODO: Remove :created_at and this option entirely in the next major version; :scheduled_at will become the only behavior.
|
|
442
439
|
def dequeue_query_sort
|
|
443
440
|
(options[:dequeue_query_sort] || rails_config[:dequeue_query_sort] || :created_at).to_sym
|
|
444
441
|
end
|
|
@@ -153,6 +153,28 @@ module GoodJob
|
|
|
153
153
|
end
|
|
154
154
|
end
|
|
155
155
|
|
|
156
|
+
# @!macro notification_responder
|
|
157
|
+
def enqueue_concurrency_limit_exceeded(event)
|
|
158
|
+
job = event.payload[:job]
|
|
159
|
+
key = event.payload[:key]
|
|
160
|
+
limit = event.payload[:limit]
|
|
161
|
+
|
|
162
|
+
info do
|
|
163
|
+
"Aborted enqueue of #{job.class.name} (Job ID: #{job.job_id}) because the concurrency key '#{key}' has reached its enqueue limit of #{limit} #{'job'.pluralize(limit)}"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @!macro notification_responder
|
|
168
|
+
def enqueue_concurrency_throttle_exceeded(event)
|
|
169
|
+
job = event.payload[:job]
|
|
170
|
+
key = event.payload[:key]
|
|
171
|
+
limit = event.payload[:limit]
|
|
172
|
+
|
|
173
|
+
info do
|
|
174
|
+
"Aborted enqueue of #{job.class.name} (Job ID: #{job.job_id}) because the concurrency key '#{key}' has reached its throttle limit of #{limit} #{'job'.pluralize(limit)}"
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
156
178
|
# @!macro notification_responder
|
|
157
179
|
def systemd_watchdog_start(event)
|
|
158
180
|
interval = event.payload[:interval]
|
data/lib/good_job/version.rb
CHANGED