diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 06:11:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-07 06:11:09 +0300 |
commit | fcfafe81d1f1aa442c5a5c93cd27b5f5b798cb90 (patch) | |
tree | c75080b3bf76b2a8f891e6b0b7437794da03519e /doc/development/sidekiq/index.md | |
parent | 11438b1771abda3c216ca627bf5319684474889b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/development/sidekiq/index.md')
-rw-r--r-- | doc/development/sidekiq/index.md | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/development/sidekiq/index.md b/doc/development/sidekiq/index.md index 565317c4939..ea6f613a1f2 100644 --- a/doc/development/sidekiq/index.md +++ b/doc/development/sidekiq/index.md @@ -96,6 +96,24 @@ def perform end ``` +## Failure handling + +Failures are typically handled by Sidekiq itself, which takes advantage of the inbuilt retry mechanism mentioned above. You should allow exceptions to be raised so that Sidekiq can reschedule the job. + +If you need to perform an action when a job fails after all of its retry attempts, add it to the `sidekiq_retries_exhausted` method. + +```ruby +sidekiq_retries_exhausted do |msg, ex| + project = Project.find(msg['args'].first) + project.perform_a_rollback # handle the permanent failure +end + +def perform(project_id) + project = Project.find(project_id) + project.some_action # throws an exception +end +``` + ## Sidekiq Queues Previously, each worker had its own queue, which was automatically set based on the |