Skip to content

Commit

Permalink
Fix Missing ClusterPipeline Lock (#2190)
Browse files Browse the repository at this point in the history
* ClusterPipeline needs to initialize self._lock, otherwise a class instance will fail when calling get_redis_connection on the node

* fix bad lint picked up from master

* added change to CHANGES file

* force ci build again

* force ci build again
  • Loading branch information
grippy authored May 30, 2022
1 parent 84418d6 commit 4807908
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Remove verbose logging when initializing ClusterPubSub, ClusterPipeline or RedisCluster
* Fix broken connection writer lock-up for asyncio (#2065)
* Fix auth bug when provided with no username (#2086)
* Fix missing ClusterPipeline._lock (#2189)

* 4.1.3 (Feb 8, 2022)
* Fix flushdb and flushall (#1926)
Expand Down
5 changes: 5 additions & 0 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ def pipeline(self, transaction=None, shard_hint=None):
cluster_error_retry_attempts=self.cluster_error_retry_attempts,
read_from_replicas=self.read_from_replicas,
reinitialize_steps=self.reinitialize_steps,
lock=self._lock,
)

def lock(
Expand Down Expand Up @@ -1754,6 +1755,7 @@ def __init__(
read_from_replicas=False,
cluster_error_retry_attempts=5,
reinitialize_steps=10,
lock=None,
**kwargs,
):
""" """
Expand All @@ -1776,6 +1778,9 @@ def __init__(
kwargs.get("encoding_errors", "strict"),
kwargs.get("decode_responses", False),
)
if lock is None:
lock = threading.Lock()
self._lock = lock

def __repr__(self):
""" """
Expand Down
1 change: 1 addition & 0 deletions redis/commands/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def pipeline(self, transaction=True, shard_hint=None):
cluster_error_retry_attempts=self.client.cluster_error_retry_attempts,
read_from_replicas=self.client.read_from_replicas,
reinitialize_steps=self.client.reinitialize_steps,
lock=self.client._lock,
)

else:
Expand Down
1 change: 1 addition & 0 deletions redis/commands/timeseries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def pipeline(self, transaction=True, shard_hint=None):
cluster_error_retry_attempts=self.client.cluster_error_retry_attempts,
read_from_replicas=self.client.read_from_replicas,
reinitialize_steps=self.client.reinitialize_steps,
lock=self.client._lock,
)

else:
Expand Down

0 comments on commit 4807908

Please sign in to comment.