HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.24k stars 1.68k forks source link

Hangfire Job is not getting into completed state #2158

Open schroedermarius opened 1 year ago

schroedermarius commented 1 year ago

Hi,

I am using Hangfire with SQLServer (I've also tried InMemory which leaded to other problems). I'm facing a weird issue, where I have a lot of jobs in queue and 4 jobs are beeing processed in parallel.

I've added a lot of logs to my own code to check where it is getting stucked. I've assumed that if hangfire cant determine the state of the job its getting cancled anytime?

Anyway: I can see from the logs, that my job completed with success:

2023-01-30T07:22:51.267595296Z       Extraction of '0x47ba3cdba6b6b5db:0x532b6cd370783333' completed. Next page CAESBkVnSUlaQQ==.

2023-01-30T07:22:51.277868061Z       Downloading id 0x47ba3cdba6b6b5db:0x532b6cd370783333 (CAESBkVnSUlaQQ==).

2023-01-30T07:22:53.103529103Z       Extraction of '0x47ba3cdba6b6b5db:0x532b6cd370783333' completed.

2023-01-30T07:22:53.116562079Z       Completed extraction for '0x47ba3cdba6b6b5db:0x532b6cd370783333'. Found 102 elements.

Weird is, that it is still in processing state in the hangfire dashboard. Which leads to a job beeing processed forever.

image

I am also using Hangfire Console to log some more things to the dashboard. This is also not getting updated. Logs in my console are normally the same as on the dashboard output.

Background job is enqued like the following: BackgroundJob.Enqueue<FileExtractor>(s => s.StartExtraction(null!, entity.Id, CancellationToken.None));

Function definition: [AutomaticRetry(Attempts = 0)] public async Task StartExtraction(PerformContext context, string? id, CancellationToken ct = default)

I am using services which are registered transient. If that could lead to any help.

So from my log perspective I am pretty sure, that my function/background job is completing successfully but hangfire does not catch it anyhow.

schroedermarius commented 1 year ago

Also when reenqueing the job which was stuck, hangfire wont take another one. He worked with 4 workers, I reenqueued the job which was stuck and now he is only working with 3 workers.