Skip to content

Commit

Permalink
retry_jobs now requires the sidekiq API due to recent constant extrac…
Browse files Browse the repository at this point in the history
…tion, fixes sidekiq#1915
  • Loading branch information
mperham committed Aug 28, 2014
1 parent dffdd22 commit 055fdfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/sidekiq/api.rb
Expand Up @@ -326,7 +326,7 @@ def kill
Sidekiq.redis do |conn|
conn.multi do
conn.zadd('dead', now, message)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::DEAD_JOB_TIMEOUT)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT)
conn.zremrangebyrank('dead', 0, - DeadSet::MAX_JOBS)
end
end
Expand Down Expand Up @@ -520,7 +520,7 @@ def retry_all
# Allows enumeration of dead jobs within Sidekiq.
#
class DeadSet < JobSet
DEAD_JOB_TIMEOUT = 180 * 24 * 60 * 60 # 6 months
TIMEOUT = 180 * 24 * 60 * 60 # 6 months
MAX_JOBS = 10_000

def initialize
Expand Down
6 changes: 2 additions & 4 deletions lib/sidekiq/middleware/server/retry_jobs.rb
@@ -1,4 +1,5 @@
require 'sidekiq/scheduled'
require 'sidekiq/api'

module Sidekiq
module Middleware
Expand Down Expand Up @@ -131,9 +132,6 @@ def call(worker, msg, queue)

private

DEAD_JOB_TIMEOUT = 180 * 24 * 60 * 60 # 6 months
MAX_JOBS = 10_000

def retries_exhausted(worker, msg)
logger.debug { "Dropping message after hitting the retry maximum: #{msg}" }
begin
Expand All @@ -154,7 +152,7 @@ def send_to_morgue(msg)
Sidekiq.redis do |conn|
conn.multi do
conn.zadd('dead', now, payload)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::DEAD_JOB_TIMEOUT)
conn.zremrangebyscore('dead', '-inf', now - DeadSet::TIMEOUT)
conn.zremrangebyrank('dead', 0, -DeadSet::MAX_JOBS)
end
end
Expand Down

0 comments on commit 055fdfd

Please sign in to comment.