Quick revision
The short answer
The 1,800 updates were written by the two application servers that stayed on the old primary's side of the partition. That primary kept accepting writes because it did not know it had been replaced, and when the partition healed, Sentinel made it a replica of the new primary, whose full resync replaced its whole dataset and discarded those writes. min-replicas-to-write 1 with min-replicas-max-lag 10 would have made the isolated primary refuse writes after about 10 seconds, and clients that retry NOREPLICAS errors after asking Sentinel again, idempotent consumers and a durable record of the status would have limited the loss further.
What to remember
In this answer, we traced the lost updates to the two application servers that kept writing to the isolated old primary, and saw that the resync after the partition replaced its dataset with the new primary's, discarding them. Sentinel manages roles but cannot merge histories, and the old primary could not know it had been replaced. min-replicas-to-write with min-replicas-max-lag lets the primary refuse writes on its own after a bounded time, and clients that retry after asking Sentinel, idempotent consumers and a durable record of the status keep the remaining loss harmless.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The 1,800 updates were written by the two application servers that stayed on the old primary's side of the partition. That primary kept accepting writes because it did not know it had been replaced, and when the partition healed, Sentinel made it a replica of the new primary, whose full resync replaced its whole dataset and discarded those writes. min-replicas-to-write 1 with min-replicas-max-lag 10 would have made the isolated primary refuse writes after about 10 seconds, and clients that retry NOREPLICAS errors after asking Sentinel again, idempotent consumers and a durable record of the status would have limited the loss further.
Why this question is asked
Lost data after a partition is one of the hardest incidents to explain to the business, because nothing crashed: every write got OK, and the data is simply gone. Interviewers ask about it to see whether we can trace exactly where data went in a distributed system, rather than blaming Redis in general. In this answer, we will recap how Sentinel handles a failover, replay the 40 seconds step by step, see why Sentinel cannot merge the two histories, and then go through the settings and application changes that would have bounded the loss.
1A Quick Recap of Sentinel
Sentinel is a set of separate processes, usually three or five, that watch a Redis primary and its replicas. When a majority of Sentinels cannot reach the primary for down-after-milliseconds, they agree that it is objectively down, elect a leader among themselves, and promote one replica to primary. Clients ask Sentinel which node is the primary, so after a failover they are told the new address.
The important limit is that Sentinel only manages roles. It does not copy data, compare data or merge data. Each Redis node keeps its own dataset, and whichever node is primary is the truth.
2Replaying the Partition
Before the partition, all six application servers wrote to the primary, P1. Then the network split: P1 and two application servers on one side; the Sentinels, the replicas and four application servers on the other. The Sentinels on the majority side could not reach P1, agreed it was down and promoted replica R1 to primary. The four servers asked Sentinel, learned about R1, and wrote there.
The two servers on P1's side could not reach Sentinel, so they kept the connection they had. P1 had no idea it had been replaced, so it kept accepting their writes. For about 40 seconds, the system had two primaries, each with its own history. When the network healed, Sentinel saw P1 again, still claiming to be a primary, and sent it REPLICAOF R1. P1 asked R1 for a sync; because their histories had diverged, R1 sent a full copy of its dataset, and P1 replaced its own data with it. The 1,800 updates existed only in P1's old dataset, so they were deleted.
7 messages in order. Play them, or step through them one at a time.
P1 accepted writes it could never keep, because nobody told it it had been replaced.
3Why Sentinel Cannot Save Those Writes
It is tempting to ask why Sentinel did not merge P1's writes back. The reason is that Redis has no way to merge two histories. A status key may have been changed on both sides; there is no record of which change should win, and Redis data types have no merge rules. The design choice is simple and predictable: the elected primary wins, and the other side's divergent writes are discarded.
It also could not stop P1 from accepting them. While isolated, P1 could not hear from Sentinel, so it had no way of learning that it was no longer the primary. Only P1 itself can decide to stop, based on what it can observe, and that is exactly what the next setting is for.
4The Setting That Bounds the Loss
min-replicas-to-write and min-replicas-max-lag give the primary a rule it can enforce on its own. Replicas send an acknowledgement to the primary every second. With the settings below, the primary refuses writes when fewer than one replica has acknowledged within the last 10 seconds.
So instead of 40 seconds of lost writes, we lose at most about 10 seconds' worth, a few hundred updates rather than 1,800 at this write rate. A smaller lag, such as 5 seconds, narrows it further, at the cost of rejecting writes sooner when replicas are briefly slow.
5What the Application Must Do
A refused write is only better than a lost one if the client handles it. The application should treat NOREPLICAS, and connection errors, as failures to retry, and before retrying it should ask Sentinel for the current primary instead of reusing the old connection. With Lettuce this means using a Sentinel-aware connection, which rediscovers the primary, rather than a fixed address.
Retries mean some work happens twice, so queue consumers must be idempotent: processing the same status update twice must leave the same result, for example by storing a version or an event id and ignoring anything older. Finally, for data that must not be lost, Redis should not hold the only copy. The authoritative order status belongs in the database, and the Redis copy can be rebuilt from it after an incident; a queue that must not lose items belongs in a durable broker such as Kafka or RabbitMQ with persistent messages.
| Change | Effect on this incident |
|---|---|
| min-replicas-to-write 1, max-lag 10 | P1 refuses writes after ~10 s instead of 40 s |
| Retry NOREPLICAS after asking Sentinel | refused updates reach R1 instead of failing |
| Idempotent consumers | retried or duplicated work is safe |
| Status in the database, Redis rebuilt from it | lost Redis writes can be restored |
| Durable broker for the work queue | queue items survive any Redis failover |
6Follow-up questions
What is the cost of min-replicas-to-write when a replica is down for maintenance?
If we require one replica and the only replica is taken down, or both replicas lag at the same time, the primary refuses all writes, so maintenance can become an outage. The usual answer is to run at least two replicas when requiring one, so one can be down while the other keeps acknowledging, to take replicas down one at a time, and to watch the connected_slaves and lag values in INFO replication before maintenance. Some teams temporarily relax the setting during planned work, but that reopens the loss window for that period.
Would Redis Cluster have behaved differently?
Similar in principle. A primary on the minority side of a partition stops accepting writes once cluster-node-timeout passes without reaching a majority of primaries, so the loss is bounded by that timeout. Writes it accepted before then are discarded when it rejoins as a replica.
Could we have recovered the 1,800 updates?
Only from outside Redis: from application logs, from the database if the status was also written there, or from the old primary's AOF or RDB files if they were copied before the resync replaced them. This is why keeping the authoritative status in the database matters.
7Conclusion
In this answer, we traced the lost updates to the two application servers that kept writing to the isolated old primary, and saw that the resync after the partition replaced its dataset with the new primary's, discarding them. Sentinel manages roles but cannot merge histories, and the old primary could not know it had been replaced. min-replicas-to-write with min-replicas-max-lag lets the primary refuse writes on its own after a bounded time, and clients that retry after asking Sentinel, idempotent consumers and a durable record of the status keep the remaining loss harmless.
Open with
During the partition we had two primaries. The old primary was cut off together with two application servers, and it did not know it had been replaced, so it kept answering OK to their writes.
Then, if they want more
On the other side the Sentinels promoted a replica, and the other four servers wrote there. When the network healed, Sentinel told the old primary to become a replica of the new one. Their histories had diverged, so it did a full resync and replaced its whole dataset, which deleted the 1,800 updates that only it had.
Sentinel only manages roles; it cannot merge two histories, and the isolated primary could not hear it. The setting that would have helped is min-replicas-to-write 1 with min-replicas-max-lag 10: the primary stops accepting writes about 10 seconds after it loses its replicas, so the loss is bounded by the lag instead of the whole 40 seconds.
Then the application must treat the NOREPLICAS errors as failures to retry after asking Sentinel for the current primary, and the queue consumers must be idempotent so retries are safe.
For the work queue and the status, I would keep the authoritative data in the database or a durable broker and rebuild the Redis copy from it after incidents like this.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Redis documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "About 1,800 status updates written during the partition are gone. Explain exactly where...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/40a4df1f0a/