Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request migrates the Redis session service to a new versioned key schema (v2) using unpadded URL-safe Base64 encoding to prevent key collisions, and adds identity verification checks across session operations. The review feedback suggests reverting the transaction-based delete in delete_session to a direct delete to improve performance and avoid blocking the deletion of corrupted sessions. Additionally, it recommends using exists instead of get in append_event to prevent redundant double-reading and parsing of large session JSONs.
srkyn
marked this pull request as ready for review
October 20, 2026 19:50
This was referenced Oct 29, 2026
7 of 9 tasks
Merge current upstream main while preserving the watched Redis state transaction and canonical key checks. Remove an identical test introduced by overlapping upstream changes. Refs google#7464
7 of 9 tasks
Workers sharing a Redis instance and key prefix must cut over together because legacy and v2 session and state keys are disjoint. Document the overlap hazard in both Redis guides. Refs google#7464
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #7464
Change
Redis session, user-state, and app-state keys now use distinct type tags and unpadded Base64URL identity components under a versioned
v2:namespace. With the default prefix, new keys start withadk:session:v2:. Reads and appends reject mismatched stored session identities; deletion addresses the exact v2 key. Listing also confirms each scanned key is the canonical v2 key for its stored identity, so a legacy key that matches the scan pattern is ignored. A watched transaction keeps session and state writes together when appending events.Compatibility
This is a cutover, not an automatic migration. Existing Redis keys stay untouched and are not read by the new format. The Redis README and guide now warn that workers sharing an instance and key prefix must cut over together; the README also describes expiry and careful manual cleanup. There is no legacy read fallback because ambiguous old keys could preserve the original alias. The existing same-identity append retry behavior after a concurrent deletion or expiry is unchanged.
Testing
a0f582f2, the two Redis docs passed all applicable pre-commit checks, including documentation links and codespell;git diff --checkpassed. No source code changed.5d89397c, all 49 focused Redis unit tests passed, with 95% coverage of_redis_session_service.py. The wheel and source distribution built successfully.git diff --checkpassed on that code head. The Windows pre-commit wrapper forcheck-new-py-prefixcould not invoke/bin/bash; its underlying Python check passed directly.