Ensure done jobs get deleted periodically #289
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Done jobs aren't being deleted so they must have streams hanging around on the jobs. I'm removing the logic that updates the last update time when streaming events and made a change to shouldDelete jobs.
The new logic:
A job without listeners will get deleted if it is done and time since last update > retention time or if it's not done and time since last update > expriy time.
A job with listeners will get delete if it is done and time sice last update is > resumption time.
Any job that hasn't had an update in 2x expiry will be deleted.
I've also ensured j.Done is set to false when we create a new execution and added warnings around deleting jobs with listeners.