HangfireIO / HangfireIO/Hangfire

Hangfire Job is not getting into completed state

Open
#2,158 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.1k
Forks
1.8k
Avg merge
1h 19m
Merged PRs (30d)
1

Description

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](https://user-images.githubusercontent.com/7676542/215435884-75456199-9f0c-40d5-b6c3-1b7e526ab573.png)

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(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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior from the BackgroundJob.Enqueue call and the StartExtraction method, using the reported SQLServer and InMemory storage configurations. Compare the application and Hangfire Console logs with the dashboard's Processing state; done means the job reaches Completed or the cause of the persistent Processing state is documented with a reproducible case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.