From 10076c6a3e53e316328ef148dfb58f6597da527f Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Fri, 12 Jan 2024 08:28:07 +0530 Subject: [PATCH] feat: set lock timeout to 1 second (#8661) --- app/jobs/send_on_slack_job.rb | 2 +- lib/redis/lock_manager.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/jobs/send_on_slack_job.rb b/app/jobs/send_on_slack_job.rb index 2503be121..eececa409 100644 --- a/app/jobs/send_on_slack_job.rb +++ b/app/jobs/send_on_slack_job.rb @@ -1,6 +1,6 @@ class SendOnSlackJob < MutexApplicationJob queue_as :medium - retry_on LockAcquisitionError, wait: 1.second, attempts: 6 + retry_on LockAcquisitionError, wait: 1.second, attempts: 8 def perform(message, hook) with_lock(::Redis::Alfred::SLACK_MESSAGE_MUTEX, conversation_id: message.conversation_id, reference_id: hook.reference_id) do diff --git a/lib/redis/lock_manager.rb b/lib/redis/lock_manager.rb index d8017a49e..63063542c 100644 --- a/lib/redis/lock_manager.rb +++ b/lib/redis/lock_manager.rb @@ -12,10 +12,10 @@ # end # class Redis::LockManager - # Default lock timeout set to 2 seconds. This means that if the lock isn't released - # within 2 seconds, it will automatically expire. + # Default lock timeout set to 1 second. This means that if the lock isn't released + # within 1 second, it will automatically expire. # This helps to avoid deadlocks in case the process holding the lock crashes or fails to release it. - LOCK_TIMEOUT = 2.seconds + LOCK_TIMEOUT = 1.second # Attempts to acquire a lock for the given key. #