Search code examples
amazon-dynamodbdistributed-systemleader-electionleader

Handling writes & consistent reads until leader lease expires


The DynamoDB paper (https://www.usenix.org/system/files/atc22-elhemali.pdf) mentions that for replication they use Multi-Paxos, and leaders are assigned for a lease.

In case of leader failure,

The new leader won't serve any writes or consistent reads until the previous leader's lease expires

Let's say the leader was assigned at T1, with lease until T1 + 100.

At, T1 + 50; the replicas detect the leader is not responsive so go ahead with leader election; then how is serving the consistent reads and writes until T1 + 50 to T1 + 100?


Solution

  • From that time frame when a new leader is being elected, you are subject to either timeout exceptions or more likely InternalServerErrors which returns a 5XX to the client. Clients have built in backoff and retry which usually overcomes any leader election issues, so writes and strongly consistent reads will be eventually served, albeit with a higher latency.