Skip to content

Commit

Permalink
Fix flushdb and flushall (#1926)
Browse files Browse the repository at this point in the history
* 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 <c@kirshen.com>
Co-authored-by: dvora-h <dvora.heller@redis.com>
(cherry picked from commit 045d5ed)
  • Loading branch information
MeirShpilraien authored and gkorland committed Feb 8, 2022
1 parent df0f931 commit a7626ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions redis/cluster.py
Expand Up @@ -118,6 +118,7 @@ def fix_server(*args):
"ssl_certfile",
"ssl_cert_reqs",
"ssl_keyfile",
"ssl_password",
"unix_socket_path",
"username",
)
Expand Down Expand Up @@ -241,8 +242,6 @@ class RedisCluster(RedisClusterCommands):
"SHUTDOWN",
"KEYS",
"SCAN",
"FLUSHALL",
"FLUSHDB",
"DBSIZE",
"BGSAVE",
"SLOWLOG GET",
Expand Down Expand Up @@ -286,6 +285,13 @@ class RedisCluster(RedisClusterCommands):
],
DEFAULT_NODE,
),
list_keys_to_dict(
[
"FLUSHALL",
"FLUSHDB",
],
PRIMARIES,
),
list_keys_to_dict(
[
"CLUSTER COUNTKEYSINSLOT",
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cluster.py
Expand Up @@ -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

0 comments on commit a7626ae

Please sign in to comment.