redis icon indicating copy to clipboard operation
redis copied to clipboard

Deleting keys by pattern fails in cluster mode

Open kostapsimoulis opened this issue 9 years ago • 2 comments

REDIS_VERSION=3.2.9 Tested with Docker 3.2-alpine Expected behavior: Since both redis-cli connect to the exact same node, it should accept the DEL command

docker exec -it docker_redis-c1_1 ash -c 'redis-cli --raw -p 7002 KEYS "foo_bar*" | xargs redis-cli -c -p 7002 DEL'
(error) CROSSSLOT Keys in request don't hash to the same slot

Docker compose file

version: "3"

services:
  redis-c1:
    image: redis:3-alpine
    command: redis-server --port 7001 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host
  redis-c2:
    image: redis:3-alpine
    command: redis-server --port 7002 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host
  redis-c3:
    image: redis:3-alpine
    command: redis-server --port 7003 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host
  redis-c4:
    image: redis:3-alpine
    command: redis-server --port 7004 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host
  redis-c5:
    image: redis:3-alpine
    command: redis-server --port 7005 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host
  redis-c6:
    image: redis:3-alpine
    command: redis-server --port 7006 --bind 0.0.0.0 --protected-mode no --appendonly yes --cluster-enabled yes
    network_mode: host

kostapsimoulis avatar Jul 24 '17 20:07 kostapsimoulis

That is by design. Redis Cluster doesn't allow multi-key commands across multiple hash slots, even if they might be on the same host.

(Now that you brought it up I checked the docu and we probably should update it, as it is slightly incorrect)

badboy avatar Jul 24 '17 20:07 badboy

Is there a suggested workaround for this? How will you approach to delete keys from redis cluster that comply to specific pattern?

DamirCiganovic-Jankovic avatar Nov 05 '18 14:11 DamirCiganovic-Jankovic