HangfireIO/Hangfire

Implement an alternative to DisableConcurrentExecution attribute

Open

#1,053 创建于 2017年11月9日

在 GitHub 查看
 (18 评论) (16 反应) (0 负责人)C# (10,068 star) (1,748 fork)batch import
a: corehelp wantedt: feature-request

描述

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 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!

贡献者指南

Implement an alternative to DisableConcurrentExecution attribute · HangfireIO/Hangfire#1053 | Good First Issue