redis_queued_locks 1.22.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 +88 -36
- data/.claude/rules/acquirer.md +11 -7
- data/.claude/rules/arguments.md +2 -2
- data/.claude/rules/logic.md +5 -4
- data/.claude/rules/tests.md +4 -4
- data/.claude/rules/type-checking.md +2 -3
- data/.claude/rules/visitors.md +8 -6
- data/.claude/skills/rql-code-review/SKILL.md +25 -20
- data/.ruby-version +1 -1
- data/CHANGELOG.md +24 -1
- data/CLAUDE.md +5 -4
- data/README.md +247 -96
- data/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +4 -4
- data/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +582 -276
- data/lib/redis_queued_locks/acquirer/acquire_lock.rb +26 -26
- data/lib/redis_queued_locks/acquirer/extend_lock_ttl.rb +13 -13
- 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.rb +1 -1
- data/lib/redis_queued_locks/client.rb +55 -25
- data/lib/redis_queued_locks/version.rb +2 -2
- data/redis_queued_locks.gemspec +21 -14
- data/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +1 -1
- data/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +106 -5
- data/sig/redis_queued_locks/acquirer/acquire_lock.rbs +1 -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/client.rbs +70 -3
- metadata +32 -11
- data/lib/redis_queued_locks/acquirer/lock_series_poc/instr_visitor.rb +0 -61
- data/lib/redis_queued_locks/acquirer/lock_series_poc/log_visitor.rb +0 -104
- data/lib/redis_queued_locks/acquirer/lock_series_poc.rb +0 -513
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# @since 1.0.0
|
|
5
5
|
module RedisQueuedLocks::Acquirer
|
|
6
6
|
require_relative 'acquirer/acquire_lock'
|
|
7
|
-
require_relative 'acquirer/
|
|
7
|
+
require_relative 'acquirer/lock_series'
|
|
8
8
|
require_relative 'acquirer/release_lock'
|
|
9
9
|
require_relative 'acquirer/release_read_lock'
|
|
10
10
|
require_relative 'acquirer/release_all_locks'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @api public
|
|
4
4
|
# @since 1.0.0
|
|
5
|
-
# @version 1.
|
|
5
|
+
# @version 1.23.0
|
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
|
7
7
|
class RedisQueuedLocks::Client
|
|
8
8
|
# @return [RedisClient]
|
|
@@ -222,7 +222,7 @@ class RedisQueuedLocks::Client
|
|
|
222
222
|
# - `:wait_for_lock` - (default) - work in classic way
|
|
223
223
|
# (with timeouts, retry delays, retry limits, etc - in classic way :));
|
|
224
224
|
# - `:dead_locking` - fail with deadlock exception;
|
|
225
|
-
# @option
|
|
225
|
+
# @option rw_mode [Symbol]
|
|
226
226
|
# - The lock mode (read/write lock semantics);
|
|
227
227
|
# - `:write` mode is used by default;
|
|
228
228
|
# - Supports:
|
|
@@ -366,7 +366,7 @@ class RedisQueuedLocks::Client
|
|
|
366
366
|
#
|
|
367
367
|
# @api public
|
|
368
368
|
# @since 1.0.0
|
|
369
|
-
# @version 1.
|
|
369
|
+
# @version 1.23.0
|
|
370
370
|
# rubocop:disable Metrics/MethodLength
|
|
371
371
|
def lock(
|
|
372
372
|
lock_name,
|
|
@@ -381,7 +381,7 @@ class RedisQueuedLocks::Client
|
|
|
381
381
|
raise_errors: false,
|
|
382
382
|
fail_fast: false,
|
|
383
383
|
conflict_strategy: config['default_conflict_strategy'],
|
|
384
|
-
|
|
384
|
+
rw_mode: :write,
|
|
385
385
|
access_strategy: config['default_access_strategy'],
|
|
386
386
|
priority: config['default_lock_priority'],
|
|
387
387
|
identity: uniq_identity,
|
|
@@ -422,7 +422,7 @@ class RedisQueuedLocks::Client
|
|
|
422
422
|
identity:,
|
|
423
423
|
fail_fast:,
|
|
424
424
|
conflict_strategy:,
|
|
425
|
-
|
|
425
|
+
rw_mode:,
|
|
426
426
|
access_strategy:,
|
|
427
427
|
priority:,
|
|
428
428
|
lock_priorities: config['lock_priorities'],
|
|
@@ -444,12 +444,41 @@ class RedisQueuedLocks::Client
|
|
|
444
444
|
end
|
|
445
445
|
# rubocop:enable Metrics/MethodLength
|
|
446
446
|
|
|
447
|
-
#
|
|
447
|
+
# Obtains a series of locks atomically: all locks of the series are obtained at the same moment
|
|
448
|
+
# with the same ttl or none of them (nothing is held while the series waits for its locks).
|
|
449
|
+
# Lock series are deadlock-free for any order of the lock names.
|
|
450
|
+
#
|
|
451
|
+
# @param lock_names [Array<String>]
|
|
452
|
+
# Lock names to be obtained (at least one; a duplicated name is the same lock).
|
|
453
|
+
# @option detailed_result [Boolean]
|
|
454
|
+
# Return the detailed result of the series (the block result, times, lock keys).
|
|
455
|
+
# @option ttl [Integer]
|
|
456
|
+
# The time to live of each lock of the series (in milliseconds). See `#lock`.
|
|
457
|
+
# @option timeout [Integer,NilClass]
|
|
458
|
+
# Time period whe should try to acquire the whole series (in seconds). See `#lock`.
|
|
459
|
+
# @option retry_count [Integer,NilClass]
|
|
460
|
+
# How many times we should try to acquire the whole series. See `#lock`.
|
|
461
|
+
# @option rw_mode [Symbol]
|
|
462
|
+
# The mode of all locks of the series. See `#lock`.
|
|
463
|
+
# @option priority [Integer,Symbol]
|
|
464
|
+
# The lock request priority of the series. See `#lock`.
|
|
465
|
+
# @yield A block of code that should be executed under all obtained locks.
|
|
466
|
+
# @yieldreturn [Any]
|
|
467
|
+
# @return [Hash<Symbol,Any>,yield]
|
|
468
|
+
# - the result of the block when the series is obtained with a block;
|
|
469
|
+
# - `{ ok: true, result: { lock_series:, rql_lock_series:, acq_id:, hst_id:, ts:, ttl: } }`
|
|
470
|
+
# when the series is obtained without a block (the locks live till their ttl);
|
|
471
|
+
# - the detailed result of the series with `detailed_result: true`;
|
|
472
|
+
# - `{ ok: false, result: { error:, detailed_errors:, lock_series:, acquired_locks:,
|
|
473
|
+
# missing_locks:, failed_on_lock: } }` when the series is not obtained;
|
|
474
|
+
#
|
|
475
|
+
# @note See #lock method signature for all other options.
|
|
476
|
+
#
|
|
448
477
|
# rubocop:disable Metrics/MethodLength
|
|
449
478
|
# @api public
|
|
450
479
|
# @since 1.16.0
|
|
451
|
-
# @version 1.
|
|
452
|
-
def lock_series(
|
|
480
|
+
# @version 1.23.0
|
|
481
|
+
def lock_series(
|
|
453
482
|
*lock_names,
|
|
454
483
|
detailed_result: false,
|
|
455
484
|
ttl: config['default_lock_ttl'],
|
|
@@ -463,7 +492,7 @@ class RedisQueuedLocks::Client
|
|
|
463
492
|
raise_errors: false,
|
|
464
493
|
fail_fast: false,
|
|
465
494
|
conflict_strategy: config['default_conflict_strategy'],
|
|
466
|
-
|
|
495
|
+
rw_mode: :write,
|
|
467
496
|
access_strategy: config['default_access_strategy'],
|
|
468
497
|
priority: config['default_lock_priority'],
|
|
469
498
|
identity: uniq_identity,
|
|
@@ -483,7 +512,7 @@ class RedisQueuedLocks::Client
|
|
|
483
512
|
instr_sample_this: false,
|
|
484
513
|
&block
|
|
485
514
|
)
|
|
486
|
-
RedisQueuedLocks::Acquirer::
|
|
515
|
+
RedisQueuedLocks::Acquirer::LockSeries.lock_series(
|
|
487
516
|
redis_client,
|
|
488
517
|
lock_names,
|
|
489
518
|
detailed_result:,
|
|
@@ -505,7 +534,7 @@ class RedisQueuedLocks::Client
|
|
|
505
534
|
identity:,
|
|
506
535
|
fail_fast:,
|
|
507
536
|
conflict_strategy:,
|
|
508
|
-
|
|
537
|
+
rw_mode:,
|
|
509
538
|
access_strategy:,
|
|
510
539
|
priority:,
|
|
511
540
|
lock_priorities: config['lock_priorities'],
|
|
@@ -527,12 +556,13 @@ class RedisQueuedLocks::Client
|
|
|
527
556
|
end
|
|
528
557
|
# rubocop:enable Metrics/MethodLength
|
|
529
558
|
|
|
530
|
-
#
|
|
559
|
+
# @note See #lock_series method signature.
|
|
560
|
+
#
|
|
531
561
|
# rubocop:disable Metrics/MethodLength
|
|
532
562
|
# @api public
|
|
533
563
|
# @since 1.16.0
|
|
534
|
-
# @version 1.
|
|
535
|
-
def lock_series!(
|
|
564
|
+
# @version 1.23.0
|
|
565
|
+
def lock_series!(
|
|
536
566
|
*lock_names,
|
|
537
567
|
detailed_result: false,
|
|
538
568
|
ttl: config['default_lock_ttl'],
|
|
@@ -545,7 +575,7 @@ class RedisQueuedLocks::Client
|
|
|
545
575
|
retry_jitter: config['retry_jitter'],
|
|
546
576
|
fail_fast: false,
|
|
547
577
|
conflict_strategy: config['default_conflict_strategy'],
|
|
548
|
-
|
|
578
|
+
rw_mode: :write,
|
|
549
579
|
access_strategy: config['default_access_strategy'],
|
|
550
580
|
priority: config['default_lock_priority'],
|
|
551
581
|
identity: uniq_identity,
|
|
@@ -565,8 +595,8 @@ class RedisQueuedLocks::Client
|
|
|
565
595
|
instr_sample_this: false,
|
|
566
596
|
&block
|
|
567
597
|
)
|
|
568
|
-
lock_series(
|
|
569
|
-
*lock_names,
|
|
598
|
+
lock_series(
|
|
599
|
+
*lock_names,
|
|
570
600
|
detailed_result:,
|
|
571
601
|
ttl:,
|
|
572
602
|
queue_ttl:,
|
|
@@ -579,7 +609,7 @@ class RedisQueuedLocks::Client
|
|
|
579
609
|
raise_errors: true,
|
|
580
610
|
fail_fast:,
|
|
581
611
|
conflict_strategy:,
|
|
582
|
-
|
|
612
|
+
rw_mode:,
|
|
583
613
|
access_strategy:,
|
|
584
614
|
priority:,
|
|
585
615
|
identity:,
|
|
@@ -607,7 +637,7 @@ class RedisQueuedLocks::Client
|
|
|
607
637
|
# rubocop:disable Metrics/MethodLength
|
|
608
638
|
# @api public
|
|
609
639
|
# @since 1.0.0
|
|
610
|
-
# @version 1.
|
|
640
|
+
# @version 1.23.0
|
|
611
641
|
def lock!(
|
|
612
642
|
lock_name,
|
|
613
643
|
ttl: config['default_lock_ttl'],
|
|
@@ -620,7 +650,7 @@ class RedisQueuedLocks::Client
|
|
|
620
650
|
retry_jitter: config['retry_jitter'],
|
|
621
651
|
fail_fast: false,
|
|
622
652
|
conflict_strategy: config['default_conflict_strategy'],
|
|
623
|
-
|
|
653
|
+
rw_mode: :write,
|
|
624
654
|
access_strategy: config['default_access_strategy'],
|
|
625
655
|
priority: config['default_lock_priority'],
|
|
626
656
|
identity: uniq_identity,
|
|
@@ -660,7 +690,7 @@ class RedisQueuedLocks::Client
|
|
|
660
690
|
instrument:,
|
|
661
691
|
instrumenter:,
|
|
662
692
|
conflict_strategy:,
|
|
663
|
-
|
|
693
|
+
rw_mode:,
|
|
664
694
|
access_strategy:,
|
|
665
695
|
priority:,
|
|
666
696
|
log_sampling_enabled:,
|
|
@@ -952,7 +982,7 @@ class RedisQueuedLocks::Client
|
|
|
952
982
|
# @param lock_name [String]
|
|
953
983
|
# @param milliseconds [Integer]
|
|
954
984
|
# How many milliseconds should be added: a positive Integer.
|
|
955
|
-
# @option
|
|
985
|
+
# @option rw_mode [Symbol]
|
|
956
986
|
# - `:write` (default) - extends the write lock (the method description above);
|
|
957
987
|
# - `:read` - extends the read lock of the current acquirer only (an expired read lock or
|
|
958
988
|
# a read lock replaced by a writer is not extended);
|
|
@@ -981,11 +1011,11 @@ class RedisQueuedLocks::Client
|
|
|
981
1011
|
#
|
|
982
1012
|
# @api public
|
|
983
1013
|
# @since 1.0.0
|
|
984
|
-
# @version 1.
|
|
1014
|
+
# @version 1.23.0
|
|
985
1015
|
def extend_lock_ttl(
|
|
986
1016
|
lock_name,
|
|
987
1017
|
milliseconds,
|
|
988
|
-
|
|
1018
|
+
rw_mode: :write,
|
|
989
1019
|
all_read_locks: false,
|
|
990
1020
|
identity: uniq_identity,
|
|
991
1021
|
logger: config['logger'],
|
|
@@ -1004,7 +1034,7 @@ class RedisQueuedLocks::Client
|
|
|
1004
1034
|
redis_client,
|
|
1005
1035
|
lock_name,
|
|
1006
1036
|
milliseconds,
|
|
1007
|
-
|
|
1037
|
+
rw_mode,
|
|
1008
1038
|
all_read_locks,
|
|
1009
1039
|
current_acquirer_id(identity:),
|
|
1010
1040
|
config['lock_index_enabled'],
|
data/redis_queued_locks.gemspec
CHANGED
|
@@ -14,20 +14,27 @@ Gem::Specification.new do |spec|
|
|
|
14
14
|
'Distributed locks with "prioritized lock acquisition queue" ' \
|
|
15
15
|
'capabilities based on the Redis Database.'
|
|
16
16
|
|
|
17
|
-
spec.description =
|
|
18
|
-
|
|
19
|
-
"based on the Redis Database
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
spec.description = <<~GEMSPEC_DESCRIPTION
|
|
18
|
+
RedisQueuedLocks (aka RQL, aka RQL-lock) - distributed locks with
|
|
19
|
+
"prioritized lock acquisition queue" capabilities based on the Redis Database.
|
|
20
|
+
|
|
21
|
+
Each lock request is put into the request queue
|
|
22
|
+
(each lock is hosted by its own queue separately from other queues)
|
|
23
|
+
and processed in order of their priority: requests of a higher priority go first,
|
|
24
|
+
requests of the same priority are processed in FIFO order.
|
|
25
|
+
Each lock request lives some period of time (RTTL) (with requeue capabilities)
|
|
26
|
+
which guarantees the request queue will never be stacked.
|
|
27
|
+
|
|
28
|
+
In addition to the classic queued (FIFO) strategy RQL supports random (RANDOM)
|
|
29
|
+
lock obtaining strategy when any acquirer from the lock queue
|
|
30
|
+
can obtain the lock regardless the position in the queue.
|
|
31
|
+
|
|
32
|
+
Supports lock request prioritization, Read/Write locks and Reentrant locks.
|
|
33
|
+
|
|
34
|
+
Provides flexible invocation flow, parametrized limits (lock request ttl, lock ttl,
|
|
35
|
+
queue ttl, lock attempts limit, fast failing, etc), zombie locks elimination,
|
|
36
|
+
lock indexing, logging and instrumentation (and much more).
|
|
37
|
+
GEMSPEC_DESCRIPTION
|
|
31
38
|
|
|
32
39
|
spec.homepage = 'https://github.com/0exp/redis_queued_locks'
|
|
33
40
|
spec.license = 'MIT'
|
|
@@ -13,6 +13,9 @@ module RedisQueuedLocks
|
|
|
13
13
|
LOCK_STATE_QUEUE_REPLIES_AT: Integer
|
|
14
14
|
QUEUE_HEAD_REPLY: Integer
|
|
15
15
|
OPPOSITE_QUEUE_HEAD_REPLY: Integer
|
|
16
|
+
QUEUE_REPLIES: Integer
|
|
17
|
+
QUEUE_LOCK_INDEX_REPLIES: Integer
|
|
18
|
+
READ_LOCK_EXTENSION_COMMANDS: Integer
|
|
16
19
|
MAX_DEAD_REQUEST_REMOVALS: Integer
|
|
17
20
|
|
|
18
21
|
# { ok: bool, result: Symbol }
|
|
@@ -35,7 +38,7 @@ module RedisQueuedLocks
|
|
|
35
38
|
RQL::loggerObj logger,
|
|
36
39
|
bool log_lock_try,
|
|
37
40
|
String lock_key,
|
|
38
|
-
RQL::readWriteMode
|
|
41
|
+
RQL::readWriteMode rw_mode,
|
|
39
42
|
String lock_key_queue,
|
|
40
43
|
String read_lock_key_queue,
|
|
41
44
|
String lock_readers_key,
|
|
@@ -60,6 +63,83 @@ module RedisQueuedLocks
|
|
|
60
63
|
|
|
61
64
|
private
|
|
62
65
|
|
|
66
|
+
def same_process_conflict_status: (
|
|
67
|
+
RQL::conflictStrategy conflict_strategy,
|
|
68
|
+
bool lock_upgrade
|
|
69
|
+
) -> Symbol
|
|
70
|
+
|
|
71
|
+
def transact_write_lock_extension: (
|
|
72
|
+
RedisClient::Multi transact,
|
|
73
|
+
String lock_key,
|
|
74
|
+
String lock_name,
|
|
75
|
+
Integer? ttl,
|
|
76
|
+
bool lock_index_enabled,
|
|
77
|
+
Float spc_processed_timestamp
|
|
78
|
+
) -> void
|
|
79
|
+
|
|
80
|
+
def transact_read_lock_extension: (
|
|
81
|
+
RedisClient::Multi transact,
|
|
82
|
+
String lock_readers_key,
|
|
83
|
+
String? read_lock_key,
|
|
84
|
+
String lock_name,
|
|
85
|
+
String acquirer_id,
|
|
86
|
+
Integer? ttl,
|
|
87
|
+
bool lock_index_enabled,
|
|
88
|
+
Float? own_read_lock_expiration,
|
|
89
|
+
Integer redis_time,
|
|
90
|
+
Float spc_processed_timestamp
|
|
91
|
+
) -> void
|
|
92
|
+
|
|
93
|
+
def transact_lock_index_extension: (
|
|
94
|
+
RedisClient::Multi transact,
|
|
95
|
+
String lock_name,
|
|
96
|
+
Integer? ttl,
|
|
97
|
+
bool lock_index_enabled
|
|
98
|
+
) -> void
|
|
99
|
+
|
|
100
|
+
def transact_write_lock_work_through: (
|
|
101
|
+
RedisClient::Multi transact,
|
|
102
|
+
String lock_key,
|
|
103
|
+
Float spc_processed_timestamp
|
|
104
|
+
) -> void
|
|
105
|
+
|
|
106
|
+
def transact_read_lock_work_through: (
|
|
107
|
+
RedisClient::Multi transact,
|
|
108
|
+
String? read_lock_key,
|
|
109
|
+
Float? own_read_lock_expiration,
|
|
110
|
+
Integer redis_time,
|
|
111
|
+
Float spc_processed_timestamp
|
|
112
|
+
) -> void
|
|
113
|
+
|
|
114
|
+
def transact_read_lock_obtaining: (
|
|
115
|
+
RedisClient::Multi transact,
|
|
116
|
+
String request_queue,
|
|
117
|
+
String lock_readers_key,
|
|
118
|
+
String? read_lock_key,
|
|
119
|
+
String lock_name,
|
|
120
|
+
String acquirer_id,
|
|
121
|
+
Integer? ttl,
|
|
122
|
+
bool lock_index_enabled,
|
|
123
|
+
Integer lock_index_grace_period,
|
|
124
|
+
Hash[String|Symbol,untyped]? meta,
|
|
125
|
+
Integer redis_time,
|
|
126
|
+
Float timestamp
|
|
127
|
+
) -> void
|
|
128
|
+
|
|
129
|
+
def transact_write_lock_obtaining: (
|
|
130
|
+
RedisClient::Multi transact,
|
|
131
|
+
String lock_key,
|
|
132
|
+
String request_queue,
|
|
133
|
+
String lock_name,
|
|
134
|
+
String acquirer_id,
|
|
135
|
+
String host_id,
|
|
136
|
+
Integer? ttl,
|
|
137
|
+
bool lock_index_enabled,
|
|
138
|
+
Integer lock_index_grace_period,
|
|
139
|
+
Hash[String|Symbol,untyped]? meta,
|
|
140
|
+
Float timestamp
|
|
141
|
+
) -> void
|
|
142
|
+
|
|
63
143
|
def queue_lock_request: (
|
|
64
144
|
RedisClient::Pipeline pipeline,
|
|
65
145
|
String request_queue,
|
|
@@ -135,7 +215,7 @@ module RedisQueuedLocks
|
|
|
135
215
|
String acquirer_id,
|
|
136
216
|
String host_id,
|
|
137
217
|
RQL::accessStrategy access_strategy,
|
|
138
|
-
RQL::readWriteMode
|
|
218
|
+
RQL::readWriteMode rw_mode,
|
|
139
219
|
String? waiting_acquirer,
|
|
140
220
|
Integer? waiting_priority,
|
|
141
221
|
[String, Float]? opposite_waiting_request,
|
|
@@ -150,7 +230,7 @@ module RedisQueuedLocks
|
|
|
150
230
|
|
|
151
231
|
def drop_dead_requests_ahead: (
|
|
152
232
|
RC::client rconn,
|
|
153
|
-
RQL::readWriteMode
|
|
233
|
+
RQL::readWriteMode rw_mode,
|
|
154
234
|
String request_queue,
|
|
155
235
|
String opposite_request_queue,
|
|
156
236
|
String acquirer_id,
|
|
@@ -161,6 +241,27 @@ module RedisQueuedLocks
|
|
|
161
241
|
[String, Float]? opposite_waiting_request
|
|
162
242
|
) -> [[String, Float]?, [String, Float]?, Array[[String, Integer]]]?
|
|
163
243
|
|
|
244
|
+
def find_dead_requests_ahead: (
|
|
245
|
+
bool read_mode,
|
|
246
|
+
RQL::accessStrategy access_strategy,
|
|
247
|
+
String acquirer_id,
|
|
248
|
+
Integer|Float acquirer_position,
|
|
249
|
+
Float acquirer_dead_score,
|
|
250
|
+
[String, Float]? waiting_request,
|
|
251
|
+
[String, Float]? opposite_waiting_request
|
|
252
|
+
) -> [[String, Float]?, Integer?, [String, Float]?, Integer?]?
|
|
253
|
+
|
|
254
|
+
def pipeline_dead_requests_ahead_removal: (
|
|
255
|
+
RedisClient::Pipeline pipeline,
|
|
256
|
+
String request_queue,
|
|
257
|
+
String opposite_request_queue,
|
|
258
|
+
Float acquirer_dead_score,
|
|
259
|
+
[String, Float]? dead_head,
|
|
260
|
+
Integer? dead_head_priority,
|
|
261
|
+
[String, Float]? dead_ahead,
|
|
262
|
+
Integer? dead_ahead_priority
|
|
263
|
+
) -> void
|
|
264
|
+
|
|
164
265
|
def log_dropped_requests: (
|
|
165
266
|
RQL::loggerObj logger,
|
|
166
267
|
bool log_sampled,
|
|
@@ -170,7 +271,7 @@ module RedisQueuedLocks
|
|
|
170
271
|
String acquirer_id,
|
|
171
272
|
String host_id,
|
|
172
273
|
RQL::accessStrategy access_strategy,
|
|
173
|
-
RQL::readWriteMode
|
|
274
|
+
RQL::readWriteMode rw_mode,
|
|
174
275
|
Array[[String, Integer]] dropped_requests
|
|
175
276
|
) -> void
|
|
176
277
|
|
|
@@ -182,7 +283,7 @@ module RedisQueuedLocks
|
|
|
182
283
|
bool log_sampled,
|
|
183
284
|
bool log_lock_try,
|
|
184
285
|
String lock_key,
|
|
185
|
-
RQL::readWriteMode
|
|
286
|
+
RQL::readWriteMode rw_mode,
|
|
186
287
|
String lock_readers_key,
|
|
187
288
|
String request_queue,
|
|
188
289
|
String opposite_request_queue,
|
|
@@ -38,7 +38,7 @@ module RedisQueuedLocks
|
|
|
38
38
|
log_lock_try: bool,
|
|
39
39
|
instrument: untyped?,
|
|
40
40
|
conflict_strategy: RQL::conflictStrategy,
|
|
41
|
-
|
|
41
|
+
rw_mode: Symbol, # NOTE: (rbs test) validated at runtime (Step 0.1 (RW)): any Symbol is accepted here
|
|
42
42
|
access_strategy: RQL::accessStrategy,
|
|
43
43
|
priority: RQL::lockPriority,
|
|
44
44
|
lock_priorities: Hash[Symbol, Integer],
|
|
@@ -13,7 +13,7 @@ module RedisQueuedLocks
|
|
|
13
13
|
RC::client redis_client,
|
|
14
14
|
String lock_name,
|
|
15
15
|
Integer milliseconds,
|
|
16
|
-
Symbol
|
|
16
|
+
Symbol rw_mode, # NOTE: (rbs test) validated at runtime: any Symbol is accepted here
|
|
17
17
|
bool all_read_locks,
|
|
18
18
|
String acquirer_id,
|
|
19
19
|
bool lock_index_enabled,
|
|
@@ -35,7 +35,7 @@ module RedisQueuedLocks
|
|
|
35
35
|
String lock_name,
|
|
36
36
|
String lock_key,
|
|
37
37
|
Integer milliseconds,
|
|
38
|
-
RQL::readWriteMode
|
|
38
|
+
RQL::readWriteMode rw_mode,
|
|
39
39
|
bool all_read_locks,
|
|
40
40
|
String acquirer_id,
|
|
41
41
|
bool lock_index_enabled
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
use RedisQueuedLocks as RQL
|
|
2
|
+
|
|
3
|
+
module RedisQueuedLocks
|
|
4
|
+
module Acquirer
|
|
5
|
+
module LockSeries
|
|
6
|
+
module InstrVisitor
|
|
7
|
+
def self.lock_series_intermediate_lock_obtained: (
|
|
8
|
+
RQL::instrObj instrumenter,
|
|
9
|
+
bool instr_sampled,
|
|
10
|
+
String lock_key,
|
|
11
|
+
Array[String] lock_keys,
|
|
12
|
+
RQL::readWriteMode rw_mode,
|
|
13
|
+
Integer priority,
|
|
14
|
+
Integer ttl,
|
|
15
|
+
String acq_id,
|
|
16
|
+
String hst_id,
|
|
17
|
+
Integer|Float ts,
|
|
18
|
+
Integer|Float acq_time,
|
|
19
|
+
untyped? instrument
|
|
20
|
+
) -> void
|
|
21
|
+
|
|
22
|
+
def self.lock_series_lock_obtained: (
|
|
23
|
+
RQL::instrObj instrumenter,
|
|
24
|
+
bool instr_sampled,
|
|
25
|
+
String lock_key,
|
|
26
|
+
Array[String] lock_keys,
|
|
27
|
+
RQL::readWriteMode rw_mode,
|
|
28
|
+
Integer priority,
|
|
29
|
+
Integer ttl,
|
|
30
|
+
String acq_id,
|
|
31
|
+
String hst_id,
|
|
32
|
+
Integer|Float ts,
|
|
33
|
+
Integer|Float acq_time,
|
|
34
|
+
untyped? instrument
|
|
35
|
+
) -> void
|
|
36
|
+
|
|
37
|
+
def self.lock_series_lock_obtaining_failed: (
|
|
38
|
+
RQL::instrObj instrumenter,
|
|
39
|
+
bool instr_sampled,
|
|
40
|
+
String lock_key,
|
|
41
|
+
Array[String] lock_keys,
|
|
42
|
+
RQL::readWriteMode rw_mode,
|
|
43
|
+
Integer priority,
|
|
44
|
+
Integer ttl,
|
|
45
|
+
String acq_id,
|
|
46
|
+
String hst_id,
|
|
47
|
+
Integer|Float ts,
|
|
48
|
+
Integer|Float acq_time,
|
|
49
|
+
Symbol result,
|
|
50
|
+
untyped? instrument
|
|
51
|
+
) -> void
|
|
52
|
+
|
|
53
|
+
def self.lock_series_obtained: (
|
|
54
|
+
RQL::instrObj instrumenter,
|
|
55
|
+
bool instr_sampled,
|
|
56
|
+
Array[String] lock_keys,
|
|
57
|
+
RQL::readWriteMode rw_mode,
|
|
58
|
+
Integer priority,
|
|
59
|
+
Integer ttl,
|
|
60
|
+
String acq_id,
|
|
61
|
+
String hst_id,
|
|
62
|
+
Integer|Float ts,
|
|
63
|
+
Integer|Float acq_time,
|
|
64
|
+
Array[String] reentrant_lock_keys,
|
|
65
|
+
untyped? instrument
|
|
66
|
+
) -> void
|
|
67
|
+
|
|
68
|
+
def self.lock_series_hold_and_release: (
|
|
69
|
+
RQL::instrObj instrumenter,
|
|
70
|
+
bool instr_sampled,
|
|
71
|
+
Array[String] lock_keys,
|
|
72
|
+
RQL::readWriteMode rw_mode,
|
|
73
|
+
Integer priority,
|
|
74
|
+
Integer ttl,
|
|
75
|
+
String acq_id,
|
|
76
|
+
String hst_id,
|
|
77
|
+
Integer|Float ts,
|
|
78
|
+
Integer|Float acq_time,
|
|
79
|
+
Integer|Float hold_time,
|
|
80
|
+
Array[String] reentrant_lock_keys,
|
|
81
|
+
untyped? instrument
|
|
82
|
+
) -> void
|
|
83
|
+
|
|
84
|
+
def self.lock_series_obtaining_failed: (
|
|
85
|
+
RQL::instrObj instrumenter,
|
|
86
|
+
bool instr_sampled,
|
|
87
|
+
Array[String] lock_keys,
|
|
88
|
+
RQL::readWriteMode rw_mode,
|
|
89
|
+
Integer priority,
|
|
90
|
+
Integer ttl,
|
|
91
|
+
String acq_id,
|
|
92
|
+
String hst_id,
|
|
93
|
+
Integer|Float ts,
|
|
94
|
+
Integer|Float acq_time,
|
|
95
|
+
Symbol result,
|
|
96
|
+
String? failed_lock_key,
|
|
97
|
+
untyped? instrument
|
|
98
|
+
) -> void
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|