procrastinate icon indicating copy to clipboard operation
procrastinate copied to clipboard

Add support for abort notification

Open onlyann opened this issue 1 year ago • 4 comments

Successful PR Checklist:

  • [ ] Tests
    • [ ] (not applicable?)
  • [x] Documentation
    • [ ] (not applicable?)

PR label(s):

  • [x] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20breaking%20%F0%9F%92%A5
  • [x] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20feature%20%E2%AD%90%EF%B8%8F
  • [ ] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20bugfix%20%F0%9F%95%B5%EF%B8%8F
  • [ ] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20miscellaneous%20%F0%9F%91%BE
  • [ ] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20dependencies%20%F0%9F%A4%96
  • [ ] https://github.com/procrastinate-org/procrastinate/labels/PR%20type%3A%20documentation%20%F0%9F%93%9A

Context

So far, the only use of LISTEN/NOTIFY has been to let the worker know that a new job is ready to be processed.

This extends listen_notify to accept different types of notification through using the payload:

  • job_inserted: the existing notification
  • abort_job_requested: when a running job is requested to be aborted.

Instead of making explicit calls to the database every time a job calls should_abort, the worker uses the same mechanism than for detecting new jobs, a combination of Postgres notification and polling.

Other changes

The edge case of retrying a job to be aborted is handled at the database level instead of the worker.

Next steps

Once this change lands in v3, it will help with cancellation during the shutdown event and #1084

onlyann avatar Aug 25 '24 14:08 onlyann