Provide strong consistency in Redis Cluster

I need to load static data one time in redis in the master node and only when the synchronization is finished for all slaves I am going to be able to read. This is because we are going to have a lot reading and a few writing, and the data is not going to change for a long time.

I read from oficial documentation Redis cluster tutorial – Redis in Redis Cluster consistency guarantees.

I read also Can the WAIT command provide strong consistency in Redis? but without to get a conclusion.

If I use synchronous replication and wait command to check if the replication was successful, do I have some guarantees about consistency ?

What is the best trusted way to get consistency ? I am not worried abut availability, because I need performance and consistency.

Thank you.

If the any WAIT command fails, you’ll need to retry that write. If the WAIT command always succeeds, then your data will be consistent.

Note that WAIT does not imply synchronous replication. Replications is still asynchronous, but calling WAIT blocks until the data is acknowledged.

Also, you don’t need to call WAIT after every write. You can call WAIT periodically to ensure that your replicas are in sync.

Ok with WAIT, but what about this:

where it says:

WAIT implements synchronous replication for Redis. Synchronous replication is required but not sufficient in order to achieve strong consistency. Strong consistency is practically the sum of two things:

  1. Synchronous replication to the majority of nodes on a distributed system.
  2. A way to orchestrate change of leadership (failover basically) so that it is guaranteed that only a node preserving the full history of acknowledged operations in the previous leader can be elected.

WAIT does not provide “2”. The replication process in Redis is performed by Sentinel or Redis Cluster, and is not able to provide property 2 (since the synchronous replication in Redis is the exception not the rule, so there was no much focus on that aspect). However what Redis replication does is to attempt to promote the slave that appears to preserve the greatest amount of data . While this does not change the theoretical guarantees of Redis failover, that can still lose acknowledged writes, it means that if you use WAIT , there are more slaves having a given operation into their memory, and in turn it is a lot more likely that in the event of a failover, the operation will be retained. However while this will make a failure mode that discards the acknowledged operation hard to trigger, there always exists a failure mode with this properties.

TLDR: WAIT does not make Redis linearizable, what it does is to make sure the specified number of slaves will receive the write, that in turn makes failover more robust, but without any hard guarantee.

is It possible to disable automatic failover ? is there a way to know when master got failover state ? because in this case we prefer to check consistency or initialize master node.

There are very few distributed database systems that implement perfect consistency. To get that, you generally need a proven consistency protocol such as Raft. (See RedisRaft, for example).

Are there failure scenarios where the WAIT strategy will succeed in spite of actual data loss? Yes, certainly there are. But this is true of most database. See the Jepsen analyses for a through treatment of this: Analyses