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

Commit e6a6e69

Browse files
committed
Fix unnecessary 'MoveErrors'
If a command timed out, try a random node, only if the command is a read command. Write commands must only be used on the master node for the slot.
1 parent f0627c9 commit e6a6e69

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rediscluster/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,11 @@ def _execute_command(self, *args, **kwargs):
677677
if ttl < self.RedisClusterRequestTTL / 2:
678678
time.sleep(0.05)
679679
else:
680-
try_random_node = True
680+
# If the command is not a read command, we must use the master node for the slot
681+
# otherwise we just get a MOVE response back, sending us back to the main
682+
# node.
683+
if command in READ_COMMANDS:
684+
try_random_node = True
681685
except ClusterDownError as e:
682686
log.exception("ClusterDownError")
683687

0 commit comments

Comments
 (0)