sidekiq-unique-jobs 7.1.8 → 7.1.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0525a9235a69f86ef177c23a54afea5977a4a99fe4c09867d88c88d29eeb280
4
- data.tar.gz: f105453b5082cb2a37ff2484e8c92213ec578a488b5f97f894b7f06e901aca23
3
+ metadata.gz: bd2a8c713ad1593ff340793f2cbd1d07427bbb239d3efd4cc810489f99801e8b
4
+ data.tar.gz: e33006dc4b63292e1e8cf7576d7c80d59ee077dfea852d6dbb7230afa52ed116
5
5
  SHA512:
6
- metadata.gz: 24eeed23d326f74ebf0c06d34913c8429d1ce7848bdb384606176bf8362ae74f8e1a3dbd0cffad10fbdac1344fe7a1170804e332f5974713c890f6fb330fae91
7
- data.tar.gz: 61ce06ebeb3b49f25dbb3ffb12cfe90f164e9c668756e47b81d527181f66e27a07dc836f5230bb1949ca94429c59bdfe2fa7bc13c3dbac3a53ebe1feb2257080
6
+ metadata.gz: e0a410cd505b3ccf292ded829328fa78f7250f42a350709e88d220f2ce5ec73e7f93d7c6c6adaab7fc0ffb0c28314e3ba3ce6b6e96c02918c9a6f2d908cf31d0
7
+ data.tar.gz: 6fbbb12c4db8a91a29c5baf6cc96b208576074744d417649191b26bccc7b8069ceeddd178ecf864c5028fc35744700c7ffdf621f0a2cc8669d79c4f675a1ac54
data/CHANGELOG.md CHANGED
@@ -1,5 +1,60 @@
1
1
  # Changelog
2
2
 
3
+ ## [v7.1.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.12) (2021-12-01)
4
+
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.11...v7.1.12)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Improve Ruby Reaper performance under heavy load [\#663](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/663)
10
+ - Improve reaper performance under heavy load [\#666](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/666) ([mhenrixon](https://github.com/mhenrixon))
11
+
12
+ ## [v7.1.11](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.11) (2021-11-30)
13
+
14
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.10...v7.1.11)
15
+
16
+ **Fixed bugs:**
17
+
18
+ - Fix ruby reaper edge case [\#661](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/661) ([mhenrixon](https://github.com/mhenrixon))
19
+
20
+ **Closed issues:**
21
+
22
+ - Question: Wait instead of cancelling if it is executing? [\#655](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/655)
23
+ - Expired Locks remain in zset of digests \[using "until\_expired" lock\] [\#653](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/653)
24
+ - \[Q&A\] Performance & Dead Locks [\#652](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/652)
25
+ - Sidekiq 6.3.0 includes Job module that clashes with sidekiq\_unique\_ext.rb class Job [\#651](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/651)
26
+
27
+ ## [v7.1.10](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.10) (2021-10-18)
28
+
29
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.8...v7.1.10)
30
+
31
+ **Fixed bugs:**
32
+
33
+ - "IndexError: string not matched" when job is replaced on client [\#635](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/635)
34
+
35
+ **Merged pull requests:**
36
+
37
+ - Update URL for Sidekiq's Enterprise unique jobs [\#648](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/648) ([jsantos](https://github.com/jsantos))
38
+
39
+ ## [v7.1.8](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.8) (2021-10-08)
40
+
41
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.13...v7.1.8)
42
+
43
+ **Fixed bugs:**
44
+
45
+ - undefined method `delete' for class `Sidekiq::Job' [\#634](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/634)
46
+ - INFO keys not persisted when job is enqueued [\#602](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/602)
47
+ - lock\_info set to true but no lock info showing up in web ui [\#589](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/589)
48
+ - Prevent too eager cleanup of lock info [\#645](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/645) ([mhenrixon](https://github.com/mhenrixon))
49
+
50
+ **Closed issues:**
51
+
52
+ - Compatibility with unreleased Sidekiq 6.3.0 [\#636](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/636)
53
+
54
+ **Merged pull requests:**
55
+
56
+ - Update docs [\#644](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/644) ([andypple](https://github.com/andypple))
57
+
3
58
  ## [v7.0.13](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.13) (2021-09-27)
4
59
 
5
60
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.7...v7.0.13)
data/README.md CHANGED
@@ -599,7 +599,7 @@ Expected BadWorker to have valid sidekiq options but found the following problem
599
599
  If you are not using RSpec (a lot of people prefer minitest or test unit) you can do something like:
600
600
 
601
601
  ```ruby
602
- assert SidekiqUniqueJobs.validate_worker!(BadWorker.get_sidekiq_options)
602
+ assert_raise(InvalidWorker){ SidekiqUniqueJobs.validate_worker!(BadWorker.get_sidekiq_options) }
603
603
  ```
604
604
 
605
605
  ### Uniqueness
@@ -1043,7 +1043,7 @@ There is a [![Join the chat at https://gitter.im/mhenrixon/sidekiq-unique-jobs](
1043
1043
 
1044
1044
  You can find a list of contributors over on [Contributors][]
1045
1045
 
1046
- [Enterprise unique jobs]: https://www.dailydrip.com/topics/sidekiq/drips/sidekiq-enterprise-unique-jobs
1046
+ [Enterprise unique jobs]: https://github.com/mperham/sidekiq/wiki/Ent-Unique-Jobs
1047
1047
  [Contributors]: https://github.com/mhenrixon/sidekiq-unique-jobs/graphs/contributors
1048
1048
  [v4.0.18]: https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.18
1049
1049
  [v5.0.10]: https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v5.0.10.
@@ -62,9 +62,9 @@ module SidekiqUniqueJobs
62
62
  #
63
63
  def page(cursor: 0, pattern: "*", page_size: 100)
64
64
  redis do |conn|
65
- total_size, result = conn.multi do
66
- conn.zcard(key)
67
- conn.zscan(key, cursor, match: pattern, count: page_size)
65
+ total_size, result = conn.multi do |pipeline|
66
+ pipeline.zcard(key)
67
+ pipeline.zscan(key, cursor, match: pattern, count: page_size)
68
68
  end
69
69
 
70
70
  [
@@ -95,9 +95,9 @@ module SidekiqUniqueJobs
95
95
  #
96
96
  def page(cursor: 0, pattern: SCAN_PATTERN, page_size: 100)
97
97
  redis do |conn|
98
- total_size, digests = conn.multi do
99
- conn.zcard(key)
100
- conn.zscan(key, cursor, match: pattern, count: page_size)
98
+ total_size, digests = conn.multi do |pipeline|
99
+ pipeline.zcard(key)
100
+ pipeline.zscan(key, cursor, match: pattern, count: page_size)
101
101
  end
102
102
 
103
103
  [
@@ -62,13 +62,13 @@ module SidekiqUniqueJobs
62
62
  #
63
63
  def lock(job_id, lock_info = {})
64
64
  redis do |conn|
65
- conn.multi do
66
- conn.set(key.digest, job_id)
67
- conn.hset(key.locked, job_id, now_f)
65
+ conn.multi do |pipeline|
66
+ pipeline.set(key.digest, job_id)
67
+ pipeline.hset(key.locked, job_id, now_f)
68
68
  info.set(lock_info)
69
- conn.zadd(key.digests, now_f, key.digest)
70
- conn.zadd(key.changelog, now_f, changelog_json(job_id, "queue.lua", "Queued"))
71
- conn.zadd(key.changelog, now_f, changelog_json(job_id, "lock.lua", "Locked"))
69
+ pipeline.zadd(key.digests, now_f, key.digest)
70
+ pipeline.zadd(key.changelog, now_f, changelog_json(job_id, "queue.lua", "Queued"))
71
+ pipeline.zadd(key.changelog, now_f, changelog_json(job_id, "lock.lua", "Locked"))
72
72
  end
73
73
  end
74
74
  end
@@ -65,18 +65,12 @@ redis.call("LREM", queued, -1, job_id)
65
65
  log_debug("LREM", primed, -1, job_id)
66
66
  redis.call("LREM", primed, -1, job_id)
67
67
 
68
- if limit and limit <= 1 and locked_count and locked_count <= 1 then
69
- log_debug("ZREM", digests, digest)
70
- redis.call("ZREM", digests, digest)
71
- end
72
-
73
68
  local redis_version = toversion(redisversion)
74
69
  local del_cmd = "DEL"
75
70
 
76
71
  if tonumber(redis_version["major"]) >= 4 then del_cmd = "UNLINK"; end
77
72
 
78
73
  if lock_type ~= "until_expired" then
79
-
80
74
  log_debug(del_cmd, digest, info)
81
75
  redis.call(del_cmd, digest, info)
82
76
 
@@ -86,11 +80,16 @@ end
86
80
 
87
81
  local locked_count = redis.call("HLEN", locked)
88
82
 
89
- if tonumber(locked_count) < 1 then
83
+ if locked_count and locked_count < 1 then
90
84
  log_debug(del_cmd, locked)
91
85
  redis.call(del_cmd, locked)
92
86
  end
93
87
 
88
+ if limit and limit <= 1 and locked_count and locked_count <= 1 then
89
+ log_debug("ZREM", digests, digest)
90
+ redis.call("ZREM", digests, digest)
91
+ end
92
+
94
93
  log_debug("LPUSH", queued, "1")
95
94
  redis.call("LPUSH", queued, "1")
96
95
 
@@ -9,6 +9,7 @@ module SidekiqUniqueJobs
9
9
  #
10
10
  # @author Mikael Henriksson <mikael@mhenrixon.com>
11
11
  #
12
+ # rubocop:disable Metrics/ClassLength
12
13
  class RubyReaper < Reaper
13
14
  #
14
15
  # @return [String] the suffix for :RUN locks
@@ -54,13 +55,27 @@ module SidekiqUniqueJobs
54
55
  #
55
56
  # @return [Array<String>] an array of orphaned digests
56
57
  #
57
- def orphans
58
- conn.zrevrange(digests.key, 0, -1).each_with_object([]) do |digest, memo|
59
- next if belongs_to_job?(digest)
58
+ def orphans # rubocop:disable Metrics/MethodLength
59
+ page = 0
60
+ per = reaper_count * 2
61
+ orphans = []
62
+ results = conn.zrange(digests.key, page * per, (page + 1) * per)
60
63
 
61
- memo << digest
62
- break if memo.size >= reaper_count
64
+ while results.size.positive?
65
+ results.each do |digest|
66
+ next if belongs_to_job?(digest)
67
+
68
+ orphans << digest
69
+ break if orphans.size >= reaper_count
70
+ end
71
+
72
+ break if orphans.size >= reaper_count
73
+
74
+ page += 1
75
+ results = conn.zrange(digests.key, page * per, (page + 1) * per)
63
76
  end
77
+
78
+ orphans
64
79
  end
65
80
 
66
81
  #
@@ -211,5 +226,6 @@ module SidekiqUniqueJobs
211
226
  conn.zscan_each(key, match: "*#{digest}*", count: 1).to_a.any?
212
227
  end
213
228
  end
229
+ # rubocop:enable Metrics/ClassLength
214
230
  end
215
231
  end
@@ -68,7 +68,7 @@ module Sidekiq
68
68
  prepend UniqueExtension
69
69
  end
70
70
 
71
- if Sidekiq.const_defined?("JobRecord")
71
+ if Sidekiq.const_defined?(:JobRecord)
72
72
  # See Sidekiq::Api
73
73
  class JobRecord
74
74
  #
@@ -34,12 +34,22 @@ module SidekiqUniqueJobs
34
34
 
35
35
  # The hook to call after a successful unlock
36
36
  # @return [Proc]
37
- def after_unlock_hook
37
+ def after_unlock_hook # rubocop:disable Metrics/MethodLength
38
38
  lambda do
39
39
  if @worker_class.respond_to?(:after_unlock)
40
- @worker_class.after_unlock # instance method in sidekiq v6
40
+ # instance method in sidekiq v6
41
+ if @worker_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
42
+ @worker_class.after_unlock(item)
43
+ else
44
+ @worker_class.after_unlock
45
+ end
41
46
  elsif worker_class.respond_to?(:after_unlock)
42
- worker_class.after_unlock # class method regardless of sidekiq version
47
+ # class method regardless of sidekiq version
48
+ if worker_class.method(:after_unlock).arity.positive? # arity check to maintain backwards compatibility
49
+ worker_class.after_unlock(item)
50
+ else
51
+ worker_class.after_unlock
52
+ end
43
53
  end
44
54
  end
45
55
  end
@@ -48,7 +48,7 @@ module SidekiqUniqueJobs
48
48
  # @return [Float]
49
49
  #
50
50
  def clock_stamp
51
- if Process.const_defined?("CLOCK_MONOTONIC")
51
+ if Process.const_defined?(:CLOCK_MONOTONIC)
52
52
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
53
53
  else
54
54
  now_f
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.1.8"
6
+ VERSION = "7.1.13"
7
7
  end
@@ -27,7 +27,7 @@ module SidekiqUniqueJobs
27
27
  # @return [String] the file contents of the template
28
28
  #
29
29
  def unique_template(name)
30
- File.open(unique_filename(name)).read
30
+ File.read(unique_filename(name))
31
31
  end
32
32
 
33
33
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.8
4
+ version: 7.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-08 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script
@@ -211,15 +211,11 @@ files:
211
211
  - lib/sidekiq_unique_jobs/web/views/lock.erb
212
212
  - lib/sidekiq_unique_jobs/web/views/locks.erb
213
213
  - lib/tasks/changelog.rake
214
- homepage: https://mhenrixon.github.io/sidekiq-unique-jobs
214
+ homepage: https://github.com/mhenrixon/sidekiq-unique-jobs
215
215
  licenses:
216
216
  - MIT
217
217
  metadata:
218
- homepage_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
219
- bug_tracker_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/issues
220
- documentation_uri: https://mhenrixon.github.io/sidekiq-unique-jobs
221
- source_code_uri: https://github.com/mhenrixon/sidekiq-unique-jobs
222
- changelog_uri: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/master/CHANGELOG.md
218
+ rubygems_mfa_required: 'true'
223
219
  post_install_message: |
224
220
  IMPORTANT!
225
221
 
@@ -261,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
257
  - !ruby/object:Gem::Version
262
258
  version: '0'
263
259
  requirements: []
264
- rubygems_version: 3.2.28
260
+ rubygems_version: 3.3.4
265
261
  signing_key:
266
262
  specification_version: 4
267
263
  summary: Sidekiq middleware that prevents duplicates jobs