Fix configuration for sidekiq-unique-jobs after 7.x upgrade (#15908)

Remove locks from scheduled jobs
signup-info-prompt
Eugen Rochko 2021-03-15 11:17:43 +01:00 committed by GitHub
parent 33198d8c05
commit e89e976e92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 30 additions and 14 deletions

View File

@ -3,7 +3,7 @@
class Scheduler::BackupCleanupScheduler class Scheduler::BackupCleanupScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
old_backups.reorder(nil).find_each(&:destroy!) old_backups.reorder(nil).find_each(&:destroy!)

View File

@ -3,7 +3,7 @@
class Scheduler::DoorkeeperCleanupScheduler class Scheduler::DoorkeeperCleanupScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all Doorkeeper::AccessToken.where('revoked_at IS NOT NULL').where('revoked_at < NOW()').delete_all

View File

@ -3,7 +3,7 @@
class Scheduler::EmailScheduler class Scheduler::EmailScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
FREQUENCY = 7.days.freeze FREQUENCY = 7.days.freeze
SIGN_IN_OFFSET = 1.day.freeze SIGN_IN_OFFSET = 1.day.freeze

View File

@ -4,7 +4,7 @@ class Scheduler::FeedCleanupScheduler
include Sidekiq::Worker include Sidekiq::Worker
include Redisable include Redisable
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
clean_home_feeds! clean_home_feeds!

View File

@ -3,7 +3,7 @@
class Scheduler::InstanceRefreshScheduler class Scheduler::InstanceRefreshScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
Instance.refresh Instance.refresh

View File

@ -5,7 +5,7 @@ class Scheduler::IpCleanupScheduler
IP_RETENTION_PERIOD = 1.year.freeze IP_RETENTION_PERIOD = 1.year.freeze
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
clean_ip_columns! clean_ip_columns!

View File

@ -3,7 +3,7 @@
class Scheduler::MediaCleanupScheduler class Scheduler::MediaCleanupScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
unattached_media.find_each(&:destroy) unattached_media.find_each(&:destroy)

View File

@ -3,7 +3,7 @@
class Scheduler::PgheroScheduler class Scheduler::PgheroScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
PgHero.capture_space_stats PgHero.capture_space_stats

View File

@ -3,7 +3,7 @@
class Scheduler::ScheduledStatusesScheduler class Scheduler::ScheduledStatusesScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
publish_scheduled_statuses! publish_scheduled_statuses!

View File

@ -3,7 +3,7 @@
class Scheduler::TrendingTagsScheduler class Scheduler::TrendingTagsScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
TrendingTags.update! if Setting.trends TrendingTags.update! if Setting.trends

View File

@ -3,7 +3,7 @@
class Scheduler::UserCleanupScheduler class Scheduler::UserCleanupScheduler
include Sidekiq::Worker include Sidekiq::Worker
sidekiq_options lock: :until_executed, retry: 0 sidekiq_options retry: 0
def perform def perform
clean_unconfirmed_accounts! clean_unconfirmed_accounts!

View File

@ -14,14 +14,30 @@ Sidekiq.configure_server do |config|
chain.add SidekiqErrorHandler chain.add SidekiqErrorHandler
end end
config.death_handlers << lambda do |job, _ex| config.server_middleware do |chain|
digest = job['lock_digest'] chain.add SidekiqUniqueJobs::Middleware::Server
SidekiqUniqueJobs::Digests.delete_by_digest(digest) if digest
end end
config.client_middleware do |chain|
chain.add SidekiqUniqueJobs::Middleware::Client
end
SidekiqUniqueJobs::Server.configure(config)
end 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 SidekiqUniqueJobs::Middleware::Client
end
end end
Sidekiq.logger.level = ::Logger.const_get(ENV.fetch('RAILS_LOG_LEVEL', 'info').upcase.to_s) Sidekiq.logger.level = ::Logger.const_get(ENV.fetch('RAILS_LOG_LEVEL', 'info').upcase.to_s)
SidekiqUniqueJobs.configure do |config|
config.reaper = :ruby
config.reaper_count = 1000
config.reaper_interval = 600
config.reaper_timeout = 150
end