From 86ba8c4e6a490980aa69dd07fd9b0f468b0c5ded Mon Sep 17 00:00:00 2001 From: Rustam Ibragimov Date: Thu, 28 Nov 2024 00:48:19 +0300 Subject: [PATCH] [typo] acquier -> acquirer --- CHANGELOG.md | 15 ++- README.md | 48 ++++---- .../acquirer/acquire_lock.rb | 38 +++--- .../acquire_lock/dequeue_from_lock_queue.rb | 8 +- .../dequeue_from_lock_queue/log_visitor.rb | 6 +- .../acquirer/acquire_lock/log_visitor.rb | 40 +++---- .../acquirer/acquire_lock/try_to_lock.rb | 86 +++++++------- .../acquire_lock/try_to_lock/log_visitor.rb | 108 +++++++++--------- .../acquirer/acquire_lock/with_acq_timeout.rb | 11 +- .../acquirer/acquire_lock/yield_expire.rb | 16 +-- .../acquire_lock/yield_expire/log_visitor.rb | 12 +- .../acquirer/clear_dead_requests.rb | 2 +- lib/redis_queued_locks/acquirer/lock_info.rb | 2 +- lib/redis_queued_locks/acquirer/queue_info.rb | 2 +- lib/redis_queued_locks/client.rb | 14 +-- lib/redis_queued_locks/errors.rb | 6 +- lib/redis_queued_locks/resource.rb | 20 ++-- lib/redis_queued_locks/swarm.rb | 6 +- lib/redis_queued_locks/swarm/flush_zombies.rb | 14 +-- lib/redis_queued_locks/swarm/zombie_info.rb | 16 +-- .../acquire_lock/dequeue_from_lock_queue.rbs | 2 +- .../dequeue_from_lock_queue/log_visitor.rbs | 2 +- .../acquirer/acquire_lock/log_visitor.rbs | 14 +-- .../acquirer/acquire_lock/try_to_lock.rbs | 4 +- .../acquire_lock/try_to_lock/log_visitor.rbs | 36 +++--- .../acquirer/acquire_lock/yield_expire.rbs | 4 +- .../yield_with_expire/log_visitor.rbs | 4 +- sig/redis_queued_locks/client.rbs | 4 +- sig/redis_queued_locks/errors.rbs | 6 +- sig/redis_queued_locks/resource.rbs | 8 +- sig/redis_queued_locks/swarm.rbs | 2 +- sig/redis_queued_locks/swarm/zombie_info.rbs | 4 +- spec/redis_queued_locks_spec.rb | 40 +++---- 33 files changed, 303 insertions(+), 297 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4da07f..1f52e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,13 @@ ## Changed - Updated development dependencies (`armitage-rubocop`); -- Constant renaming: all constants and constant parts were renamed from `Acquier` to `Acquirer`; - CI is splitted to "mainstream ruby version" and "previous actually maintaned ruby versions"; +- `Acquier` -> `Acquirer`, `Acquierment` -> `Acquirement` (typos): + - [**Breaking**] Constant renaming: all constants and constant parts were renamed from `Acquier` to `Acquirer`; + - [**Breaking**] Method and variable names renaming: all `acquier` text parts of method/variable names were renamed to `acquirer`; + - [**Breaking**] Logs: all `acquier` text parts of each log message type were renamed to `acquirer`; + - [**Breaking**] Instrumentation: all `acquier` text parts of each event name were renamed to `acquirer`; + - [**Breaking**] Exceptions: all `Acquierment` exception constant name parts were renamed to `Acquirement`; ## Added - Type signatures (`RBS`, see the `sig` directory) + `Steep` integration (see `Steepfile` for details); - CI: added `TypeCheck` step; @@ -54,7 +59,7 @@ - each ruby worker of the swarm probes himself that he is alive; - worker that does not probes himselfs treats as a zombie; - worekr becomes dead when your ruby process is dead, or thread is dead or your ractor is dead; - - each zombie's lock, acquier and position in queue are flushed in background via `flush_zombies` swarm element; + - each zombie's lock, acquirer and position in queue are flushed in background via `flush_zombies` swarm element; - the supervisor module keeps up and running each swarm melement (`probe_hosts` and `flush_zombies`): - cuz each element works in background and can fail by any unexpected exception the supervisor guarantees that your elements will ressurect after that; - each element can be deeply configured (and enabled/disabled); @@ -65,7 +70,7 @@ - supervisor that keeps all elements running and wokring; - an ability to check the swarm status (`#swarm_status`): who is working, who is dead, running status, internal main loop states, etc; - an abiltiy to check the swarm information (`#swarm_info`): showing the current swarm hosts and their last probes and current zombie status; - - an ability to find zombie locks, zombie acquiers and zombie hosts (`#zombie_locks`, `#zombie_acquiers`, `#zombie_hosts`); + - an ability to find zombie locks, zombie acquirers and zombie hosts (`#zombie_locks`, `#zombie_acquiers`, `#zombie_hosts`); - an ability to extract the full zombie information (`#zombies_info`/`#zombies`); - each zombie lock will be flushed in background by appropriated swarm element (`flush_zombies`); - deeply configurable zombie factors: zombie ttl, host probing period, supervisor check period; @@ -264,7 +269,7 @@ ## [0.0.27] - 2024-03-21 ### Changed -- Better acquier position accuracy: acquier position in lock queue +- Better acquirer position accuracy: acquirer position in lock queue should be represented as EPOCH in seconds+microseconds (previously: simply in seconds); ## [0.0.26] - 2024-03-21 @@ -343,7 +348,7 @@ ## [0.0.9] - 2024-02-27 ### Changed -- The lock acquier identifier (`acq_id`) now includes the fiber id, the ractor id and an unique per-process +- The lock acquirer identifier (`acq_id`) now includes the fiber id, the ractor id and an unique per-process 10 byte string. It is added in order to prevent collisions between different processes/pods that will have the same process id / thread id identifiers (cuz it is an object_id integers) that can lead to the same position with the same `acq_id` for different processes/pods in the lock request queue. diff --git a/README.md b/README.md index 437b298..bdc908f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Provides flexible invocation flow, parametrized limits (lock request ttl, lock t - [zombies_info](#zombies_info) - [zombie_locks](#zombie_locks) - [zombie_hosts](#zombie_hosts) - - [zombie_acquiers](#zombie_acquiers) + - [zombie_acquirers](#zombie_acquirers) - [Lock Access Strategies](#lock-access-strategies) - [queued](#lock-access-strategies) - [random](#lock-access-strategies) @@ -251,7 +251,7 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config| # (default: -> { RedisQueuedLocks::Resource.calc_uniq_identity }) # - uniqude idenfitier that is uniq per process/pod; # - prevents potential lock-acquirement collisions bettween different process/pods - # that have identical process_id/thread_id/fiber_id/ractor_id (identivcal acquier ids); + # that have identical process_id/thread_id/fiber_id/ractor_id (identivcal acquirer ids); # - it is calculated once per `RedisQueudLocks::Client` instance; # - expects the proc object; # - `SecureRandom.hex(8)` by default; @@ -264,7 +264,7 @@ clinet = RedisQueuedLocks::Client.new(redis_client) do |config| # - at this moment the only debug logs are realised in following cases: # - "[redis_queued_locks.start_lock_obtaining]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); # - "[redis_queued_locks.start_try_to_lock_cycle]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); - # - "[redis_queued_locks.dead_score_reached__reset_acquier_position]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); + # - "[redis_queued_locks.dead_score_reached__reset_acquirer_position]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); # - "[redis_queued_locks.lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); # - "[redis_queued_locks.extendable_reentrant_lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); # - "[redis_queued_locks.reentrant_lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); @@ -375,7 +375,7 @@ end - the block's result will be returned; - If block is not passed: - the obtained lock will be released after lock's ttl; - - the lock information will be returned (hash with technical info that contains: lock key, acquier identifier, acquirement timestamp, lock's ttl, type of obtaining process, etc); + - the lock information will be returned (hash with technical info that contains: lock key, acquirer identifier, acquirement timestamp, lock's ttl, type of obtaining process, etc); ```ruby def lock( @@ -594,8 +594,8 @@ Return value: { ok: true, result: { - lock_key: String, # acquierd lock key ("rql:lock:your_lock_name") - acq_id: String, # acquier identifier ("process_id/thread_id/fiber_id/ractor_id/identity") + lock_key: String, # acquirerd lock key ("rql:lock:your_lock_name") + acq_id: String, # acquirer identifier ("process_id/thread_id/fiber_id/ractor_id/identity") hst_id: String, # host identifier ("process_id/thread_id/ractor_id/identity") ts: Float, # time (epoch) when lock was obtained (float, Time#to_f) ttl: Integer, # lock's time to live in milliseconds (integer) @@ -786,8 +786,8 @@ rql.lock('my_lock', retry_delay: 3000, ttl: 3000, access_strategy: :random) - `#lock!` - exceptional lock obtaining; - fails when (and with): - (`RedisQueuedLocks::LockAlreadyObtainedError`) when `fail_fast` is `true` and lock is already obtained; - - (`RedisQueuedLocks::LockAcquiermentTimeoutError`) `timeout` limit reached before lock is obtained; - - (`RedisQueuedLocks::LockAcquiermentRetryLimitError`) `retry_count` limit reached before lock is obtained; + - (`RedisQueuedLocks::LockAcquirementTimeoutError`) `timeout` limit reached before lock is obtained; + - (`RedisQueuedLocks::LockAcquirementRetryLimitError`) `retry_count` limit reached before lock is obtained; - (`RedisQueuedLocks::ConflictLockObtainError`) when `conflict_strategy: :dead_locking` is used and the "same-process-dead-lock" is happened (see [Deadlocks and Reentrant locks](#deadlocks-and-reentrant-locks) for details); ```ruby @@ -834,7 +834,7 @@ See `#lock` method [documentation](#lock---obtain-a-lock). - returns `nil` if lock does not exist; - lock data (`Hash`): - `"lock_key"` - `string` - lock key in redis; - - `"acq_id"` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity); + - `"acq_id"` - `string` - acquirer identifier (process_id/thread_id/fiber_id/ractor_id/identity); - `"hst_id"` - `string` - host identifier (process_id/thread_id/ractor_id/identity); - `"ts"` - `numeric`/`epoch` - the time when lock was obtained; - `"init_ttl"` - `integer` - (milliseconds) initial lock key ttl; @@ -927,12 +927,12 @@ you can receive the lock queue info with empty queue value (an empty array). - queue represents the ordered set of lock key reqests: - set is ordered by score in ASC manner (inside the Redis Set); - score is represented as a timestamp when the lock request was made; - - represents the acquier identifier and their score as an array of hashes; + - represents the acquirer identifier and their score as an array of hashes; - returns `nil` if lock queue does not exist; - lock queue data (`Hash>`): - `"lock_queue"` - `string` - lock queue key in redis; - `"queue"` - `array` - an array of lock requests (array of hashes): - - `"acq_id"` - `string` - acquier identifier (process_id/thread_id/fiber_id/ractor_id/identity by default); + - `"acq_id"` - `string` - acquirer identifier (process_id/thread_id/fiber_id/ractor_id/identity by default); - `"score"` - `float`/`epoch` - time when the lock request was made (epoch); ```ruby @@ -1340,7 +1340,7 @@ rql.locks_info # or rql.locks_info(scan_size: 123) - returns `Set>` (see [#queue_info](#queue_info) and examples below for details). - contained data: `{ queue: String, requests: Array> }` - `:queue` - `String` - lock key queue in Redis; - - `:requests` - `Array>` - lock requests in the que with their acquier id and score. + - `:requests` - `Array>` - lock requests in the que with their acquirer id and score. ```ruby rql.queues_info # or rql.qeuues_info(scan_size: 123) @@ -1576,7 +1576,7 @@ rql.possible_host_ids - [zombies_info](#zombies_info) - [zombie_locks](#zombie_locks) - [zombie_hosts](#zombie_hosts) -- [zombie_acquiers](#zombie_acquiers) +- [zombie_acquirers](#zombie_acquirers)
@@ -1609,7 +1609,7 @@ rql.possible_host_ids # (flush_zombies) zombie flushing configuration config.swarm.flush_zombies.enabled_for_swarm = true # NOTE: run zombie flushing or not config.swarm.flush_zombies.zombie_flush_period = 10 # NOTE: (in seconds) period of time when the zombie flusher is triggered - config.swarm.flush_zombies.zombie_ttl = 15_000 # NOTE: (in milliseconds) when the lock/host/acquier is considered a zombie + config.swarm.flush_zombies.zombie_ttl = 15_000 # NOTE: (in milliseconds) when the lock/host/acquirer is considered a zombie config.swarm.flush_zombies.zombie_lock_scan_size = 500 # NOTE: scan sizec during zombie flushing config.swarm.flush_zombies.zombie_queue_scan_size = 500 # NOTE: scan sizec during zombie flushing # (flush_zombies) individual redis config @@ -1688,7 +1688,7 @@ rql.possible_host_ids :zombie_locks=>#} [5] pry(main)> rql.zombie_locks => # - [6] pry(main)> rql.zombie_acquiers + [6] pry(main)> rql.zombie_acquirers => # [7] pry(main)> rql.zombie_hosts => #{:enabled=>true, :ractor=>{:running=>true, :state=>"running"}, :main_loop=>{:running=>true, :state=>"sleep"}}} [11] pry(main)> rql.zombies_info => {:zombie_hosts=>#, :zombie_acquirers=>#, :zombie_locks=>#} - [12] pry(main)> rql.zombie_acquiers + [12] pry(main)> rql.zombie_acquirers => # [13] pry(main)> rql.zombie_hosts => # @@ -1796,7 +1796,7 @@ rql.possible_host_ids ```ruby "[redis_queued_locks.start_lock_obtaining]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); "[redis_queued_locks.start_try_to_lock_cycle]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); -"[redis_queued_locks.dead_score_reached__reset_acquier_position]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); +"[redis_queued_locks.dead_score_reached__reset_acquirer_position]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); "[redis_queued_locks.lock_obtained]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time"); "[redis_queued_locks.extendable_reentrant_lock_obtained]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat", "acq_time"); "[redis_queued_locks.reentrant_lock_obtained]" # (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat", "acq_time"); @@ -1843,7 +1843,7 @@ rql.possible_host_ids # - at this moment the only debug logs are realised in following cases: # - "[redis_queued_locks.start_lock_obtaining]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); # - "[redis_queued_locks.start_try_to_lock_cycle]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); -# - "[redis_queued_locks.dead_score_reached__reset_acquier_position]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); +# - "[redis_queued_locks.dead_score_reached__reset_acquirer_position]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acs_strat"); # - "[redis_queued_locks.lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); # - "[redis_queued_locks.extendable_reentrant_lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); # - "[redis_queued_locks.reentrant_lock_obtained]" (logs "lock_key", "queue_ttl", "acq_id", "hst_id", "acq_time", "acs_strat"); @@ -1985,7 +1985,7 @@ Detalized event semantics and payload structure: - raised from `#lock`/`#lock!`; - payload: - `:ttl` - `integer`/`milliseconds` - lock ttl; - - `:acq_id` - `string` - lock acquier identifier; + - `:acq_id` - `string` - lock acquirer identifier; - `:hst_id` - `string` - lock's host identifier; - `:lock_key` - `string` - lock name; - `:ts` - `numeric`/`epoch` - the time when the lock was obtaiend; @@ -1998,7 +1998,7 @@ Detalized event semantics and payload structure: - payload: - `:lock_key` - `string` - lock name; - `:ttl` - `integer`/`milliseconds` - last lock ttl by reentrant locking; - - `:acq_id` - `string` - lock acquier identifier; + - `:acq_id` - `string` - lock acquirer identifier; - `:hst_id` - `string` - lock's host identifier; - `:ts` - `numeric`/`epoch` - the time when the lock was obtaiend as extendable reentrant lock; - `:acq_time` - `float`/`milliseconds` - time spent on lock acquiring; @@ -2010,7 +2010,7 @@ Detalized event semantics and payload structure: - payload: - `:lock_key` - `string` - lock name; - `:ttl` - `integer`/`milliseconds` - last lock ttl by reentrant locking; - - `:acq_id` - `string` - lock acquier identifier; + - `:acq_id` - `string` - lock acquirer identifier; - `:hst_id` - `string` - lock's host identifier; - `:ts` - `numeric`/`epoch` - the time when the lock was obtaiend as reentrant lock; - `:acq_time` - `float`/`milliseconds` - time spent on lock acquiring; @@ -2022,7 +2022,7 @@ Detalized event semantics and payload structure: - payload: - `:hold_time` - `float`/`milliseconds` - lock hold time; - `:ttl` - `integer`/`milliseconds` - lock ttl; - - `:acq_id` - `string` - lock acquier identifier; + - `:acq_id` - `string` - lock acquirer identifier; - `:hst_id` - `string` - lock's host identifier; - `:lock_key` - `string` - lock name; - `:ts` - `numeric`/`epoch` - the time when lock was obtained; @@ -2036,7 +2036,7 @@ Detalized event semantics and payload structure: - payload: - `:hold_time` - `float`/`milliseconds` - lock hold time; - `:ttl` - `integer`/`milliseconds` - last lock ttl by reentrant locking; - - `:acq_id` - `string` - lock acquier identifier; + - `:acq_id` - `string` - lock acquirer identifier; - `:hst_id` - `string` - lock's host identifier; - `:ts` - `numeric`/`epoch` - the time when the lock was obtaiend as reentrant lock; - `:lock_key` - `string` - lock name; @@ -2093,7 +2093,7 @@ Detalized event semantics and payload structure: whose ttl may expire before the block execution completes). It makes sense for non-`timed` locks *only*; - sized lock queues (with an ability of dynamically growing size); - better code stylization (+ some refactorings); - - `RedisQueuedLocks::Acquier::Try.try_to_lock` - detailed successful result analization; + - `RedisQueuedLocks::Acquirer::Try.try_to_lock` - detailed successful result analization; - Support for LIFO strategy; - better specs with 100% test coverage (total specs rework); - statistics with UI; diff --git a/lib/redis_queued_locks/acquirer/acquire_lock.rb b/lib/redis_queued_locks/acquirer/acquire_lock.rb index 318c26a..3f7a5e9 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock.rb @@ -32,7 +32,7 @@ class << self # @param redis [RedisClient] # Redis connection client. # @param lock_name [String] - # Lock name to be acquier. + # Lock name to be acquirer. # @option process_id [Integer,String] # The process that want to acquire a lock. # @option thread_id [Integer,String] @@ -224,7 +224,7 @@ def acquire_lock( end # Step 1: prepare lock requirements (generate lock name, calc lock ttl, etc). - acquier_id = RedisQueuedLocks::Resource.acquier_identifier( + acquirer_id = RedisQueuedLocks::Resource.acquirer_identifier( process_id, thread_id, fiber_id, @@ -240,7 +240,7 @@ def acquire_lock( lock_ttl = ttl lock_key = RedisQueuedLocks::Resource.prepare_lock_key(lock_name) lock_key_queue = RedisQueuedLocks::Resource.prepare_lock_queue(lock_name) - acquier_position = RedisQueuedLocks::Resource.calc_initial_acquier_position + acquirer_position = RedisQueuedLocks::Resource.calc_initial_acquirer_position log_sampled = RedisQueuedLocks::Logging.should_log?( log_sampling_enabled, @@ -275,7 +275,7 @@ def acquire_lock( lock_key, lock_key_queue, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, log_sampled, @@ -285,7 +285,7 @@ def acquire_lock( LogVisitor.start_lock_obtaining( logger, log_sampled, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) # Step 2: try to lock with timeout @@ -305,17 +305,17 @@ def acquire_lock( LogVisitor.start_try_to_lock_cycle( logger, log_sampled, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) # Step 2.X: check the actual score: is it in queue ttl limit or not? - if RedisQueuedLocks::Resource.dead_score_reached?(acquier_position, queue_ttl) + if RedisQueuedLocks::Resource.dead_score_reached?(acquirer_position, queue_ttl) # Step 2.X.X: dead score reached => re-queue the lock request with the new score; - acquier_position = RedisQueuedLocks::Resource.calc_initial_acquier_position + acquirer_position = RedisQueuedLocks::Resource.calc_initial_acquirer_position - LogVisitor.dead_score_reached__reset_acquier_position( + LogVisitor.dead_score_reached__reset_acquirer_position( logger, log_sampled, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) end @@ -325,9 +325,9 @@ def acquire_lock( log_lock_try, lock_key, lock_key_queue, - acquier_id, + acquirer_id, host_id, - acquier_position, + acquirer_position, lock_ttl, queue_ttl, fail_fast, @@ -356,7 +356,7 @@ def acquire_lock( # instrumetnation: (reentrant lock with ttl extension) LogVisitor.extendable_reentrant_lock_obtained( logger, log_sampled, result[:lock_key], - queue_ttl, acquier_id, host_id, acq_time, access_strategy + queue_ttl, acquirer_id, host_id, acq_time, access_strategy ) InstrVisitor.extendable_reentrant_lock_obtained( instrumenter, instr_sampled, result[:lock_key], @@ -367,7 +367,7 @@ def acquire_lock( # instrumetnation: (reentrant lock without ttl extension) LogVisitor.reentrant_lock_obtained( logger, log_sampled, result[:lock_key], - queue_ttl, acquier_id, host_id, acq_time, access_strategy + queue_ttl, acquirer_id, host_id, acq_time, access_strategy ) InstrVisitor.reentrant_lock_obtained( instrumenter, instr_sampled, result[:lock_key], @@ -379,7 +379,7 @@ def acquire_lock( # NOTE: classic is: acq_process[:result][:process] == :lock_obtaining LogVisitor.lock_obtained( logger, log_sampled, result[:lock_key], - queue_ttl, acquier_id, host_id, acq_time, access_strategy + queue_ttl, acquirer_id, host_id, acq_time, access_strategy ) InstrVisitor.lock_obtained( instrumenter, instr_sampled, result[:lock_key], @@ -424,7 +424,7 @@ def acquire_lock( raise( RedisQueuedLocks::ConflictLockObtainError, "Lock Conflict: trying to acquire the lock \"#{lock_key}\" " \ - "that is already acquired by the current acquier (acq_id: \"#{acquier_id}\")." + "that is already acquired by the current acquirer (acq_id: \"#{acquirer_id}\")." ) end else @@ -450,7 +450,7 @@ def acquire_lock( if raise_errors raise( - RedisQueuedLocks::LockAcquiermentRetryLimitError, + RedisQueuedLocks::LockAcquirementRetryLimitError, "Failed to acquire the lock \"#{lock_key}\" " \ "for the given retry_count limit (#{retry_count} times)." ) @@ -491,7 +491,7 @@ def acquire_lock( redis, logger, lock_key, - acquier_id, + acquirer_id, host_id, access_strategy, timed, @@ -558,7 +558,7 @@ def acquire_lock( # - **(notice: in other cases the lock obtaining time and tries count are infinite) acq_process[:result] = :timeout_reached end - # Step 3.b: lock is not acquired (acquier is dequeued by timeout callback) + # Step 3.b: lock is not acquired (acquirer is dequeued by timeout callback) RedisQueuedLocks::Data[ok: false, result: acq_process[:result]] # steep:ignore end end diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb b/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb index e628120..8544363 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rb @@ -10,7 +10,7 @@ module RedisQueuedLocks::Acquirer::AcquireLock::DequeueFromLockQueue # @param lock_key [String] # @param lock_key_queue [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @param log_sampled [Boolean] @@ -26,16 +26,16 @@ def dequeue_from_lock_queue( lock_key, lock_key_queue, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, log_sampled, instr_sampled ) - result = redis.call('ZREM', lock_key_queue, acquier_id) + result = redis.call('ZREM', lock_key_queue, acquirer_id) LogVisitor.dequeue_from_lock_queue( logger, log_sampled, - lock_key, queue_ttl, acquier_id, host_id, access_strategy + lock_key, queue_ttl, acquirer_id, host_id, access_strategy ) RedisQueuedLocks::Data[ok: true, result: result] # steep:ignore end diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb b/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb index 1759e52..accb8af 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rb @@ -8,7 +8,7 @@ class << self # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -21,7 +21,7 @@ def dequeue_from_lock_queue( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -31,7 +31,7 @@ def dequeue_from_lock_queue( "[redis_queued_locks.fail_fast_or_limits_reached_or_deadlock__dequeue] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}" end rescue nil diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb b/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb index 03f3d82..b98bc55 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/log_visitor.rb @@ -10,7 +10,7 @@ class << self # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -23,7 +23,7 @@ def start_lock_obtaining( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -33,7 +33,7 @@ def start_lock_obtaining( "[redis_queued_locks.start_lock_obtaining] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -43,7 +43,7 @@ def start_lock_obtaining( # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -56,7 +56,7 @@ def start_try_to_lock_cycle( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -66,7 +66,7 @@ def start_try_to_lock_cycle( "[redis_queued_locks.start_try_to_lock_cycle] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -76,7 +76,7 @@ def start_try_to_lock_cycle( # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -84,22 +84,22 @@ def start_try_to_lock_cycle( # @api private # @since 1.7.0 # @version 1.9.0 - def dead_score_reached__reset_acquier_position( + def dead_score_reached__reset_acquirer_position( logger, log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) return unless log_sampled logger.debug do - "[redis_queued_locks.dead_score_reached__reset_acquier_position] " \ + "[redis_queued_locks.dead_score_reached__reset_acquirer_position] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -109,7 +109,7 @@ def dead_score_reached__reset_acquier_position( # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param acq_time [Numeric] # @param access_strategy [Symbol] @@ -123,7 +123,7 @@ def extendable_reentrant_lock_obtained( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, acq_time, access_strategy @@ -134,7 +134,7 @@ def extendable_reentrant_lock_obtained( "[redis_queued_locks.extendable_reentrant_lock_obtained] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "host_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "acq_time => #{acq_time} (ms)" @@ -145,7 +145,7 @@ def extendable_reentrant_lock_obtained( # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param acq_time [Numeric] # @param access_strategy [Symbol] @@ -159,7 +159,7 @@ def reentrant_lock_obtained( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, acq_time, access_strategy @@ -170,7 +170,7 @@ def reentrant_lock_obtained( "[redis_queued_locks.reentrant_lock_obtained] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "acq_time => #{acq_time} (ms)" @@ -181,7 +181,7 @@ def reentrant_lock_obtained( # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param acq_time [Numeric] # @param access_strategy [Symbol] @@ -195,7 +195,7 @@ def lock_obtained( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, acq_time, access_strategy @@ -206,7 +206,7 @@ def lock_obtained( "[redis_queued_locks.lock_obtained] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "acq_time => #{acq_time} (ms)" diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb b/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb index 1ecf039..cf2eb20 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rb @@ -21,9 +21,9 @@ module RedisQueuedLocks::Acquirer::AcquireLock::TryToLock # @param log_lock_try [Boolean] # @param lock_key [String] # @param lock_key_queue [String] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] - # @param acquier_position [Numeric] + # @param acquirer_position [Numeric] # @param ttl [Integer] # @param queue_ttl [Integer] # @param fail_fast [Boolean] @@ -44,9 +44,9 @@ def try_to_lock( log_lock_try, lock_key, lock_key_queue, - acquier_id, + acquirer_id, host_id, - acquier_position, + acquirer_position, ttl, queue_ttl, fail_fast, @@ -66,19 +66,19 @@ def try_to_lock( LogVisitor.start( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) # Step X: start to work with lock acquiring result = redis.with do |rconn| LogVisitor.rconn_fetched( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) # Step 0: # watch the lock key changes (and discard acquirement if lock is already - # obtained by another acquier during the current lock acquiremntt) + # obtained by another acquirer during the current lock acquiremntt) rconn.multi(watch: [lock_key]) do |transact| # SP-Conflict status PREPARING: get the current lock obtainer current_lock_obtainer = rconn.call('HGET', lock_key, 'acq_id') @@ -86,10 +86,10 @@ def try_to_lock( sp_conflict_status = nil # SP-Conflict Step X1: calculate the current deadlock status - if current_lock_obtainer != nil && acquier_id == current_lock_obtainer + if current_lock_obtainer != nil && acquirer_id == current_lock_obtainer LogVisitor.same_process_conflict_detected( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) # SP-Conflict Step X2: self-process dead lock moment started. @@ -116,7 +116,7 @@ def try_to_lock( end LogVisitor.same_process_conflict_analyzed( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, sp_conflict_status + queue_ttl, acquirer_id, host_id, access_strategy, sp_conflict_status ) end @@ -159,7 +159,7 @@ def try_to_lock( # @type var spc_processed_timestamp: ::Float LogVisitor.reentrant_lock__extend_and_work_through( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, + queue_ttl, acquirer_id, host_id, access_strategy, sp_conflict_status, ttl, spc_processed_timestamp ) # SP-Conflict-Step X2: switch to dead lock logic or not @@ -186,7 +186,7 @@ def try_to_lock( # @type var spc_processed_timestamp: ::Float LogVisitor.reentrant_lock__work_through( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, + queue_ttl, acquirer_id, host_id, access_strategy, sp_conflict_status, spc_processed_timestamp ) # SP-Conflict-Step X2: switch to dead lock logic or not @@ -198,7 +198,7 @@ def try_to_lock( # @type var spc_processed_timestamp: ::Float LogVisitor.single_process_lock_conflict__dead_lock( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, + queue_ttl, acquirer_id, host_id, access_strategy, sp_conflict_status, spc_processed_timestamp ) # Reached the SP-Non-Conflict Mode (NOTE): @@ -208,84 +208,84 @@ def try_to_lock( # Fast-Step X1: lock is already obtained. fail fast leads to "no try". inter_result = :fail_fast_no_try else - # Step 1: add an acquier to the lock acquirement queue - rconn.call('ZADD', lock_key_queue, 'NX', acquier_position, acquier_id) + # Step 1: add an acquirer to the lock acquirement queue + rconn.call('ZADD', lock_key_queue, 'NX', acquirer_position, acquirer_id) LogVisitor.acq_added_to_queue( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) - # Step 2.1: drop expired acquiers from the lock queue + # Step 2.1: drop expired acquirers from the lock queue rconn.call( 'ZREMRANGEBYSCORE', lock_key_queue, '-inf', - RedisQueuedLocks::Resource.acquier_dead_score(queue_ttl) + RedisQueuedLocks::Resource.acquirer_dead_score(queue_ttl) ) LogVisitor.remove_expired_acqs( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) - # Step 3: get the actual acquier waiting in the queue - waiting_acquier = Array(rconn.call('ZRANGE', lock_key_queue, '0', '0')).first + # Step 3: get the actual acquirer waiting in the queue + waiting_acquirer = Array(rconn.call('ZRANGE', lock_key_queue, '0', '0')).first LogVisitor.get_first_from_queue( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, waiting_acquier + queue_ttl, acquirer_id, host_id, access_strategy, waiting_acquirer ) # Step PRE-4.x: check if the request time limit is reached # (when the current try self-removes itself from queue (queue ttl has come)) - if waiting_acquier == nil + if waiting_acquirer == nil LogVisitor.exit__queue_ttl_reached( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) inter_result = :dead_score_reached # Step STRATEGY: check the stragegy and corresponding preventing factor - # Step STRATEGY (queued): check the actual acquier: is it ours? are we aready to lock? - elsif access_strategy == :queued && waiting_acquier != acquier_id + # Step STRATEGY (queued): check the actual acquirer: is it ours? are we aready to lock? + elsif access_strategy == :queued && waiting_acquirer != acquirer_id # Step ROLLBACK 1.1: our time hasn't come yet. retry! LogVisitor.exit__no_first( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, waiting_acquier, + queue_ttl, acquirer_id, host_id, access_strategy, waiting_acquirer, rconn.call('HGETALL', lock_key).to_h ) - inter_result = :acquier_is_not_first_in_queue + inter_result = :acquirer_is_not_first_in_queue # Step STRAGEY: successfull (:queued OR :random) - elsif (access_strategy == :queued && waiting_acquier == acquier_id) || + elsif (access_strategy == :queued && waiting_acquirer == acquirer_id) || (access_strategy == :random) # NOTE: our time has come! let's try to acquire the lock! # Step 5: find the lock -> check if the our lock is already acquired - locked_by_acquier = rconn.call('HGET', lock_key, 'acq_id') + locked_by_acquirer = rconn.call('HGET', lock_key, 'acq_id') - if locked_by_acquier + if locked_by_acquirer # Step ROLLBACK 2: required lock is stil acquired. retry! LogVisitor.exit__lock_still_obtained( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy, - waiting_acquier, locked_by_acquier, + queue_ttl, acquirer_id, host_id, access_strategy, + waiting_acquirer, locked_by_acquirer, rconn.call('HGETALL', lock_key).to_h ) inter_result = :lock_is_still_acquired else # NOTE: required lock is free and ready to be acquired! acquire! - # Step 6.1: remove our acquier from waiting queue - transact.call('ZREM', lock_key_queue, acquier_id) + # Step 6.1: remove our acquirer from waiting queue + transact.call('ZREM', lock_key_queue, acquirer_id) - # Step 6.2: acquire a lock and store an info about the acquier and host + # Step 6.2: acquire a lock and store an info about the acquirer and host transact.call( 'HSET', lock_key, - 'acq_id', acquier_id, + 'acq_id', acquirer_id, 'hst_id', host_id, 'ts', (timestamp = Time.now.to_f), 'ini_ttl', ttl, @@ -297,7 +297,7 @@ def try_to_lock( LogVisitor.obtain__free_to_acquire( logger, log_sampled, log_lock_try, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) end end @@ -327,7 +327,7 @@ def try_to_lock( RedisQueuedLocks::Data[ok: true, result: { process: :extendable_conflict_work_through, lock_key: lock_key, - acq_id: acquier_id, + acq_id: acquirer_id, hst_id: host_id, ts: spc_processed_timestamp, ttl: ttl @@ -341,7 +341,7 @@ def try_to_lock( RedisQueuedLocks::Data[ok: true, result: { process: :extendable_conflict_work_through, lock_key: lock_key, - acq_id: acquier_id, + acq_id: acquirer_id, hst_id: host_id, ts: spc_processed_timestamp, ttl: ttl @@ -369,7 +369,7 @@ def try_to_lock( RedisQueuedLocks::Data[ok: true, result: { process: :conflict_work_through, lock_key: lock_key, - acq_id: acquier_id, + acq_id: acquirer_id, hst_id: host_id, ts: spc_processed_timestamp, ttl: ttl @@ -384,7 +384,7 @@ def try_to_lock( RedisQueuedLocks::Data[ok: false, result: inter_result] # steep:ignore when inter_result == :dead_score_reached RedisQueuedLocks::Data[ok: false, result: inter_result] # steep:ignore - when inter_result == :lock_is_still_acquired || inter_result == :acquier_is_not_first_in_queue + when inter_result == :lock_is_still_acquired || inter_result == :acquirer_is_not_first_in_queue # Step 7.b: lock is still acquired by another process => failed to acquire RedisQueuedLocks::Data[ok: false, result: inter_result] # steep:ignore when result == nil || (result.is_a?(::Array) && result.empty?) @@ -407,7 +407,7 @@ def try_to_lock( RedisQueuedLocks::Data[ok: true, result: { process: :lock_obtaining, lock_key: lock_key, - acq_id: acquier_id, + acq_id: acquirer_id, hst_id: host_id, ts: timestamp, ttl: ttl diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb b/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb index ae4dc89..a94ddb5 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rb @@ -11,7 +11,7 @@ class << self # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -25,7 +25,7 @@ def start( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -35,7 +35,7 @@ def start( "[redis_queued_locks.try_lock.start] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -46,7 +46,7 @@ def start( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -60,7 +60,7 @@ def rconn_fetched( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -70,7 +70,7 @@ def rconn_fetched( "[redis_queued_locks.try_lock.rconn_fetched] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -81,7 +81,7 @@ def rconn_fetched( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -95,7 +95,7 @@ def same_process_conflict_detected( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -105,7 +105,7 @@ def same_process_conflict_detected( "[redis_queued_locks.try_lock.same_process_conflict_detected] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -116,7 +116,7 @@ def same_process_conflict_detected( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @param sp_conflict_status [Symbol] @@ -131,7 +131,7 @@ def same_process_conflict_analyzed( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, sp_conflict_status @@ -142,7 +142,7 @@ def same_process_conflict_analyzed( "[redis_queued_locks.try_lock.same_process_conflict_analyzed] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "spc_status => '#{sp_conflict_status}'" @@ -154,7 +154,7 @@ def same_process_conflict_analyzed( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @param sp_conflict_status [Symbol] @@ -171,7 +171,7 @@ def reentrant_lock__extend_and_work_through( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, sp_conflict_status, @@ -184,7 +184,7 @@ def reentrant_lock__extend_and_work_through( "[redis_queued_locks.try_lock.reentrant_lock__extend_and_work_through] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "spc_status => '#{sp_conflict_status}' " \ @@ -198,7 +198,7 @@ def reentrant_lock__extend_and_work_through( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @param sp_conflict_status [Symbol] @@ -214,7 +214,7 @@ def reentrant_lock__work_through( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, sp_conflict_status, @@ -226,7 +226,7 @@ def reentrant_lock__work_through( "[redis_queued_locks.try_lock.reentrant_lock__work_through] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "spc_status => '#{sp_conflict_status}' " \ @@ -239,7 +239,7 @@ def reentrant_lock__work_through( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @param sp_conflict_status [Symbol] @@ -255,7 +255,7 @@ def single_process_lock_conflict__dead_lock( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, sp_conflict_status, @@ -267,7 +267,7 @@ def single_process_lock_conflict__dead_lock( "[redis_queued_locks.try_lock.single_process_lock_conflict__dead_lock] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ "spc_status => '#{sp_conflict_status}' " \ @@ -280,7 +280,7 @@ def single_process_lock_conflict__dead_lock( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -294,7 +294,7 @@ def acq_added_to_queue( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -304,7 +304,7 @@ def acq_added_to_queue( "[redis_queued_locks.try_lock.acq_added_to_queue] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -315,7 +315,7 @@ def acq_added_to_queue( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -329,7 +329,7 @@ def remove_expired_acqs( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -339,7 +339,7 @@ def remove_expired_acqs( "[redis_queued_locks.try_lock.remove_expired_acqs] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -350,10 +350,10 @@ def remove_expired_acqs( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] - # @param waiting_acquier [String,NilClass] + # @param waiting_acquirer [String,NilClass] # @return [void] # # @api private @@ -365,10 +365,10 @@ def get_first_from_queue( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, - waiting_acquier + waiting_acquirer ) return unless log_sampled && log_lock_try @@ -376,10 +376,10 @@ def get_first_from_queue( "[redis_queued_locks.try_lock.get_first_from_queue] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ - "first_acq_id_in_queue => '#{waiting_acquier}'" + "first_acq_id_in_queue => '#{waiting_acquirer}'" end rescue nil end @@ -388,7 +388,7 @@ def get_first_from_queue( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -402,7 +402,7 @@ def exit__queue_ttl_reached( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -412,7 +412,7 @@ def exit__queue_ttl_reached( "[redis_queued_locks.try_lock.exit__queue_ttl_reached] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -423,10 +423,10 @@ def exit__queue_ttl_reached( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] - # @param waiting_acquier [String,NilClass] + # @param waiting_acquirer [String,NilClass] # @param current_lock_data [Hash] # @return [void] # @@ -439,10 +439,10 @@ def exit__no_first( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, - waiting_acquier, + waiting_acquirer, current_lock_data ) return unless log_sampled && log_lock_try @@ -451,10 +451,10 @@ def exit__no_first( "[redis_queued_locks.try_lock.exit__no_first] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ - "first_acq_id_in_queue => '#{waiting_acquier}' " \ + "first_acq_id_in_queue => '#{waiting_acquirer}' " \ " => <<#{current_lock_data}>>" end rescue nil end @@ -464,11 +464,11 @@ def exit__no_first( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] - # @param waiting_acquier [String,NilClass] - # @param locked_by_acquier [String] + # @param waiting_acquirer [String,NilClass] + # @param locked_by_acquirer [String] # @param current_lock_data [Hash] # @return [void] # @@ -481,11 +481,11 @@ def exit__lock_still_obtained( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy, - waiting_acquier, - locked_by_acquier, + waiting_acquirer, + locked_by_acquirer, current_lock_data ) return unless log_sampled && log_lock_try @@ -494,11 +494,11 @@ def exit__lock_still_obtained( "[redis_queued_locks.try_lock.exit__lock_still_obtained] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}' " \ - "first_acq_id_in_queue => '#{waiting_acquier}' " \ - "locked_by_acq_id => '#{locked_by_acquier}' " \ + "first_acq_id_in_queue => '#{waiting_acquirer}' " \ + "locked_by_acq_id => '#{locked_by_acquirer}' " \ " => <<#{current_lock_data}>>" end rescue nil end @@ -508,7 +508,7 @@ def exit__lock_still_obtained( # @param log_lock_try [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -522,7 +522,7 @@ def obtain__free_to_acquire( log_lock_try, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -532,7 +532,7 @@ def obtain__free_to_acquire( "[redis_queued_locks.try_lock.obtain__free_to_acquire] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb b/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb index 888d398..b2758d4 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/with_acq_timeout.rb @@ -20,7 +20,8 @@ module RedisQueuedLocks::Acquirer::AcquireLock::WithAcqTimeout # @param block [Block] Custom logic that should be invoked under the obtained lock. # @return [Any] # - # @raise [RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError] + # @raise [RedisQueuedLocks::LockAcquirementIntermediateTimeoutError] + # @raise [RedisQueuedLocks::LockAcquirementTimeoutError] # # @api private # @since 1.0.0 @@ -35,8 +36,8 @@ def with_acq_timeout( on_timeout: nil, &block ) - ::Timeout.timeout(timeout, RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError, &block) - rescue RedisQueuedLocks::LockAcquiermentIntermediateTimeoutError + ::Timeout.timeout(timeout, RedisQueuedLocks::LockAcquirementIntermediateTimeoutError, &block) + rescue RedisQueuedLocks::LockAcquirementIntermediateTimeoutError if on_timeout != nil # @type var on_timeout: ::Proc on_timeout.call @@ -52,7 +53,7 @@ def with_acq_timeout( # rubocop:disable Metrics/BlockNesting raise( - RedisQueuedLocks::LockAcquiermentTimeoutError, + RedisQueuedLocks::LockAcquirementTimeoutError, "Failed to acquire the lock \"#{lock_key}\" " \ "for the given <#{timeout} seconds> timeout. Details: " \ " => #{lock_info ? lock_info.inspect : ''}; " \ @@ -61,7 +62,7 @@ def with_acq_timeout( # rubocop:enable Metrics/BlockNesting else raise( - RedisQueuedLocks::LockAcquiermentTimeoutError, + RedisQueuedLocks::LockAcquirementTimeoutError, "Failed to acquire the lock \"#{lock_key}\" " \ "for the given <#{timeout} seconds> timeout." ) diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb b/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb index c5fa245..428bc83 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire.rb @@ -18,7 +18,7 @@ module RedisQueuedLocks::Acquirer::AcquireLock::YieldExpire # @param redis [RedisClient] Redis connection. # @param logger [::Logger,#debug] Logger object. # @param lock_key [String] Obtained lock key that should be expired. - # @param acquier_id [String] Acquirer identifier. + # @param acquirer_id [String] Acquirer identifier. # @param host_id [String] Host identifier. # @param access_strategy [Symbol] Lock obtaining strategy. # @param timed [Boolean] Should the lock be wrapped by Timeout with with lock's ttl @@ -43,7 +43,7 @@ def yield_expire( redis, logger, lock_key, - acquier_id, + acquirer_id, host_id, access_strategy, timed, @@ -79,7 +79,7 @@ def yield_expire( end # steep:ignore:end - yield_with_timeout(timeout, lock_key, ttl, acquier_id, host_id, meta, &block) + yield_with_timeout(timeout, lock_key, ttl, acquirer_id, host_id, meta, &block) else yield end @@ -88,7 +88,7 @@ def yield_expire( if should_expire LogVisitor.expire_lock( logger, log_sampled, lock_key, - queue_ttl, acquier_id, host_id, access_strategy + queue_ttl, acquirer_id, host_id, access_strategy ) redis.call('EXPIRE', lock_key, '0') elsif should_decrease @@ -101,7 +101,7 @@ def yield_expire( if decreased_ttl > 0 LogVisitor.decrease_lock( logger, log_sampled, lock_key, - decreased_ttl, queue_ttl, acquier_id, host_id, access_strategy + decreased_ttl, queue_ttl, acquirer_id, host_id, access_strategy ) # NOTE:# NOTE: EVAL signature -> , (number of keys), *(keys), *(arguments) redis.call('EVAL', DECREASE_LOCK_PTTL, 1, lock_key, decreased_ttl) @@ -116,7 +116,7 @@ def yield_expire( # @param timeout [Float] # @parma lock_key [String] # @param lock_ttl [Integer,NilClass] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param meta [NilClass,Hash] # @param block [Blcok] @@ -127,7 +127,7 @@ def yield_expire( # @api private # @since 1.3.0 # @version 1.12.0 - def yield_with_timeout(timeout, lock_key, lock_ttl, acquier_id, host_id, meta, &block) + def yield_with_timeout(timeout, lock_key, lock_ttl, acquirer_id, host_id, meta, &block) ::Timeout.timeout(timeout, RedisQueuedLocks::TimedLockIntermediateTimeoutError, &block) rescue RedisQueuedLocks::TimedLockIntermediateTimeoutError raise( @@ -136,7 +136,7 @@ def yield_with_timeout(timeout, lock_key, lock_ttl, acquier_id, host_id, meta, & "(lock: \"#{lock_key}\", " \ "ttl: #{lock_ttl}, " \ "meta: #{meta ? meta.inspect : ''}, " \ - "acq_id: \"#{acquier_id}\", " \ + "acq_id: \"#{acquirer_id}\", " \ "hst_id: \"#{host_id}\")" ) end diff --git a/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb b/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb index 8dbfd51..93692ef 100644 --- a/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb +++ b/lib/redis_queued_locks/acquirer/acquire_lock/yield_expire/log_visitor.rb @@ -8,7 +8,7 @@ class << self # @param log_sampled [Boolean] # @param lock_key [String] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -21,7 +21,7 @@ def expire_lock( log_sampled, lock_key, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -31,7 +31,7 @@ def expire_lock( "[redis_queued_locks.expire_lock] " \ "lock_key => '#{lock_key}' " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil @@ -42,7 +42,7 @@ def expire_lock( # @param lock_key [String] # @param decreased_ttl [Integer] # @param queue_ttl [Integer] - # @param acquier_id [String] + # @param acquirer_id [String] # @param host_id [String] # @param access_strategy [Symbol] # @return [void] @@ -56,7 +56,7 @@ def decrease_lock( lock_key, decreased_ttl, queue_ttl, - acquier_id, + acquirer_id, host_id, access_strategy ) @@ -67,7 +67,7 @@ def decrease_lock( "lock_key => '#{lock_key}' " \ "decreased_ttl => #{decreased_ttl} " \ "queue_ttl => #{queue_ttl} " \ - "acq_id => '#{acquier_id}' " \ + "acq_id => '#{acquirer_id}' " \ "hst_id => '#{host_id}' " \ "acs_strat => '#{access_strategy}'" end rescue nil diff --git a/lib/redis_queued_locks/acquirer/clear_dead_requests.rb b/lib/redis_queued_locks/acquirer/clear_dead_requests.rb index 1422191..29b1e02 100644 --- a/lib/redis_queued_locks/acquirer/clear_dead_requests.rb +++ b/lib/redis_queued_locks/acquirer/clear_dead_requests.rb @@ -39,7 +39,7 @@ def clear_dead_requests( instr_sampler, instr_sample_this ) - dead_score = RedisQueuedLocks::Resource.acquier_dead_score(dead_ttl / 1_000.0) + dead_score = RedisQueuedLocks::Resource.acquirer_dead_score(dead_ttl / 1_000.0) # @type var result: ::Set[::String] result = Set.new.tap do |processed_queues| diff --git a/lib/redis_queued_locks/acquirer/lock_info.rb b/lib/redis_queued_locks/acquirer/lock_info.rb index 7255885..d708f7f 100644 --- a/lib/redis_queued_locks/acquirer/lock_info.rb +++ b/lib/redis_queued_locks/acquirer/lock_info.rb @@ -10,7 +10,7 @@ class << self # - `nil` is returned when lock key does not exist or expired; # - result format: { # 'lock_key' => "rql:lock:your_lockname", # acquired lock key - # 'acq_id' => "rql:acq:123/456/789/987/uniqstring", # lock acquier identifier + # 'acq_id' => "rql:acq:123/456/789/987/uniqstring", # lock acquirer identifier # 'hst_id' => "rql:hst:123/456/987/uniqstring", # lock host identifier # 'ts' => 123456789.2649841, # time stamp (epoch, seconds.microseconds) # 'ini_ttl' => 123456789, # initial lock key ttl (milliseconds) diff --git a/lib/redis_queued_locks/acquirer/queue_info.rb b/lib/redis_queued_locks/acquirer/queue_info.rb index 2d1d111..d4c1f5d 100644 --- a/lib/redis_queued_locks/acquirer/queue_info.rb +++ b/lib/redis_queued_locks/acquirer/queue_info.rb @@ -20,7 +20,7 @@ class << self # { "acq_id" => "rql:acq:123/456/789/987/identity", "score" => 123.456 }, # { "acq_id" => "rql:acq:123/686/789/987/identity", "score" => 456.789 }, # ... - # ] # ordered set (by score) with information about an acquier and their position in queue + # ] # ordered set (by score) with information about an acquirer and their position in queue # } # # @api private diff --git a/lib/redis_queued_locks/client.rb b/lib/redis_queued_locks/client.rb index bb9a5ad..4b955ea 100644 --- a/lib/redis_queued_locks/client.rb +++ b/lib/redis_queued_locks/client.rb @@ -141,7 +141,7 @@ class RedisQueuedLocks::Client attr_reader :swarm # @param redis_client [RedisClient] - # Redis connection manager, which will be used for the lock acquierment and distribution. + # Redis connection manager, which will be used for the lock acquirerment and distribution. # It should be an instance of RedisClient. # @param configs [Block] # Custom configs for in-runtime configuration. @@ -234,11 +234,11 @@ def zombie_locks( # # @api ppublic # @since 1.9.0 - def zombie_acquiers( + def zombie_acquirers( zombie_ttl: config[:swarm][:flush_zombies][:zombie_ttl], # steep:ignore lock_scan_size: config[:swarm][:flush_zombies][:zombie_lock_scan_size] # steep:ignore ) - swarm.zombie_acquiers(zombie_ttl:, lock_scan_size:) + swarm.zombie_acquirers(zombie_ttl:, lock_scan_size:) end # @option zombie_ttl [Integer] @@ -253,7 +253,7 @@ def zombie_hosts(zombie_ttl: config[:swarm][:flush_zombies][:zombie_ttl]) # stee # @return [Hash>] # Format: { # zombie_hosts: >, - # zombie_acquiers: >, + # zombie_acquirers: >, # zombie_locks: > # } # @@ -647,7 +647,7 @@ def queue_info(lock_name) # @option identity [String] Unique per-process string. See `config[:uniq_identifier]`. # @return [String] # - # @see RedisQueuedLocks::Resource.acquier_identifier + # @see RedisQueuedLocks::Resource.acquirer_identifier # @see RedisQueuedLocks::Resource.get_process_id # @see RedisQueuedLocks::Resource.get_thread_id # @see RedisQueuedLocks::Resource.get_fiber_id @@ -656,14 +656,14 @@ def queue_info(lock_name) # # @api public # @since 1.8.0 - def current_acquier_id( + def current_acquirer_id( process_id: RedisQueuedLocks::Resource.get_process_id, thread_id: RedisQueuedLocks::Resource.get_thread_id, fiber_id: RedisQueuedLocks::Resource.get_fiber_id, ractor_id: RedisQueuedLocks::Resource.get_ractor_id, identity: uniq_identity ) - RedisQueuedLocks::Resource.acquier_identifier( + RedisQueuedLocks::Resource.acquirer_identifier( process_id, thread_id, fiber_id, diff --git a/lib/redis_queued_locks/errors.rb b/lib/redis_queued_locks/errors.rb index eec45f7..09fc69e 100644 --- a/lib/redis_queued_locks/errors.rb +++ b/lib/redis_queued_locks/errors.rb @@ -19,15 +19,15 @@ class LockAlreadyObtainedError < Error; end # @api private # @since 1.11.0 - class LockAcquiermentIntermediateTimeoutError < ::Timeout::Error; end + class LockAcquirementIntermediateTimeoutError < ::Timeout::Error; end # @api public # @since 1.0.0 - class LockAcquiermentTimeoutError < Error; end + class LockAcquirementTimeoutError < Error; end # @api public # @since 1.0.0 - class LockAcquiermentRetryLimitError < Error; end + class LockAcquirementRetryLimitError < Error; end # @api private # @since 1.12.0 diff --git a/lib/redis_queued_locks/resource.rb b/lib/redis_queued_locks/resource.rb index 16a3240..3e6329c 100644 --- a/lib/redis_queued_locks/resource.rb +++ b/lib/redis_queued_locks/resource.rb @@ -55,7 +55,7 @@ def calc_uniq_identity # # @api private # @since 1.0.0 - def acquier_identifier(process_id, thread_id, fiber_id, ractor_id, identity) + def acquirer_identifier(process_id, thread_id, fiber_id, ractor_id, identity) "rql:acq:#{process_id}/#{thread_id}/#{fiber_id}/#{ractor_id}/#{identity}" end @@ -97,16 +97,16 @@ def prepare_lock_queue(lock_name) # # @api private # @since 1.0.0 - def calc_initial_acquier_position + def calc_initial_acquirer_position Time.now.to_f end # @param queue_ttl [Numeric] In seconds - # @return [Float] Redis's score barrier for acquiers that should be removed from queue. + # @return [Float] Redis's score barrier for acquirers that should be removed from queue. # # @api private # @since 1.0.0 - def acquier_dead_score(queue_ttl) + def acquirer_dead_score(queue_ttl) Time.now.to_f - queue_ttl end @@ -119,9 +119,9 @@ def calc_zombie_score(zombie_ttl) Time.now.to_f - zombie_ttl end - # @param acquier_position [Float] + # @param acquirer_position [Float] # A time (epoch, seconds.milliseconds) that represents - # the acquier position in lock request queue. + # the acquirer position in lock request queue. # @parma queue_ttl [Integer] # In second. # @return [Boolean] @@ -129,8 +129,8 @@ def calc_zombie_score(zombie_ttl) # # @api private # @since 1.0.0 - def dead_score_reached?(acquier_position, queue_ttl) - (acquier_position + queue_ttl) < Time.now.to_f + def dead_score_reached?(acquirer_position, queue_ttl) + (acquirer_position + queue_ttl) < Time.now.to_f end # @param lock_queue [String] @@ -196,9 +196,9 @@ def possible_host_identifiers(identity) # steep:ignore:start # NOTE: rbs/steep can't declare the type of dynamic `[]` variable mutated via tap :'( - [].tap do |acquiers| + [].tap do |acquirers| current_threads.each do |thread| - acquiers << host_identifier( + acquirers << host_identifier( current_process_id, thread.object_id, current_ractor_id, diff --git a/lib/redis_queued_locks/swarm.rb b/lib/redis_queued_locks/swarm.rb index 2a81e30..d231cdf 100644 --- a/lib/redis_queued_locks/swarm.rb +++ b/lib/redis_queued_locks/swarm.rb @@ -110,7 +110,7 @@ def probe_hosts # RedisQueuedLocks::Data[ # ok: , # deleted_zombie_hosts: >, - # deleted_zombie_acquiers: >, + # deleted_zombie_acquirers: >, # deleted_zombie_locks: > # ] # ] @@ -153,11 +153,11 @@ def zombie_locks( # # @api ppublic # @since 1.9.0 - def zombie_acquiers( + def zombie_acquirers( zombie_ttl: rql_client.config[:swarm][:flush_zombies][:zombie_ttl], lock_scan_size: rql_client.config[:swarm][:flush_zombies][:zombie_lock_scan_size] ) - RedisQueuedLocks::Swarm::ZombieInfo.zombie_acquiers( + RedisQueuedLocks::Swarm::ZombieInfo.zombie_acquirers( rql_client.redis_client, zombie_ttl, lock_scan_size diff --git a/lib/redis_queued_locks/swarm/flush_zombies.rb b/lib/redis_queued_locks/swarm/flush_zombies.rb index 4345810..0e1f511 100644 --- a/lib/redis_queued_locks/swarm/flush_zombies.rb +++ b/lib/redis_queued_locks/swarm/flush_zombies.rb @@ -12,7 +12,7 @@ class << self # RedisQueuedLocks::Data[ # ok: , # deleted_zombie_hosts: >, - # deleted_zombie_acquiers: >, + # deleted_zombie_acquirers: >, # deleted_zombie_locks: > # ] # ] @@ -53,15 +53,15 @@ def flush_zombies( # NOTE: original redis does not support indexing so we need to use # internal data structers to simulate data indexing (such as sorted sets or lists); zombie_locks = Set.new #: ::Set[::String] - zombie_acquiers = Set.new #: ::Set[::String] + zombie_acquirers = Set.new #: ::Set[::String] rconn.scan( 'MATCH', RedisQueuedLocks::Resource::LOCK_PATTERN, count: lock_scan_size ) do |lock_key| - acquier_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') + acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') if zombie_hosts.include?(host_id) zombie_locks << lock_key - zombie_acquiers << acquier_id + zombie_acquirers << acquirer_id end end @@ -75,8 +75,8 @@ def flush_zombies( rconn.scan( 'MATCH', RedisQueuedLocks::Resource::LOCK_QUEUE_PATTERN, count: queue_scan_size ) do |lock_queue| - zombie_acquiers.each do |zombie_acquier| - rconn.call('ZREM', lock_queue, zombie_acquier) + zombie_acquirers.each do |zombie_acquirer| + rconn.call('ZREM', lock_queue, zombie_acquirer) end end @@ -88,7 +88,7 @@ def flush_zombies( RedisQueuedLocks::Data[ ok: true, deleted_zombie_hosts: zombie_hosts, - deleted_zombie_acquiers: zombie_acquiers, + deleted_zombie_acquirers: zombie_acquirers, deleted_zombie_locks: zombie_locks ] # steep:ignore:end diff --git a/lib/redis_queued_locks/swarm/zombie_info.rb b/lib/redis_queued_locks/swarm/zombie_info.rb index 4e40745..9e244b9 100644 --- a/lib/redis_queued_locks/swarm/zombie_info.rb +++ b/lib/redis_queued_locks/swarm/zombie_info.rb @@ -54,9 +54,9 @@ def zombie_hosts(redis_client, zombie_ttl) # # @api private # @since 1.9.0 - def zombie_acquiers(redis_client, zombie_ttl, lock_scan_size) + def zombie_acquirers(redis_client, zombie_ttl, lock_scan_size) redis_client.with do |rconn| - extract_zombie_acquiers(rconn, zombie_ttl, lock_scan_size) + extract_zombie_acquirers(rconn, zombie_ttl, lock_scan_size) end end @@ -89,7 +89,7 @@ def extract_zombie_locks(rconn, zombie_ttl, lock_scan_size) rconn.scan( 'MATCH', RedisQueuedLocks::Resource::LOCK_PATTERN, count: lock_scan_size ) do |lock_key| - _acquier_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') + _acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') zombie_locks << lock_key if zombie_hosts.include?(host_id) end zombie_locks @@ -102,14 +102,14 @@ def extract_zombie_locks(rconn, zombie_ttl, lock_scan_size) # # @api private # @since 1.9.0 - def extract_zombie_acquiers(rconn, zombie_ttl, lock_scan_size) + def extract_zombie_acquirers(rconn, zombie_ttl, lock_scan_size) zombie_hosts = extract_zombie_hosts(rconn, zombie_ttl) zombie_acquirers = Set.new rconn.scan( 'MATCH', RedisQueuedLocks::Resource::LOCK_PATTERN, count: lock_scan_size ) do |lock_key| - acquier_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') - zombie_acquirers << acquier_id if zombie_hosts.include?(host_id) + acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') + zombie_acquirers << acquirer_id if zombie_hosts.include?(host_id) end zombie_acquirers end @@ -133,9 +133,9 @@ def extract_all(rconn, zombie_ttl, lock_scan_size) rconn.scan( 'MATCH', RedisQueuedLocks::Resource::LOCK_PATTERN, count: lock_scan_size ) do |lock_key| - acquier_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') + acquirer_id, host_id = rconn.call('HMGET', lock_key, 'acq_id', 'hst_id') if zombie_hosts.include?(host_id) - zombie_acquirers << acquier_id + zombie_acquirers << acquirer_id zombie_locks << lock_key end end diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs index 4cfb1f8..64b70db 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue.rbs @@ -8,7 +8,7 @@ module RedisQueuedLocks ::String lock_key, ::String lock_key_queue, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, bool log_sampled, diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs index 095552e..160094b 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/dequeue_from_lock_queue/log_visitor.rbs @@ -8,7 +8,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs index d228648..ddaf523 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/log_visitor.rbs @@ -7,7 +7,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -17,17 +17,17 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void - def self.dead_score_reached__reset_acquier_position: ( + def self.dead_score_reached__reset_acquirer_position: ( ::Logger|RedisQueuedLocks::_Loggable logger, bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -37,7 +37,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Integer|::Float acq_time, ::Symbol access_strategy @@ -48,7 +48,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Integer|::Float acq_time, ::Symbol access_strategy @@ -59,7 +59,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Integer|::Float acq_time, ::Symbol access_strategy diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs index f300756..491efa2 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock.rbs @@ -10,9 +10,9 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::String lock_key_queue, - ::String acquier_id, + ::String acquirer_id, ::String host_id, - ::Integer|::Float acquier_position, + ::Integer|::Float acquirer_position, ::Integer? ttl, ::Integer queue_ttl, bool fail_fast, diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs index 6c6d304..701b01e 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/try_to_lock/log_visitor.rbs @@ -9,7 +9,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -20,7 +20,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -31,7 +31,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -42,7 +42,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, ::Symbol sp_conflict_status @@ -54,7 +54,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, ::Symbol sp_conflict_status, @@ -68,7 +68,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, ::Symbol sp_conflict_status, @@ -81,7 +81,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, ::Symbol sp_conflict_status, @@ -94,7 +94,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -105,7 +105,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -116,10 +116,10 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, - ::String? waiting_acquier + ::String? waiting_acquirer ) -> void def self.exit__queue_ttl_reached: ( @@ -128,7 +128,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -139,10 +139,10 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, - ::String? waiting_acquier, + ::String? waiting_acquirer, ::Hash[::String,untyped] current_lock_data ) -> void @@ -152,11 +152,11 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, - ::String? waiting_acquier, - ::String locked_by_acquier, + ::String? waiting_acquirer, + ::String locked_by_acquirer, ::Hash[::String,untyped] current_lock_data ) -> void @@ -166,7 +166,7 @@ module RedisQueuedLocks bool log_lock_try, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs index 24f5ce5..25f7d02 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/yield_expire.rbs @@ -8,7 +8,7 @@ module RedisQueuedLocks ::RedisClient redis, ::Logger|::RedisQueuedLocks::_Loggable logger, ::String lock_key, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy, bool timed, @@ -28,7 +28,7 @@ module RedisQueuedLocks ::Float timeout, ::String lock_key, ::Integer? lock_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Hash[::String|::Symbol,untyped]? meta, ) { (?) -> untyped } -> untyped diff --git a/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs b/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs index 24722a3..d6e9f40 100644 --- a/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs +++ b/sig/redis_queued_locks/acquirer/acquire_lock/yield_with_expire/log_visitor.rbs @@ -8,7 +8,7 @@ module RedisQueuedLocks bool log_sampled, ::String lock_key, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void @@ -19,7 +19,7 @@ module RedisQueuedLocks ::String lock_key, ::Integer decreased_ttl, ::Integer queue_ttl, - ::String acquier_id, + ::String acquirer_id, ::String host_id, ::Symbol access_strategy ) -> void diff --git a/sig/redis_queued_locks/client.rbs b/sig/redis_queued_locks/client.rbs index b480270..0fab0f9 100644 --- a/sig/redis_queued_locks/client.rbs +++ b/sig/redis_queued_locks/client.rbs @@ -22,7 +22,7 @@ module RedisQueuedLocks def probe_hosts: () -> untyped def flush_zombies: (?zombie_ttl: untyped, ?lock_scan_size: untyped, ?queue_scan_size: untyped) -> untyped def zombie_locks: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped - def zombie_acquiers: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped + def zombie_acquirers: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped def zombie_hosts: (?zombie_ttl: untyped) -> untyped def zombies_info: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped @@ -108,7 +108,7 @@ module RedisQueuedLocks def lock_info: (untyped lock_name) -> untyped def queue_info: (untyped lock_name) -> untyped - def current_acquier_id: (?process_id: untyped, ?thread_id: untyped, ?fiber_id: untyped, ?ractor_id: untyped, ?identity: untyped) -> untyped + def current_acquirer_id: (?process_id: untyped, ?thread_id: untyped, ?fiber_id: untyped, ?ractor_id: untyped, ?identity: untyped) -> untyped def current_host_id: (?process_id: untyped, ?thread_id: untyped, ?ractor_id: untyped, ?identity: untyped) -> untyped diff --git a/sig/redis_queued_locks/errors.rbs b/sig/redis_queued_locks/errors.rbs index 7bf713a..0eb0fff 100644 --- a/sig/redis_queued_locks/errors.rbs +++ b/sig/redis_queued_locks/errors.rbs @@ -8,13 +8,13 @@ module RedisQueuedLocks class LockAlreadyObtainedError < Error end - class LockAcquiermentIntermediateTimeoutError < ::Timeout::Error + class LockAcquirementIntermediateTimeoutError < ::Timeout::Error end - class LockAcquiermentTimeoutError < Error + class LockAcquirementTimeoutError < Error end - class LockAcquiermentRetryLimitError < Error + class LockAcquirementRetryLimitError < Error end class TimedLockIntermediateTimeoutError < ::Timeout::Error diff --git a/sig/redis_queued_locks/resource.rbs b/sig/redis_queued_locks/resource.rbs index e0a37c0..93cb7ad 100644 --- a/sig/redis_queued_locks/resource.rbs +++ b/sig/redis_queued_locks/resource.rbs @@ -7,7 +7,7 @@ module RedisQueuedLocks REDIS_TIMESHIFT_ERROR: ::Integer def self.calc_uniq_identity: () -> ::String - def self.acquier_identifier: ( + def self.acquirer_identifier: ( ::Integer|::String process_id, ::Integer|::String thread_id, ::Integer|::String fiber_id, @@ -24,10 +24,10 @@ module RedisQueuedLocks def self.prepare_lock_key: (::String lock_name) -> ::String def self.prepare_lock_queue: (::String lock_name) -> ::String - def self.calc_initial_acquier_position: () -> ::Float - def self.acquier_dead_score: (::Integer|::Float queue_ttl) -> ::Float + def self.calc_initial_acquirer_position: () -> ::Float + def self.acquirer_dead_score: (::Integer|::Float queue_ttl) -> ::Float def self.calc_zombie_score: (::Float zombie_ttl) -> ::Float - def self.dead_score_reached?: (::Float acquier_position, ::Integer queue_ttl) -> bool + def self.dead_score_reached?: (::Float acquirer_position, ::Integer queue_ttl) -> bool def self.lock_key_from_queue: (::String lock_queue) -> ::String def self.get_thread_id: () -> ::Integer def self.get_fiber_id: () -> ::Integer diff --git a/sig/redis_queued_locks/swarm.rbs b/sig/redis_queued_locks/swarm.rbs index 53cacb4..3c865e4 100644 --- a/sig/redis_queued_locks/swarm.rbs +++ b/sig/redis_queued_locks/swarm.rbs @@ -19,7 +19,7 @@ module RedisQueuedLocks def probe_hosts: () -> untyped def flush_zombies: (?zombie_ttl: untyped, ?lock_scan_size: untyped, ?queue_scan_size: untyped) -> untyped def zombie_locks: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped - def zombie_acquiers: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped + def zombie_acquirers: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped def zombie_hosts: (?zombie_ttl: untyped) -> untyped def zombies_info: (?zombie_ttl: untyped, ?lock_scan_size: untyped) -> untyped def swarm!: () -> untyped diff --git a/sig/redis_queued_locks/swarm/zombie_info.rbs b/sig/redis_queued_locks/swarm/zombie_info.rbs index 55b0c7c..5f820c0 100644 --- a/sig/redis_queued_locks/swarm/zombie_info.rbs +++ b/sig/redis_queued_locks/swarm/zombie_info.rbs @@ -18,7 +18,7 @@ module RedisQueuedLocks ::Integer zombie_ttl ) -> ::Set[::String] - def self.zombie_acquiers: ( + def self.zombie_acquirers: ( ::RedisClient redis_client, ::Integer zombie_ttl, ::Integer lock_scan_size @@ -37,7 +37,7 @@ module RedisQueuedLocks ::Integer lock_scan_size ) -> ::Set[::String] - def self.extract_zombie_acquiers: ( + def self.extract_zombie_acquirers: ( ::RedisClient rconn, ::Integer zombie_ttl, ::Integer lock_scan_size diff --git a/spec/redis_queued_locks_spec.rb b/spec/redis_queued_locks_spec.rb index 01e1211..7e9d58c 100644 --- a/spec/redis_queued_locks_spec.rb +++ b/spec/redis_queued_locks_spec.rb @@ -359,12 +359,12 @@ })) zombie_host = client.current_host_id - zombie_acquier = client.current_acquier_id + zombie_acquirer = client.current_acquirer_id zombie_lock = 'rql:lock:super-mega-long-lock' expect(client.locked?('super-mega-long-lock')).to eq(true) expect(client.zombie_locks).to include(zombie_lock) - expect(client.zombie_acquiers).to include(zombie_acquier) + expect(client.zombie_acquirers).to include(zombie_acquirer) expect(client.zombie_hosts).to include(zombie_host) # try to flush them all @@ -373,17 +373,17 @@ expect(result).to match({ ok: true, deleted_zombie_hosts: include(zombie_host), - deleted_zombie_acquiers: include(zombie_acquier), + deleted_zombie_acquirers: include(zombie_acquirer), deleted_zombie_locks: include(zombie_lock) }) expect(client.locked?('super-mega-long-lock')).to eq(false) expect(client.zombie_locks).to eq(Set.new) - expect(client.zombie_acquiers).not_to include(zombie_acquier) + expect(client.zombie_acquirers).not_to include(zombie_acquirer) expect(client.zombie_hosts).not_to include(zombie_host) end end - specify '(auto-swarming!): zombie locks (with hosts and acquiers)' do + specify '(auto-swarming!): zombie locks (with hosts and acquirers)' do main_client = RedisQueuedLocks::Client.new(redis) do |conf| conf.swarm.auto_swarm = true conf.swarm.probe_hosts.enabled_for_swarm = true @@ -395,7 +395,7 @@ aggregate_failures 'no zombies at start' do expect(main_client.zombie_locks).to eq(Set.new) # empty set expect(main_client.zombie_hosts).to eq(Set.new) # empty set - expect(main_client.zombie_acquiers).to eq(Set.new) # empty set + expect(main_client.zombie_acquirers).to eq(Set.new) # empty set expect(main_client.zombies_info).to match({ zombie_locks: Set.new, @@ -421,7 +421,7 @@ conf.swarm.flush_zombies.enabled_for_swarm = false end - outer_acquirer1 = client.current_acquier_id + outer_acquirer1 = client.current_acquirer_id outer_host1 = client.current_host_id client.swarmize! @@ -435,7 +435,7 @@ conf.swarm.flush_zombies.enabled_for_swarm = false end - outer_acquirer2 = client.current_acquier_id + outer_acquirer2 = client.current_acquirer_id outer_host2 = client.current_host_id client.swarmize! @@ -457,7 +457,7 @@ expect(main_client.locked?('another_long_lock')).to eq(true) expect(main_client.zombie_locks).to eq(Set.new) # empty set expect(main_client.zombie_hosts).to eq(Set.new) # empty set - expect(main_client.zombie_acquiers).to eq(Set.new) # empty set + expect(main_client.zombie_acquirers).to eq(Set.new) # empty set expect(main_client.zombies_info).to match({ zombie_locks: Set.new, @@ -486,7 +486,7 @@ # ZOMBIE LOCK HOSTS AND ACQUIRERS expect(main_client.zombie_hosts).to include(outer_host1, outer_host2) - expect(main_client.zombie_acquiers).to include(outer_acquirer1, outer_acquirer2) + expect(main_client.zombie_acquirers).to include(outer_acquirer1, outer_acquirer2) expect(main_client.zombies_info).to match({ zombie_locks: Set.new(%w[rql:lock:long_lock rql:lock:another_long_lock]), @@ -512,7 +512,7 @@ expect(main_client.locked?('another_long_lock')).to eq(false) # lock is unlocked expect(main_client.zombie_locks).to eq(Set.new) # no zombie locks expect(main_client.zombie_hosts).to eq(Set.new) # no zombie hosts - expect(main_client.zombie_acquiers).to eq(Set.new) # no zombie acquiers + expect(main_client.zombie_acquirers).to eq(Set.new) # no zombie acquirers end end end @@ -1218,7 +1218,7 @@ def debug(progname = nil, &block) client.lock('kek.dead.lock2', ttl: 50_000, queue_ttl: 60, timeout: nil, retry_count: nil) end sleep(1) - # kill acquiers => requests will live in redis now (zombie requests! bu!) + # kill acquirers => requests will live in redis now (zombie requests! bu!) lockers1.each(&:kill) lockers2.each(&:kill) locker3.kill @@ -1649,11 +1649,11 @@ def notify(event, payload = {}) expect do client.lock('some-long-lock', timeout: 2, retry_count: nil, raise_errors: true) - end.to raise_error(RedisQueuedLocks::LockAcquiermentTimeoutError) + end.to raise_error(RedisQueuedLocks::LockAcquirementTimeoutError) common_timeout_error = begin client.lock('some-long-lock', timeout: 2, retry_count: nil, raise_errors: true) - rescue RedisQueuedLocks::LockAcquiermentTimeoutError => error + rescue RedisQueuedLocks::LockAcquirementTimeoutError => error error end @@ -1672,7 +1672,7 @@ def notify(event, payload = {}) raise_errors: true, detailed_acq_timeout_error: true ) - rescue RedisQueuedLocks::LockAcquiermentTimeoutError => error + rescue RedisQueuedLocks::LockAcquirementTimeoutError => error error end @@ -1694,7 +1694,7 @@ def notify(event, payload = {}) raise_errors: true, detailed_acq_timeout_error: true ) - rescue RedisQueuedLocks::LockAcquiermentTimeoutError => error + rescue RedisQueuedLocks::LockAcquirementTimeoutError => error error end @@ -1726,7 +1726,7 @@ def notify(event, payload = {}) expect(timed_lock_error.message).to include('lock: "rql:lock:some-timed-lock",') expect(timed_lock_error.message).to include('ttl: 1000,') expect(timed_lock_error.message).to include('meta: ,') - expect(timed_lock_error.message).to include("acq_id: \"#{client.current_acquier_id}\"") + expect(timed_lock_error.message).to include("acq_id: \"#{client.current_acquirer_id}\"") expect(timed_lock_error.message).to include("hst_id: \"#{client.current_host_id}\"") end @@ -1747,7 +1747,7 @@ def notify(event, payload = {}) "meta: #{{ kek: 'pek' }.inspect}" ) expect(timed_lock_error_with_meta.message).to include( - "acq_id: \"#{client.current_acquier_id}\"" + "acq_id: \"#{client.current_acquirer_id}\"" ) expect(timed_lock_error_with_meta.message).to include( "hst_id: \"#{client.current_host_id}\"" @@ -1776,11 +1776,11 @@ def notify(event, payload = {}) expect do client.lock!('some-kek-super-pek', retry_count: 1) - end.to raise_error(RedisQueuedLocks::LockAcquiermentRetryLimitError) + end.to raise_error(RedisQueuedLocks::LockAcquirementRetryLimitError) expect do client.lock!('some-kek-super-pek', retry_count: 1, timeout: 1) - end.to raise_error(RedisQueuedLocks::LockAcquiermentRetryLimitError) + end.to raise_error(RedisQueuedLocks::LockAcquirementRetryLimitError) end specify 'lock_info, queue_info' do