DDIA chapter 7, Replica

By | April 19, 2021
Share the joy
  •  
  •  
  •  
  •  
  •  
  •  

leader based repliaction, elasticache
replica pulls master replication log

sync, async, semi-sync(only 1 replica is sync, other replicas are async)

setup a new replica, or replica is down
1. copy snapshot
2. start sync from the log sequence number

master is down
1. replica votes a new master
2. new master has data almost same as old master
3. when old master came back, let old master be a replica

How to sync to replica?
1. statement based. INSERT/UPDATE/DELETE, but it may have nondeterministic statement, such as random(). Or where conditions. But different replica are not synced
2. WAL, consistent, low level, binary. But it’s highly relates to database product and maybe version.
3. row/record based. change data capatured

Async replica could cause data inconsistency between master and replica. In order to conquer this, there is read-after-write consistency. It enforces that replica are all updated.