wanlitao / HangfireExtension

Hangfire Extension plugins
Apache License 2.0
22 stars 32 forks source link

Work Item is picked and processed multiple times. #3

Closed agabuza closed 2 years ago

agabuza commented 8 years ago

Looks like there is some synchronization and/or DB locking issue. Same Work Item processed multiple times (even when max attempts count set) and then stuck in processing forever. In case of large number of workers it might lead to the situation when same work item is being processed by multiple workers in the same time. Any idea or similar issues?

wanlitao commented 8 years ago

As SQLite DB Locking base on OS file system, there is no reliable way to achieve distributed lock. So best practices is no concurrency, set the workers count to 1 just as follows:

new BackgroundJobServer(new BackgroundJobServerOptions { WorkerCount = 1 });
odinserj commented 7 years ago

I believe the main root of the problem is the dequeue method, where GET-UPDATE operation is non-atomic, because there is no any transaction. This allows multiple workers to pick up the same background job, leading to multiple executions.

NicolasDorier commented 7 years ago

I am hitting this problem as well...

darkthread commented 6 years ago

I have a idea to fix this issue. #19

firatesmer commented 6 years ago

WorkerCount = 1 worked for me.