Skip to content

Asycnio ClusterPipeline execute won't execute any commands when cluster_error_retry_attempts is 0 #3419

@ryan-smylski

Description

@ryan-smylski

Version: 5.0.3 (code hasn't changed in any subsequent version)

Platform: Python 3.8.6 / Almalinux 3.9 / AWS

Description: Calls to delete in asyncio RedisCluster do not execute if cluster_error_retry_attempts is 0
Last part of stack trace

    return sum(await self._execute_pipeline_by_slot(command, slots_to_keys))
  File "/usr/local/lib/python3.8/site-packages/redis/commands/cluster.py", line 341, in _execute_pipeline_by_slot
    return await pipe.execute()
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/cluster.py", line 1502, in execute
    raise exception
UnboundLocalError: local variable 'exception' referenced before assignment

The retry logic in ClusterPipeline is incorrect, in that it will execute cluster_error_retry_attempts - 1 times as range(n) creates a list that is n-1 in length. So, when the variable is 0, it will not even execute the command once.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions