You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation provides an example: rc.keys(target_nodes=Redis.ALL_NODES). This looks acceptable as a default to me.
The KEYS command does not make sense in a cluster environment without checking at least the Redis.PRIMARIES.
Could KEYS either be moved to PRIMARIES/ALL_NODES or a note be added to the Clustering section of the documentation which explains this behaviour?
I can say, though, that generally KEYS is frowned upon in production and SCAN is often the suggested replacement.
That doesn't actually go towards your issue 🙃 but if you can be convinced to use SCAN, then in Grokzen/redis-py-cluster you can use scan_iter to transparently iterate the nodes and also the paged results of the SCAN. Seems like, yeah, it grabs all the primary nodes for that automatically.
In redis-py there's also a scan_iter... I just haven't used it first-hand to tell you that it behaves the same or not. You might have to bring your own list of target nodes.
Hello, a year later!
I believe we've removed usages of KEYS from our system and migrated from redis-py-cluster to redis~=4.4.0.
In any case, the current code in master still exhibits this issue. KEYS should be configured to run against PRIMARIES rather than DEFAULT_NODE (I am not sure whether this requires any other code to change)
redis-py/redis/cluster.py
Line 225 in e39c7ba
The documentation provides an example:
rc.keys(target_nodes=Redis.ALL_NODES)
. This looks acceptable as a default to me.The KEYS command does not make sense in a cluster environment without checking at least the Redis.PRIMARIES.
Could KEYS either be moved to PRIMARIES/ALL_NODES or a note be added to the
Clustering
section of the documentation which explains this behaviour?In redis-py-cluster, this command was given the flag
all-nodes
: https://github.com/Grokzen/redis-py-cluster/blob/8a8102a9d758d61a7ec1e2ac9050fcd34029ff3f/rediscluster/client.py#L183As such
rc.keys("...")
breaks after switching to redis-pyThe text was updated successfully, but these errors were encountered: