sidekiq-unique-jobs 7.1.29 → 7.1.30
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 +4 -4
- data/lib/sidekiq_unique_jobs/batch_delete.rb +1 -1
- data/lib/sidekiq_unique_jobs/core_ext.rb +1 -1
- data/lib/sidekiq_unique_jobs/job.rb +5 -0
- data/lib/sidekiq_unique_jobs/lock/until_executed.rb +1 -0
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +1 -2
- data/lib/sidekiq_unique_jobs/lock_type.rb +37 -0
- data/lib/sidekiq_unique_jobs/locksmith.rb +13 -3
- data/lib/sidekiq_unique_jobs/lua/shared/_find_digest_in_process_set.lua +1 -1
- data/lib/sidekiq_unique_jobs/options_with_fallback.rb +1 -1
- data/lib/sidekiq_unique_jobs/orphans/manager.rb +2 -2
- data/lib/sidekiq_unique_jobs/orphans/ruby_reaper.rb +1 -1
- data/lib/sidekiq_unique_jobs/script/caller.rb +7 -7
- data/lib/sidekiq_unique_jobs/sidekiq_unique_jobs.rb +3 -3
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- data/lib/sidekiq_unique_jobs/web/views/lock.erb +5 -3
- data/lib/sidekiq_unique_jobs.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fec809cda45f395d8eed686c8b2ac69d59c332d04dc1a4968d66aa03b521c04
|
4
|
+
data.tar.gz: da85dc0ef4b155d3baec392d11230f7f59955ee617c1459cfaba4455e1cd4a17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df2fccd762fe81f71ce9fa20d3e413ff2b4147bac2d10f2bcfbe479d420b895fe888050f8f3f980bfeee693448c052d12e9c78b5ecd524c96277e29d4277685
|
7
|
+
data.tar.gz: c60f92fdd29a4f37f5903776108f11e0c3ea1e04c5d2462700d5ee01ad57d1cdd5b20fa725ed662f95c873663ce04d932f6c90267b0cea631095285f57324de3
|
@@ -112,7 +112,7 @@ module SidekiqUniqueJobs
|
|
112
112
|
|
113
113
|
def keys_for_digest(digest)
|
114
114
|
[digest, "#{digest}:RUN"].each_with_object([]) do |key, digest_keys|
|
115
|
-
digest_keys.
|
115
|
+
digest_keys.push(key)
|
116
116
|
digest_keys.concat(SUFFIXES.map { |suffix| "#{key}:#{suffix}" })
|
117
117
|
end
|
118
118
|
end
|
@@ -98,7 +98,7 @@ class Hash
|
|
98
98
|
def _deep_transform_keys_in_object(object, &block)
|
99
99
|
case object
|
100
100
|
when Hash
|
101
|
-
object.each_with_object(
|
101
|
+
object.each_with_object(self.class.new) do |(key, value), result|
|
102
102
|
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
|
103
103
|
end
|
104
104
|
when Array
|
@@ -11,6 +11,7 @@ module SidekiqUniqueJobs
|
|
11
11
|
# @return [Hash] the job hash
|
12
12
|
def prepare(item)
|
13
13
|
stringify_on_conflict_hash(item)
|
14
|
+
add_lock_type(item)
|
14
15
|
add_lock_timeout(item)
|
15
16
|
add_lock_ttl(item)
|
16
17
|
add_digest(item)
|
@@ -54,5 +55,9 @@ module SidekiqUniqueJobs
|
|
54
55
|
def add_lock_prefix(item)
|
55
56
|
item[LOCK_PREFIX] ||= SidekiqUniqueJobs.config.lock_prefix
|
56
57
|
end
|
58
|
+
|
59
|
+
def add_lock_type(item)
|
60
|
+
item[LOCK] ||= SidekiqUniqueJobs::LockType.call(item)
|
61
|
+
end
|
57
62
|
end
|
58
63
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SidekiqUniqueJobs
|
4
|
+
# Calculates the lock type
|
5
|
+
#
|
6
|
+
class LockType
|
7
|
+
# includes "SidekiqUniqueJobs::SidekiqWorkerMethods"
|
8
|
+
# @!parse include SidekiqUniqueJobs::SidekiqWorkerMethods
|
9
|
+
include SidekiqUniqueJobs::SidekiqWorkerMethods
|
10
|
+
|
11
|
+
#
|
12
|
+
# Computes lock type from job arguments, sidekiq_options.
|
13
|
+
#
|
14
|
+
# @return [Symbol] the lock type
|
15
|
+
# @return [NilClass] if no lock type is found.
|
16
|
+
#
|
17
|
+
def self.call(item)
|
18
|
+
new(item).call
|
19
|
+
end
|
20
|
+
|
21
|
+
# @!attribute [r] item
|
22
|
+
# @return [Hash] the Sidekiq job hash
|
23
|
+
attr_reader :item
|
24
|
+
|
25
|
+
# @param [Hash] item the Sidekiq job hash
|
26
|
+
# @option item [Symbol, nil] :lock the type of lock to use.
|
27
|
+
# @option item [String] :class the class of the sidekiq worker
|
28
|
+
def initialize(item)
|
29
|
+
@item = item
|
30
|
+
self.job_class = item[CLASS]
|
31
|
+
end
|
32
|
+
|
33
|
+
def call
|
34
|
+
item[LOCK] || job_options[LOCK] || default_job_options[LOCK]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -127,7 +127,10 @@ module SidekiqUniqueJobs
|
|
127
127
|
#
|
128
128
|
def unlock!(conn = nil)
|
129
129
|
call_script(:unlock, key.to_a, argv, conn) do |unlocked_jid|
|
130
|
-
|
130
|
+
if unlocked_jid == job_id
|
131
|
+
reflect(:debug, :unlocked, item, unlocked_jid)
|
132
|
+
reflect(:unlocked, item)
|
133
|
+
end
|
131
134
|
|
132
135
|
unlocked_jid
|
133
136
|
end
|
@@ -248,8 +251,12 @@ module SidekiqUniqueJobs
|
|
248
251
|
concurrent_timeout = add_drift(timeout)
|
249
252
|
|
250
253
|
reflect(:debug, :timeouts, item,
|
251
|
-
timeouts: {
|
254
|
+
timeouts: {
|
255
|
+
brpoplpush_timeout: brpoplpush_timeout,
|
256
|
+
concurrent_timeout: concurrent_timeout,
|
257
|
+
})
|
252
258
|
|
259
|
+
# NOTE: When debugging, change .value to .value!
|
253
260
|
primed_jid = Concurrent::Promises
|
254
261
|
.future(conn) { |red_con| pop_queued(red_con, timeout) }
|
255
262
|
.value
|
@@ -300,7 +307,10 @@ module SidekiqUniqueJobs
|
|
300
307
|
def brpoplpush(conn, wait)
|
301
308
|
# passing timeout 0 to brpoplpush causes it to block indefinitely
|
302
309
|
raise InvalidArgument, "wait must be an integer" unless wait.is_a?(Integer)
|
303
|
-
|
310
|
+
|
311
|
+
if defined?(::Redis::Namespace) && conn.instance_of?(::Redis::Namespace)
|
312
|
+
return conn.brpoplpush(key.queued, key.primed, wait)
|
313
|
+
end
|
304
314
|
|
305
315
|
if VersionCheck.satisfied?(redis_version, ">= 6.2.0") && conn.respond_to?(:blmove)
|
306
316
|
conn.blmove(key.queued, key.primed, "RIGHT", "LEFT", timeout: wait)
|
@@ -15,7 +15,7 @@ local function find_digest_in_process_set(digest, threshold)
|
|
15
15
|
log_debug("Found number of processes:", #processes, "next cursor:", next_process_cursor)
|
16
16
|
|
17
17
|
for _, process in ipairs(processes) do
|
18
|
-
local workers_key = process .. ":
|
18
|
+
local workers_key = process .. ":work"
|
19
19
|
log_debug("searching in process set:", process,
|
20
20
|
"for digest:", digest,
|
21
21
|
"cursor:", process_cursor)
|
@@ -72,7 +72,7 @@ module SidekiqUniqueJobs
|
|
72
72
|
# @return [<type>] <description>
|
73
73
|
#
|
74
74
|
def task
|
75
|
-
@task ||= default_task
|
75
|
+
@task ||= default_task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
76
76
|
end
|
77
77
|
|
78
78
|
#
|
@@ -100,7 +100,7 @@ module SidekiqUniqueJobs
|
|
100
100
|
# @return [void]
|
101
101
|
#
|
102
102
|
def task=(task)
|
103
|
-
@task = task
|
103
|
+
@task = task # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
104
104
|
end
|
105
105
|
|
106
106
|
#
|
@@ -54,13 +54,13 @@ module SidekiqUniqueJobs
|
|
54
54
|
# Only used to reduce a little bit of duplication
|
55
55
|
# @see call_script
|
56
56
|
def do_call(file_name, conn, keys, argv)
|
57
|
-
argv = argv.dup.
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
argv = argv.dup.push(
|
58
|
+
now_f,
|
59
|
+
debug_lua,
|
60
|
+
max_history,
|
61
|
+
file_name,
|
62
|
+
redis_version,
|
63
|
+
)
|
64
64
|
Script.execute(file_name, conn, keys: keys, argv: argv)
|
65
65
|
end
|
66
66
|
|
@@ -17,7 +17,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
|
|
17
17
|
# @return [SidekiqUniqueJobs::Config] the gem configuration
|
18
18
|
#
|
19
19
|
def config
|
20
|
-
@config ||= reset!
|
20
|
+
@config ||= reset! # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
21
21
|
end
|
22
22
|
|
23
23
|
#
|
@@ -108,7 +108,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
|
|
108
108
|
# @return [SidekiqUniqueJobs::Config] a default gem configuration
|
109
109
|
#
|
110
110
|
def reset!
|
111
|
-
@config = SidekiqUniqueJobs::Config.default
|
111
|
+
@config = SidekiqUniqueJobs::Config.default # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
112
112
|
end
|
113
113
|
|
114
114
|
#
|
@@ -288,7 +288,7 @@ module SidekiqUniqueJobs # rubocop:disable Metrics/ModuleLength
|
|
288
288
|
# @return [Reflections]
|
289
289
|
#
|
290
290
|
def reflections
|
291
|
-
@reflections ||= Reflections.new
|
291
|
+
@reflections ||= Reflections.new # rubocop:disable ThreadSafety/InstanceVariableInClassMethod
|
292
292
|
end
|
293
293
|
|
294
294
|
#
|
@@ -7,9 +7,11 @@
|
|
7
7
|
<div class="col-sm-7 table-responsive">
|
8
8
|
<% if @lock.info.none? %>
|
9
9
|
<h3>No Lock Information Available</h3>
|
10
|
-
|
11
|
-
<
|
12
|
-
|
10
|
+
<% unless SidekiqUniqueJobs.config.lock_info %>
|
11
|
+
<p>To use it turn the following setting on:
|
12
|
+
<code>SidekiqUniqueJobs.config.lock_info = true</code>
|
13
|
+
</p>
|
14
|
+
<% end %>
|
13
15
|
<% else %>
|
14
16
|
<table class="table table-striped table-bordered table-white table-hover">
|
15
17
|
<caption>Information about lock</caption>
|
data/lib/sidekiq_unique_jobs.rb
CHANGED
@@ -27,6 +27,7 @@ require "sidekiq_unique_jobs/logging"
|
|
27
27
|
require "sidekiq_unique_jobs/logging/middleware_context"
|
28
28
|
require "sidekiq_unique_jobs/timing"
|
29
29
|
require "sidekiq_unique_jobs/sidekiq_worker_methods"
|
30
|
+
require "sidekiq_unique_jobs/lock_type"
|
30
31
|
require "sidekiq_unique_jobs/connection"
|
31
32
|
require "sidekiq_unique_jobs/exceptions"
|
32
33
|
require "sidekiq_unique_jobs/script"
|
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.
|
4
|
+
version: 7.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikael Henriksson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: brpoplpush-redis_script
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/sidekiq_unique_jobs/lock_info.rb
|
152
152
|
- lib/sidekiq_unique_jobs/lock_timeout.rb
|
153
153
|
- lib/sidekiq_unique_jobs/lock_ttl.rb
|
154
|
+
- lib/sidekiq_unique_jobs/lock_type.rb
|
154
155
|
- lib/sidekiq_unique_jobs/locksmith.rb
|
155
156
|
- lib/sidekiq_unique_jobs/logging.rb
|
156
157
|
- lib/sidekiq_unique_jobs/logging/middleware_context.rb
|
@@ -273,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
274
|
- !ruby/object:Gem::Version
|
274
275
|
version: '0'
|
275
276
|
requirements: []
|
276
|
-
rubygems_version: 3.
|
277
|
+
rubygems_version: 3.4.15
|
277
278
|
signing_key:
|
278
279
|
specification_version: 4
|
279
280
|
summary: Sidekiq middleware that prevents duplicates jobs
|