mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-23 21:15:05 +01:00
Do not execute the job with the same arguments as the retry job (#4814)
This commit is contained in:
parent
e821c00e74
commit
be7ffa2d75
@ -3,7 +3,7 @@
|
|||||||
class Pubsubhubbub::SubscribeWorker
|
class Pubsubhubbub::SubscribeWorker
|
||||||
include Sidekiq::Worker
|
include Sidekiq::Worker
|
||||||
|
|
||||||
sidekiq_options queue: 'push', retry: 10, unique: :until_executed, dead: false
|
sidekiq_options queue: 'push', retry: 10, unique: :until_executed, dead: false, unique_retry: true
|
||||||
|
|
||||||
sidekiq_retry_in do |count|
|
sidekiq_retry_in do |count|
|
||||||
case count
|
case count
|
||||||
|
@ -10,6 +10,7 @@ require_relative '../app/lib/exceptions'
|
|||||||
require_relative '../lib/paperclip/gif_transcoder'
|
require_relative '../lib/paperclip/gif_transcoder'
|
||||||
require_relative '../lib/paperclip/video_transcoder'
|
require_relative '../lib/paperclip/video_transcoder'
|
||||||
require_relative '../lib/mastodon/version'
|
require_relative '../lib/mastodon/version'
|
||||||
|
require_relative '../lib/mastodon/unique_retry_job_middleware'
|
||||||
|
|
||||||
Dotenv::Railtie.load
|
Dotenv::Railtie.load
|
||||||
|
|
||||||
|
@ -13,4 +13,7 @@ end
|
|||||||
|
|
||||||
Sidekiq.configure_client do |config|
|
Sidekiq.configure_client do |config|
|
||||||
config.redis = redis_params
|
config.redis = redis_params
|
||||||
|
config.client_middleware do |chain|
|
||||||
|
chain.add Mastodon::UniqueRetryJobMiddleware
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
20
lib/mastodon/unique_retry_job_middleware.rb
Normal file
20
lib/mastodon/unique_retry_job_middleware.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Mastodon::UniqueRetryJobMiddleware
|
||||||
|
def call(_worker_class, item, _queue, _redis_pool)
|
||||||
|
return if item['unique_retry'] && retried?(item)
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def retried?(item)
|
||||||
|
# Use unique digest key of SidekiqUniqueJobs
|
||||||
|
unique_key = SidekiqUniqueJobs::UNIQUE_DIGEST_KEY
|
||||||
|
unique_digest = item[unique_key]
|
||||||
|
class_name = item['class']
|
||||||
|
retries = Sidekiq::RetrySet.new
|
||||||
|
|
||||||
|
retries.any? { |job| job.item['class'] == class_name && job.item[unique_key] == unique_digest }
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user