Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
e18aa95
Initial code changes to throw 503 on 429/3092.
kundadebdatta Sep 11, 2024
e44f080
Updated client retry policy. Added more tests to cover 429/3092.
kundadebdatta Sep 11, 2024
9006b5f
Code changes to update direct package version. Updating the tests.
kundadebdatta Sep 12, 2024
e7710c1
Code changes to refactor client retry policy.
kundadebdatta Sep 12, 2024
5a1b505
Minor code cleanup.
kundadebdatta Sep 12, 2024
ebf1a11
Merge branch 'master' into users/kundadebdatta/4390_cross_regional_re…
kundadebdatta Sep 12, 2024
91cc3ea
Reverting the direct version bump up change.
kundadebdatta Sep 13, 2024
b479714
Merge branch 'master' into users/kundadebdatta/4656_cross_regional_re…
kundadebdatta Sep 13, 2024
6ebb9e6
Code changes to address some of the review comments.
kundadebdatta Sep 13, 2024
47cacdf
Merge branch 'master' into users/kundadebdatta/4656_cross_regional_re…
kundadebdatta Sep 13, 2024
e6e2766
Code changes to move failover logic in client retry policy.
kundadebdatta Sep 14, 2024
9575986
Minor code clean up.
kundadebdatta Sep 14, 2024
0c5304d
Code changes to clean up some cosmetic items.
kundadebdatta Sep 15, 2024
ce3c62f
Further clean up.
kundadebdatta Sep 15, 2024
bf5e649
Merge branch 'master' into users/kundadebdatta/4656_cross_regional_re…
kundadebdatta Sep 16, 2024
973f1f1
Code changes to address review comments.
kundadebdatta Sep 17, 2024
40560cc
Minor refactor to address cosmetic update.
kundadebdatta Sep 17, 2024
a198a04
Code changes to address cosmetic review comment.
kundadebdatta Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code changes to address review comments.
  • Loading branch information
kundadebdatta committed Sep 17, 2024
commit 973f1f18f4a4d9d394d4c634756a9c63a593bb22
8 changes: 4 additions & 4 deletions Microsoft.Azure.Cosmos/src/ClientRetryPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ public async Task<ShouldRetryResult> ShouldRetryAsync(
// for write requests targeted to a multiple master account. In such case, the 429/3092 will be treated as 503. The
// reason to keep the code out of the throttling retry policy is that in the near future, the 3092 sub status code
// might not be a throttling scenario at all and the status code in that case would be different than 429.
if (this.ShouldMarkEndpointUnavailableOnSystemResourceUnavailable(
if (this.ShouldMarkEndpointUnavailableOnSystemResourceUnavailableForWrite(
clientException.StatusCode,
clientException.GetSubStatus()))
{
DefaultTrace.TraceError(
"Operation will NOT be retried. Treating SystemResourceUnavailable (429/3092) as ServiceUnavailable (503). Status code: {0}, sub status code: {1}.",
"Operation will NOT be retried on local region. Treating SystemResourceUnavailable (429/3092) as ServiceUnavailable (503). Status code: {0}, sub status code: {1}.",
StatusCodes.TooManyRequests, SubStatusCodes.SystemResourceUnavailable);

return this.TryMarkEndpointUnavailableForPkRangeAndRetryOnServiceUnavailable(
Expand Down Expand Up @@ -167,7 +167,7 @@ public async Task<ShouldRetryResult> ShouldRetryAsync(
// for write requests targeted to a multiple master account. In such case, the 429/3092 will be treated as 503. The
// reason to keep the code out of the throttling retry policy is that in the near future, the 3092 sub status code
// might not be a throttling scenario at all and the status code in that case would be different than 429.
if (this.ShouldMarkEndpointUnavailableOnSystemResourceUnavailable(
if (this.ShouldMarkEndpointUnavailableOnSystemResourceUnavailableForWrite(
cosmosResponseMessage.StatusCode,
cosmosResponseMessage?.Headers.SubStatusCode))
{
Expand Down Expand Up @@ -514,7 +514,7 @@ private ShouldRetryResult ShouldRetryOnServiceUnavailable()
/// <param name="statusCode">An instance of <see cref="HttpStatusCode"/> containing the status code.</param>
/// <param name="subStatusCode">An instance of <see cref="SubStatusCodes"/> containing the sub status code.</param>
/// <returns>A boolean flag indicating is the endpoint should be marked as unavailable.</returns>
private bool ShouldMarkEndpointUnavailableOnSystemResourceUnavailable(
private bool ShouldMarkEndpointUnavailableOnSystemResourceUnavailableForWrite(
HttpStatusCode? statusCode,
SubStatusCodes? subStatusCode)
{
Expand Down
6 changes: 4 additions & 2 deletions Microsoft.Azure.Cosmos/src/Routing/GlobalEndpointManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,10 @@ public virtual async Task RefreshLocationAsync(bool forceRefresh = false)
/// <returns>A boolean flag indicating if the available write locations are more than one.</returns>
public bool CanSupportMultipleWriteLocations(DocumentServiceRequest request)
{
return this.CanUseMultipleWriteLocations(request)
&& this.locationCache.GetAvailableWriteLocations()?.Count > 1;
return this.locationCache.CanUseMultipleWriteLocations()
&& this.locationCache.GetAvailableWriteLocations()?.Count > 1
&& (request.ResourceType == ResourceType.Document ||
(request.ResourceType == ResourceType.StoredProcedure && request.OperationType == OperationType.Execute));
}

#pragma warning disable VSTHRD100 // Avoid async void methods
Expand Down
2 changes: 1 addition & 1 deletion Microsoft.Azure.Cosmos/src/Routing/LocationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ private ReadOnlyDictionary<string, Uri> GetEndpointByLocation(IEnumerable<Accoun
return new ReadOnlyDictionary<string, Uri>(endpointsByLocation);
}

private bool CanUseMultipleWriteLocations()
internal bool CanUseMultipleWriteLocations()
{
return this.useMultipleWriteLocations && this.enableMultipleWriteLocations;
}
Expand Down