February 23, 2018, 10:01pm
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.
February 24, 2018, 12:40am
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
https://github.com/pieceofsummer/Hangfire.Console/issues/50 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 :-).