Module: RedisQueuedLocks::Acquirer::ReleaseLock Private
- Extended by:
- Utilities
- Defined in:
- lib/redis_queued_locks/acquirer/release_lock.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Constant Summary
Constants included from Utilities
Utilities::RACTOR_LIVENESS_PATTERN, Utilities::RACTOR_STATUS_PATTERN, Utilities::RUBY_OVER_4
Class Method Summary collapse
-
.release_lock(redis, lock_name, instrumenter, logger, log_sampling_enabled, log_sampling_percent, log_sampler, log_sample_this, instr_sampling_enabled, instr_sampling_percent, instr_sampler, instr_sample_this) ⇒ Hash<Symbol,Boolean<Hash<Symbol,Numeric|String|Symbol>>] Format: { ok: true/false, result: Hash<Symbol,Numeric|String|Symbol> }
private
Release the concrete lock: - 1.
Methods included from Utilities
clock_gettime, ractor_alive?, ractor_status, ruby_over_4?, run_non_critical, thread_state
Class Method Details
.release_lock(redis, lock_name, instrumenter, logger, log_sampling_enabled, log_sampling_percent, log_sampler, log_sample_this, instr_sampling_enabled, instr_sampling_percent, instr_sampler, instr_sample_this) ⇒ Hash<Symbol,Boolean<Hash<Symbol,Numeric|String|Symbol>>] Format: { ok: true/false, result: Hash<Symbol,Numeric|String|Symbol> }
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Release the concrete lock:
-
- clear lock queue: al; related processes released from the lock aquierment and should retry;
-
- delete the lock: drop lock key from Redis; It is safe because the lock obtain logic is transactional and watches the original lock for changes.
rubocop:disable Metrics/MethodLength
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/redis_queued_locks/acquirer/release_lock.rb', line 76 def release_lock( redis, lock_name, instrumenter, logger, log_sampling_enabled, log_sampling_percent, log_sampler, log_sample_this, instr_sampling_enabled, instr_sampling_percent, instr_sampler, instr_sample_this ) lock_key = RedisQueuedLocks::Resource.prepare_lock_key(lock_name) lock_key_queue = RedisQueuedLocks::Resource.prepare_lock_queue(lock_name) rel_start_time = clock_gettime fully_release_lock(redis, lock_key, lock_key_queue) => { ok:, result: } # steep:ignore # @type var ok: bool # @type var result: Hash[Symbol,Symbol] time_at = Time.now.to_f rel_end_time = clock_gettime rel_time = ((rel_end_time - rel_start_time) / 1_000.0).ceil(2) instr_sampled = RedisQueuedLocks::Instrument.should_instrument?( instr_sampling_enabled, instr_sample_this, instr_sampling_percent, instr_sampler ) run_non_critical do instrumenter.notify('redis_queued_locks.explicit_lock_release', { lock_key: lock_key, lock_key_queue: lock_key_queue, rel_time: rel_time, at: time_at }) end if instr_sampled { ok: true, result: { rel_time: rel_time, rel_key: lock_key, rel_queue: lock_key_queue, queue_res: result[:queue], lock_res: result[:lock] } } end |