Skip to content

Commit 2b75581

Browse files
committed
readd lost jobs
1 parent 5c78e8d commit 2b75581

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

MyApp.ServiceInterface/JobServices.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ public object Any(RestoreModelQueues request)
3939
var incompleteJobs = Db.Select(Db.From<PostJob>().Where(x => x.CompletedDate == null));
4040
var missingJobs = incompleteJobs.Where(x => !pendingJobIds.Contains(x.Id) && x.StartedDate == null).ToList();
4141
var startedJobs = incompleteJobs.Where(x => x.StartedDate != null).ToList();
42+
var lostJobsBefore = DateTime.UtcNow.Add(TimeSpan.FromMinutes(-5));
43+
var lostJobs = startedJobs.Where(x => x.StartedDate < lostJobsBefore && missingJobs.All(m => m.Id != x.Id)).ToList();
4244

45+
foreach (var lostJob in lostJobs)
46+
{
47+
workerQueues.Enqueue(lostJob);
48+
}
4349
foreach (var missingJob in missingJobs)
4450
{
4551
workerQueues.Enqueue(missingJob);
@@ -51,7 +57,7 @@ public object Any(RestoreModelQueues request)
5157
$"{pendingJobs.Count} pending jobs in queue",
5258
$"{incompleteJobs.Count} incomplete jobs in database",
5359
$"{startedJobs.Count} jobs being processed by workers",
54-
$"{missingJobs.Count} jobs missing and re-added to queue",
60+
$"{missingJobs.Count} missing and ${lostJobs.Count} lost jobs re-added to queue",
5561
]
5662
};
5763
}

0 commit comments

Comments
 (0)