Skip to content

Commit 896c506

Browse files
committed
Logging WRN when TrySetException/TrySetResult fails
1 parent 3ded142 commit 896c506

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/ServiceControl.Audit/Auditing/AuditIngestor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ public async Task Ingest(List<MessageContext> contexts)
8080

8181
foreach (var context in contexts)
8282
{
83-
context.GetTaskCompletionSource().TrySetResult(true);
83+
if (!context.GetTaskCompletionSource().TrySetResult(true))
84+
{
85+
Log.Warn("TrySetResult failed");
86+
}
8487
}
8588
}
8689
catch (Exception e)

src/ServiceControl.Audit/Auditing/AuditPersister.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,10 @@ void ProcessSagaAuditMessage(MessageContext context)
229229
}
230230

231231
// releasing the failed message context early so that they can be retried outside the current batch
232-
context.GetTaskCompletionSource().TrySetException(e);
232+
if (!context.GetTaskCompletionSource().TrySetException(e))
233+
{
234+
Logger.Warn("ProcessSagaAuditMessage TrySetException failed");
235+
}
233236
}
234237
}
235238

@@ -297,7 +300,10 @@ await messageDispatcher.Value.Dispatch(new TransportOperations(messagesToEmit.To
297300
}
298301

299302
// releasing the failed message context early so that they can be retried outside the current batch
300-
context.GetTaskCompletionSource().TrySetException(e);
303+
if (!context.GetTaskCompletionSource().TrySetException(e))
304+
{
305+
Logger.Warn("ProcessAuditMessage TrySetException failed");
306+
}
301307
}
302308
}
303309

0 commit comments

Comments
 (0)