Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead jobs #308

Merged
merged 2 commits into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [Finer Control over Uniqueness](#finer-control-over-uniqueness)
* [After Unlock Callback](#after-unlock-callback)
* [Logging](#logging)
* [Cleanup Dead Locks](#cleanup-dead-locks)
* [Debugging](#debugging)
* [Sidekiq Web](#sidekiq-web)
* [Show Unique Digests](#show-unique-digests)
Expand Down Expand Up @@ -353,6 +354,29 @@ class UniqueJobWithFilterMethod
end
```

### Cleanup Dead Jobs

For sidekiq versions before 5.1 a `sidekiq_retries_exhausted` block is required per worker class.

```ruby
class MyWorker
sidekiq_retries_exhausted do |msg, _ex|
SidekiqUniqueJobs::Digests.delete_by(digest: msg['unique_digest']) if msg['unique_digest']
end
end
```

Starting in v5.1, Sidekiq can also fire a global callback when a job dies:

```ruby
# this goes in your initializer
Sidekiq.configure_server do |config|
config.death_handlers << ->(job, _ex) do
SidekiqUniqueJobs::Digests.delete_by(digest: job['unique_digest']) if job['unique_digest']
end
end
```

## Debugging

There are two ways to display and remove keys regarding uniqueness. The console way and the command line way.
Expand Down
4 changes: 0 additions & 4 deletions lib/sidekiq_unique_jobs/web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ module Web
module Helpers
VIEW_PATH = File.expand_path('../web/views', __dir__)

def filtering(pattern, count)
SidekiqUniqueJobs::Util.keys(pattern, count)
end

def unique_template(name)
File.open(File.join(VIEW_PATH, "#{name}.erb")).read
end
Expand Down
3 changes: 3 additions & 0 deletions rails_example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
/log/*
!/log/.keep
/tmp

# Ignore master key for decrypting credentials and more.
/config/master.key
1 change: 1 addition & 0 deletions rails_example/config/credentials.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5Z9kpiujtSvYTo0oVBzG8XPabCc5wRxo16cGro+mSgdOslR2hjejEZfh6D3eM0S9eq0afAJ7yR/vOR/1L/ACREZ+uXxh72n2YwuOSveaSz0291pfHrUSCZMjo0oU03znya7lQvopYdPpFUaIsD+wBYM2s/9ItBUoJBMex8ZrqRjzjvJq+EvO/O5WgObBvNtRMyQBfrgOhpSuMLye2dgrtB7LFKSM7cTUrj1XFVg4bVertSrQIUjGZXAKW5yKI4Xtqx7hstEMyucFPXjjwHiNAKAugecg3ttG3H2AvAq6AFQC5qJyBcAZFBPsmpnoUEv+8msGvVp9s4N/plnGz3Vh43e0o3z1t9BXrcYiYyR+Eu/scvnmbf7NTuDNeyoG7PxH5mXWiXJUfqnu8wRBs4zxOy1Ub5DAz4FIx7YT--evpxuoVG2tMsVyuM--GK3U5kJh/q1AexJTiGkrvA==
6 changes: 5 additions & 1 deletion rails_example/config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defaults: &defaults
adapter: postgresql
host: <%= ENV.fetch('DB_HOST') { 'localhost' } %>
port: <%= ENV.fetch('DB_PORT') { 5432 } %>
username: <%= ENV.fetch('DB_USERNAME') { 'mhenrixon' } %>
username: <%= ENV.fetch('DB_USERNAME') { `whoami` } %>
password: <%= ENV.fetch('DB_PASSWORD') { nil } %>
pool: <%= ENV.fetch('DB_POOL') { 25 } %>
timeout: <%= ENV.fetch('DB_TIMEOUT') { 5000 } %>
Expand All @@ -17,3 +17,7 @@ test:
<<: *defaults
database: rails_example_test

production:
<<: *defaults
database: rails_example_prod