good_job 1.12.1 → 1.12.2

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: 5b4629010561604c4f1d77812c3ca7301e5600fa8e0637fd584a769898d43aa5
4
- data.tar.gz: 1216b9d590c40c047fa25c13afec94021891752bab8ec36ff7f6c968af8e285e
3
+ metadata.gz: 0af2c2293c2a0970a95ac200776850daa396a91d75aeda3f4612de23ee951a5c
4
+ data.tar.gz: c938c0efca849771e68b39634e56fbdacf2987a83bdf8115e8050b9c49da40c3
5
5
  SHA512:
6
- metadata.gz: ef51328facf01deeec6a2e67c38c526c944d1c7381fa45cf97f7f05aa4897ac711c324f616e8d948c3c5e6e4e5fae636ea2c7c3c9d48d79de0ead78ed438580f
7
- data.tar.gz: e4efa15858ac7a6c0849ec084a00de8fbb8f6751523e78c9234b118bee2c84f3709c549cfc1f161af5166b2d54ff1f358b2dbd18e54adca06d6c62ad10757827
6
+ metadata.gz: 3b4da4eec468271fc88260fc0abcdb6faaaa9e43532e5587338fdca0a4f92f89d4e4f780678fe2c74a714adb0e7a1af263fb0578193382ee8181e11c44aea20d
7
+ data.tar.gz: 91f4ae034471774f5ec1915750ccbf1d9d6ad9cc68df4f5ffa4c0bf6bca57928115e6871a59d30d6bab79b22faa7a4a293d55f55c1bf2cc659d55c0c60049040
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [v1.12.2](https://github.com/bensheldon/good_job/tree/v1.12.2) (2021-08-13)
4
+
5
+ [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.12.1...v1.12.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Fixes for race conditions in ActiveJob concurrency extension [\#326](https://github.com/bensheldon/good_job/pull/326) ([codyrobbins](https://github.com/codyrobbins))
10
+
11
+ **Merged pull requests:**
12
+
13
+ - On gem release, add instructions to author a Github Release [\#324](https://github.com/bensheldon/good_job/pull/324) ([bensheldon](https://github.com/bensheldon))
14
+
3
15
  ## [v1.12.1](https://github.com/bensheldon/good_job/tree/v1.12.1) (2021-08-05)
4
16
 
5
17
  [Full Changelog](https://github.com/bensheldon/good_job/compare/v1.12.0...v1.12.1)
@@ -29,7 +41,7 @@
29
41
  - Add the ability to schedule repeating / recurring / cron-like jobs [\#53](https://github.com/bensheldon/good_job/issues/53)
30
42
  - Add cron-like support for recurring/repeating jobs [\#297](https://github.com/bensheldon/good_job/pull/297) ([bensheldon](https://github.com/bensheldon))
31
43
 
32
- **Merged pull requests:**
44
+ **Fixed bugs:**
33
45
 
34
46
  - Place Dashboard shared view partials under `good_job` namespace [\#310](https://github.com/bensheldon/good_job/pull/310) ([bensheldon](https://github.com/bensheldon))
35
47
  - Ensure Dashboard inline javascript has CSP nonce for strict Content-Security Policy [\#309](https://github.com/bensheldon/good_job/pull/309) ([bensheldon](https://github.com/bensheldon))
@@ -9,21 +9,21 @@ module GoodJob
9
9
  included do
10
10
  class_attribute :good_job_concurrency_config, instance_accessor: false, default: {}
11
11
 
12
- before_enqueue do |job|
12
+ around_enqueue do |job, block|
13
13
  # Always allow jobs to be retried because the current job's execution will complete momentarily
14
- next if CurrentExecution.active_job_id == job.job_id
14
+ next(block.call) if CurrentExecution.active_job_id == job.job_id
15
15
 
16
16
  limit = job.class.good_job_concurrency_config.fetch(:enqueue_limit, Float::INFINITY)
17
- next if limit.blank? || (0...Float::INFINITY).exclude?(limit)
17
+ next(block.call) if limit.blank? || (0...Float::INFINITY).exclude?(limit)
18
18
 
19
19
  key = job.good_job_concurrency_key
20
- next if key.blank?
20
+ next(block.call) if key.blank?
21
21
 
22
22
  GoodJob::Job.new.with_advisory_lock(key: key, function: "pg_advisory_lock") do
23
23
  # TODO: Why is `unscoped` necessary? Nested scope is bleeding into subsequent query?
24
24
  enqueue_concurrency = GoodJob::Job.unscoped.where(concurrency_key: key).unfinished.count
25
25
  # The job has not yet been enqueued, so check if adding it will go over the limit
26
- throw :abort if enqueue_concurrency + 1 > limit
26
+ block.call unless enqueue_concurrency + 1 > limit
27
27
  end
28
28
  end
29
29
 
@@ -41,9 +41,9 @@ module GoodJob
41
41
  next if key.blank?
42
42
 
43
43
  GoodJob::Job.new.with_advisory_lock(key: key, function: "pg_advisory_lock") do
44
- perform_concurrency = GoodJob::Job.unscoped.where(concurrency_key: key).advisory_locked.count
44
+ allowed_active_job_ids = GoodJob::Job.unscoped.where(concurrency_key: key).advisory_locked.order(Arel.sql("COALESCE(performed_at, scheduled_at, created_at) ASC")).limit(limit).pluck(:active_job_id)
45
45
  # The current job has already been locked and will appear in the previous query
46
- raise GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError if perform_concurrency > limit
46
+ raise GoodJob::ActiveJobExtensions::Concurrency::ConcurrencyExceededError unless allowed_active_job_ids.include? job.job_id
47
47
  end
48
48
  end
49
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module GoodJob
3
3
  # GoodJob gem version.
4
- VERSION = '1.12.1'
4
+ VERSION = '1.12.2'
5
5
  end
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: 1.12.1
4
+ version: 1.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Sheldon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-05 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob