Skip to content

The best way to abort the jobs running in the current process and release their locks before exiting #1995

@dko-slapdash

Description

@dko-slapdash

Hi. I'm trying to implement a "graceful stop" sequence for a worker process which happens when e.g. a machine is stopping. The idea is to call queue.pause(true), then wait for some reasonable amount of time (say, 10 seconds) letting most of the short-lived jobs to finish on their own. Then, there will always be some remaining jobs (long-lived) for which 10 seconds is not enough; for them, we can do nothing, so I just terminate the process.

The problem is with locks of these remaining jobs. Theoretically, I know for 100% that these jobs will stop running within a second (since the process dies), so I want the locks to be released immediately; this way, the jobs' keys can be rescheduled ASAP and not when the locks expire (due to various reasons, the locks timeouts are set to some high value, like 60 seconds, to eliminate the chances of expiring them during some temporary problems with CPU load or network).

Is there a way to tell Bull to force-release locks for all the jobs which are still running in the current (!) process?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions