Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
V3 Monitoring - Improve logging when queue message processing fails (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bommarito authored Nov 26, 2018
1 parent 49ed106 commit a1a4bf4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/Ng/Jobs/MonitoringProcessorJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,31 @@ private async Task HandleQueueMessageAsync(
// We can remove the message from the queue because it was processed.
messageWasProcessed = true;
}
catch (Exception e)
catch (Exception validationFailedToRunException)
{
// Validations failed to run! Save this failed status to storage.
await SaveFailedPackageMonitoringStatusAsync(queuedContext, e, token);
// We can then remove the message from the queue because this failed status can be used to requeue the message.
messageWasProcessed = true;
try
{
// Validations failed to run! Save this failed status to storage.
await SaveFailedPackageMonitoringStatusAsync(queuedContext, validationFailedToRunException, token);
// We can then remove the message from the queue because this failed status can be used to requeue the message.
messageWasProcessed = true;
}
catch (Exception failedValidationSaveFailureException)
{
// We failed to run validations and failed to save the failed validation!
// We were not able to process this message. We need to log the exceptions so we can debug the issue.
var aggregateException = new AggregateException(
"Validations failed to run and saving unsuccessful validation failed!",
new[] { validationFailedToRunException, failedValidationSaveFailureException });

Logger.LogCritical(
NuGet.Services.Metadata.Catalog.Monitoring.LogEvents.QueueMessageFatalFailure,
aggregateException,
"Failed to process queue message");
}
}

// Note that if both validations fail and saving the failure status fail, we cannot remove the message from the queue.
// If we failed to run validations and failed to save the failed validation, we cannot remove the message from the queue.
if (messageWasProcessed)
{
await _queue.RemoveAsync(queueMessage, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ public static class LogEvents

public static EventId StatusDeserializationFailure = new EventId(903, "Status deserialization failed!");
public static EventId StatusDeserializationFatalFailure = new EventId(904, "Status deserialization failed, and was unable to parse id and version from filename!");

public static EventId QueueMessageFatalFailure = new EventId(905, "Failed to process queue message");
}
}

0 comments on commit a1a4bf4

Please sign in to comment.