Hangfire.MAMQSqlExtension icon indicating copy to clipboard operation
Hangfire.MAMQSqlExtension copied to clipboard

Why don't all implementations of GetFirstByLowestScoreFromSet filter by queue?

Open TheWrightDev opened this issue 3 years ago • 2 comments

Ran across this extension while trying to debug some issues that turned out to be because of the scheduled jobs just freely being deserialized on any server.

I think I have it setup correctly but I'm still seeing instances where it tries to schedule it on the wrong server and errors out since the types are wrong (will randomly get lucky and have it work sometimes, but stopping a starting a bunch to try and get lucky is a bit of a drag).

System.InvalidOperationException: Recurring job can't be scheduled, see inner exception for details. ---> Hangfire.Common.JobLoadException: Could not load the job. See inner exception for the details. ---> System.InvalidOperationException: The type `RecurringJobs.Daily.RecurringTestJob` does not contain a method with signature `Run(CancellationToken)`

Poking around I noticed that only the implementation of GetFirstByLowestScoreFromSet that returns the list of Ids does any filtering and the one that simple gets the first does not: https://github.com/GeXiaoguo/Hangfire.MAMQSqlExtension/blob/87d54acce685f2d91f82341b419026e6855297d2/Hangfire.MAMQSqlExtension/MAMQSqlServerConnection.cs#L92

Is there a reason for this, could this be part of my problem?

TheWrightDev avatar Nov 03 '21 19:11 TheWrightDev

Looking at it more, it seems like if it was filtered then it would have issues since it would be blocked from scheduling anything as long as the first item wasn't in an allowed queue which is definitely not what you'd want. Am I maybe missing some configuration that would cause the string GetFirstByLowestScoreFromSet method to be called in a instance when it should always be using the List<string> GetFirstByLowestScoreFromSet method?

TheWrightDev avatar Nov 03 '21 19:11 TheWrightDev

No particular reason why public override string GetFirstByLowestScoreFromSet(string key, double fromScore, double toScore) is not filtered. Whether it needs to be filtered and the impact of filtering it depend on how it is used by Hangfire of which I have lost recollection of. I have used this version in production for more than a year and have not seen any problem.

GeXiaoguo avatar Jan 10 '22 23:01 GeXiaoguo