redis_queued_locks 1.21.0 → 1.23.0
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/.claude/project-overview.md +294 -51
- data/.claude/rules/acquirer.md +16 -11
- data/.claude/rules/arguments.md +2 -2
- data/.claude/rules/changelog.md +27 -0
- data/.claude/rules/git.md +1 -1
- data/.claude/rules/logic.md +14 -15
- data/.claude/rules/swarm.md +3 -4
- data/.claude/rules/tests.md +9 -9
- data/.claude/rules/type-checking.md +14 -16
- data/.claude/rules/visitors.md +11 -9
- data/.claude/skills/rql-code-review/SKILL.md +129 -47
- data/.ruby-version +1 -1
- data/CHANGELOG.md +122 -245
- data/CLAUDE.md +12 -10
- data/README.md +516 -175
- data/Rakefile +11 -0
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +4 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rb +28 -12
- data/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +38 -16
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +92 -15
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +945 -272
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +82 -32
- data/lib/redis_queued_locks/acquirer/clear_dead_requests.rb +240 -45
- data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +15 -13
- data/lib/redis_queued_locks/acquirer/keys.rb +6 -2
- data/lib/redis_queued_locks/acquirer/lock_series/instr_visitor.rb +243 -0
- data/lib/redis_queued_locks/acquirer/lock_series/log_visitor.rb +472 -0
- data/lib/redis_queued_locks/acquirer/lock_series/release_lock_series.rb +181 -0
- data/lib/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rb +1051 -0
- data/lib/redis_queued_locks/acquirer/lock_series.rb +948 -0
- data/lib/redis_queued_locks/acquirer/locks.rb +6 -2
- data/lib/redis_queued_locks/acquirer/queue_info.rb +30 -7
- data/lib/redis_queued_locks/acquirer/queues.rb +17 -6
- data/lib/redis_queued_locks/acquirer/release_all_locks.rb +6 -2
- data/lib/redis_queued_locks/acquirer/release_locks_of.rb +6 -2
- data/lib/redis_queued_locks/acquirer.rb +1 -1
- data/lib/redis_queued_locks/client.rb +116 -44
- data/lib/redis_queued_locks/config.rb +93 -1
- data/lib/redis_queued_locks/resource.rb +124 -9
- data/lib/redis_queued_locks/swarm/swarm_element/threaded.rb +6 -5
- data/lib/redis_queued_locks/swarm/zombie_info.rb +6 -2
- data/lib/redis_queued_locks/version.rb +2 -2
- data/rbs_collection.lock.yaml +4 -0
- data/rbs_collection.yaml +2 -1
- data/redis_queued_locks.gemspec +21 -14
- data/sig/manifest.yml +1 -0
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock/instr_visitor.rbs +12 -6
- data/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +21 -14
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +61 -40
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +160 -11
- data/sig/redis_queued_locks/acquirer/acquire_lock/{yield_with_expire → yield_expire}/log_visitor.rbs +4 -4
- data/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +5 -3
- data/sig/redis_queued_locks/acquirer/clear_dead_requests.rbs +14 -1
- data/sig/redis_queued_locks/acquirer/extend_lock_ttl.rbs +2 -2
- data/sig/redis_queued_locks/acquirer/lock_series/instr_visitor.rbs +102 -0
- data/sig/redis_queued_locks/acquirer/lock_series/log_visitor.rbs +154 -0
- data/sig/redis_queued_locks/acquirer/lock_series/release_lock_series.rbs +37 -0
- data/sig/redis_queued_locks/acquirer/lock_series/try_to_lock_series.rbs +198 -0
- data/sig/redis_queued_locks/acquirer/lock_series.rbs +106 -0
- data/sig/redis_queued_locks/acquirer/queues.rbs +1 -1
- data/sig/redis_queued_locks/client.rbs +77 -7
- data/sig/redis_queued_locks/config.rbs +54 -1
- data/sig/redis_queued_locks/instrument/sampler.rbs +3 -1
- data/sig/redis_queued_locks/instrument/void_notifier.rbs +3 -1
- data/sig/redis_queued_locks/logging/sampler.rbs +3 -1
- data/sig/redis_queued_locks/resource.rbs +22 -12
- data/sig/redis_queued_locks/swarm/swarm_element/threaded.rbs +1 -1
- data/sig/redis_queued_locks/utilities.rbs +2 -1
- data/sig/redis_queued_locks.rbs +7 -0
- metadata +35 -13
- data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +0 -56
- data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +0 -95
- data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +0 -484
- /data/sig/redis_queued_locks/{acquier.rbs → acquirer.rbs} +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api private
|
|
4
|
+
# @since 1.23.0
|
|
5
|
+
# rubocop:disable Metrics/ModuleLength
|
|
6
|
+
module RedisQueuedLocks::Acquirer::LockSeries::InstrVisitor
|
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
|
8
|
+
class << self
|
|
9
|
+
# @param instrumenter [#notify]
|
|
10
|
+
# @param instr_sampled [Boolean]
|
|
11
|
+
# @param lock_key [String] The lock of the series.
|
|
12
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
13
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
14
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
15
|
+
# @param ttl [Integer]
|
|
16
|
+
# @param acq_id [String]
|
|
17
|
+
# @param hst_id [String]
|
|
18
|
+
# @param ts [Numeric]
|
|
19
|
+
# @param acq_time [Numeric]
|
|
20
|
+
# @param instrument [NilClass,Any]
|
|
21
|
+
# @return [void]
|
|
22
|
+
#
|
|
23
|
+
# @api private
|
|
24
|
+
# @since 1.23.0
|
|
25
|
+
def lock_series_intermediate_lock_obtained(
|
|
26
|
+
instrumenter,
|
|
27
|
+
instr_sampled,
|
|
28
|
+
lock_key,
|
|
29
|
+
lock_keys,
|
|
30
|
+
rw_mode,
|
|
31
|
+
priority,
|
|
32
|
+
ttl,
|
|
33
|
+
acq_id,
|
|
34
|
+
hst_id,
|
|
35
|
+
ts,
|
|
36
|
+
acq_time,
|
|
37
|
+
instrument
|
|
38
|
+
)
|
|
39
|
+
return unless instr_sampled
|
|
40
|
+
instrumenter.notify('redis_queued_locks.lock_series_intermediate_lock_obtained', {
|
|
41
|
+
lock_key:, lock_keys:, rw_mode:, priority:, ttl:, acq_id:, hst_id:, ts:, acq_time:,
|
|
42
|
+
instrument:
|
|
43
|
+
}) rescue nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @param instrumenter [#notify]
|
|
47
|
+
# @param instr_sampled [Boolean]
|
|
48
|
+
# @param lock_key [String] The lock of the series.
|
|
49
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
50
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
51
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
52
|
+
# @param ttl [Integer]
|
|
53
|
+
# @param acq_id [String]
|
|
54
|
+
# @param hst_id [String]
|
|
55
|
+
# @param ts [Numeric]
|
|
56
|
+
# @param acq_time [Numeric]
|
|
57
|
+
# @param instrument [NilClass,Any]
|
|
58
|
+
# @return [void]
|
|
59
|
+
#
|
|
60
|
+
# @api private
|
|
61
|
+
# @since 1.23.0
|
|
62
|
+
def lock_series_lock_obtained(
|
|
63
|
+
instrumenter,
|
|
64
|
+
instr_sampled,
|
|
65
|
+
lock_key,
|
|
66
|
+
lock_keys,
|
|
67
|
+
rw_mode,
|
|
68
|
+
priority,
|
|
69
|
+
ttl,
|
|
70
|
+
acq_id,
|
|
71
|
+
hst_id,
|
|
72
|
+
ts,
|
|
73
|
+
acq_time,
|
|
74
|
+
instrument
|
|
75
|
+
)
|
|
76
|
+
return unless instr_sampled
|
|
77
|
+
instrumenter.notify('redis_queued_locks.lock_series_lock_obtained', {
|
|
78
|
+
lock_key:, lock_keys:, rw_mode:, priority:, ttl:, acq_id:, hst_id:, ts:, acq_time:,
|
|
79
|
+
instrument:
|
|
80
|
+
}) rescue nil
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @param instrumenter [#notify]
|
|
84
|
+
# @param instr_sampled [Boolean]
|
|
85
|
+
# @param lock_key [String] The lock that blocks the series.
|
|
86
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
87
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
88
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
89
|
+
# @param ttl [Integer]
|
|
90
|
+
# @param acq_id [String]
|
|
91
|
+
# @param hst_id [String]
|
|
92
|
+
# @param ts [Numeric]
|
|
93
|
+
# @param acq_time [Numeric]
|
|
94
|
+
# @param result [Symbol] The failure result (`:timeout_reached`, `:retry_limit_reached`, ...).
|
|
95
|
+
# @param instrument [NilClass,Any]
|
|
96
|
+
# @return [void]
|
|
97
|
+
#
|
|
98
|
+
# @api private
|
|
99
|
+
# @since 1.23.0
|
|
100
|
+
def lock_series_lock_obtaining_failed(
|
|
101
|
+
instrumenter,
|
|
102
|
+
instr_sampled,
|
|
103
|
+
lock_key,
|
|
104
|
+
lock_keys,
|
|
105
|
+
rw_mode,
|
|
106
|
+
priority,
|
|
107
|
+
ttl,
|
|
108
|
+
acq_id,
|
|
109
|
+
hst_id,
|
|
110
|
+
ts,
|
|
111
|
+
acq_time,
|
|
112
|
+
result,
|
|
113
|
+
instrument
|
|
114
|
+
)
|
|
115
|
+
return unless instr_sampled
|
|
116
|
+
instrumenter.notify('redis_queued_locks.lock_series_lock_obtaining_failed', {
|
|
117
|
+
lock_key:, lock_keys:, rw_mode:, priority:, ttl:, acq_id:, hst_id:, ts:, acq_time:, result:,
|
|
118
|
+
instrument:
|
|
119
|
+
}) rescue nil
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# @param instrumenter [#notify]
|
|
123
|
+
# @param instr_sampled [Boolean]
|
|
124
|
+
# @param lock_keys [Array<String>]
|
|
125
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
126
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
127
|
+
# @param ttl [Integer]
|
|
128
|
+
# @param acq_id [String]
|
|
129
|
+
# @param hst_id [String]
|
|
130
|
+
# @param ts [Numeric]
|
|
131
|
+
# @param acq_time [Numeric]
|
|
132
|
+
# @param reentrant_lock_keys [Array<String>]
|
|
133
|
+
# The locks of the series that are obtained by the outer logic of the current acquirer.
|
|
134
|
+
# @param instrument [NilClass,Any]
|
|
135
|
+
# @return [void]
|
|
136
|
+
#
|
|
137
|
+
# @api private
|
|
138
|
+
# @since 1.23.0
|
|
139
|
+
def lock_series_obtained(
|
|
140
|
+
instrumenter,
|
|
141
|
+
instr_sampled,
|
|
142
|
+
lock_keys,
|
|
143
|
+
rw_mode,
|
|
144
|
+
priority,
|
|
145
|
+
ttl,
|
|
146
|
+
acq_id,
|
|
147
|
+
hst_id,
|
|
148
|
+
ts,
|
|
149
|
+
acq_time,
|
|
150
|
+
reentrant_lock_keys,
|
|
151
|
+
instrument
|
|
152
|
+
)
|
|
153
|
+
return unless instr_sampled
|
|
154
|
+
instrumenter.notify('redis_queued_locks.lock_series_obtained', {
|
|
155
|
+
lock_keys:, rw_mode:, priority:, ttl:, acq_id:, hst_id:, ts:, acq_time:,
|
|
156
|
+
reentrant_lock_keys:, instrument:
|
|
157
|
+
}) rescue nil
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @param instrumenter [#notify]
|
|
161
|
+
# @param instr_sampled [Boolean]
|
|
162
|
+
# @param lock_keys [Array<String>]
|
|
163
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
164
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
165
|
+
# @param ttl [Integer]
|
|
166
|
+
# @param acq_id [String]
|
|
167
|
+
# @param hst_id [String]
|
|
168
|
+
# @param ts [Numeric]
|
|
169
|
+
# @param acq_time [Numeric]
|
|
170
|
+
# @param hold_time [Numeric]
|
|
171
|
+
# @param reentrant_lock_keys [Array<String>]
|
|
172
|
+
# The locks of the series that are obtained by the outer logic of the current acquirer.
|
|
173
|
+
# @param instrument [NilClass,Any]
|
|
174
|
+
# @return [void]
|
|
175
|
+
#
|
|
176
|
+
# @api private
|
|
177
|
+
# @since 1.23.0
|
|
178
|
+
def lock_series_hold_and_release(
|
|
179
|
+
instrumenter,
|
|
180
|
+
instr_sampled,
|
|
181
|
+
lock_keys,
|
|
182
|
+
rw_mode,
|
|
183
|
+
priority,
|
|
184
|
+
ttl,
|
|
185
|
+
acq_id,
|
|
186
|
+
hst_id,
|
|
187
|
+
ts,
|
|
188
|
+
acq_time,
|
|
189
|
+
hold_time,
|
|
190
|
+
reentrant_lock_keys,
|
|
191
|
+
instrument
|
|
192
|
+
)
|
|
193
|
+
return unless instr_sampled
|
|
194
|
+
instrumenter.notify('redis_queued_locks.lock_series_hold_and_release', {
|
|
195
|
+
lock_keys:, rw_mode:, priority:, hold_time:, ttl:, acq_id:, hst_id:, ts:, acq_time:,
|
|
196
|
+
reentrant_lock_keys:, instrument:
|
|
197
|
+
}) rescue nil
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# @param instrumenter [#notify]
|
|
201
|
+
# @param instr_sampled [Boolean]
|
|
202
|
+
# @param lock_keys [Array<String>]
|
|
203
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
204
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
205
|
+
# @param ttl [Integer]
|
|
206
|
+
# @param acq_id [String]
|
|
207
|
+
# @param hst_id [String]
|
|
208
|
+
# @param ts [Numeric]
|
|
209
|
+
# @param acq_time [Numeric]
|
|
210
|
+
# @param result [Symbol] The failure result (`:timeout_reached`, `:retry_limit_reached`, ...).
|
|
211
|
+
# @param failed_lock_key [String,NilClass]
|
|
212
|
+
# The lock of the series that blocks the series (`nil`: unknown, an attempt was not finished
|
|
213
|
+
# or some lock state was changed during the attempt).
|
|
214
|
+
# @param instrument [NilClass,Any]
|
|
215
|
+
# @return [void]
|
|
216
|
+
#
|
|
217
|
+
# @api private
|
|
218
|
+
# @since 1.23.0
|
|
219
|
+
def lock_series_obtaining_failed(
|
|
220
|
+
instrumenter,
|
|
221
|
+
instr_sampled,
|
|
222
|
+
lock_keys,
|
|
223
|
+
rw_mode,
|
|
224
|
+
priority,
|
|
225
|
+
ttl,
|
|
226
|
+
acq_id,
|
|
227
|
+
hst_id,
|
|
228
|
+
ts,
|
|
229
|
+
acq_time,
|
|
230
|
+
result,
|
|
231
|
+
failed_lock_key,
|
|
232
|
+
instrument
|
|
233
|
+
)
|
|
234
|
+
return unless instr_sampled
|
|
235
|
+
instrumenter.notify('redis_queued_locks.lock_series_obtaining_failed', {
|
|
236
|
+
lock_keys:, rw_mode:, priority:, ttl:, acq_id:, hst_id:, ts:, acq_time:, result:,
|
|
237
|
+
failed_lock_key:, instrument:
|
|
238
|
+
}) rescue nil
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
# rubocop:enable Metrics/ClassLength
|
|
242
|
+
end
|
|
243
|
+
# rubocop:enable Metrics/ModuleLength
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @api private
|
|
4
|
+
# @since 1.23.0
|
|
5
|
+
# rubocop:disable Metrics/ModuleLength
|
|
6
|
+
module RedisQueuedLocks::Acquirer::LockSeries::LogVisitor
|
|
7
|
+
# rubocop:disable Metrics/ClassLength
|
|
8
|
+
class << self
|
|
9
|
+
# @param logger [::Logger,#debug]
|
|
10
|
+
# @param log_sampled [Boolean]
|
|
11
|
+
# @param lock_keys [Array<String>]
|
|
12
|
+
# @param queue_ttl [Integer]
|
|
13
|
+
# @param acquirer_id [String]
|
|
14
|
+
# @param host_id [String]
|
|
15
|
+
# @param access_strategy [Symbol]
|
|
16
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
17
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
18
|
+
# @return [void]
|
|
19
|
+
#
|
|
20
|
+
# @api private
|
|
21
|
+
# @since 1.23.0
|
|
22
|
+
def start_lock_series_obtaining(
|
|
23
|
+
logger,
|
|
24
|
+
log_sampled,
|
|
25
|
+
lock_keys,
|
|
26
|
+
queue_ttl,
|
|
27
|
+
acquirer_id,
|
|
28
|
+
host_id,
|
|
29
|
+
access_strategy,
|
|
30
|
+
rw_mode,
|
|
31
|
+
priority
|
|
32
|
+
)
|
|
33
|
+
return unless log_sampled
|
|
34
|
+
|
|
35
|
+
logger.debug do
|
|
36
|
+
"[redis_queued_locks.start_lock_series_obtaining] " \
|
|
37
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
38
|
+
"queue_ttl => #{queue_ttl} " \
|
|
39
|
+
"acq_id => '#{acquirer_id}' " \
|
|
40
|
+
"hst_id => '#{host_id}' " \
|
|
41
|
+
"acs_strat => '#{access_strategy}' " \
|
|
42
|
+
"rw_mode => '#{rw_mode}' " \
|
|
43
|
+
"priority => #{priority}"
|
|
44
|
+
end rescue nil
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# @param logger [::Logger,#debug]
|
|
48
|
+
# @param log_sampled [Boolean]
|
|
49
|
+
# @param lock_keys [Array<String>]
|
|
50
|
+
# @param queue_ttl [Integer]
|
|
51
|
+
# @param acquirer_id [String]
|
|
52
|
+
# @param host_id [String]
|
|
53
|
+
# @param access_strategy [Symbol]
|
|
54
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
55
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
56
|
+
# @return [void]
|
|
57
|
+
#
|
|
58
|
+
# @api private
|
|
59
|
+
# @since 1.23.0
|
|
60
|
+
def start_try_to_lock_series_cycle(
|
|
61
|
+
logger,
|
|
62
|
+
log_sampled,
|
|
63
|
+
lock_keys,
|
|
64
|
+
queue_ttl,
|
|
65
|
+
acquirer_id,
|
|
66
|
+
host_id,
|
|
67
|
+
access_strategy,
|
|
68
|
+
rw_mode,
|
|
69
|
+
priority
|
|
70
|
+
)
|
|
71
|
+
return unless log_sampled
|
|
72
|
+
|
|
73
|
+
logger.debug do
|
|
74
|
+
"[redis_queued_locks.start_try_to_lock_series_cycle] " \
|
|
75
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
76
|
+
"queue_ttl => #{queue_ttl} " \
|
|
77
|
+
"acq_id => '#{acquirer_id}' " \
|
|
78
|
+
"hst_id => '#{host_id}' " \
|
|
79
|
+
"acs_strat => '#{access_strategy}' " \
|
|
80
|
+
"rw_mode => '#{rw_mode}' " \
|
|
81
|
+
"priority => #{priority}"
|
|
82
|
+
end rescue nil
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# @param logger [::Logger,#debug]
|
|
86
|
+
# @param log_sampled [Boolean]
|
|
87
|
+
# @param lock_keys [Array<String>]
|
|
88
|
+
# @param queue_ttl [Integer]
|
|
89
|
+
# @param acquirer_id [String]
|
|
90
|
+
# @param host_id [String]
|
|
91
|
+
# @param access_strategy [Symbol]
|
|
92
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
93
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
94
|
+
# @return [void]
|
|
95
|
+
#
|
|
96
|
+
# @api private
|
|
97
|
+
# @since 1.23.0
|
|
98
|
+
def dead_score_reached__reset_series_position(
|
|
99
|
+
logger,
|
|
100
|
+
log_sampled,
|
|
101
|
+
lock_keys,
|
|
102
|
+
queue_ttl,
|
|
103
|
+
acquirer_id,
|
|
104
|
+
host_id,
|
|
105
|
+
access_strategy,
|
|
106
|
+
rw_mode,
|
|
107
|
+
priority
|
|
108
|
+
)
|
|
109
|
+
return unless log_sampled
|
|
110
|
+
|
|
111
|
+
logger.debug do
|
|
112
|
+
"[redis_queued_locks.dead_score_reached__reset_series_position] " \
|
|
113
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
114
|
+
"queue_ttl => #{queue_ttl} " \
|
|
115
|
+
"acq_id => '#{acquirer_id}' " \
|
|
116
|
+
"hst_id => '#{host_id}' " \
|
|
117
|
+
"acs_strat => '#{access_strategy}' " \
|
|
118
|
+
"rw_mode => '#{rw_mode}' " \
|
|
119
|
+
"priority => #{priority}"
|
|
120
|
+
end rescue nil
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# @param logger [::Logger,#debug]
|
|
124
|
+
# @param log_sampled [Boolean]
|
|
125
|
+
# @param lock_key [String] The lock of the series.
|
|
126
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
127
|
+
# @param queue_ttl [Integer]
|
|
128
|
+
# @param acquirer_id [String]
|
|
129
|
+
# @param host_id [String]
|
|
130
|
+
# @param acq_time [Numeric]
|
|
131
|
+
# @param access_strategy [Symbol]
|
|
132
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
133
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
134
|
+
# @return [void]
|
|
135
|
+
#
|
|
136
|
+
# @api private
|
|
137
|
+
# @since 1.23.0
|
|
138
|
+
def lock_series_intermediate_lock_obtained(
|
|
139
|
+
logger,
|
|
140
|
+
log_sampled,
|
|
141
|
+
lock_key,
|
|
142
|
+
lock_keys,
|
|
143
|
+
queue_ttl,
|
|
144
|
+
acquirer_id,
|
|
145
|
+
host_id,
|
|
146
|
+
acq_time,
|
|
147
|
+
access_strategy,
|
|
148
|
+
rw_mode,
|
|
149
|
+
priority
|
|
150
|
+
)
|
|
151
|
+
return unless log_sampled
|
|
152
|
+
|
|
153
|
+
logger.debug do
|
|
154
|
+
"[redis_queued_locks.lock_series_intermediate_lock_obtained] " \
|
|
155
|
+
"lock_key => '#{lock_key}' " \
|
|
156
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
157
|
+
"queue_ttl => #{queue_ttl} " \
|
|
158
|
+
"acq_id => '#{acquirer_id}' " \
|
|
159
|
+
"hst_id => '#{host_id}' " \
|
|
160
|
+
"acs_strat => '#{access_strategy}' " \
|
|
161
|
+
"rw_mode => '#{rw_mode}' " \
|
|
162
|
+
"priority => #{priority} " \
|
|
163
|
+
"acq_time => #{acq_time} (ms)"
|
|
164
|
+
end rescue nil
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# @param logger [::Logger,#debug]
|
|
168
|
+
# @param log_sampled [Boolean]
|
|
169
|
+
# @param lock_key [String] The lock of the series.
|
|
170
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
171
|
+
# @param queue_ttl [Integer]
|
|
172
|
+
# @param acquirer_id [String]
|
|
173
|
+
# @param host_id [String]
|
|
174
|
+
# @param acq_time [Numeric]
|
|
175
|
+
# @param access_strategy [Symbol]
|
|
176
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
177
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
178
|
+
# @return [void]
|
|
179
|
+
#
|
|
180
|
+
# @api private
|
|
181
|
+
# @since 1.23.0
|
|
182
|
+
def lock_series_lock_obtained(
|
|
183
|
+
logger,
|
|
184
|
+
log_sampled,
|
|
185
|
+
lock_key,
|
|
186
|
+
lock_keys,
|
|
187
|
+
queue_ttl,
|
|
188
|
+
acquirer_id,
|
|
189
|
+
host_id,
|
|
190
|
+
acq_time,
|
|
191
|
+
access_strategy,
|
|
192
|
+
rw_mode,
|
|
193
|
+
priority
|
|
194
|
+
)
|
|
195
|
+
return unless log_sampled
|
|
196
|
+
|
|
197
|
+
logger.debug do
|
|
198
|
+
"[redis_queued_locks.lock_series_lock_obtained] " \
|
|
199
|
+
"lock_key => '#{lock_key}' " \
|
|
200
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
201
|
+
"queue_ttl => #{queue_ttl} " \
|
|
202
|
+
"acq_id => '#{acquirer_id}' " \
|
|
203
|
+
"hst_id => '#{host_id}' " \
|
|
204
|
+
"acs_strat => '#{access_strategy}' " \
|
|
205
|
+
"rw_mode => '#{rw_mode}' " \
|
|
206
|
+
"priority => #{priority} " \
|
|
207
|
+
"acq_time => #{acq_time} (ms)"
|
|
208
|
+
end rescue nil
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# @param logger [::Logger,#debug]
|
|
212
|
+
# @param log_sampled [Boolean]
|
|
213
|
+
# @param lock_keys [Array<String>]
|
|
214
|
+
# @param queue_ttl [Integer]
|
|
215
|
+
# @param acquirer_id [String]
|
|
216
|
+
# @param host_id [String]
|
|
217
|
+
# @param acq_time [Numeric]
|
|
218
|
+
# @param access_strategy [Symbol]
|
|
219
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
220
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
221
|
+
# @param reentrant_lock_keys [Array<String>]
|
|
222
|
+
# The locks of the series that are obtained by the outer logic of the current acquirer.
|
|
223
|
+
# @return [void]
|
|
224
|
+
#
|
|
225
|
+
# @api private
|
|
226
|
+
# @since 1.23.0
|
|
227
|
+
def lock_series_obtained(
|
|
228
|
+
logger,
|
|
229
|
+
log_sampled,
|
|
230
|
+
lock_keys,
|
|
231
|
+
queue_ttl,
|
|
232
|
+
acquirer_id,
|
|
233
|
+
host_id,
|
|
234
|
+
acq_time,
|
|
235
|
+
access_strategy,
|
|
236
|
+
rw_mode,
|
|
237
|
+
priority,
|
|
238
|
+
reentrant_lock_keys
|
|
239
|
+
)
|
|
240
|
+
return unless log_sampled
|
|
241
|
+
|
|
242
|
+
logger.debug do
|
|
243
|
+
"[redis_queued_locks.lock_series_obtained] " \
|
|
244
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
245
|
+
"queue_ttl => #{queue_ttl} " \
|
|
246
|
+
"acq_id => '#{acquirer_id}' " \
|
|
247
|
+
"hst_id => '#{host_id}' " \
|
|
248
|
+
"acs_strat => '#{access_strategy}' " \
|
|
249
|
+
"rw_mode => '#{rw_mode}' " \
|
|
250
|
+
"priority => #{priority} " \
|
|
251
|
+
"acq_time => #{acq_time} (ms) " \
|
|
252
|
+
"reentrant_lock_keys => '#{reentrant_lock_keys.inspect}'"
|
|
253
|
+
end rescue nil
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# @param logger [::Logger,#debug]
|
|
257
|
+
# @param log_sampled [Boolean]
|
|
258
|
+
# @param lock_key [String] The lock that blocks the series.
|
|
259
|
+
# @param lock_keys [Array<String>] All locks of the series.
|
|
260
|
+
# @param queue_ttl [Integer]
|
|
261
|
+
# @param acquirer_id [String]
|
|
262
|
+
# @param host_id [String]
|
|
263
|
+
# @param acq_time [Numeric]
|
|
264
|
+
# @param access_strategy [Symbol]
|
|
265
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
266
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
267
|
+
# @param result [Symbol] The failure result (`:timeout_reached`, `:retry_limit_reached`, ...).
|
|
268
|
+
# @return [void]
|
|
269
|
+
#
|
|
270
|
+
# @api private
|
|
271
|
+
# @since 1.23.0
|
|
272
|
+
def lock_series_lock_obtaining_failed(
|
|
273
|
+
logger,
|
|
274
|
+
log_sampled,
|
|
275
|
+
lock_key,
|
|
276
|
+
lock_keys,
|
|
277
|
+
queue_ttl,
|
|
278
|
+
acquirer_id,
|
|
279
|
+
host_id,
|
|
280
|
+
acq_time,
|
|
281
|
+
access_strategy,
|
|
282
|
+
rw_mode,
|
|
283
|
+
priority,
|
|
284
|
+
result
|
|
285
|
+
)
|
|
286
|
+
return unless log_sampled
|
|
287
|
+
|
|
288
|
+
logger.debug do
|
|
289
|
+
"[redis_queued_locks.lock_series_lock_obtaining_failed] " \
|
|
290
|
+
"lock_key => '#{lock_key}' " \
|
|
291
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
292
|
+
"queue_ttl => #{queue_ttl} " \
|
|
293
|
+
"acq_id => '#{acquirer_id}' " \
|
|
294
|
+
"hst_id => '#{host_id}' " \
|
|
295
|
+
"acs_strat => '#{access_strategy}' " \
|
|
296
|
+
"rw_mode => '#{rw_mode}' " \
|
|
297
|
+
"priority => #{priority} " \
|
|
298
|
+
"acq_time => #{acq_time} (ms) " \
|
|
299
|
+
"result => '#{result}'"
|
|
300
|
+
end rescue nil
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# @param logger [::Logger,#debug]
|
|
304
|
+
# @param log_sampled [Boolean]
|
|
305
|
+
# @param lock_keys [Array<String>]
|
|
306
|
+
# @param queue_ttl [Integer]
|
|
307
|
+
# @param acquirer_id [String]
|
|
308
|
+
# @param host_id [String]
|
|
309
|
+
# @param acq_time [Numeric]
|
|
310
|
+
# @param access_strategy [Symbol]
|
|
311
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
312
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
313
|
+
# @param result [Symbol] The failure result (`:timeout_reached`, `:retry_limit_reached`, ...).
|
|
314
|
+
# @param failed_lock_key [String,NilClass]
|
|
315
|
+
# The lock of the series that blocks the series (`nil`: unknown, an attempt was not finished
|
|
316
|
+
# or some lock state was changed during the attempt).
|
|
317
|
+
# @return [void]
|
|
318
|
+
#
|
|
319
|
+
# @api private
|
|
320
|
+
# @since 1.23.0
|
|
321
|
+
def lock_series_obtaining_failed(
|
|
322
|
+
logger,
|
|
323
|
+
log_sampled,
|
|
324
|
+
lock_keys,
|
|
325
|
+
queue_ttl,
|
|
326
|
+
acquirer_id,
|
|
327
|
+
host_id,
|
|
328
|
+
acq_time,
|
|
329
|
+
access_strategy,
|
|
330
|
+
rw_mode,
|
|
331
|
+
priority,
|
|
332
|
+
result,
|
|
333
|
+
failed_lock_key
|
|
334
|
+
)
|
|
335
|
+
return unless log_sampled
|
|
336
|
+
|
|
337
|
+
logger.debug do
|
|
338
|
+
"[redis_queued_locks.lock_series_obtaining_failed] " \
|
|
339
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
340
|
+
"queue_ttl => #{queue_ttl} " \
|
|
341
|
+
"acq_id => '#{acquirer_id}' " \
|
|
342
|
+
"hst_id => '#{host_id}' " \
|
|
343
|
+
"acs_strat => '#{access_strategy}' " \
|
|
344
|
+
"rw_mode => '#{rw_mode}' " \
|
|
345
|
+
"priority => #{priority} " \
|
|
346
|
+
"acq_time => #{acq_time} (ms) " \
|
|
347
|
+
"result => '#{result}' " \
|
|
348
|
+
"failed_lock_key => '#{failed_lock_key}'"
|
|
349
|
+
end rescue nil
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# @param logger [::Logger,#debug]
|
|
353
|
+
# @param log_sampled [Boolean]
|
|
354
|
+
# @param lock_keys [Array<String>]
|
|
355
|
+
# @param queue_ttl [Integer]
|
|
356
|
+
# @param acquirer_id [String]
|
|
357
|
+
# @param host_id [String]
|
|
358
|
+
# @param access_strategy [Symbol]
|
|
359
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
360
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
361
|
+
# @return [void]
|
|
362
|
+
#
|
|
363
|
+
# @api private
|
|
364
|
+
# @since 1.23.0
|
|
365
|
+
def dequeue_from_lock_series_queues(
|
|
366
|
+
logger,
|
|
367
|
+
log_sampled,
|
|
368
|
+
lock_keys,
|
|
369
|
+
queue_ttl,
|
|
370
|
+
acquirer_id,
|
|
371
|
+
host_id,
|
|
372
|
+
access_strategy,
|
|
373
|
+
rw_mode,
|
|
374
|
+
priority
|
|
375
|
+
)
|
|
376
|
+
return unless log_sampled
|
|
377
|
+
|
|
378
|
+
logger.debug do
|
|
379
|
+
"[redis_queued_locks.dequeue_from_lock_series_queues] " \
|
|
380
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
381
|
+
"queue_ttl => #{queue_ttl} " \
|
|
382
|
+
"acq_id => '#{acquirer_id}' " \
|
|
383
|
+
"hst_id => '#{host_id}' " \
|
|
384
|
+
"acs_strat => '#{access_strategy}' " \
|
|
385
|
+
"rw_mode => '#{rw_mode}' " \
|
|
386
|
+
"priority => #{priority}"
|
|
387
|
+
end rescue nil
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# @param logger [::Logger,#debug]
|
|
391
|
+
# @param log_sampled [Boolean]
|
|
392
|
+
# @param lock_keys [Array<String>]
|
|
393
|
+
# @param queue_ttl [Integer]
|
|
394
|
+
# @param acquirer_id [String]
|
|
395
|
+
# @param host_id [String]
|
|
396
|
+
# @param access_strategy [Symbol]
|
|
397
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
398
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
399
|
+
# @return [void]
|
|
400
|
+
#
|
|
401
|
+
# @api private
|
|
402
|
+
# @since 1.23.0
|
|
403
|
+
def expire_lock_series(
|
|
404
|
+
logger,
|
|
405
|
+
log_sampled,
|
|
406
|
+
lock_keys,
|
|
407
|
+
queue_ttl,
|
|
408
|
+
acquirer_id,
|
|
409
|
+
host_id,
|
|
410
|
+
access_strategy,
|
|
411
|
+
rw_mode,
|
|
412
|
+
priority
|
|
413
|
+
)
|
|
414
|
+
return unless log_sampled
|
|
415
|
+
|
|
416
|
+
logger.debug do
|
|
417
|
+
"[redis_queued_locks.expire_lock_series] " \
|
|
418
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
419
|
+
"queue_ttl => #{queue_ttl} " \
|
|
420
|
+
"acq_id => '#{acquirer_id}' " \
|
|
421
|
+
"hst_id => '#{host_id}' " \
|
|
422
|
+
"acs_strat => '#{access_strategy}' " \
|
|
423
|
+
"rw_mode => '#{rw_mode}' " \
|
|
424
|
+
"priority => #{priority}"
|
|
425
|
+
end rescue nil
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# @param logger [::Logger,#debug]
|
|
429
|
+
# @param log_sampled [Boolean]
|
|
430
|
+
# @param lock_keys [Array<String>]
|
|
431
|
+
# The extended reentrant locks of the series (`:extendable_work_through`).
|
|
432
|
+
# @param decreased_ttl [Integer] In milliseconds.
|
|
433
|
+
# @param queue_ttl [Integer]
|
|
434
|
+
# @param acquirer_id [String]
|
|
435
|
+
# @param host_id [String]
|
|
436
|
+
# @param access_strategy [Symbol]
|
|
437
|
+
# @param rw_mode [Symbol] The mode of the lock series (`:read` or `:write`).
|
|
438
|
+
# @param priority [Integer] The lock request priority of the series.
|
|
439
|
+
# @return [void]
|
|
440
|
+
#
|
|
441
|
+
# @api private
|
|
442
|
+
# @since 1.23.0
|
|
443
|
+
def decrease_lock_series(
|
|
444
|
+
logger,
|
|
445
|
+
log_sampled,
|
|
446
|
+
lock_keys,
|
|
447
|
+
decreased_ttl,
|
|
448
|
+
queue_ttl,
|
|
449
|
+
acquirer_id,
|
|
450
|
+
host_id,
|
|
451
|
+
access_strategy,
|
|
452
|
+
rw_mode,
|
|
453
|
+
priority
|
|
454
|
+
)
|
|
455
|
+
return unless log_sampled
|
|
456
|
+
|
|
457
|
+
logger.debug do
|
|
458
|
+
"[redis_queued_locks.decrease_lock_series] " \
|
|
459
|
+
"lock_keys => '#{lock_keys.inspect}' " \
|
|
460
|
+
"decreased_ttl => #{decreased_ttl} " \
|
|
461
|
+
"queue_ttl => #{queue_ttl} " \
|
|
462
|
+
"acq_id => '#{acquirer_id}' " \
|
|
463
|
+
"hst_id => '#{host_id}' " \
|
|
464
|
+
"acs_strat => '#{access_strategy}' " \
|
|
465
|
+
"rw_mode => '#{rw_mode}' " \
|
|
466
|
+
"priority => #{priority}"
|
|
467
|
+
end rescue nil
|
|
468
|
+
end
|
|
469
|
+
end
|
|
470
|
+
# rubocop:enable Metrics/ClassLength
|
|
471
|
+
end
|
|
472
|
+
# rubocop:enable Metrics/ModuleLength
|