Fix assessment job retries and error reporting

This commit is contained in:
biss committed 2026-11-14 19:03:17 +08:00
1 parent 39ddc24699
commit d32387bb67
6 files changed
+40 -10

No files matched your search

@@ -1507,6 +1507,7 @@ public sealed class ComprehensiveAssessmentsController(
outbox.ProcessingToken = null;
outbox.LeaseExpiresAt = null;
outbox.LastError = null;
outbox.ProcessingAttempts = 0;
}
}
@@ -515,15 +515,19 @@ public sealed class OperationsController(
var ids = pageItems.Select(x => x.Id).ToArray();
var attemptRows = await db.BackgroundJobOutboxMessages.AsNoTracking()
.WhereIn(ids, x => x.JobId)
.Select(x => new { x.JobKind, x.JobId, x.ProcessingAttempts })
.Select(x => new { x.JobKind, x.JobId, x.ProcessingAttempts, x.LastError })
.ToListAsync(cancellationToken);
var attempts = attemptRows.ToDictionary(
x => (x.JobKind.ToString(), x.JobId),
x => x.ProcessingAttempts);
x => new { x.ProcessingAttempts, x.LastError });
pageItems = pageItems
.Select(x => x with
{
ProcessingAttempts = attempts.GetValueOrDefault((x.Kind, x.Id))
ProcessingAttempts = attempts.GetValueOrDefault((x.Kind, x.Id))?.ProcessingAttempts ?? 0,
ErrorMessage = x.Kind == nameof(BackgroundJobKind.ComprehensiveAssessmentCalculation) &&
!string.IsNullOrWhiteSpace(attempts.GetValueOrDefault((x.Kind, x.Id))?.LastError)
? attempts[(x.Kind, x.Id)].LastError!
: x.ErrorMessage
})
.ToArray();
}
@@ -48,6 +48,7 @@ public sealed class ComprehensiveAssessmentLiveRefreshWorker(
x.CalculationStatus != ComprehensiveAssessmentCalculationStatus.Running &&
x.LiveCalculationStatus != ComprehensiveAssessmentCalculationStatus.Queued &&
x.LiveCalculationStatus != ComprehensiveAssessmentCalculationStatus.Running &&
x.LiveCalculationStatus != ComprehensiveAssessmentCalculationStatus.Failed &&
(!x.LiveCalculatedAt.HasValue || x.LiveCalculatedAt < staleBefore) &&
x.DimensionLocks.Any(d => d.Status != ComprehensiveAssessmentDimensionLockStatus.Locked))
.OrderBy(x => x.LiveCalculatedAt)
@@ -76,6 +77,7 @@ public sealed class ComprehensiveAssessmentLiveRefreshWorker(
outbox.ProcessingToken = null;
outbox.LeaseExpiresAt = null;
outbox.LastError = null;
outbox.ProcessingAttempts = 0;
}
await db.SaveChangesAsync(token);
logger.LogInformation("Queued {Count} comprehensive assessment live refresh jobs.", batches.Count);
Loaded 3 of 6 files, more files were not shown because too many files have changed in this diff. Show more