1、Dynamic Multi-RaftDongxu HuangPingCAPConsensusis the only problem in distributed system.Modern HAMaster-slave is not an option,why?masterslaveslaveslaveClientMySQL MHA+Semi-Sync?masterSlaveSlave(1)Insert A,but master crash when doing semi-sync masterSlaveSlaveRestart(2)Read A,OK;But degrade to async
2、-replicationmasterNew masterSlave(3)Master crash again.then new master is elected Read A,fail,oops.TiDB Project(Requirement)Strong consistency Scalability High availabilityTiKVTiKVTiKVTiKVRaftRaftRaftTiDBTiDBTiDB.Placement Driver(PD)Control flow:Balance/FailoverMetadata/Timestamp request Stateless S
3、QL Layer Distributed Storage LayergRPCgRPCgRPCTiDB Project OverviewToday we are focusing on this partTiKVTiKVTiKVTiKVRaftRaftRaftTiDBTiDBTiDB.Placement Driver(PD)Control flow:Balance/FailoverMetadata/Timestamp request Stateless SQL Layer Distributed Storage LayergRPCgRPCgRPCTiDB Project OverviewRepl
4、icated State MachinesAll servers execute same commands in same orderSystem makes progress as long as any majority of servers upAgreement on shared state(single system image)Recovers from server failures autonomously Minority of servers fail:no problem Majority fail:lose availability,retain strong co
5、nsistencyIMHO,there are only two RSM implementations:Multi-Paxos/RaftThe problem in Paxos(Multi Paxos)“The dirty little secret of the NSDI community isthat at most five people really,truly understandevery part of Paxos;-).”NSDI reviewerRaft saves the dayLeader electionSelect one of the servers to ac
6、t as cluster leaderDetect crashes,choose new leaderLog replicationLeader takes commands from clients,appends to its logLeader replicates its log to other servers(overwriting inconsistencies)SafetyOnly a server with an up-to-date log can become leaderUse Raft in databaseSingle RSM is NOT gonna work.Y