marcoCasamento / Hangfire.Redis.StackExchange

HangFire Redis storage based on original (and now unsupported) Hangfire.Redis but using lovely StackExchange.Redis client
Other
456 stars 109 forks source link

Recurring Jobs - on trigger exception thrown 'A null value is not valid in this context' periodically as Hangfire attempts to retry jobs #47

Closed kieranbenton closed 4 years ago

kieranbenton commented 7 years ago

Full stack trace as per the below. Not sure what I can do to up logging and diagnose the problem in more detail?

It seems to be traced to a null value being persisted inside a hashmap in Hangfire.Redis.RedisConnection.CreateExpiredJob but can't tell with just introspection as to which value is the problem.

[RecurringJobScheduler] ERROR  {RecurringJobScheduler} Error occurred during execution of 'RecurringJobScheduler' process. Execution will be retried (attempt #34) in 00:05:00 seconds. 
System.ArgumentException: A null value is not valid in this context
   at StackExchange.Redis.RedisValue.AssertNotNull()
   at StackExchange.Redis.Message.Create(Int32 db, CommandFlags flags, RedisCommand command, RedisKey key, RedisValue[] values)
   at StackExchange.Redis.RedisDatabase.GetHashSetMessage(RedisKey key, HashEntry[] hashFields, CommandFlags flags)
   at StackExchange.Redis.RedisDatabase.HashSetAsync(RedisKey key, HashEntry[] hashFields, CommandFlags flags)
   at Hangfire.Redis.RedisConnection.CreateExpiredJob(Job job, IDictionary`2 parameters, DateTime createdAt, TimeSpan expireIn)
   at Hangfire.Client.CoreBackgroundJobFactory.Create(CreateContext context)
   at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass7_0.<CreateWithFilters>b__0()
   at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)
   at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass7_1.<CreateWithFilters>b__2()
   at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter, CreatingContext preContext, Func`1 continuation)
   at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass7_1.<CreateWithFilters>b__2()
   at Hangfire.Client.BackgroundJobFactory.CreateWithFilters(CreateContext context, IEnumerable`1 filters)
   at Hangfire.Client.BackgroundJobFactory.Create(CreateContext context)
   at Hangfire.Server.RecurringJobScheduler.TryScheduleJob(JobStorage storage, IStorageConnection connection, String recurringJobId, IReadOnlyDictionary`2 recurringJob)
   at Hangfire.Server.RecurringJobScheduler.Execute(BackgroundProcessContext context)
   at Hangfire.Server.ServerProcessExtensions.Execute(IServerProcess process, BackgroundProcessContext context)
   at Hangfire.Server.AutomaticRetryProcess.Execute(BackgroundProcessContext context)
kieranbenton commented 7 years ago

Still not able to execute any recurring jobs - any pointers? On latest nuget v1.6.7.24

marcoCasamento commented 7 years ago

I've never seen this error, I'm on the latest version and I do use Recurring Jobs in production. Could you provide a repro ?

kieranbenton commented 7 years ago

I've dug a bit deeper (decompiled the dll -> pdb and debugged through fully) and this was down to me attaching a filter and applying a job parameter that in certain cases had a value of null. So it was my fault - but perhaps you might want to try and catch the issue and provide a more descriptive exception?

Thanks!