Skip to content

Commit

Permalink
Add DeleteAsync failure logging (#7360)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Oct 23, 2024
1 parent 755da5d commit de98c10
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/Akka.Persistence/Snapshot/SnapshotStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Event;
using Akka.Pattern;

namespace Akka.Persistence.Snapshot
Expand All @@ -20,6 +21,7 @@ public abstract class SnapshotStore : ActorBase
private readonly TaskContinuationOptions _continuationOptions = TaskContinuationOptions.ExecuteSynchronously;
private readonly bool _publish;
private readonly CircuitBreaker _breaker;
private readonly ILoggingAdapter _log;

/// <summary>
/// Initializes a new instance of the <see cref="SnapshotStore"/> class.
Expand All @@ -42,6 +44,8 @@ protected SnapshotStore()
config.GetInt("circuit-breaker.max-failures", 10),
config.GetTimeSpan("circuit-breaker.call-timeout", TimeSpan.FromSeconds(10)),
config.GetTimeSpan("circuit-breaker.reset-timeout", TimeSpan.FromSeconds(30)));

_log = Context.GetLogger();
}

/// <inheritdoc/>
Expand Down Expand Up @@ -103,7 +107,16 @@ private bool ReceiveSnapshotStore(object message)
try
{
ReceivePluginInternal(message);
_breaker.WithCircuitBreaker(() => DeleteAsync(saveSnapshotFailure.Metadata));
_breaker.WithCircuitBreaker(() => DeleteAsync(saveSnapshotFailure.Metadata))
.ContinueWith(t =>
{
if(t.IsFaulted)
_log.Error(t.Exception, "DeleteAsync operation after SaveSnapshot failure failed.");
else if(t.IsCanceled)
_log.Error(t.Exception, t.Exception is not null
? "DeleteAsync operation after SaveSnapshot failure canceled."
: "DeleteAsync operation after SaveSnapshot failure canceled, possibly due to timing out.");
}, TaskContinuationOptions.ExecuteSynchronously);
}
finally
{
Expand Down

0 comments on commit de98c10

Please sign in to comment.