Skip to content

Commit

Permalink
[Internal] HttpTimeoutPolicy: Removes Data Plane Writes from being ab…
Browse files Browse the repository at this point in the history
…le to be retried (#3607)

* data plane writes no longer failover on timeout

* removed duplication of test\
  • Loading branch information
NaluTripician authored Dec 15, 2022
1 parent a34bac7 commit 6b1fa03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Microsoft.Azure.Cosmos/src/HttpClient/HttpTimeoutPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public static HttpTimeoutPolicy GetTimeoutPolicy(
return HttpTimeoutPolicyControlPlaneRetriableHotPath.Instance;
}

//Data Plane Read & Write
if (!HttpTimeoutPolicy.IsMetaData(documentServiceRequest))
//Data Plane Read
if (!HttpTimeoutPolicy.IsMetaData(documentServiceRequest) && documentServiceRequest.IsReadOnlyRequest)
{
return HttpTimeoutPolicyDefault.InstanceShouldThrow503OnTimeout;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, Cancellatio

Assert.AreEqual(3, count, "Should retry 3 times");
}

[TestMethod]
public async Task HttpTimeoutThrow503TestAsync()
{
Expand Down Expand Up @@ -307,8 +307,8 @@ async Task<HttpResponseMessage> sendFunc(HttpRequestMessage request, Cancellatio
//Data plane read
await TestScenarioAsync(HttpMethod.Get, ResourceType.Document, HttpTimeoutPolicyDefault.InstanceShouldThrow503OnTimeout, typeof(CosmosException), 3);

//Data plane write
await TestScenarioAsync(HttpMethod.Post, ResourceType.Document, HttpTimeoutPolicyDefault.InstanceShouldThrow503OnTimeout, typeof(CosmosException), 1);
//Data plane write (Should throw a 408 OperationCanceledException rather than a 503)
await TestScenarioAsync(HttpMethod.Post, ResourceType.Document, HttpTimeoutPolicyDefault.Instance, typeof(TaskCanceledException), 1);

//Meta data read
await TestScenarioAsync(HttpMethod.Get, ResourceType.Database, HttpTimeoutPolicyDefault.InstanceShouldThrow503OnTimeout, typeof(CosmosException), 3);
Expand Down

0 comments on commit 6b1fa03

Please sign in to comment.