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: https://stackoverflow.com/questions/48904368/my-job-executes-an-arbitrary-number-of-times-even-though-only-scheduled-once

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.

Hi,

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 :-).