8
8
using System ;
9
9
using System . Threading . Tasks ;
10
10
using Akka . Actor ;
11
+ using Akka . Event ;
11
12
using Akka . Pattern ;
12
13
13
14
namespace Akka . Persistence . Snapshot
@@ -20,6 +21,7 @@ public abstract class SnapshotStore : ActorBase
20
21
private readonly TaskContinuationOptions _continuationOptions = TaskContinuationOptions . ExecuteSynchronously ;
21
22
private readonly bool _publish ;
22
23
private readonly CircuitBreaker _breaker ;
24
+ private readonly ILoggingAdapter _log ;
23
25
24
26
/// <summary>
25
27
/// Initializes a new instance of the <see cref="SnapshotStore"/> class.
@@ -42,6 +44,8 @@ protected SnapshotStore()
42
44
config . GetInt ( "circuit-breaker.max-failures" , 10 ) ,
43
45
config . GetTimeSpan ( "circuit-breaker.call-timeout" , TimeSpan . FromSeconds ( 10 ) ) ,
44
46
config . GetTimeSpan ( "circuit-breaker.reset-timeout" , TimeSpan . FromSeconds ( 30 ) ) ) ;
47
+
48
+ _log = Context . GetLogger ( ) ;
45
49
}
46
50
47
51
/// <inheritdoc/>
@@ -103,7 +107,16 @@ private bool ReceiveSnapshotStore(object message)
103
107
try
104
108
{
105
109
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 ) ;
107
120
}
108
121
finally
109
122
{
0 commit comments