Skip to content

fix: replace keys() with search indexes to prevent Redis CrossSlot errors (#25) #48

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

Merged
merged 1 commit into from
May 29, 2025

Conversation

bsbodden
Copy link
Contributor

Replace all redis.keys() pattern matching calls with queries
to prevent CROSSSLOT errors with Redis Cluster.

Changes:

  • Replace keys() usage in base.py _load_pending_writes method
  • Replace keys() usage in aio.py _aload_pending_writes method
  • Replace keys() usage in init.py get_tuple method
  • Fix checkpoint_ns sentinel value handling for RediSearch tag fields
  • Fix type attribute access in get_channel_values method
  • Add proper type annotations and handle blob data encoding

…rrors (#25)

  Fixes #25

  Replace all redis.keys() pattern matching calls with queries
  to prevent CROSSSLOT errors with Redis Cluster.

  Changes:
  - Replace keys() usage in base.py _load_pending_writes method
  - Replace keys() usage in aio.py _aload_pending_writes method
  - Replace keys() usage in __init__.py get_tuple method
  - Fix checkpoint_ns sentinel value handling for RediSearch tag fields
  - Fix type attribute access in get_channel_values method
  - Add proper type annotations and handle blob data encoding
Copy link

@Copilot Copilot AI left a 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 replaces all direct Redis keys() calls with RediSearch index queries to avoid CrossSlot errors, adjusts blob handling and type access, and adds end-to-end integration tests.

  • Switch keys()FilterQuery in sync/async pending-writes loaders
  • Mirror search-index usage in get_tuple for blobs and writes, and tighten blob/type handling
  • Add test_crossslot_integration.py for Redis Cluster scenarios

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/test_crossslot_integration.py New integration tests to validate CrossSlot fixes
langgraph/checkpoint/redis/base.py Use FilterQuery in _load_pending_writes, adjust sentinel usage
langgraph/checkpoint/redis/aio.py Async counterpart: replace keys() with index search
langgraph/checkpoint/redis/init.py Switch blob/write key lookups to index queries, fix blob deserialization

@bsbodden bsbodden removed the request for review from abrookins May 29, 2025 12:03
@bsbodden bsbodden merged commit 4095ce2 into main May 29, 2025
39 checks passed
@bsbodden bsbodden deleted the bsb/issue-25 branch May 29, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant