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

Implement TTL mechanism for jobs being processed #677

Closed
manast opened this issue Aug 6, 2021 · 3 comments
Closed

Implement TTL mechanism for jobs being processed #677

manast opened this issue Aug 6, 2021 · 3 comments
Labels
enhancement New feature or request PRO

Comments

@manast
Copy link
Contributor

manast commented Aug 6, 2021

Summary

It should be possible to define a TTL (time to live) for jobs being processed by a worker.

If this TTL is reached and the job has not yet being completed we should notify the worker that the job has exceeded its time to live and that it will be "discarded" so that the processor code has an opportunity to close itself gracefully.

Details

A new TTL option should be introduced in the Job's options, so that we can have different TTLs for every job in a given queue if needed.
A new optional callback function can be provided in the processor function, this callback will be called before expiring the job. This function should be async so that the TTL can wait for asynchronous graceful shutdown (however we also need a TTL for this graceful shutdown).

The expiring mechanism will imply that the worker removes the lock token for the given job and fails it with reason "TTL Expired". For a standard worker it could happen that the processor does not close gracefully and so this processor may actually complete in the future and try to move the job to the completed state, however this will not be possible since the lock has been removed so the operation will fail and ignored.
For sandboxed processes we can actually kill the process entirely, which will work as long as we keep the concurrency of processors per process to 1. Killing the process will clean all the resources associated to the malfunctioning processor which I think is what most users would expect.

@manast manast added the enhancement New feature or request label Aug 6, 2021
@ATheCoder
Copy link
Contributor

@manast I'm willing to implement this, If you have give me some hints as to how to do it.

@manast manast added the PRO label Nov 12, 2021
@ATheCoder
Copy link
Contributor

:(

@roggervalf
Copy link
Collaborator

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

No branches or pull requests

3 participants