-
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
Open
dibahlfi
wants to merge
2
commits into
main
Choose a base branch
from
users/dibahl/session-token-data-optimization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+98
−0
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,6 +153,51 @@ def test_session_token_sm_for_ops(self): | |
| assert self.created_db.client_connection.last_response_headers.get(HttpHeaders.SessionToken) is not None | ||
| assert self.created_db.client_connection.last_response_headers.get(HttpHeaders.SessionToken) != batch_response_token | ||
|
|
||
| def test_session_token_compound_not_sent_for_single_partition_query(self): | ||
| """ | ||
| Verify that when querying with a feed range (single physical partition), | ||
| only that partition's session token is sent, not the entire compound token. | ||
| """ | ||
| test_container = self.created_db.create_container( | ||
| "Container query test" + str(uuid.uuid4()), | ||
| PartitionKey(path="/pk"), | ||
| offer_throughput=11000 | ||
| ) | ||
|
|
||
| try: | ||
| # Create items across multiple partition keys | ||
| for i in range(100): | ||
| test_container.create_item({ | ||
| 'id': str(uuid.uuid4()), | ||
| 'pk': f"pk_{i:04d}" | ||
| }) | ||
|
|
||
| # Get feed ranges and verify multiple exist | ||
| feed_ranges = list(test_container.read_feed_ranges()) | ||
| self.assertGreater(len(feed_ranges), 1, "Expected multiple feed ranges") | ||
|
|
||
| # Capture session token sent with feed range query | ||
| captured_session_token = {} | ||
|
|
||
| def capture_session_token(request): | ||
| captured_session_token['token'] = request.http_request.headers.get(HttpHeaders.SessionToken) | ||
|
|
||
| # Query with single feed range | ||
| list(test_container.query_items( | ||
| query="SELECT * FROM c", | ||
| feed_range=feed_ranges[0], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a |
||
| raw_request_hook=capture_session_token | ||
| )) | ||
|
|
||
| # Verify only single partition token was sent | ||
| token = captured_session_token.get('token') | ||
| self.assertIsNotNone(token, "Session token should be present") | ||
| self.assertNotIn(',', token, | ||
| f"Expected single partition token, got compound token: {token}") | ||
|
|
||
| finally: | ||
| self.created_db.delete_container(test_container) | ||
|
|
||
| def test_session_token_with_space_in_container_name(self): | ||
|
|
||
| # Session token should not be sent for control plane operations | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.