I have a recurring job, it works perfectly first time, but after the next execution, it gives ERROR. However, there isn't any exception or error in my GetPendingTrips() method.
Can some guide me what is the issue here in next attempt of recurring job?
RecurringJob.AddOrUpdate<ITripManager>(nameof(ITripManager), job => job.GetPendingTrips(), Cron.Minutely);
I have realized that Hangfire will not work continuously on background in IIS server, it will immediately stop the recurring job when there isn't any activity on the server. So in order to run the recurring job you need to do the following steps as mentioned in this article.
https://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html
Related
I am having issue where when I trigger a hangfire task it doesn't process. It shows as fetched but not queued.
If I fully delete the hangfire schema and restart my application then I am able to run the task to completion but then subsequent triggered tasks go into the same fetched state.
If I look in succeeded then there is a count for a succeeded task but nothing shows:
The code itself executes fine (on first attempt after schema built). It looks like some error is happening on task completion but I see no error in the logs.
I am using Hangfire.PostgreSQL provider.
How can I fix/debug this?
I'm trying to execute a process to update my database, but the problem is that I set different RecurringJobs for it at different hours.
Today when I checked hangfire status, since yesterday that I instanced hangfire, I found the job should execute yesterday and the one task for today, both executed 30 minutes ago at the same time, and this has created duplicates in the database.
Can you help me with this?
If your problem is one of concurrency, you can solve it by running hangfire single threaded. Simply configure the number of hangfire worker threads on startup:
var server = new BackgroundJobServer(new BackgroundJobServerOptions
{
WorkerCount = 1
});
This will force hangfire to process queued jobs sequentially.
Alternatively, if you have the Pro version of hangfire you can control order using batch chaining.
I don't know if a worker can be considered as a thread.
Within a hangfire worker, single threaded code will be run by exactly one thread
This doesn't look like a concurrency issue as has been suggested. It's not completely clear what you are trying to do but I'm assuming you want the job to run at 7, 12:45, and 17:30 and had issues because both the 7am and 17:30 job ran at the same time (7am).
Based on the created time it looks like you created these around 14:30. That means the 17:30 job should have ran but didn't until the next morning around 7am. My best guess is this was hosted in IIS and the site app pool was recycled.
This would cause any recurring jobs that were supposed to run to be delayed until the app pool / site was started again (which I assume was around 7am).
Check out these documents on how to ensure your site is always running: http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html
If it's not an IIS issue something must have caused the BackgroundJobServer to stop monitoring the database for jobs until ~7:00am (server shutdown, error, etc).
I use hangfire to run recurring jobs.
My job get current data from the database, perform an action and leave a trace on records processed. If a job didn't run this minute - I have no need to run it twice the next minute.
Somehow I got my recurring jobs (1 minute cycle) queued by their thousands and never executed. When I restarted my IIS it tried to execute them all at once and clog the DB.
Besides than fixing the problem of no execution, is there a way to stop them from queuing up?
If you want to disable retry of failed job simply decorate your method with an AutomaticRetryAttribute and set Attempts to 0
See https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.Core/AutomaticRetryAttribute.cs for more details
I have set up an hourly recurring job at the start of the Hangfire server. When I go to the dashboard I can see the job under the Recurring Jobs tab. However, the Next Execution says "in 6 hours" while the cron says "every hour."
Why is that?
I'm facing the same issue, attaching a comment here so I can add a screenshot:
For what it's worth, I just rebooted this box and when it came back up, it had the wrong time. IIS was running, and then I changed the clock.
I have a job that is supposed to run every 11 AM and 8 PM. About two weeks ago, it started to not respect the schedule. The "fix" that I found was to start the job manually and then the job would restart respecting the schedule for a while but eventually the issue reappears.
The big problem is that there are no error message what so ever. If the job fails, I am supposed to get a notification Email which I do not. In the sql server agent logs and the Job history, there are no errors. In the job history, I can see clearly that the job skipped the schedule since there are no entries. It looks like it did not even start as if the running time had not arrived.
The schedule is set to run everyday and there are no limits on how long it is supposed to run. The sql Agent is set to restart automatically if it stops unexpectedly.
Did anyone get this problem before?
Check the user which is used to run the job. Maybe the user password is expired or the user itself is no longer active.