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.44k stars 1.71k forks source link

AddOrUpdate not working for updating a disabled schedule such as "0 0 30 2 *" #2352

Closed qpzmm2000 closed 10 months ago

qpzmm2000 commented 10 months ago

Initally I have created a job with "0 0 30 2 *" because I am not sure the schedule. It will be marked as "disable" and I can trigger the job manually. If I call the method AddOrUpdate to update the schedule, the cron expression will be updated but the job will never run.

I checked the HangFire.Set table is not updating. The cron on HangFire.Hash is updated but the NextExecution is empty. There is a workaround by deleting the job and call the AddOrUpdate again to change the schedule.

odinserj commented 10 months ago

Can you tell me more about the use case and how can I reproduce the issue. I just tried to make the following calls, and get the output as expected. Also, what version of Hangfire.Core you are using?

RecurringJob.AddOrUpdate("initially-disabled", () => Console.WriteLine("Disabled"), "0 0 30 2 *");
RecurringJob.AddOrUpdate("initially-disabled", () => Console.WriteLine("Now enabled"), "* * * * *");
qpzmm2000 commented 10 months ago

The bug occur on version 1.8.3 and fixed on the latest version. Thank you.