From be014e7f44918d33fb6cb73ea4d7af9c44a227f2 Mon Sep 17 00:00:00 2001 From: meir Date: Thu, 3 Feb 2022 15:58:29 +0200 Subject: [PATCH 1/4] Fix flushdb and flushall Both commands should be broadcasted to all the shards. --- redis/cluster.py | 9 +++++++-- tests/test_cluster.py | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/redis/cluster.py b/redis/cluster.py index 546472357d..9c88befb3d 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -241,8 +241,6 @@ class RedisCluster(RedisClusterCommands): "SHUTDOWN", "KEYS", "SCAN", - "FLUSHALL", - "FLUSHDB", "DBSIZE", "BGSAVE", "SLOWLOG GET", @@ -286,6 +284,13 @@ class RedisCluster(RedisClusterCommands): ], DEFAULT_NODE, ), + list_keys_to_dict( + [ + "FLUSHALL", + "FLUSHDB", + ], + ALL_NODES, + ), list_keys_to_dict( [ "CLUSTER COUNTKEYSINSLOT", diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 90f52d4899..49e44207bd 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -2640,3 +2640,10 @@ def test_command_with_escaped_data(self, r): r.get(byte_string) response = wait_for_command(r, m, "GET {foo}bar\\\\x92", key=key) assert response["command"] == "GET {foo}bar\\\\x92" + + def test_flush(self, r): + r.set('x', '1') + r.set('z', '1') + r.flushall() + assert r.get('x') == None + assert r.get('y') == None From 649b962013ae6ecb6955f0d14f80292ed285e586 Mon Sep 17 00:00:00 2001 From: meir Date: Thu, 3 Feb 2022 16:28:35 +0200 Subject: [PATCH 2/4] Support ssl_password on cluster --- redis/cluster.py | 1 + 1 file changed, 1 insertion(+) diff --git a/redis/cluster.py b/redis/cluster.py index 9c88befb3d..7e2e56c578 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -118,6 +118,7 @@ def fix_server(*args): "ssl_certfile", "ssl_cert_reqs", "ssl_keyfile", + "ssl_password", "unix_socket_path", "username", ) From 4dd64872c731e082e63dc2fc7dfce4751f972e31 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Sun, 6 Feb 2022 09:12:27 +0200 Subject: [PATCH 3/4] linter fix --- tests/test_cluster.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 49e44207bd..ab98ed515d 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -2642,8 +2642,8 @@ def test_command_with_escaped_data(self, r): assert response["command"] == "GET {foo}bar\\\\x92" def test_flush(self, r): - r.set('x', '1') - r.set('z', '1') + r.set("x", "1") + r.set("z", "1") r.flushall() - assert r.get('x') == None - assert r.get('y') == None + assert r.get("x") is None + assert r.get("y") is None From 1aa301bf0316e4ca537c1fdd53e89e02e41ad897 Mon Sep 17 00:00:00 2001 From: dvora-h Date: Mon, 7 Feb 2022 09:33:24 +0200 Subject: [PATCH 4/4] change commands to run only on primary nodes --- redis/cluster.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redis/cluster.py b/redis/cluster.py index 7e2e56c578..b594d3084a 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -290,7 +290,7 @@ class RedisCluster(RedisClusterCommands): "FLUSHALL", "FLUSHDB", ], - ALL_NODES, + PRIMARIES, ), list_keys_to_dict( [