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

Optimize reads/queries to Gateway and only send SessionToken when applicable #16111

Merged

Conversation

FabianMeiswinkel
Copy link
Member

When using TransportMode==Gateway we always send the SessionToken today when the default consistency is Session even when on request level only Eventual consistency is requested. Because of the 16KB header size limitation this can make it impossible to execute queries/readFeed because the combined session token (across al pk ranges) is used. With this change the session token is only sent when appplicable - optimizing when customer opted-for lower consistency and unblocking queries with eventual consistency for accounts with large number of partitions.

@FabianMeiswinkel
Copy link
Member Author

Same issue exists in .Net btw. - will port the change to .Net after check-in as well.

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.

If the account default consistency is session, client default consistency is set to be eventual, but for an individual request consistency is set to session, we need tuning; otherwise session consistency will not be met.

By default in java v4 we don't capture session tokens for non session consistency.
we should document that if the user wants to use this per request option, the user has to enable per request session capturing on the cosmos-client-builder and we should make the method for that public.

see CosmosClientBuilder:sessionCapturingOverrideEnabled()

CosmosItemRequestOption.setConsistencyLevel() and CosmosClientBuilder:sessionCapturingOverrideEnabled() should go hand in hand.

* NOTE: If the consistency-level set on a request level here is higher than the default consistency
* level set when constructing the CosmosClient instance via CosmosClientBuilder.consistencyLevel
* session token capturing also needs to be enabled by calling
* CosmosClientBuilder:sessionCapturingOverrideEnabled(true).
Copy link
Contributor

@moderakh moderakh Oct 12, 2020

Choose a reason for hiding this comment

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

CosmosClientBuilder:sessionCapturingOverrideEnabled(true) would only be needed when you set the request consistency to Session.

It is not needed if you set the request consistency to Strong nor for Bounded-Staleness.

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.

LGTM.

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.

4 participants