Skip to content

Wrong number of response items from pipeline execution error on pipeline when client-side-caching is enabled #3453

Open
@iRhonin

Description

@iRhonin

Version: redis-py==5.2.0 redis==7.4.1

Platform: Python==3.8.18 Ubuntu==24.04

Description:

I am getting Wrong number of response items from pipeline execution error when client-side-caching is enabled. The error occurs when using pipeline and at least one of the keys in the pipeline is cached in client.

Steps to reproduce:

r = Redis(protocol=3, cache_config=CacheConfig())

pipe = r.pipeline()
pipe.set('foo', 5)
pipe.set('bar', 18.5)
pipe.execute()

r.get('foo')

pipe = r.pipeline()
pipe.set('foo', 5)
pipe.set('bar', 18.5)
pipe.execute()

Error:

ResponseError                             Traceback (most recent call last)
Cell In[43], line 4
      2 pipe.set('foo', 5)
      3 pipe.set('bar', 18.5)
----> 4 pipe.execute()

File ~/.pyenv/versions/3.8.18/lib/python3.8/site-packages/redis/client.py:1530, in Pipeline.execute(self, raise_on_error)
   1527     self.connection = conn
   1529 try:
-> 1530     return conn.retry.call_with_retry(
   1531         lambda: execute(conn, stack, raise_on_error),
   1532         lambda error: self._disconnect_raise_reset(conn, error),
   1533     )
   1534 finally:
   1535     self.reset()

File ~/.pyenv/versions/3.8.18/lib/python3.8/site-packages/redis/retry.py:62, in Retry.call_with_retry(self, do, fail)
     60 while True:
     61     try:
---> 62         return do()
     63     except self._supported_errors as error:
     64         failures += 1

File ~/.pyenv/versions/3.8.18/lib/python3.8/site-packages/redis/client.py:1531, in Pipeline.execute.<locals>.<lambda>()
   1527     self.connection = conn
   1529 try:
   1530     return conn.retry.call_with_retry(
-> 1531         lambda: execute(conn, stack, raise_on_error),
   1532         lambda error: self._disconnect_raise_reset(conn, error),
   1533     )
   1534 finally:
   1535     self.reset()

File ~/.pyenv/versions/3.8.18/lib/python3.8/site-packages/redis/client.py:1410, in Pipeline._execute_transaction(self, connection, commands, raise_on_error)
   1408 if len(response) != len(commands):
   1409     self.connection.disconnect()
-> 1410     raise ResponseError(
   1411         "Wrong number of response items from pipeline execution"
   1412     )
   1414 # find any errors in the response and raise if necessary
   1415 if raise_on_error:

ResponseError: Wrong number of response items from pipeline execution

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions