Skip to content

Commit

Permalink
Don't cancel the all users update job on exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
stanriders committed Nov 5, 2024
1 parent c251483 commit 946a845
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions backend/Mutualify/Jobs/UserAllUpdateJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,21 @@ public async Task Run(PerformContext context, CancellationToken token)
continue;
}

_isRunning = false;

throw;
_logger.LogWarning(e, "[{JobId}] All users update job error occured!", jobId);
}
catch (DbUpdateConcurrencyException) { } // don't fail on HttpRequestExceptions or DbUpdateConcurrencyException, just keep going
catch (HttpRequestException) { }
catch (OperationCanceledException ex)
{
_logger.LogWarning(ex, "[{JobId}] All users update job has been cancelled!", jobId);

_isRunning = false;

return;
}
catch (Exception ex)
{
// try to keep going
_logger.LogWarning(ex, "[{JobId}] All users update job error occured!", jobId);
}
finally
{
var endTime = DateTime.Now;
Expand All @@ -106,7 +108,7 @@ public async Task Run(PerformContext context, CancellationToken token)
var elapsed = endTime - startTime;
var timeout = elapsed.TotalSeconds < _interval ? _interval - (int) elapsed.TotalSeconds : 0;

await Task.Delay((int)(timeout * 1000), token);
await Task.Delay((int) (timeout * 1000), token);
}
}

Expand Down

0 comments on commit 946a845

Please sign in to comment.