diff --git a/app/jobs/webhooks/facebook_events_job.rb b/app/jobs/webhooks/facebook_events_job.rb index de32af8cf..12e3656d9 100644 --- a/app/jobs/webhooks/facebook_events_job.rb +++ b/app/jobs/webhooks/facebook_events_job.rb @@ -3,7 +3,7 @@ class Webhooks::FacebookEventsJob < ApplicationJob queue_as :default # https://edgeapi.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on - retry_on LockAcquisitionError, wait: 2.seconds, attempts: 5 + retry_on LockAcquisitionError, wait: 1.second, attempts: 6 def perform(message) response = ::Integrations::Facebook::MessageParser.new(message) @@ -12,7 +12,7 @@ class Webhooks::FacebookEventsJob < ApplicationJob lock_manager = Redis::LockManager.new if lock_manager.locked?(lock_key) - Rails.logger.error "[Facebook::MessageCreator] Failed to acquire lock on attempt #{executions + 1}: #{lock_key}" + Rails.logger.error "[Facebook::MessageCreator] Failed to acquire lock on attempt #{executions}: #{lock_key}" raise LockAcquisitionError, "Failed to acquire lock for key: #{lock_key}" end diff --git a/lib/redis/lock_manager.rb b/lib/redis/lock_manager.rb index 87106168a..d8017a49e 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 5 seconds. This means that if the lock isn't released - # within 5 seconds, it will automatically expire. + # Default lock timeout set to 2 seconds. This means that if the lock isn't released + # within 2 seconds, it will automatically expire. # This helps to avoid deadlocks in case the process holding the lock crashes or fails to release it. - LOCK_TIMEOUT = 5.seconds + LOCK_TIMEOUT = 2.seconds # Attempts to acquire a lock for the given key. #