HangfireIO / HangfireIO/Hangfire
Not launching a scheduled job if the previous one didn't complete
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
Good Morning everyone,
I have a simple use case that I couldn't solve, and I'm sure there should be a way to do it. I have looked into **DisableConcurrentExecution**, but it seems not doing what I expect. Besides, this I have read that not always works especially with mongo as storage provider.
The case is simple: I have a **recurring** Job 1 scheduled each X time (let's say **1 day**). This job launches thousands of other jobs and sometimes the time it takes to execute all the jobs tree, it is more than 1 day.
What I would like to achieve is that if the **Job 1** tree didn't finish, hangfire skips completely the next execution and wait for another time window, or two depending on when the Job 1 finishes. If for example it takes 3 days, the Job 1 scheduled for the second day and third day should be skipped, avoiding creating a perpetual queue, where more and more jobs can be added than the actual process can handle.
Is there a way to do something like this? I'm sure yes
Many thanks for the help
Contributor guide
Research direction
Start by reading the recurring-job scheduling behavior and the DisableConcurrentExecution mechanism, with attention to Mongo storage limitations. Reproduce a recurring Job 1 that launches thousands of jobs and runs longer than its one-day interval; done means later executions are skipped while the job tree is still running, without creating an unbounded queue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100