Skip to content

Commit 9af809d

Browse files
HttpTimeoutPolicy: Fixes aggressive 500ms first-attempt timeout in HttpTimeoutPolicyControlPlaneRetriableHotPath
Raises the first-attempt timeout for HttpTimeoutPolicyControlPlaneRetriableHotPath from 500ms to 1s, aligning with the precedent set by HttpTimeoutPolicyForThinClient (#5496) and HttpTimeoutPolicyForPartitionFailover (#5484). The original 500ms value was too aggressive for .NET 10's HttpConnectionPool behavior and any environment with moderate network latency, producing spurious TaskCanceledExceptions that the SDK then retried successfully but at the cost of wasted work and noisy customer telemetry. The 5s and 65s tail attempts are preserved to keep the existing retry budget for genuinely slow control-plane operations. Fixes #5642 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0d5f925 commit 9af809d

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicyControlPlaneRetriableHotPath.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ private HttpTimeoutPolicyControlPlaneRetriableHotPath(bool shouldThrow503OnTimeo
2020
this.shouldThrow503OnTimeout = shouldThrow503OnTimeout;
2121
}
2222

23+
// The first-attempt timeout was raised from 500ms to 1s to align with HttpTimeoutPolicyForThinClient
24+
// (see issue #5642). The original 500ms value caused spurious TaskCanceledException retries on
25+
// .NET 10 due to changes in HttpConnectionPool behavior and any environment with moderate network
26+
// latency. The 5s and 65s tail attempts are preserved to keep the existing retry budget for slow
27+
// control-plane operations.
2328
private readonly IReadOnlyList<(TimeSpan requestTimeout, TimeSpan delayForNextRequest)> TimeoutsAndDelays = new List<(TimeSpan requestTimeout, TimeSpan delayForNextRequest)>()
2429
{
25-
(TimeSpan.FromSeconds(.5), TimeSpan.Zero),
30+
(TimeSpan.FromSeconds(1), TimeSpan.Zero),
2631
(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(1)),
2732
(TimeSpan.FromSeconds(65), TimeSpan.Zero),
2833
};

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/CosmosHttpClientCoreTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public async Task RetryTransientIssuesTestAsync()
7575
}},
7676
{HttpTimeoutPolicyControlPlaneRetriableHotPath.Instance, new List<TimeSpan>()
7777
{
78-
TimeSpan.FromSeconds(1),
78+
TimeSpan.FromSeconds(2),
7979
TimeSpan.FromSeconds(6),
8080
TimeSpan.FromSeconds(66)
8181
}},

0 commit comments

Comments
 (0)