HangfireIO / HangfireIO/Hangfire
Implement an alternative to DisableConcurrentExecution attribute
- Dominant language
- C#
- Stars
- 10.1k
- Forks
- 1.8k
- Avg merge
- 1h 19m
- Merged PRs (30d)
- 1
Description
The implementation is crappy for long-running jobs, because it requires a long-running distributed lock. And it's totally unclear what timeout to use, because it should cover the maximum possible duration of a background job. The following problems arise, when using high values for timeouts (consider 4 hours, for example):
1. Any worker that fetched a job protected by this attribute will wait, and will wait for 4 hours in our example. Have multiple attributes – the whole processing could be stopped.
2. For very high values, like 24 hours, resource governors may simply release the distributed lock, and we'll get 2 or more concurrent executions depending on the job duration.
If we are using low values, we could end up with permanent `DistributedLockTimeoutException` or `TimeoutException` depending on the version. There's the [`MutexAttribute`](https://gist.github.com/odinserj/4a3bf40606c4da9183588a5a325dfb99) that was implemented as a gist, and it is using short distributed locks, but its implementation could be greatly simplified by using a single hash value instead of sets.
So if someone wants to deep dive into Hangfire internals and extensibility points, this is a good entry point!
Contributor guide
Research direction
Start with the linked MutexAttribute gist and Hangfire's attribute, distributed-lock, and extensibility entry points. Compare the gist's short-lock approach with the current DisableConcurrentExecution behavior, including the single-hash simplification. Done means a defined replacement that avoids long-held locks while preserving mutual exclusion for long-running jobs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100