MIT6.824 Lab2B TestBackup2B 分析

TestBackup2B 分析:

1.

0 1 2 3 4

All add a log and commit l1 leader 0
0: <l1,1>
1: <l1,1>
2: <l1,1>
3: <l1,1>
4: <l1,1>

2.

2,3,4 offline
0,1 add a log but not commit

0 1

0: <l1,1>, <l2,1>
1: <l1,1>, <l2,1>
2: <l1,1>
3: <l1,1>
4: <l1,1>

3.

0,1 offline
2,3,4 reconnect ,maybe leader 2 and leader's term change ,add a log l3 and commit. leader 2

2 3 4

0: <l1,1>, <l2,1>
1: <l1,1>, <l2,1>
2: <l1,1>, <l3,2>
3: <l1,1>, <l3,2>
4: <l1,1>, <l3,2>

4.

Disconnect a follower from 2,3,4, eg: 3
Then add a log l4

2 4

0: <l1,1>, <l2,1>
1: <l1,1>, <l2,1>
2: <l1,1>, <l3,2>, <l4,2>
3: <l1,1>, <l3,2>
4: <l1,1>, <l3,2>, <l4,2>

5.

All disconnect ,and reconnect 0, 1 and a follower from step 4( server 3) ,
So now server 3 should be the leader ( has last log ),then term change .maybe 3
Server convert to candidate
Then add a log l5 (server 0 was leader from step 1)

0 1 3

0: <l1,1>, <l2,1>
1: <l1,1>, <l2,1>
2: <l1,1>, <l3,2>, <l4,2>
3: <l1,1>, <l3,2>, <l5,3>
4: <l1,1>, <l3,2>, <l4,2>

Sync to server 0 and server 1
0: <l1,1>, <l3,2>, <l5,3>
1: <l1,1>, <l3,2>, <l5,3>
2: <l1,1>, <l3,2>, <l4,2>
3: <l1,1>, <l3,2>, <l5,3>
4: <l1,1>, <l3,2>, <l4,2>

6.

Then all start and add a log l6
Server should be the leader

0 1 2 3 4

0: <l1,1>, <l3,2>, <l5,3>
1: <l1,1>, <l3,2>, <l5,3>
2: <l1,1>, <l3,2>, <l4,2>
3: <l1,1>, <l3,2>, <l5,3> ,<l6,3>
4: <l1,1>, <l3,2>, <l4,2>
Then sync log to others

本篇文章由一文多發平臺ArtiPub自動發佈

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章