worker icon indicating copy to clipboard operation
worker copied to clipboard

allow custom job lock interval

Open Ashniu123 opened this issue 4 years ago • 7 comments

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:fix passes.
  • [ ] I've added tests for the new feature, and yarn test passes.
  • [ ] I have detailed the new feature in the relevant documentation.
  • [ ] I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
  • [ ] If this is a breaking change I've explained why.

Ashniu123 avatar Aug 18 '21 07:08 Ashniu123

@Ashniu123 Could you take a look at #210 ?

gorbak25 avatar Aug 18 '21 10:08 gorbak25

Please run yarn db:dump and commit the updated dump, it makes the migration easier to read.

benjie avatar Aug 24 '21 11:08 benjie

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?

benjie avatar Aug 24 '21 11:08 benjie

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.

Ashniu123 avatar Aug 24 '21 14:08 Ashniu123

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.

benjie avatar Aug 24 '21 17:08 benjie

Hey. Did think of a better solution yet? :monocle_face:

Ashniu123 avatar Sep 23 '21 07:09 Ashniu123

Yes: https://github.com/graphile/worker/issues/222

benjie avatar Sep 23 '21 09:09 benjie

Closing in favour of #222

benjie avatar Oct 23 '23 14:10 benjie