Skip to content

Conversation

@Praveen-Msft
Copy link
Contributor

@Praveen-Msft Praveen-Msft commented Nov 6, 2025

Pull Request Template

Description

This PR fixes:

  1. Allow QueryPlan requests to do local retries (within region), before doing cross regional retries.
  2. Removing dependency on HttpMethod based retry, Enable all GET calls without DocumentServiceRequest to retry.
  3. Enable caller (CosmosHttpClientCore) to determine when to retry safely.

Additional details on the updates in this PR:
Allow Retries in following cases:

  • When DocumentServiceRequest is null
  • If the DocumentServiceRequest's ResourceType is Address
  • If the DocumentServiceRequest is a ReadOnlyRequest (based on existing criteria).

Follow up:
Another PR will include enhancing/adjusting the defined timeouts on HttpTimeoutPolicyForPartitionFailover and potentially HttpTimeoutPolicyForThinClient

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Closing issues

To automatically close an issue: closes #5481

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!

@kundadebdatta kundadebdatta changed the title Update safe retry detection using document service request resource type and operation type [Internal] HttpTimeoutPolicy‎: Refactors Timeout Policy to Safely Retry DocumentServiceRequest Using Resource and Operation Type Nov 7, 2025
@kundadebdatta kundadebdatta marked this pull request as ready for review November 7, 2025 02:11
@kundadebdatta kundadebdatta requested a review from Copilot November 7, 2025 02:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the retry safety determination logic from using HTTP method-based checks to using DocumentServiceRequest-based checks. The primary purpose is to consolidate retry logic by moving the IsSafeToRetry decision from individual timeout policy classes to a centralized implementation in CosmosHttpClientCore that considers the request's properties.

Key changes:

  • Removed the abstract IsSafeToRetry(HttpMethod) method from HttpTimeoutPolicy and all its implementations
  • Added a new static IsSafeToRetry(DocumentServiceRequest) method in CosmosHttpClientCore that determines retry safety based on request properties
  • Updated test files to pass documentServiceRequest parameter and OperationType to support the new retry logic

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
HttpTimeoutPolicy.cs Removed abstract IsSafeToRetry(HttpMethod) method declaration
HttpTimeoutPolicyNoRetry.cs Removed IsSafeToRetry implementation
HttpTimeoutPolicyForThinClient.cs Removed IsSafeToRetry method and updated to use shouldRetry field directly
HttpTimeoutPolicyForPartitionFailover.cs Removed IsSafeToRetry implementation
HttpTimeoutPolicyDefault.cs Removed IsSafeToRetry implementation
HttpTimeoutPolicyControlPlaneRetriableHotPath.cs Removed IsSafeToRetry implementation and related check
HttpTimeoutPolicyControlPlaneRead.cs Removed IsSafeToRetry implementation
CosmosHttpClientCore.cs Added new IsSafeToRetry(DocumentServiceRequest) method, updated retry logic to use it, simplified IsOutOfRetries signature
GatewayStoreModelTest.cs Updated test to pass documentServiceRequest parameter
CosmosHttpClientCoreTests.cs Added OperationType parameter to test scenarios and updated all test calls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Praveen-Msft
Copy link
Contributor Author

@Praveen-Msft please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

kundadebdatta
kundadebdatta previously approved these changes Nov 7, 2025
Copy link
Member

@kundadebdatta kundadebdatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Now.

@kundadebdatta kundadebdatta added the auto-merge Enables automation to merge PRs label Nov 7, 2025
@kundadebdatta kundadebdatta changed the title [Internal] HttpTimeoutPolicy‎: Refactors Timeout Policy to Safely Retry DocumentServiceRequest Using Resource and Operation Type [Internal] HttpTimeoutPolicy (Phase 1)‎: Refactors Timeout Policy to Safely Retry DocumentServiceRequest Using Resource and Operation Type Nov 7, 2025
@kundadebdatta kundadebdatta changed the title [Internal] HttpTimeoutPolicy (Phase 1)‎: Refactors Timeout Policy to Safely Retry DocumentServiceRequest Using Resource and Operation Type [Internal] HttpTimeoutPolicy (Phase 1)‎: Refactors Code to Move IsSafeToRetry() Method Out of Individual Timeout Policies Nov 7, 2025
kundadebdatta
kundadebdatta previously approved these changes Nov 7, 2025
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few NITs - otherwise LGTM now. Thanks!

@kirankumarkolli
Copy link
Member

Please enhance PR description

  • Its visible impact: Is [Internal] still applicable?
  • Title: Not pure refractor but behavior change for a bug fix please call out
  • Also please call out the decisions and follow-ups as discussed

@Praveen-Msft Praveen-Msft changed the title [Internal] HttpTimeoutPolicy Improvements Phase 1: Refactors Code to Move IsSafeToRetry() Method Out of Individual Timeout Policies HttpTimeoutPolicy Improvements Phase 1: Update IsSafeToRetry() Method behavior based on the OperationType and ResourceType Nov 7, 2025
@Praveen-Msft Praveen-Msft changed the title HttpTimeoutPolicy Improvements Phase 1: Update IsSafeToRetry() Method behavior based on the OperationType and ResourceType HttpTimeoutPolicy Improvements Phase 1: Fixes IsSafeToRetry() method behavior based on the OperationType and ResourceType Nov 7, 2025
@Praveen-Msft Praveen-Msft changed the title HttpTimeoutPolicy Improvements Phase 1: Fixes IsSafeToRetry() method behavior based on the OperationType and ResourceType HttpTimeoutPolicy Improvements Phase 1: Fixes QueryPlan requests retry gaps Nov 7, 2025
Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now.

@microsoft-github-policy-service microsoft-github-policy-service bot merged commit 5951364 into master Nov 8, 2025
32 checks passed
@microsoft-github-policy-service microsoft-github-policy-service bot deleted the fix-retry-for-http-timeout-policies branch November 8, 2025 02:37
Praveen-Msft added a commit that referenced this pull request Nov 13, 2025
…y gaps (#5476)

# Pull Request Template

## Description
This PR fixes:
1. Allow QueryPlan requests to do local retries (within region), before
doing cross regional retries.
2. Removing dependency on HttpMethod based retry, Enable all `GET` calls
without `DocumentServiceRequest` to retry.
3. Enable caller (CosmosHttpClientCore) to determine when to retry
safely.

Additional details on the updates in this PR:
Allow Retries in following cases:
- When `DocumentServiceRequest` is null
- If the DocumentServiceRequest's ResourceType is Address
- If the DocumentServiceRequest is a ReadOnlyRequest (based on existing
criteria).

**Follow up**:
Another PR will include enhancing/adjusting the defined timeouts on
`HttpTimeoutPolicyForPartitionFailover` and potentially
`HttpTimeoutPolicyForThinClient`

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

## Closing issues

To automatically close an issue: closes #5481

---------

Co-authored-by: Debdatta Kunda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fundamentals] HttpTimeoutPolicy‎: Move IsSafeToRetry() Method Out of Individual Timeout Policies

5 participants