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

Add new deferred_ttl job attribute and cleanup for deferred jobs #1685

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

raymondguo-db
Copy link

Currently there is no cleanup for deferred jobs in the DeferredJobRegistry. The only way for jobs to leave the DeferredJobRegistry is if the jobs' dependencies succeed. If dependencies fail or never execute, then deferred jobs are not cleaned up.

In my use case, we saw that our DeferredJobRegistry was getting too large, hitting our Redis instance limits. Our workaround so far for this was to make a periodic job that clears the DeferredJobRegistry.

This PR simplifies this process by adding an optional deferred_ttl attribute to deferred jobs. By default, the value for this is +inf (the current behavior, so existing workflows aren't affected). deferred_ttl in effect is a time limit for deferred jobs before they stop waiting and are considered failed, cleaned up by the DeferredJobRegistry.

@raymondguo-db raymondguo-db marked this pull request as ready for review August 1, 2022 22:55
@raymondguo-db
Copy link
Author

cc @rauchy

@selwin
Copy link
Collaborator

selwin commented Aug 2, 2022

Hey, this is a good idea, but I'd like this to be implemented via the newly added Dependency class. This is how the API should look like:

queue.enqueue(foo, depends_on=Dependency(bar, ttl=90))

Mind making this change? I think the change shouldn't be too big and it makes the API cleaner by grouping related args together.

@selwin
Copy link
Collaborator

selwin commented Aug 13, 2022

A reminder to make this change when you're free :).

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

Successfully merging this pull request may close these issues.

None yet

2 participants