sidekiq-unique-jobs 7.1.11 → 7.1.15

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: b360fae82f2428f0a6c2d390b6320291bc34da86cb6670e858d902ea111751cc
4
- data.tar.gz: c9668d930a39b39635317451a21bd560bb971aa2eecfad6f6aeabbc5559cda1d
3
+ metadata.gz: 05fc5a66be1f5117707cf5409bfbd37c7b22677a7035f8a9377fc89a949b85f1
4
+ data.tar.gz: 5e7f255449d07dbc0758ffc315b7b22442132bb053cedbdf25a0253ea4c5a59f
5
5
  SHA512:
6
- metadata.gz: 60540d8412247eae7dc99328eb77a79ad18dccc4fe83345b4abfb1bf4e3aa4e9fe713a49b6c2adaa5b081122471d95e88898cf19f5c97914a84f04fdfa259a11
7
- data.tar.gz: c5c5c92b36675ce1567cbbba76839ba9466ac03fdd53000947d611f9f8a3a68df6cafca6909d947c3c367839014cdc61e5fd8a45c7f5c3e5ac114a811aa69828
6
+ metadata.gz: 3554b3ca12ea3dd79d6c6fced007e6cb8fd40a0314a7edeecae397f3da4bb1fd276f48bbb84c16f9f99c1d915b2780595547232a6fdc20d6b0cf559c82acc6c3
7
+ data.tar.gz: 169ee0a9a4809904e9a74957479a0a4f08e2f5d9f464d3e137a4eb2a2796eda3ea64a298f7e9b7a3c49d83d2b86a5df8c10848b4cfe74745828fd7166d5f9d79
data/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## [v7.1.14](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.14) (2022-02-04)
4
+
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.13...v7.1.14)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Fix the remaining deprecation warnings [\#681](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/681) ([mhenrixon](https://github.com/mhenrixon))
10
+
11
+ ## [v7.1.13](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.13) (2022-02-03)
12
+
13
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.12...v7.1.13)
14
+
15
+ **Implemented enhancements:**
16
+
17
+ - Prepare for redis 5.0.0 [\#680](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/680) ([mhenrixon](https://github.com/mhenrixon))
18
+
19
+ **Fixed bugs:**
20
+
21
+ - Fix homepage url [\#667](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/667) ([dal-ioki](https://github.com/dal-ioki))
22
+
23
+ **Closed issues:**
24
+
25
+ - Job finished, but lock is not cleared [\#677](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/677)
26
+ - sidekiq\_options lock conflicts with sidekiq-lock gem lock option [\#669](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/669)
27
+ - Slow evalsha causing timeouts [\#668](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/668)
28
+ - Inconsistent documentation for config validation [\#647](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/647)
29
+
30
+ **Merged pull requests:**
31
+
32
+ - Bump bundler and friends [\#674](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/674) ([mhenrixon](https://github.com/mhenrixon))
33
+ - readme: fix minitest assertion. [\#672](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/672) ([crondaemon](https://github.com/crondaemon))
34
+ - Pass `item` in `after_unlock` callback [\#665](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/665) ([piloos](https://github.com/piloos))
35
+
36
+ ## [v7.1.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.12) (2021-12-01)
37
+
38
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.11...v7.1.12)
39
+
40
+ **Implemented enhancements:**
41
+
42
+ - Improve Ruby Reaper performance under heavy load [\#663](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/663)
43
+ - Improve reaper performance under heavy load [\#666](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/666) ([mhenrixon](https://github.com/mhenrixon))
44
+
45
+ ## [v7.1.11](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.11) (2021-11-30)
46
+
47
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.10...v7.1.11)
48
+
49
+ **Fixed bugs:**
50
+
51
+ - Fix ruby reaper edge case [\#661](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/661) ([mhenrixon](https://github.com/mhenrixon))
52
+
53
+ **Closed issues:**
54
+
55
+ - Question: Wait instead of cancelling if it is executing? [\#655](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/655)
56
+ - Expired Locks remain in zset of digests \[using "until\_expired" lock\] [\#653](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/653)
57
+ - \[Q&A\] Performance & Dead Locks [\#652](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/652)
58
+ - 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)
59
+
60
+ ## [v7.1.10](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.10) (2021-10-18)
61
+
62
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.1.8...v7.1.10)
63
+
64
+ **Fixed bugs:**
65
+
66
+ - "IndexError: string not matched" when job is replaced on client [\#635](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/635)
67
+
68
+ **Merged pull requests:**
69
+
70
+ - Update URL for Sidekiq's Enterprise unique jobs [\#648](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/648) ([jsantos](https://github.com/jsantos))
71
+
3
72
  ## [v7.1.8](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.1.8) (2021-10-08)
4
73
 
5
74
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.13...v7.1.8)
@@ -109,7 +178,7 @@
109
178
  **Implemented enhancements:**
110
179
 
111
180
  - Reflections [\#611](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/611) ([mhenrixon](https://github.com/mhenrixon))
112
- - Start new orphan reaper process if orphan reaper is not running [\#604](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/604) ([Assa1121](https://github.com/Assa1121))
181
+ - Start new orphan reaper process if orphan reaper is not running [\#604](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/604) ([AlexFlint73](https://github.com/AlexFlint73))
113
182
 
114
183
  **Fixed bugs:**
115
184
 
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
@@ -87,10 +87,10 @@ module SidekiqUniqueJobs
87
87
  #
88
88
  def batch_delete(conn)
89
89
  digests.each_slice(BATCH_SIZE) do |chunk|
90
- conn.pipelined do
90
+ conn.pipelined do |pipeline|
91
91
  chunk.each do |digest|
92
- del_digest(conn, digest)
93
- conn.zrem(SidekiqUniqueJobs::DIGESTS, digest)
92
+ del_digest(pipeline, digest)
93
+ pipeline.zrem(SidekiqUniqueJobs::DIGESTS, digest)
94
94
  @count += 1
95
95
  end
96
96
  end
@@ -99,13 +99,13 @@ module SidekiqUniqueJobs
99
99
  @count
100
100
  end
101
101
 
102
- def del_digest(conn, digest)
102
+ def del_digest(pipeline, digest)
103
103
  removable_keys = keys_for_digest(digest)
104
104
 
105
105
  if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
106
- conn.unlink(*removable_keys)
106
+ pipeline.unlink(*removable_keys)
107
107
  else
108
- conn.del(*removable_keys)
108
+ pipeline.del(*removable_keys)
109
109
  end
110
110
  end
111
111
 
@@ -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)
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"))
65
+ conn.multi do |pipeline|
66
+ pipeline.set(key.digest, job_id)
67
+ pipeline.hset(key.locked, job_id, now_f)
68
+ info.set(lock_info, pipeline)
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
@@ -123,9 +123,9 @@ module SidekiqUniqueJobs
123
123
  #
124
124
  def del
125
125
  redis do |conn|
126
- conn.multi do
127
- conn.zrem(DIGESTS, key.digest)
128
- conn.del(key.digest, key.queued, key.primed, key.locked, key.info)
126
+ conn.multi do |pipeline|
127
+ pipeline.zrem(DIGESTS, key.digest)
128
+ pipeline.del(key.digest, key.queued, key.primed, key.locked, key.info)
129
129
  end
130
130
  end
131
131
  end
@@ -55,13 +55,13 @@ module SidekiqUniqueJobs
55
55
  #
56
56
  # @return [Hash]
57
57
  #
58
- def set(obj)
58
+ def set(obj, pipeline = nil)
59
59
  return unless SidekiqUniqueJobs.config.lock_info
60
60
  raise InvalidArgument, "argument `obj` (#{obj}) needs to be a hash" unless obj.is_a?(Hash)
61
61
 
62
62
  json = dump_json(obj)
63
63
  @value = load_json(json)
64
- super(json)
64
+ super(json, pipeline)
65
65
  value
66
66
  end
67
67
  end
@@ -96,10 +96,10 @@ module SidekiqUniqueJobs
96
96
  #
97
97
  def push_to_deadset
98
98
  redis do |conn|
99
- conn.multi do
100
- conn.zadd("dead", now_f, payload)
101
- conn.zremrangebyscore("dead", "-inf", now_f - Sidekiq::DeadSet.timeout)
102
- conn.zremrangebyrank("dead", 0, -Sidekiq::DeadSet.max_jobs)
99
+ conn.multi do |pipeline|
100
+ pipeline.zadd("dead", now_f, payload)
101
+ pipeline.zremrangebyscore("dead", "-inf", now_f - Sidekiq::DeadSet.timeout)
102
+ pipeline.zremrangebyrank("dead", 0, -Sidekiq::DeadSet.max_jobs)
103
103
  end
104
104
  end
105
105
  end
@@ -21,7 +21,7 @@ module SidekiqUniqueJobs
21
21
  # This will mess up sidekiq stats because a new job is created
22
22
  def call
23
23
  if sidekiq_worker_class?
24
- if worker_class.perform_in(5, *item[ARGS])
24
+ if worker_class.set(queue: item["queue"].to_sym).perform_in(5, *item[ARGS])
25
25
  reflect(:rescheduled, item)
26
26
  else
27
27
  reflect(:reschedule_failed, item)
@@ -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 memo 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
  #
@@ -126,14 +141,14 @@ module SidekiqUniqueJobs
126
141
  return false if procs.empty?
127
142
 
128
143
  procs.sort.each do |key|
129
- valid, workers = conn.pipelined do
144
+ valid, workers = conn.pipelined do |pipeline|
130
145
  # TODO: Remove the if statement in the future
131
- if conn.respond_to?(:exists?)
132
- conn.exists?(key)
146
+ if pipeline.respond_to?(:exists?)
147
+ pipeline.exists?(key)
133
148
  else
134
- conn.exists(key)
149
+ pipeline.exists(key)
135
150
  end
136
- conn.hgetall("#{key}:workers")
151
+ pipeline.hgetall("#{key}:workers")
137
152
  end
138
153
 
139
154
  next unless valid
@@ -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
@@ -25,7 +25,9 @@ module SidekiqUniqueJobs
25
25
  #
26
26
  # @return [true, false]
27
27
  #
28
- def set(obj)
28
+ def set(obj, pipeline = nil)
29
+ return pipeline.set(key, obj) if pipeline
30
+
29
31
  redis { |conn| conn.set(key, obj) }
30
32
  end
31
33
 
@@ -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
@@ -87,9 +87,9 @@ module SidekiqUniqueJobs
87
87
  digest = grabbed_key.gsub(":GRABBED", "")
88
88
  locks = conn.hgetall(grabbed_key)
89
89
 
90
- conn.pipelined do
91
- conn.hmset(locked_key, *locks.to_a)
92
- conn.zadd(DIGESTS, locks.values.first, digest)
90
+ conn.pipelined do |pipeline|
91
+ pipeline.hmset(locked_key, *locks.to_a)
92
+ pipeline.zadd(DIGESTS, locks.values.first, digest)
93
93
  end
94
94
  end
95
95
 
@@ -114,11 +114,11 @@ module SidekiqUniqueJobs
114
114
  def batch_delete(*keys)
115
115
  return if keys.empty?
116
116
 
117
- conn.pipelined do
117
+ conn.pipelined do |pipeline|
118
118
  if VersionCheck.satisfied?(redis_version, ">= 4.0.0")
119
- conn.unlink(*keys)
119
+ pipeline.unlink(*keys)
120
120
  else
121
- conn.del(*keys)
121
+ pipeline.del(*keys)
122
122
  end
123
123
  end
124
124
  end
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.1.11"
6
+ VERSION = "7.1.15"
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.11
4
+ version: 7.1.15
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-11-30 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script
@@ -211,7 +211,7 @@ 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:
@@ -257,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  - !ruby/object:Gem::Version
258
258
  version: '0'
259
259
  requirements: []
260
- rubygems_version: 3.2.32
260
+ rubygems_version: 3.3.6
261
261
  signing_key:
262
262
  specification_version: 4
263
263
  summary: Sidekiq middleware that prevents duplicates jobs