It takes the following steps to initialize a cluster. All the connections are bidirectional.
- Start master and slave servers,
- Master initiates connections to all the slave servers
- Master directs slaves to connect to each other; All the servers are connected with each other after the above steps
- Recover cluster state as described below
Recovering Cluster State
Recovery means reconstructing the necessary in-memory data structure from db to allow the cluster to function.
- The root chain first identifies the head of the chain by looking up the tipHash from db. However, there is no guarantee that the cluster has reached a consistent state regarding this block. But its parent is guaranteed to be consistent in the cluster. So the parent block of tipHash becomes the new head and recent blocks are loaded into memory following the hash_prev_block hash pointer.
- The root chain broadcast the recovered new head to all the shards.
- Each shard finds the latest shard block confirmed by the root blocks up to the recovered new head and use it as the new shard head. Then it recovers the shard chain from the new shard head following the prev hash pointer. Only recent blocks are loaded into memory.
- Start Slave Process:
- Start Master Process: