Skip to content

Commit de98c10

Browse files
authored
Add DeleteAsync failure logging (#7360)
1 parent 755da5d commit de98c10

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/core/Akka.Persistence/Snapshot/SnapshotStore.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System;
99
using System.Threading.Tasks;
1010
using Akka.Actor;
11+
using Akka.Event;
1112
using Akka.Pattern;
1213

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

2426
/// <summary>
2527
/// Initializes a new instance of the <see cref="SnapshotStore"/> class.
@@ -42,6 +44,8 @@ protected SnapshotStore()
4244
config.GetInt("circuit-breaker.max-failures", 10),
4345
config.GetTimeSpan("circuit-breaker.call-timeout", TimeSpan.FromSeconds(10)),
4446
config.GetTimeSpan("circuit-breaker.reset-timeout", TimeSpan.FromSeconds(30)));
47+
48+
_log = Context.GetLogger();
4549
}
4650

4751
/// <inheritdoc/>
@@ -103,7 +107,16 @@ private bool ReceiveSnapshotStore(object message)
103107
try
104108
{
105109
ReceivePluginInternal(message);
106-
_breaker.WithCircuitBreaker(() => DeleteAsync(saveSnapshotFailure.Metadata));
110+
_breaker.WithCircuitBreaker(() => DeleteAsync(saveSnapshotFailure.Metadata))
111+
.ContinueWith(t =>
112+
{
113+
if(t.IsFaulted)
114+
_log.Error(t.Exception, "DeleteAsync operation after SaveSnapshot failure failed.");
115+
else if(t.IsCanceled)
116+
_log.Error(t.Exception, t.Exception is not null
117+
? "DeleteAsync operation after SaveSnapshot failure canceled."
118+
: "DeleteAsync operation after SaveSnapshot failure canceled, possibly due to timing out.");
119+
}, TaskContinuationOptions.ExecuteSynchronously);
107120
}
108121
finally
109122
{

0 commit comments

Comments
 (0)