-
Notifications
You must be signed in to change notification settings - Fork 3.2k
session token data optimization #44484
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 fixes a session token optimization bug where compound session tokens (containing tokens for all partitions) were being sent for single-partition feed range queries. The fix ensures that when querying with a specific feed range, only the relevant partition's session token is sent, reducing unnecessary token data in requests.
Key Changes
- Added
set_session_token_headercall within the feed range loop to set partition-specific session tokens - Added comprehensive tests for both sync and async clients to verify single partition tokens are sent instead of compound tokens
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py | Adds call to set_session_token_header for specific partition within feed range loop |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py | Adds call to set_session_token_header for specific partition within feed range loop (async version) |
| sdk/cosmos/azure-cosmos/tests/test_session.py | Adds test to verify single partition tokens are sent for feed range queries |
| sdk/cosmos/azure-cosmos/tests/test_session_async.py | Adds async test to verify single partition tokens are sent for feed range queries |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Outdated
Show resolved
Hide resolved
tvaron3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but please run live tests
| EPK_sub_range = routing_range.Range(range_min=max(single_range.min, feed_range_epk.min), | ||
| range_max=min(single_range.max, feed_range_epk.max), | ||
| isMinInclusive=True, isMaxInclusive=False) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change log entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changelog should be updated to use 4.15.0b3 given the recent release, would also need an update on _version.py or if another PR is merged in before this then just adding this to the updated changelog.
| # Query with single feed range | ||
| list(test_container.query_items( | ||
| query="SELECT * FROM c", | ||
| feed_range=feed_ranges[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a feed_range overlaps multiple feed ranges?
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Fixed a bug where a compound session token (containing multiple partition tokens) was sent for single-partition feed range queries. Now, only the relevant partition's session token is sent when querying with a specific feed range reducing unnecessary token data in requests.