feat: update lock timeout and retry configuration (#7785)
This commit is contained in:
@@ -3,7 +3,7 @@ class Webhooks::FacebookEventsJob < ApplicationJob
|
|||||||
|
|
||||||
queue_as :default
|
queue_as :default
|
||||||
# https://edgeapi.rubyonrails.org/classes/ActiveJob/Exceptions/ClassMethods.html#method-i-retry_on
|
# 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)
|
def perform(message)
|
||||||
response = ::Integrations::Facebook::MessageParser.new(message)
|
response = ::Integrations::Facebook::MessageParser.new(message)
|
||||||
@@ -12,7 +12,7 @@ class Webhooks::FacebookEventsJob < ApplicationJob
|
|||||||
lock_manager = Redis::LockManager.new
|
lock_manager = Redis::LockManager.new
|
||||||
|
|
||||||
if lock_manager.locked?(lock_key)
|
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}"
|
raise LockAcquisitionError, "Failed to acquire lock for key: #{lock_key}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
class Redis::LockManager
|
class Redis::LockManager
|
||||||
# Default lock timeout set to 5 seconds. This means that if the lock isn't released
|
# Default lock timeout set to 2 seconds. This means that if the lock isn't released
|
||||||
# within 5 seconds, it will automatically expire.
|
# 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.
|
# 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.
|
# Attempts to acquire a lock for the given key.
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user