From 18bd74c0869d622fe8013ae935d59a329db375db Mon Sep 17 00:00:00 2001 From: Felix Clase Date: Wed, 15 Jan 2020 08:44:06 -0400 Subject: [PATCH 1/4] Avoid exception The given key 'X' was not present in the dictionary --- src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs b/src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs index f575528..f3aeec2 100644 --- a/src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs +++ b/src/main/Hangfire.Storage.SQLite/SQLiteMonitoringApi.cs @@ -152,7 +152,7 @@ private JobList EnqueuedJobs(HangfireDbContext connection, IEnum Job = job, State = sqlJob.StateName, EnqueuedAt = sqlJob.StateName == EnqueuedState.StateName - ? JobHelper.DeserializeNullableDateTime(stateData["EnqueuedAt"]) + ? JobHelper.DeserializeNullableDateTime(stateData.ContainsKey("EnqueuedAt") ? stateData["EnqueuedAt"] : string.Empty) : null }); } @@ -283,7 +283,7 @@ public JobList DeletedJobs(int from, int count) (sqlJob, job, stateData) => new DeletedJobDto { Job = job, - DeletedAt = JobHelper.DeserializeNullableDateTime(stateData["DeletedAt"]) + DeletedAt = JobHelper.DeserializeNullableDateTime(stateData.ContainsKey("DeletedAt") ? stateData["DeletedAt"] : string.Empty) })); } @@ -360,7 +360,7 @@ public JobList FailedJobs(int from, int count) ExceptionDetails = stateData["ExceptionDetails"], ExceptionMessage = stateData["ExceptionMessage"], ExceptionType = stateData["ExceptionType"], - FailedAt = JobHelper.DeserializeNullableDateTime(stateData["FailedAt"]) + FailedAt = JobHelper.DeserializeNullableDateTime(stateData.ContainsKey("FailedAt") ? stateData["FailedAt"] : string.Empty) })); } @@ -621,7 +621,7 @@ public JobList SucceededJobs(int from, int count) TotalDuration = stateData.ContainsKey("PerformanceDuration") && stateData.ContainsKey("Latency") ? (long?)long.Parse(stateData["PerformanceDuration"]) + (long?)long.Parse(stateData["Latency"]) : null, - SucceededAt = JobHelper.DeserializeNullableDateTime(stateData["SucceededAt"]) + SucceededAt = JobHelper.DeserializeNullableDateTime(stateData.ContainsKey("SucceededAt") ? stateData["SucceededAt"] : string.Empty) })); } /// From a093b59e3f4476afa4be5525985adbdfcec3b131 Mon Sep 17 00:00:00 2001 From: Felix Clase Date: Wed, 15 Jan 2020 09:11:47 -0400 Subject: [PATCH 2/4] Update nuget.. --- .../Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj b/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj index f8f8b16..67f89c0 100644 --- a/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj +++ b/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj @@ -20,10 +20,9 @@ Hangfire Storage SQLite An Alternative SQLite Storage for Hangfire - 0.2.2 - - Add AutoVacuum Options - - Add ExpireAt In JobParamter And State Models - - Fix pragma sql + 0.2.3 + - Avoid exception The given key 'X' was not present in the dictionary + - From c5a3a8200491b18da9f9330ab7b9405063858cc9 Mon Sep 17 00:00:00 2001 From: Felix Clase Date: Wed, 15 Jan 2020 09:31:38 -0400 Subject: [PATCH 3/4] SetJobState Transactions --- .../Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs b/src/main/Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs index cc54e43..da4d633 100644 --- a/src/main/Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs +++ b/src/main/Hangfire.Storage.SQLite/SQLiteWriteOnlyTransaction.cs @@ -307,6 +307,8 @@ public override void SetJobState(string jobId, IState state) { job.StateName = state.Name; + _.Database.BeginTransaction(); + _.Database.Insert(new State { JobId = iJobId, @@ -315,8 +317,9 @@ public override void SetJobState(string jobId, IState state) CreatedAt = DateTime.UtcNow, Data = JsonConvert.SerializeObject(state.SerializeData()) }); - _.Database.Update(job); + + _.Database.Commit(); } }); } From a9178822cf2d68b0f409b8f8e69a5e1b05d308bd Mon Sep 17 00:00:00 2001 From: Felix Clase Date: Wed, 15 Jan 2020 09:35:17 -0400 Subject: [PATCH 4/4] ... --- .../Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj b/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj index 67f89c0..d3a6574 100644 --- a/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj +++ b/src/main/Hangfire.Storage.SQLite/Hangfire.Storage.SQLite.csproj @@ -7,7 +7,7 @@ netstandard2.0;net45 - 0.2.2 + 0.2.3 RaisedApp RaisedApp Copyright © 2019 - Present @@ -22,7 +22,7 @@ 0.2.3 - Avoid exception The given key 'X' was not present in the dictionary - - + - Fix Difference State between State Table and Job Table