Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit 8a23dc1

Browse files
committed
always get the same proxy node if the master node is the same
1 parent b0e1e76 commit 8a23dc1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

rediscluster/pipeline.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _send_cluster_commands(self, stack, raise_on_error=True, allow_redirections=
187187

188188
# build a list of node objects based on node names we need to
189189
nodes = {}
190-
node_by_slot = {}
190+
proxy_node_by_master = {}
191191
connection_by_node = {}
192192

193193
# as we move through each command that still needs to be processed,
@@ -197,11 +197,13 @@ def _send_cluster_commands(self, stack, raise_on_error=True, allow_redirections=
197197
# command should route to.
198198
slot = self._determine_slot(*c.args)
199199

200-
if slot in node_by_slot:
201-
node = node_by_slot[slot]
200+
master_node = self.connection_pool.get_node_by_slot(slot)
201+
202+
if master_node['name'] in proxy_node_by_master:
203+
node = proxy_node_by_master[master_node['name']]
202204
else:
203205
node = self.connection_pool.get_node_by_slot(slot, self.read_from_replicas)
204-
node_by_slot[slot] = node
206+
proxy_node_by_master[master_node['name']] = node
205207

206208
# little hack to make sure the node name is populated. probably could clean this up.
207209
self.connection_pool.nodes.set_node_name(node)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name="redis-py-cluster-patched",
23-
version="2.1.0.999.5",
23+
version="2.1.0.999.6",
2424
description="Library for communicating with Redis Clusters. Built on top of redis-py lib",
2525
long_description=readme + '\n\n' + history,
2626
long_description_content_type="text/markdown",
@@ -30,7 +30,7 @@
3030
maintainer_email='Grokzen@gmail.com',
3131
packages=["rediscluster"],
3232
url='http://github.com/grokzen/redis-py-cluster',
33-
download_url="https://github.com/duke-cliff/redis-py-cluster/archive/2.1.0.999.5.tar.gz",
33+
download_url="https://github.com/duke-cliff/redis-py-cluster/archive/2.1.0.999.6.tar.gz",
3434
license='MIT',
3535
install_requires=[
3636
'redis>=3.0.0,<4.0.0'

0 commit comments

Comments
 (0)