Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cosmos] Fix retry handling for Session Not Found errors #17034

Merged
merged 5 commits into from
Aug 23, 2021

Conversation

southpolesteve
Copy link
Contributor

@southpolesteve southpolesteve commented Aug 23, 2021

In high throughput scenarios with multiple regions, replication lag can sometimes cause a session to not be available. A client will write a document to Region A, and later attempt to read it from Region B. But the session token from region A has not yet been replicated to Region B. This results in Error 404, substatus 1002: Session Not Found.

In these cases the SDK is supposed to retry the request on other regions and if still unsuccessful retry the request again with no session token establishing a new session token. This code was not working correctly. This PR fixes the logic and and adds a test that simulates an out of date session token in a single region scenario.

  1. Add session token test simulating 404/1002 condition
  2. Properly increment retryCount
  3. Instantiate retryCount to 0. Previously it was undefined. var++ for undefined == NaN
  4. Remove session token header when request is being retried

@ghost ghost added the Cosmos label Aug 23, 2021
@southpolesteve southpolesteve merged commit d630c5f into Azure:main Aug 23, 2021
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this pull request Mar 10, 2022
Dev/adburch/2022 01 01 (Azure#17034)

* Adds base for updating Microsoft.StorageCache from version stable/2021-09-01 to version 2022-01-01

* Updates readme

* Updates API version in new specs and examples

* Updates for 2022-01-01 stable version.

* Fix prettier errors.

* Add usages API

Co-authored-by: Adam Burch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants