procrastinate-org / procrastinate

PostgreSQL-based Task Queue for Python
https://procrastinate.readthedocs.io/
MIT License
840 stars 52 forks source link

Include cancelled aborted tasks in remove_old_jobs #1145

Closed katlyn closed 1 month ago

katlyn commented 1 month ago

Currently, the builtin remove_old_jobs task only removes jobs that are succeeded or (optionally) failed. This can lead to cancelled and aborted tasks piling up in the database.

https://github.com/procrastinate-org/procrastinate/blob/77bf6452856ce735572ec383718a2782cee9a8f0/procrastinate/manager.py#L198-L203

Ideally, there would be an additional parameter available to remove those types of jobs as well.

medihack commented 1 month ago

Yes, that sounds reasonable. We could have an include_aborted and include_cancelled. Also, the docstring seems to be wrong of delete_old_jobs.include_error (it's the other way around). Would you be interested in providing a PR? ☺️