From a7626ae0fad90600f526ee1742129a3a3f348e7e Mon Sep 17 00:00:00 2001 From: "Meir Shpilraien (Spielrein)" Date: Mon, 7 Feb 2022 09:46:45 +0200 Subject: [PATCH] Fix flushdb and flushall (#1926) * Fix flushdb and flushall Both commands should be broadcasted to all the shards. * Support ssl_password on cluster * linter fix * change commands to run only on primary nodes Co-authored-by: Chayim I. Kirshen Co-authored-by: dvora-h (cherry picked from commit 045d5ed15305ccc44a0330e6f65f669998815598) --- redis/cluster.py | 10 ++++++++-- tests/test_cluster.py | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/redis/cluster.py b/redis/cluster.py index 546472357d..b594d3084a 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", ) @@ -241,8 +242,6 @@ class RedisCluster(RedisClusterCommands): "SHUTDOWN", "KEYS", "SCAN", - "FLUSHALL", - "FLUSHDB", "DBSIZE", "BGSAVE", "SLOWLOG GET", @@ -286,6 +285,13 @@ class RedisCluster(RedisClusterCommands): ], DEFAULT_NODE, ), + list_keys_to_dict( + [ + "FLUSHALL", + "FLUSHDB", + ], + PRIMARIES, + ), list_keys_to_dict( [ "CLUSTER COUNTKEYSINSLOT", diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 90f52d4899..ab98ed515d 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") is None + assert r.get("y") is None