My job executes an arbitrary number of times even though only scheduled once

My issue seems to be very similair to Iterruption of background process on half of cycle. I too have a foreach and am seeing exactly the same kind of behaviour where the job restarts half way through.

Full details here at SO:

All help greatly appreciated.

You have one job, but how many “processing” states are there inside? What exactly shows when you open job details page?

You can also add thread id to your logging to see if the job is performed by multiple workers.


As it turns out the logging that I thought was happening was not and I was actually getting an exception of “Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction”.

As I am also using your EXCELLENT Hanfire.Console I then discovered which indicates disabling the attribute DisableConcurrentExecution which as soon as I do causes no exception and everything behaves as it should.

Keeping the attribute and removing Hangfire,Console calls in my job also fixes the issue :-).