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

Support "steps" for processors so that long operations can be broken down in atomic ones #182

Closed
manast opened this issue Apr 16, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@manast
Copy link
Contributor

manast commented Apr 16, 2020

In some jobs, several asynchronous operations need to be performed, for example storing a value in a database and updating some remote api. If the job fails and we want to retry it, the job needs to be idempotent to avoid side effects. However, sometimes is not possible to design an idempotent job, instead we could support dividing the job in steps, and if any step fails, the retry mechanism should only retry from the failed step.

@manast manast added the enhancement New feature or request label Apr 16, 2020
@wenq1
Copy link

wenq1 commented Apr 16, 2020

This should better be left in application code than in the job queue itself. You cannot satisfy all needs. Think about the the weird stacktrace appending implementation (#151) in the current codebase which at the end of the day people can do nothing about but workaround.

Your "steps" proposal sounds much likely to be fulfilled by a simple state machine. If the job is retried or attempted the first time (idempotent), depending on its state it should resume from different points. A state recording mechanism will be good enough and more generic than your "steps" proposal. Think about the case where there's a job with 3 steps. If step 3 fails one wants to retry from step 1 rather than step 3 itself. Such case is not uncommon in today's programming, and will render your "steps" proposal rather useless.

For state recording, by the way, job.updateProgress () is already doing good enough. Currently its only limitation is its numeric argument requirement. A rather interesting proposal is to have a job.updateData () function to allow for more generic data updating ().

@roggervalf
Copy link
Collaborator

This issue fits the current step jobs pattern https://docs.bullmq.io/patterns/process-step-jobs

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

No branches or pull requests

3 participants