fix(client-dotnet): size the retry outer budget for all attempts (mxaccessgw#197)

ExecuteSafeUnaryAsync capped the whole retry pipeline at one DefaultCallTimeout
while each attempt carried the same deadline, so a DeadlineExceeded first
attempt consumed the whole budget and no retry ever ran. The outer cap is now
MaxAttempts x DefaultCallTimeout + (MaxAttempts-1) x MaxDelay in both
MxGatewayClient and GalaxyRepositoryClient. Adds a slow-first-attempt test
(fails without the fix) and a budget unit test.
This commit is contained in:
Joseph Doherty
2026-11-09 12:02:46 -05:00
parent 20138b60cc
commit fad1c11e44
5 changed files with 118 additions and 4 deletions
@@ -518,7 +518,10 @@ public sealed class GalaxyRepositoryClient : IAsyncDisposable
CancellationToken cancellationToken)
{
using CancellationTokenSource timeout = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
timeout.CancelAfter(Options.DefaultCallTimeout);
// Outer budget covers every attempt (each carries its own DefaultCallTimeout deadline)
// plus back-off; capping it at one DefaultCallTimeout starved retries of a
// DeadlineExceeded first attempt (mxaccessgw#197).
timeout.CancelAfter(MxGatewayClientRetryPolicy.ComputeOverallBudget(Options.Retry, Options.DefaultCallTimeout));
return await _safeUnaryRetryPipeline.ExecuteAsync(
async token => await call(token).ConfigureAwait(false),