HangfireIO/Hangfire

Implement an alternative to DisableConcurrentExecution attribute

オープン

#1,053 opened on 2017/11/09

 (18 件のコメント) (16 件のリアクション) (0 人の担当者)C# (1,748 件のフォーク)batch import
a: corehelp wantedt: feature-request

Repository metrics

Stars
 (10,068 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

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!

コントリビューターガイド