-
Notifications
You must be signed in to change notification settings - Fork 5
/
Lecture 07 Fault Tolerance Raft (2).srt
4699 lines (3911 loc) · 136 KB
/
Lecture 07 Fault Tolerance Raft (2).srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:01,000 --> 00:00:13,400
假设三台服务器的日志如下所示,其中数字
let's imagine three servers with logs
that looked like this where the numbers
2
00:00:13,400 --> 00:00:17,060
我正在写的是该日志条目中命令的术语号,因此我们
I'm writing are the term numbers of the
command that's in that log entry so we
3
00:00:17,060 --> 00:00:20,779
不在乎实际的命令是什么,然后我得到一个数字日志
don't really care what the actual
commands are then I got a number the log
4
00:00:20,779 --> 00:00:38,840
插槽,因此,我们假设下一个学期大概是第六学期
slots and so let's imagine that the
presumably the the next term is term six
5
00:00:38,840 --> 00:00:42,500
尽管您实际上无法从董事会上的证据中看出这一点
although you can't actually tell that
from looking the evidence on the board
6
00:00:42,500 --> 00:00:47,480
但必须至少为六个或更多,让我们想象一下选择了服务器s3
but it must be at least six or greater
let's imagine that server s3 is chosen
7
00:00:47,480 --> 00:00:56,120
作为第六学期的领导者,并且在s3的某个时刻,新领导者会想要
as the leader for term six and at some
point s3 the new leader is going to want
8
00:00:56,120 --> 00:01:00,110
发送一个新的日志条目,所以我们假设它要发送第一个日志条目
to send out a new log entry so let's
suppose it wants to send out its first
9
00:01:00,110 --> 00:01:04,459
每学期六个条目的日志条目,因此我们在考虑附加条目
log entry per term six so we're sort of
thinking about the append entries our
10
00:01:04,459 --> 00:01:11,299
负责人将要发送的PC携带第一学期的日志条目
PCs that the leader is going to send out
to carry the first log entry for term
11
00:01:11,299 --> 00:01:16,459
六个确实应该位于插槽13中,图2中的规则说
six really should be under slot thirteen
the rules in Figure two say that an
12
00:01:16,459 --> 00:01:22,099
附加条目实际上是-以及客户端发送的命令
append entries are bc actually as - as
well as the command that the client sent
13
00:01:22,099 --> 00:01:25,039
进入领导者,我们要在所有
in to the leader that we want to
replicate on the logs of all the
14
00:01:25,039 --> 00:01:33,279
追随者那里有此追加条目RPC也包含此以前的日志
followers there's this append entries
RPC also contains this previous log
15
00:01:33,279 --> 00:01:44,270
索引字段和上一个对数术语字段,以及当我们发送结束时
index field and a previous log term
field and when we're sending out an end
16
00:01:44,270 --> 00:01:48,859
在这是我们领导应该输入的第一个条目的地方输入条目
pend entries for where this is the first
entry we're leaders supposed to put
17
00:01:48,859 --> 00:01:54,679
有关前一个插槽的信息,发送新信息之前的插槽
information about the previous slot the
slot before the new information sending
18
00:01:54,679 --> 00:02:04,029
因此,在这种情况下,上一个条目的对数索引为12,而
out so in this case the log index of the
previous entry is 12 and the term of the
19
00:02:04,029 --> 00:02:10,758
领导者日志中用于上一个条目的命令是通过发送的
command in the leaders log for the
previous entry is by so sends out this
20
00:02:10,758 --> 00:02:16,409
向追随者和追随者接受信息之前,
information to the followers
and the followers before they accept a
21
00:02:16,409 --> 00:02:19,890
upend条目应该检查您是否知道他们已经收到
upend entries are supposed to check you
know they know they've received an
22
00:02:19,890 --> 00:02:26,849
追加从此处开始的一些日志条目的条目以及它们的第一件事
append entries that for some log entries
that start here and the first thing they
23
00:02:26,849 --> 00:02:30,930
要做的是检查接收者是否之前有过追踪者
do is check that there are previous the
receiving followers check that their
24
00:02:30,930 --> 00:02:36,120
前一个日志条目与领导者所遵循的先前信息相匹配
previous log entry matches the previous
information that follow that the leader
25
00:02:36,120 --> 00:02:42,360
发送出去,因此对于服务器来说,它当然与服务器不匹配,因此没有条目
sent out so for a server to of course it
doesn't match the server to has a entry
26
00:02:42,360 --> 00:02:46,799
好的,但这是从学期开始的条目,而不是从第五回合开始的条目,因此
here all right but it's an entry from
term for not from turn five and so the
27
00:02:46,799 --> 00:02:51,060
服务器二人将拒绝此追加条目并发送错误回复
server twos going to reject this append
entries and sort of send a false reply
28
00:02:51,060 --> 00:02:56,700
后面的领导者和服务器甚至都没有东西,所以服务器
back leader and server one doesn't even
have anything here so server ones gonna
29
00:02:56,700 --> 00:03:03,480
还拒绝领导者中的追加条目,到目前为止,
also reject the append entries in the
leader and so so far so good right the
30
00:03:03,480 --> 00:03:08,220
在这一点上已经避免的可怕的事情是你知道
terrible thing that that has been
averted at this point is you know the
31
00:03:08,220 --> 00:03:12,030
我们绝对不希望看到的坏事是服务器实际上卡住了
bad thing we absolutely don't want to
see is that server to actually stuck the
32
00:03:12,030 --> 00:03:20,280
这里的新博客条目将本质上破坏归纳证明
new blog entry in here which would break
sort of inductive proofs essentially
33
00:03:20,280 --> 00:03:27,359
方案图所依赖并隐藏了服务器两个实际
that the figure to scheme relies on and
hide the fact that server two actually
34
00:03:27,359 --> 00:03:30,299
具有不同的日志,因此与其接受日志输入服务器这两个项目不同,
had a different log so instead of
accepting log entry server two projects
35
00:03:30,299 --> 00:03:36,150
领导者看到的这个RPC是两次拒绝,领导者正在维护
this RPC the leader sees is two
rejections and leader is maintaining
36
00:03:36,150 --> 00:03:45,199
下一个索引字段用于每个关注者,因此它具有下一个索引
this next index field one for each
follower so it has a next index for
37
00:03:45,199 --> 00:03:54,660
服务器二和领导者有一个服务器的下一个索引大概是如果
server two and the leader has a next
index for server one presumably if the
38
00:03:54,660 --> 00:03:58,430
如果服务器发送有关以下内容的信息,则应该在此之前说过:
should have said this before if the
server sending out information about
39
00:03:58,430 --> 00:04:03,870
这里的插槽13必须表示服务器的下一个索引是针对两个
slot thirteen here that must mean that
the server's next index is for both of
40
00:04:03,870 --> 00:04:11,099
这些其他服务器最初是13台,
these other servers this started out as
thirteen and that would be the case at
41
00:04:11,099 --> 00:04:14,940
服务器,如果这个领导者刚刚重启,因为图两个规则
the server if this leader had just
restarted because the figure two rules
42
00:04:14,940 --> 00:04:21,238
说下一个索引从新领导者日志的末尾开始,所以在
say that next index starts out at the
end of the new leaders log and so in
43
00:04:21,238 --> 00:04:25,980
应对领导者应该减少其下一个误差的错误
response to errors the leaders supposed
to decrement its next in
44
00:04:25,980 --> 00:04:34,710
偷,所以这样做都是因为两个人都从Boat deca先生那里得到了错误。加尔文重新发送
steal so it does that for both got
errors from boat deca mr. Calvin resends
45
00:04:34,710 --> 00:04:39,450
这次服务器将发送带有前一个的追加条目
and this time the server is going to
send out append entries with previous
46
00:04:39,450 --> 00:04:47,430
对数索引等于11,上一个对数项等于3,
log index equals 11
and previous log term equals 3 and this
47
00:04:47,430 --> 00:04:53,250
新的追加条目具有不同的先前日志索引,但是
new append entries has it has a
different previous log index but it's
48
00:04:53,250 --> 00:04:58,140
这次服务器将要发送的日志条目中的内容
the content in the log entries that the
server is going to send out this time
49
00:04:58,140 --> 00:05:03,420
包括您知道之后的新先前日志索引的所有条目
include you know all the entries after
that the new previous log index is
50
00:05:03,420 --> 00:05:10,710
发送出去,因此服务器2现在在其中查找先前的日志索引11,并且看到
sending out so server 2 now the previous
log index 11 it looks there and it sees
51
00:05:10,710 --> 00:05:15,510
呵呵,您知道术语3与读者发送给我的术语相同,因此服务器2是
a ha you know the term is 3 same as what
the reader is sending me so server 2 is
52
00:05:15,510 --> 00:05:20,520
实际上将接受此追加条目,图2规则说哦,如果您
actually going to accept this append
entries and figure 2 rules say oh if you
53
00:05:20,520 --> 00:05:24,030
接受一个吊坠,我们应该删除您日志中的所有内容,
accept a pendent we supposed to delete
everything in your log after where the
54
00:05:24,030 --> 00:05:28,340
追加条目开始并将其替换为追加条目中的所有内容,因此
append entry starts and replace it with
whatever's in the append entries so
55
00:05:28,340 --> 00:05:32,360
服务器调整现在就可以做到
server tune is going to do that now it's
56
00:05:32,810 --> 00:05:38,580
他刚去5 6服务器1仍然有问题,因为它在插槽11上什么都没有
he just went to 5 6 server 1 still has a
problem cuz it has nothing at slot 11
57
00:05:38,580 --> 00:05:47,730
中间将返回另一个错误,服务器现在将备份其服务器1
middle would return another error the
server will now backup its server 1 next
58
00:05:47,730 --> 00:05:54,330
index 2 11它将从上一个索引开始发送日志
index 2 11 it'll send out its log
starting here with the previous index
59
00:05:54,330 --> 00:05:58,250
和术语,现在指的是该插槽和该服务器实际可接受的服务器1
and term referring now to this slot and
this one's actually acceptable server 1
60
00:05:58,250 --> 00:06:03,120
它会采用它将接受新的日志条目并发送肯定的响应
it'll adopt it'll accept the new log
entries and send a positive response
61
00:06:03,120 --> 00:06:06,740
回到服务器,现在他们都
back to the server and now they're all
62
00:06:07,670 --> 00:06:13,880
现在他们都被赶上了
now they're all caught up and the
63
00:06:14,720 --> 00:06:21,420
大概服务器也在看到跟随者接受并追加时
presumably the server also when it sees
that followers accepted and append
64
00:06:21,420 --> 00:06:24,360
具有一定数量的日志条目的条目实际上会在下一个递增
entries that had a certain number of log
entries it actually increments this next
65
00:06:24,360 --> 00:06:31,020
索引可能是14 4好,所以所有这些备份的最终结果是
index could be 14 4 alright so the net
effect of all this backing up is that
66
00:06:31,020 --> 00:06:36,770
服务器已使用备份机制来检测
the server has used a backup mechanism
to detect the point at which the
67
00:06:36,770 --> 00:06:39,760
关注者日志开始与此相等
followers logs
started to be equal to this
68
00:06:39,760 --> 00:06:43,900
服务器,然后从该点开始发送每个关注者
servers and then sent each of the
followers starting from that point that
69
00:06:43,900 --> 00:06:49,810
最后的那一点之后,服务器日志的完整剩余部分
a complete remainder of the server's log
after that last point at which they were
70
00:06:49,810 --> 00:07:01,890
平等对待任何问题
equal any questions all right
71
00:07:01,920 --> 00:07:07,990
只是要重复我们之前的讨论,我们可能会再有一个
just to repeat discussion we've had
before and we'll probably have again you
72
00:07:07,990 --> 00:07:11,740
请注意,我们在此处删除了一些博客条目,这些条目现在su删除了我
notice that we erased some blog entries
here which are now su erase that I
73
00:07:11,740 --> 00:07:18,570
忘了他们是4和5,所以实际上有一些很好的东西
forget what they were 4 & 5 so there
were some well actually that was mostly
74
00:07:18,570 --> 00:07:24,760
记住,我们在这里删除了此日志条目,这对于um server来说是这样-
remember we erased this log entry here
this used to say for um server - the
75
00:07:24,760 --> 00:07:29,440
问题是为什么系统可以忽略此客户端命令是可以的
question is why was it ok for the system
to forget about this client command
76
00:07:29,440 --> 00:07:33,370
正确,我们擦除的这件事对应于现在的一些客户端命令
right this thing we erased corresponds
to some client command which are now
77
00:07:33,370 --> 00:07:42,790
扔掉我昨天谈到这个是什么理由是的
throwing away I talked about this
yesterday what's the rationale here yeah
78
00:07:42,790 --> 00:07:46,720
因此它不是大多数服务器,因此无论以前的领导者是什么
so it's not a majority of the servers
and therefore whatever previous leader
79
00:07:46,720 --> 00:07:51,310
是谁发出来的,得到了大多数人的肯定
it was who sent this out couldn't have
gotten acknowledgments from a majority
80
00:07:51,310 --> 00:07:55,240
的服务器,因此以前的领导者无法确定它是
of servers therefore that previous
leader couldn't have decided it was
81
00:07:55,240 --> 00:07:58,930
提交的文件无法执行并将其应用于应用程序状态
committed couldn't have executed it and
applied it to the application state
82
00:07:58,930 --> 00:08:03,580
永远不可能向客户发送肯定的答复,所以这不是
could never have sent a positive reply
back to the client so because this isn't
83
00:08:03,580 --> 00:08:07,060
完成了大多数服务器,我们知道发送邮件的客户端没有理由
done a majority of servers we know that
the client who send in and has no reason
84
00:08:07,060 --> 00:08:10,240
相信它的执行不可能得到答复,因为其中一项规则
to believe it was executed couldn't have
gotten a reply because one of the rules
85
00:08:10,240 --> 00:08:15,070
是服务器仅通过领导者发送,而是仅在其之后发送答复给客户端
is the server only sends over the leader
only sends a reply to a client after it
86
00:08:15,070 --> 00:08:20,380
提交并执行,因此客户没有理由相信它甚至
commits and executes so the client had
no reason to believe it was even
87
00:08:20,380 --> 00:08:24,730
然后由任何服务器接收,然后根据图的规则基本上说
received by any server and then and the
rules of figure to basically say the
88
00:08:24,730 --> 00:08:27,880
客户,如果他在一段时间后仍未收到任何响应,则应重新发送请求
client if he gets no response after a
while it supposed to resend the request
89
00:08:27,880 --> 00:08:33,700
因此,我们知道这是什么请求,它都被抛弃了,我们从未执行过
so we know whatever request this was it
threw away we've never executed never
90
00:08:33,700 --> 00:08:41,160
已包含在任何州中,客户将逐个重发
91
00:08:58,440 --> 00:09:08,290
好吧,它总是删除关注者日志的后缀,我的意思是最后排序
well it's always deleting suffix of the
followers log I mean in the end the sort
92
00:09:08,290 --> 00:09:13,840
后备答案的答案是,领导者拥有完整的日志,因此其所有
of backup answer to this is that the
leader has a complete log so all its
93
00:09:13,840 --> 00:09:19,270
失败,它只会向我们发送完整的日志给关注者,实际上,如果您知道
fails it can just send us complete log
to the follower and indeed if you know
94
00:09:19,270 --> 00:09:22,390
如果您刚刚启动了系统,即使在
if you've just started up the system and
something very strange happened even at
95
00:09:22,390 --> 00:09:26,140
一开始,您可能最终会知道,也许在某些情况下
the very beginning then you may end up
actually you know maybe in some of the
96
00:09:26,140 --> 00:09:31,330
测试第二个实验,您可能会备份到第一个条目,然后再备份
tests for lab two you may end up backing
up to the very first entry and then
97
00:09:31,330 --> 00:09:34,180
让领导者本质上发送整个日志,但是因为领导者拥有
having the leader essentially send the
whole log but because the leader has
98
00:09:34,180 --> 00:09:37,330
这整个法律,我们知道它可能会得到所有的信息
this whole law we know it could sort of
it's got all the information that's
99
00:09:37,330 --> 00:09:42,570
需要感觉每个人的日志,如果需要
required to feel everybody's logs if it
needs to
100
00:09:49,260 --> 00:09:57,850
好的,所以在此示例中,我想现在将其删除了,我们选择s3为
okay all right so in this example which
I guess are now erased we elected s3 as
101
00:09:57,850 --> 00:10:04,870
领导者,问题是我们可以知道我们可以允许谁吗
the leader and the question is could we
you know who can we who are we allowed
102
00:10:04,870 --> 00:10:10,840
选出这个领导者很酷,如果您阅读了
to elect this leader right cool
you know that all right if you read the
103
00:10:10,840 --> 00:10:15,670
纸,你知道答案不只是任何人,事实证明,这对很多人都非常重要
paper you know the answer is not just
anyone it turns out it matters a lot for
104
00:10:15,670 --> 00:10:19,900
正确性我们不允许任何人使用的系统的正确性
the correctness the correctness of the
system that we don't allow just anyone
105
00:10:19,900 --> 00:10:24,610
成为领导者,例如计时器关闭的第一个节点可能在
to be the leader like for example the
first node whose timer goes off may in
106
00:10:24,610 --> 00:10:29,800
事实上不是一个可以接受的领袖,所以事实证明筏有一些规则,
fact not be an acceptable leader and so
it turns out raft has some rules that
107
00:10:29,800 --> 00:10:35,440
适用于哦,是的,您可以成为领导者,也可以不成为领导者,以了解原因
applies about oh yes you can be leader
or you can't be leader and to see why
108
00:10:35,440 --> 00:10:43,090
这是真的,让我们提出一个可能是木筏的稻草人建议
this is true let's sort of set up a
straw man proposal that maybe raft
109
00:10:43,090 --> 00:10:49,210
应该接受应该使用日志最长的服务器作为领导者
should accept should use the server with
the longest log as the leader right you
110
00:10:49,210 --> 00:10:52,420
知道一些可能是真实的替代宇宙,实际上在
know some alternate universe that could
be true and it is actually true in
111
00:10:52,420 --> 00:10:57,340
设计不同的系统只是不在筏子里,所以我们的问题是
systems with different designs just not
in raft so the question we're
112
00:10:57,340 --> 00:11:09,910
调查是为什么不使用宫颈最长的法律作为领导,这
investigating is why not use the
cervical longest law as leader and this
113
00:11:09,910 --> 00:11:16,090
将涉及更改筏中的投票规则,只有选民投票支持
would involve changing the voting rules
in raft have a voters only vote for
114
00:11:16,090 --> 00:11:21,610
较长日志的节点可以正常运行,因此该示例将是
nodes that have longer logs all right so
the example that's going to be
115
00:11:21,610 --> 00:11:25,900
方便显示为什么这是一个坏主意,让我们假设我们有三个
convenient for showing why this is a bad
idea so let's imagine we have three
116
00:11:25,900 --> 00:11:34,360
再次服务器,现在日志集设置为服务器Wan,其中有条款条目
servers again and now the log set setups
are server Wan has entries for terms
117
00:11:34,360 --> 00:11:41,950
五六和七服务器二四五和八,服务器三也四
five six and seven server two four five
and eight and server three also four
118
00:11:41,950 --> 00:11:50,020
五和八,这是当然要避免花费时间的第一个问题
five and eight that's the first question
of course to avoid spending our time
119
00:11:50,020 --> 00:11:54,520
彻底胡说八道是要确保说服
scratching our heads about utter
nonsense is to make sure that convince
120
00:11:54,520 --> 00:11:58,060
我们自己认为这种配置实际上可能会出现,因为如果不能
ourselves that this configuration could
actually arise because if it couldn't
121
00:11:58,060 --> 00:12:01,390
可能出现然后可能是浪费时间来弄清楚
possibly arise then
may be a waste of time to figure out
122
00:12:01,390 --> 00:12:07,630
如果确实发生了会发生什么,所以任何人都想提出一系列
what would happen if it did arise so
anybody wanna propose a sequence of
123
00:12:07,630 --> 00:12:17,140
可能发生这组日志的事件
events whereby this set of logs could
have arisen how about an argument that
124
00:12:17,140 --> 00:12:31,650
不可能出现哦,是的,好吧,也许我们会在某个时候备份
it couldn't have arisen oh yeah okay so
well maybe we'll back up sometime
125
00:12:31,800 --> 00:12:37,150
好的,这样一台服务器就赢得了胜利,这是期限
all right so server one wins is wins the
election at this point and it's in term
126
00:12:37,150 --> 00:12:44,020
六个发出,是的,它收到一个客户请求,发出第一个追加
six sends out yeah it receives a client
request sends out the first append
127
00:12:44,020 --> 00:12:56,160
条目,然后就可以了,实际上一切都很好,到目前为止,没有错
entries and then that's fine actually
everything's fine so far nothing's wrong
128
00:12:56,790 --> 00:13:01,960
好吧,所有这些事情的好选择就是它崩溃了,否则
all right well a good bet for all these
things is then it crashes right or it
129
00:13:01,960 --> 00:13:06,790
在第六学期收到客户请求,将客户请求附加到其
receives the client requests in term six
it appends the client requests to its
130
00:13:06,790 --> 00:13:10,270
自己的日志,它首先会做,并且即将发送笔记录,但是它
own log which it does first and it's
about to send out a pen entries but it
131
00:13:10,270 --> 00:13:14,770
崩溃是的,它没有发送任何笔输入,然后您知道我们需要
crashes yes it didn't send out any pen
entries and then you know we need then
132
00:13:14,770 --> 00:13:19,360
它崩溃并很快重新启动,有一个新的选举和天哪服务器
it crashes and restarts very quickly
there's a new election and gosh server
133
00:13:19,360 --> 00:13:24,460
在第七届选举中再次当选一位新领导人。
one is elected again as the as the new
leader it receives in term seven and
134
00:13:24,460 --> 00:13:33,220
收到客户端请求,将其追加到其日志中,然后崩溃,然后
receives a client request appends it to
its log and then it crashes right and
135
00:13:33,220 --> 00:13:37,360
然后在发生崩溃之后,我们进行了一次新的选举,也许服务器2被选举了
then after after a crashes we have a new
election maybe server 2 gets elected
136
00:13:37,360 --> 00:13:45,970
这次服务器1可能现在已关闭,因此如果服务器2在
this time maybe server 1 is down now so
off the table if server 2 is elected at
137
00:13:45,970 --> 00:13:51,339
在这一点上,假设服务器1仍然死了,什么是服务器,什么是服务器2
this point suppose server 1 is still
dead what term is server what server two
138
00:13:51,339 --> 00:13:53,550
场地
venues
139
00:13:56,420 --> 00:14:00,710
是的,八分是正确的答案,所以为什么八而不记得这个,你知道
yeah eights the right answer so why
eight and not remember this you know
140
00:14:00,710 --> 00:14:04,570
现在不见了,为什么是八个而不是六个
this is now gone why eight and not six
141
00:14:07,240 --> 00:14:11,270
绝对正确,因此不要写在板上,而是为了服务器一
that's absolutely right so not written
on the board but in order for server one
142
00:14:11,270 --> 00:14:14,150
要在这里当选,必须获得多数节点的投票
to have been elected here it must have
votes from majority of nodes which
143
00:14:14,150 --> 00:14:21,100
如果您查看投票请求,请至少包含服务器对服务器3个中的一个
include at least one of server-to-server
three if you look at the vote request
144
00:14:21,100 --> 00:14:25,640
代码和图二,如果您投票赞成某人,那您应该
code and figure two if you vote for
somebody you're you're supposed to
145
00:14:25,640 --> 00:14:32,900
在长期存储中记录该术语,这意味着服务器2或
record the term in persistent storage
and that means that either server 2 or
146
00:14:32,900 --> 00:14:38,030
服务器3在第六学期和事实上第七学期都是新的,因此什么时候
server 3 are both new about term six and
in fact term seven and therefore when
147
00:14:38,030 --> 00:14:41,750
断绝一个人,他们不能选出新的领导人,至少其中一个人知道
sever one dies and they cannot elect a
new leader at least one of them knows
148
00:14:41,750 --> 00:14:48,020
如果这个词是当前词,那么当前词是8,而如果
that the current term was eight if that
one and only that one actually if
149
00:14:48,020 --> 00:14:51,230
只有一个人可以赢得选举,因为它拥有
there's only one of them only that one
could win an election because it has the
150
00:14:51,230 --> 00:14:53,840
他们俩都知道第八学期的末期生育率较高,如果他们都知道,对不起
higher terminal birth they both know
about term eight sorry if they both know
151
00:14:53,840 --> 00:14:57,740
大约第七学期,他们俩都将成为其中的一员
about term seven then they'll both and
either one of them will try to be leader
152
00:14:57,740 --> 00:15:02,960
和第八个学期,这样就可以保证下一个学期必须是疾病
and term eight so that fact of that the
next term must be term a dis is insured
153
00:15:02,960 --> 00:15:08,060
由多数人的财产必须重叠和事实,当前任期
by the property of the majorities must
overlap and the fact that current term
154
00:15:08,060 --> 00:15:12,710
通过投票请求进行更新,并且保持不变,并且保证没有丢失
is updated by vote request and is
persistent and guarantee did not be lost
155
00:15:12,710 --> 00:15:15,650
即使这里发生了一些崩溃,所以下一学期将是八个
even if there were some crashes here so
the next term is going to be eight
156
00:15:15,650 --> 00:15:19,490
服务器二或服务器三将赢得领导选举,让我们
server two or server three will win the
leadership election and let's just
157
00:15:19,490 --> 00:15:25,820
想象一下,无论是哪个发送新客户端的追加条目
imagine that whichever one it is sends
out append entries for a new client
158
00:15:25,820 --> 00:15:30,020
请求另一个获取它,所以现在我们有了正确的配置,因此
requests the other one gets it and so
now we have this configuration right so
159
00:15:30,020 --> 00:15:36,080
我有点走弯路,我们回到了最初的问题
I was a bit of a detour we're back to
our original question of in this
160
00:15:36,080 --> 00:15:42,860
配置假设服务器可以恢复运行,请选择
configuration suppose server one revives
we have an election would it be okay to
161
00:15:42,860 --> 00:15:48,890
使用服务器一台,只要规则是最长的日志获胜,就可以了
use server one would it be okay to have
the rule be the longest log wins the
162
00:15:48,890 --> 00:15:56,690
最长的日志成为领导者是的,显然不对,因为服务器是
longest log gets to be the leader yeah
obviously not right because server was a
163
00:15:56,690 --> 00:16:07,250
领导者确实要通过附加将其登录强制给关注者
leader did it's going to force its log
on to the to followers by the append
164
00:16:07,250 --> 00:16:09,950
几分钟前我们刚刚谈到的条目机制
entries machinery that we just talked
about a few minutes ago
165
00:16:09,950 --> 00:16:13,850
如果我们将服务器作为领导者,那您就会知道发出了一支钢笔
if we live server one to be the leader
it's gonna you know sent out a pen
166
00:16:13,850 --> 00:16:19,040
条目(无论备份如何覆盖)都会帮助追随者擦除其内容
entries whatever backup overwrite these
aids tell the followers to erase their
167
00:16:19,040 --> 00:16:23,480
术语a的日志条目接受用这六个和七个覆盖它们
log entries for term a to accept to
overwrite them with this six and seven
168
00:16:23,480 --> 00:16:30,380
日志条目,然后继续与服务器相同,因此当然
log entries and then to proceed now with
identical to server ones so of course