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

Non-idempotent jobs (max_retries unset) that fail on a dead broker are not signalled #18

Closed
bigjools opened this issue Mar 10, 2022 · 2 comments

Comments

@bigjools
Copy link
Collaborator

Work was recently completed to send signals for jobs that fail as a result of a dead broker, however those jobs that have max_retries unset are not signalled as failed at all, unlike the idempotent ones which DO send a failure signal.

@some1ataplace
Copy link

Maybe try this.

Modify the Worker class in spinach to handle non-idempotent jobs that fail on a dead broker. Specifically, you can add a check in the process_job method to see if the job has max_retries unset, and if so, signal the job as failed if it fails due to a dead broker.

Here's an example implementation:

from spinach.worker import Worker

class CustomWorker(Worker):
    def process_job(self, job):
        try:
            self._process_job(job)
        except Exception as e:
            if not job.max_retries and 'dead' in str(e):
                self.send_failure_signal(job)
            else:
                raise e

0xDEC0DE pushed a commit to 0xDEC0DE/spinach that referenced this issue Mar 23, 2024
Push running-job markers down into the Redis for all jobs, and move
the logic for re-enqueueing jobs from dead brokers into the script
itself.  Non-idempotent jobs running on a dead broker are still NOT
re-enqueued.

This should cause non-idempotent jobs to no longer run "invisibly"
on a Redis broker, as well as causing dead brokers to signal any
non-idempotent jobs that were running on them as failed.

Fixes: Issue NicolasLM#18
0xDEC0DE pushed a commit to 0xDEC0DE/spinach that referenced this issue Mar 23, 2024
Push running-job markers down into the Redis for all jobs, and move
the logic for re-enqueueing jobs from dead brokers into the script
itself.  Non-idempotent jobs running on a dead broker are still NOT
re-enqueued.

This should cause non-idempotent jobs to no longer run "invisibly"
on a Redis broker, as well as causing dead brokers to signal any
non-idempotent jobs that were running on them as failed.

Fixes: Issue NicolasLM#18
0xDEC0DE pushed a commit to 0xDEC0DE/spinach that referenced this issue Mar 24, 2024
Push running-job markers down into the Redis for all jobs, and move
the logic for re-enqueueing jobs from dead brokers into the script
itself.  Non-idempotent jobs running on a dead broker are still NOT
re-enqueued.

This should cause non-idempotent jobs to no longer run "invisibly"
on a Redis broker, as well as causing dead brokers to signal any
non-idempotent jobs that were running on them as failed.

Fixes: Issue NicolasLM#18
@bigjools
Copy link
Collaborator Author

Fixed in 0.0.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants