4 ms·
seems like 2.8 brought lots of cool things to Redis users! About this specific command, I have the feeling the client needs to know bit too much about the curre
by tbarbugli 13y ago
seems like 2.8 brought lots of cool things to Redis users!
About this specific command, I have the feeling the client needs to know bit too much about the current situation (eg. how many slaves are connected) to use and interpret the outcome of WAIT.
Would be cool if the client can wait until N/2 slaves or N (where n is the amount of slaves connected to master) with knowing (or asking) for the value of N
- antirez 13y agoThat sounds interesting indeed, however the semantical implications are extremely complex, as slaves disconnect N/2+1 changes dynamically. What it is possible to do however at least in the context of Redis Cluster is to query for "CLUSTER NODES" and get the minimum number of slaves connected for a given master, and use that to auto-configure the client. For stand alone Redis instances there is no way to obtain the max number of attached slaves, only the current number unfortunately. EDIT: another possibility is that the master itself is configured with a default value that is used when the client sends, for example, -1 as number of requested replicas.
- deleted 13y ago[deleted]
- antirez 13y agoThe N/2+1 is only applicable in a system featuring strong consistency and availability as soon as the majority of processes are working. This in turn requires that failover only works if we can see the majority of the replicas, so we are sure that at least one of the replicas will have a replication offset high enough to include all the writes reaching half+1 the replicas. In this model you have a fixed number of players that is setup a-priori, and adding or removing a node requires some administration / care. In Redis instead there is no a fixed number of slaves, it is a totally dynamic concept, so it is hard to apply, when you want such a configuration you need to hard-code in your client what the N/2+1 magic number is as currently there is no way to obtain it. Otherwise you can write it into a Redis key itself to make the process more dynamic. In many other configurations, for WAIT it does not make too much sense to default to N/2+1. One can say, I've 10 replicas but I'm ok as long as the write reaches 3 replicas, as I'm confident that when the master fails one will be alive, and so forth. This will not achieve certain properties but is acceptable in many cases.