Skip to content

fix: allow EVALSHA in ClusterPipeline (#2914) - #4206

Open
ahmed5145 wants to merge 4 commits into
redis:masterfrom
ahmed5145:fix/2914-evalsha-cluster-pipeline
Open

fix: allow EVALSHA in ClusterPipeline (#2914)#4206
ahmed5145 wants to merge 4 commits into
redis:masterfrom
ahmed5145:fix/2914-evalsha-cluster-pipeline

Conversation

@ahmed5145

@ahmed5145 ahmed5145 commented Jul 23, 2026

Copy link
Copy Markdown

Description of change

Fixes #2914

EVALSHA was listed in PIPELINE_BLOCKED_COMMANDS, so ClusterPipeline.evalsha() always raised even though RedisCluster.determine_slot() already routes EVAL/EVALSHA by keys (including the 0-key random-slot case).

This removes EVALSHA from the blocked list so cluster pipelines can queue EVALSHA like other keyed commands. Callers must still:

  • load the script on the target node(s) first (e.g. cluster SCRIPT LOAD, which loads on all primaries)
  • keep all script keys on the same hash slot

Also updates docs/lua_scripting.rst and adds regression coverage:

  • mock tests that EVALSHA is no longer blocked and can be queued on ClusterPipeline
  • a cluster integration test (test_evalsha_in_pipeline) for CI with a live cluster

Pull Request check-list

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

Note

Medium Risk
Changes cluster pipeline command routing and transactional slot logic for EVAL/EVALSHA; risk is moderate but bounded by extensive tests and narrow scope (EVALSHA only, not full scripting on pipelines).

Overview
Enables EVALSHA on cluster pipelines by removing it from PIPELINE_BLOCKED_COMMANDS, so queued scripts route like other keyed commands instead of raising immediately.

Pipeline routing treats EVAL/EVALSHA without calling COMMAND GETKEYS when numkeys is 0 (avoids Redis <7 breakage). Transactional pipelines get _resolve_transaction_slot: zero-key scripts reuse an existing transaction slot or pick one at random; keyed commands can retarget away from a slot chosen only by prior zero-key scripts.

Docs in lua_scripting.rst describe cluster pipeline EVALSHA behavior and limits (EVAL, load_scripts, etc. still unsupported on cluster pipelines). Sync/async unit and integration tests cover blocking removal, zero-key execute, and transaction slot reuse.

Reviewed by Cursor Bugbot for commit 649a36b. Bugbot is set up for automated code reviews on this repo. Configure here.

Remove EVALSHA from PIPELINE_BLOCKED_COMMANDS so scripts can be pipelined in cluster mode when keys map to one slot. Slot routing already existed in determine_slot(); update docs and add regression coverage.
Comment thread tests/test_cluster.py Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bbd5d830f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread tests/test_cluster.py
Comment thread redis/cluster.py Outdated
Comment thread tests/test_cluster.py
@ahmed5145
ahmed5145 requested a review from Sanjays2402 July 23, 2026 21:08
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.

Calling pipelined function evalsha is blocked when running redis in cluster mode

2 participants