Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyNotFoundException on /hangfire/succeeded page #286

Closed
oliverjanik opened this issue Jan 15, 2015 · 14 comments
Closed

KeyNotFoundException on /hangfire/succeeded page #286

oliverjanik opened this issue Jan 15, 2015 · 14 comments

Comments

@oliverjanik
Copy link

Normal nuget install. Default configuration.

hangfire-fail

@odinserj
Copy link
Member

@oliverjanik, thank you for reporting this. Looks like there is need for additional check, but the case is very strange and I don't understand the cause.

Have you tried to refresh the page? Does the problem persist or disappear?

@oliverjanik
Copy link
Author

It persists. I just did one console.writeline backgroundjob. Anything else I can give you?

@odinserj
Copy link
Member

What version of Hangfire.Core and Hangfire.SqlServer (from packages.config) are you using? Can you show me the Hangfire.State table (and other Hangfire tables if possible)? (here or email odinserj gmail com)

@odinserj
Copy link
Member

@oliverjanik, any news regarding to the problem problem?

@oliverjanik
Copy link
Author

Sorry I won't have access to that computer until Tue or so. I'll try to replicate on my home machine.

@oliverjanik
Copy link
Author

Here you go, replicated on different computer.

Versions:

<package id="Hangfire" version="1.3.1" targetFramework="net45" />
<package id="Hangfire.Core" version="1.3.1" targetFramework="net45" />
<package id="Hangfire.SqlServer" version="1.3.1" targetFramework="net45" />

Scripted Hangfire State:

INSERT INTO [HangFire].[State] ([Id], [JobId], [Name], [Reason], [CreatedAt], [Data]) VALUES (1, 1, N'Enqueued', NULL, N'2015-01-20 01:26:10', N'{"enqueuedAt":"2015-01-20T01:26:10.2286288Z","queue":"default"}')
INSERT INTO [HangFire].[State] ([Id], [JobId], [Name], [Reason], [CreatedAt], [Data]) VALUES (2, 1, N'Processing', NULL, N'2015-01-20 01:26:13', N'{"startedAt":"2015-01-20T01:26:13.6696288Z","serverId":"fr-130010007666:3548","workerNumber":"18"}')
INSERT INTO [HangFire].[State] ([Id], [JobId], [Name], [Reason], [CreatedAt], [Data]) VALUES (3, 1, N'Succeeded', NULL, N'2015-01-20 01:26:13', N'{"succeededAt":"2015-01-20T01:26:13.7936288Z","performanceDuration":"14","latency":"3538"}')

JobParameter (might be of interest):

INSERT INTO [HangFire].[JobParameter] ([Id], [JobId], [Name], [Value]) VALUES (1, 1, N'CurrentCulture', N'"en-AU"')
INSERT INTO [HangFire].[JobParameter] ([Id], [JobId], [Name], [Value]) VALUES (2, 1, N'CurrentUICulture', N'"en-US"')

@MichaelGG
Copy link

I'm hitting a similar bug too on succeeded, except I'm getting a NullReferenceException. Here's the top of the stack trace.

[NullReferenceException: Object reference not set to an instance of an object.]
   Hangfire.SqlServer.<>c__DisplayClass23.<SucceededJobs>b__22(SqlJob sqlJob, Job job, Dictionary`2 stateData) +142
   Hangfire.SqlServer.SqlServerMonitoringApi.DeserializeJobs(ICollection`1 jobs, Func`4 selector) +312
   Hangfire.SqlServer.SqlServerMonitoringApi.GetJobs(SqlConnection connection, Int32 from, Int32 count, String stateName, Func`4 selector) +254
   Hangfire.SqlServer.<>c__DisplayClass23.<SucceededJobs>b__21(SqlConnection connection) +232
   Hangfire.SqlServer.SqlServerMonitoringApi.UseConnection(Func`2 action) +204
   Hangfire.SqlServer.SqlServerMonitoringApi.SucceededJobs(Int32 from, Int32 count) +147
   Hangfire.Dashboard.Pages.SucceededJobs.Execute() +593
   Hangfire.Dashboard.RazorPage.TransformText(String innerContent) +68
   Hangfire.Dashboard.RazorPage.TransformText() +38
   Hangfire.Dashboard.RazorPageDispatcher.Dispatch(RequestDispatcherContext context) +297
   Hangfire.Dashboard.DashboardMiddleware.Invoke(IOwinContext context) +517

@odinserj odinserj added this to the 1.3.2 milestone Jan 26, 2015
@odinserj
Copy link
Member

@oliverjanik, thank you for the detailed response! Hangfire does not expect that property names are being serialized using camel-case convention, but it looks like it was set globally in your project. I'll find all the places that expect non-camelcase data and change them in 1.3.2.

As for now, you can use workaround by using separate serializer setting for Hangfire:

var settings = new JsonSerializerSettings();
Hangfire.Common.JobHelper.SetSerializerSettings(settings);

@MichaelGG, does your exception appear constantly or it is a transient one?

@oliverjanik
Copy link
Author

@odinserj thanx, that makes a lot of sense.

@MichaelGG
Copy link

@odinserj It was transient - and I haven't been able to get it to happen again. If it does I'll be sure to capture all the SQL tables in use.

@odinserj
Copy link
Member

@MichaelGG, thank you for the quick response. If it is transient, then I know the reason – job's state was changed during the fetch – and will fix it in 1.3.2.

@odinserj odinserj mentioned this issue Jan 27, 2015
@odinserj odinserj changed the title /hangfire/succeeded exception KeyNotFoundException on /hangfire/succeeded page Jan 27, 2015
@odinserj
Copy link
Member

@oliverjanik, this bug is fixed now in just released 1.3.2. @MichaelGG, your bug is not fixed. Can you show me State table that causes your exception in a different GitHub issue?

@MichaelGG
Copy link

@odinserj I have not been able to repro it, sorry for not grabbing the tables when it happened :.

@odinserj
Copy link
Member

@MichaelGG, no worries, this is a non-critical bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants