$src/redis-cli --cluster call 127.0.0.1:8101 set Key1 Value1
>>> Calling set Key1 Value1
127.0.0.1:8101: OK
127.0.0.1:8103: MOVED 5291 127.0.0.1:8101
127.0.0.1:8102: MOVED 5291 127.0.0.1:8101
It succeeds in one shard but attempts writing to multiple shards.
Is it worth to introduce some command-line flags to control the numbers of shards a command can go to?
- [ ]
specificflag only sends a command to a specific shard and prints the response like below
$src/redis-cli --cluster --spcific call 127.0.0.1:8101 set Key1 Value1
>>> Calling set Key1 Value1 specifically on 127.0.0.1:8101
OK
- [ ]
mastersflag will broadcast a command only to all masters. A large cluster may have too many slaves and we don't want the response from them
$src/redis-cli --cluster --master call 127.0.0.1:8101 set Key1 Value1
>>> Calling set Key1 Value1 to all Masters
.
- [ ]
slavesflag will broadcast a command only to all slaves. For example, the read commands or replication info may go to slaves only.
$src/redis-cli --cluster --slaves call 127.0.0.1:8101 set Key1 Value1
>>> Calling set Key1 Value1 to all slaves
.
Comment From: itamarhaber
Hello @hengku
I agree that it would be useful to have the ability to differentiate between broadcasting to all, masters-only or replicas-only. As for the "specific shard" use case, I believe this is covered by:
1. Not using the --cluster call syntax and simply connecting to that shard
2. The line above, with the -c switch that causes the cli to follow cluster redirections.
@artix75 - what are your thoughts on this?
Comment From: artix75
I agree with @itamarhaber
Comment From: hengku
Thank you @itamarhaber @artix75 for addressing this enhancement.
Comment From: atlas-comstock
@itamarhaber @artix75 Could I work on this?
Comment From: artix75
@YongHaoWu You can create a PR if you want. Thank you.
Comment From: atlas-comstock
@artix75 Thanks, will work on this.
Comment From: thandayuthapani
Hi @hengku @itamarhaber @artix75 I have raised PR for this issue #6491. Please have a look. Thanks!
Comment From: huangzhw
Fixed in https://github.com/redis/redis/pull/6491