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

Scoping session token per partition level for gateway call and enabling session token for multi master create request #25555

Merged

Conversation

simplynaveen20
Copy link
Member

@simplynaveen20 simplynaveen20 commented Nov 19, 2021

This PR contains below fixes

  1. Write call in direct mode for multi master missing session token , could led to conflict during failover
  2. Gateway sending session token for unnecessary write calls ( only needed for batch and multi master as direct mode)
  3. All operations in gateway mode sending global session token including all partitions , which will throw error as its size could cross more than header limit .

Approach used -

  • We needed pkrange to call method SessionTokenHelper.setPartitionLocalSessionToken , which set scope session token
  • For point operation/single partition query/ feed range query we have PartitionKeyInternal already set in request , from which we are getting EPK and eventually pkrange via SessionContainer cache
  • For Cross partition query we have pkRangeId set in header "x-ms-documentdb-partitionkeyrangeid" in query pipeline from which we fetch the pkrange via SessionContainer cache

Added test cases for CRUD/Single Partition Query/ Cross Partition Query/FeedRange query/ ReadAll/ReadMany/Batch

…ng session token for multi master create request
@kirankumarkolli
Copy link
Member

kirankumarkolli commented Nov 20, 2021

One more option which might simplify the flow is to include the sessiontoken for a single partition always reads/writes (assuming SM write with session token is not an issue). This simplifies the conceptual model, implementation and validation as well.

@simplynaveen20
Copy link
Member Author

One more option which might simplify the flow is to include the sessiontoken for a single partition always reads/writes (assuming SM write with session token is not an issue). This simplifies the conceptual model, implementation and validation as well.

In write we need session token only in one scenario (consistency have to be session and its multi master), so adding extra header on other cases is redundant. Now this is inline with our existing direct mode. Also it will be overhead to test the scenarios where we are not sending session token till now

@kirankumarkolli
Copy link
Member

One more option which might simplify the flow is to include the sessiontoken for a single partition always reads/writes (assuming SM write with session token is not an issue). This simplifies the conceptual model, implementation and validation as well.

In write we need session token only in one scenario (consistency have to be session and its multi master), so adding extra header on other cases is redundant. Now this is inline with our existing direct mode. Also it will be overhead to test the scenarios where we are not sending session token till now

Testing aspect is interesting. Practically SessionNotAvailable should never happen as the writes are to the Primary always. With SM its always guaranteed. Now the only scenario that might come into the mix is container re-create and stale session token, that a different independent problem which is applicable to writes as well.

@kirankumarkolli
Copy link
Member

Pinged backend team for feedback and will revert back with details.

@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run java - [service] - ci

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@moderakh moderakh left a comment

Choose a reason for hiding this comment

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

a few minor comments on NPE. other than that LGTM.

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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 - Thanks

Copy link
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simplynaveen20
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simplynaveen20 simplynaveen20 merged commit 63fac64 into Azure:main Dec 17, 2021
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-java that referenced this pull request Oct 12, 2023
[Hub Generated] Review request for Microsoft.AzureStackHCI to add version preview/2023-09-01-preview (Azure#25555)

* Adds base for updating Microsoft.AzureStackHCI from version preview/2023-07-01-preview to version 2023-09-01

* Updates readme

* Updates API version in new specs and examples

* update 2023-09-01 from https://github.com/Azure/azure-rest-api-specs-pr/pull/14245

* add suppressions from cluster resources

* remove suppressions from cluster team as some of the files don't exist yet

* remove name redundancy in definitions, remove x-ms-client-flatten in gateway

* remove suppression GetCollectionOnlyHasValueAndNextLink

* remove x-ms-code-generation-settings from resource files since the client name is already set in the title lin in readme file according to docs: https://github.com/Azure/azure-openapi-validator/blob/main/docs/deprecated-xms-code-generation-setting.md

* pick up changes from https://github.com/Azure/azure-rest-api-specs-pr/pull/14872

* pick up changes from https://github.com/Azure/azure-rest-api-specs-pr/pull/15062

* fix routetable properties to readonly and correct name according to https://github.com/Azure/azure-rest-api-specs-pr/blob/9b0cab3710aa58519c6aa9e11f350b22e0fc3dc9/specification/network/resource-manager/Microsoft.Network/stable/2023-02-01/routeTable.json#L707

* fix property description

* updating 2023-09-01 to 2023-09-01-preview according to breaking change committee guidance

* remove 200 response from LRO delete

* add suppression as requested reviewer

---------

Co-authored-by: Patricia Huang <pathuang@pathuang-dev>
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.

6 participants