allow custom job lock interval
Description
Currently, each job has a default lock period of 4 hours. Some jobs may last longer than 4 hours and some may last only for a few minutes. With this feature, I aim to give the developer the power to control locked duration. This will allow graphile to execute jobs which last at most locked_duration, which is fixed to 4 now.
It is a highly risky thing to configure a task's lock period to be shorter than its execution time.
Related to issue #198
Performance impact
Unknown
Security impact
Unknown
Checklist
- [x] My code matches the project's code style and
yarn lint:fixpasses. - [ ] I've added tests for the new feature, and
yarn testpasses. - [ ] I have detailed the new feature in the relevant documentation.
- [ ] I have added this feature to 'Pending' in the
RELEASE_NOTES.mdfile (if one exists). - [ ] If this is a breaking change I've explained why.
@Ashniu123 Could you take a look at #210 ?
Please run yarn db:dump and commit the updated dump, it makes the migration easier to read.
So you think that rather than doing the lock duration on a per-queue or per-task-identifier basis that it should be on a per-job basis - basically it's up to whoever adds the job to ensure that they know how long it should take. I think that makes sense, but it's going to make the table bigger for fairly marginal gains, I fear. Do you have jobs that take more than an hour to complete?
So you think that rather than doing the lock duration on a per-queue or per-task-identifier basis that it should be on a per-job basis - basically it's up to whoever adds the job to ensure that they know how long it should take. I think that makes sense, but it's going to make the table bigger for fairly marginal gains, I fear. Do you have jobs that take more than an hour to complete?
Yeah.
My take on having a custom job interval also comes from the viewpoint that if for any reason a process goes OOM which would cause jobs to be locked, a knowledgable developer should have the capability to tell graphile worker that the max run time of a job is 1 hour and to allow it to be picked up again asap.
Moreover, this PR would allow graphile worker to run jobs which last longer than 4 hours.
Yeah; it's an interesting approach. I shall ponder it. I feel there's a better solution forming... leave it with me for a few weeks to brew.
Hey. Did think of a better solution yet? :monocle_face:
Yes: https://github.com/graphile/worker/issues/222
Closing in favour of #222