raft 0.7.0

The rust language implementation of Raft algorithm.
Documentation
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
# No difference between a simple majority quorum and a simple majority quorum
# joint with an empty majority quorum. (This is asserted for all datadriven tests
# by the framework, so we don't dwell on it more).
#
# Note that by specifying cfgj explicitly we tell the test harness to treat the
# input as a joint quorum and not a majority quorum. If we didn't specify
# cfgj=zero the test would pass just the same, but it wouldn't be exercising the
# joint quorum path.
committed cfg=(1,2,3) cfgj=zero idx=(100,101,99)
----
       idx
x>     100    (id=1)
xx>    101    (id=2)
>       99    (id=3)
100

# Joint nonoverlapping singleton quorums.

committed cfg=(1) cfgj=(2) idx=(_,_)
----
      idx
?       0    (id=1)
?       0    (id=2)
0

# Voter 1 has 100 committed, 2 nothing. This means we definitely won't commit
# past 100.
committed cfg=(1) cfgj=(2) idx=(100,_)
----
      idx
x>    100    (id=1)
?       0    (id=2)
0

# Committed index collapses once both majorities do, to the lower index.
committed cfg=(1) cfgj=(2) idx=(13, 100)
----
      idx
>      13    (id=1)
x>    100    (id=2)
13

# Joint overlapping (i.e. identical) singleton quorum.

committed cfg=(1) cfgj=(1) idx=(_)
----
     idx
?      0    (id=1)
0

committed cfg=(1) cfgj=(1) idx=(100)
----
     idx
>    100    (id=1)
100



# Two-node config joint with non-overlapping single node config
committed cfg=(1,3) cfgj=(2) idx=(_,_,_)
----
       idx
?        0    (id=1)
?        0    (id=2)
?        0    (id=3)
0

committed cfg=(1,3) cfgj=(2) idx=(100,_,_)
----
       idx
xx>    100    (id=1)
?        0    (id=2)
?        0    (id=3)
0

# 1 has 100 committed, 2 has 50 (collapsing half of the joint quorum to 50).
committed cfg=(1,3) cfgj=(2) idx=(100,_,50)
----
       idx
xx>    100    (id=1)
x>      50    (id=2)
?        0    (id=3)
0

# 2 reports 45, collapsing the other half (to 45).
committed cfg=(1,3) cfgj=(2) idx=(100,45,50)
----
       idx
xx>    100    (id=1)
x>      50    (id=2)
>       45    (id=3)
45

# Two-node config with overlapping single-node config.

committed cfg=(1,2) cfgj=(2) idx=(_,_)
----
      idx
?       0    (id=1)
?       0    (id=2)
0

# 1 reports 100.
committed cfg=(1,2) cfgj=(2) idx=(100,_)
----
      idx
x>    100    (id=1)
?       0    (id=2)
0

# 2 reports 100.
committed cfg=(1,2) cfgj=(2) idx=(_,100)
----
      idx
?       0    (id=1)
x>    100    (id=2)
0

committed cfg=(1,2) cfgj=(2) idx=(50,100)
----
      idx
>      50    (id=1)
x>    100    (id=2)
50

committed cfg=(1,2) cfgj=(2) idx=(100,50)
----
      idx
x>    100    (id=1)
>      50    (id=2)
50



# Joint non-overlapping two-node configs.

committed cfg=(1,2) cfgj=(3,4) idx=(50,_,_,_)
----
        idx
xxx>     50    (id=1)
?         0    (id=2)
?         0    (id=3)
?         0    (id=4)
0

committed cfg=(1,2) cfgj=(3,4) idx=(50,_,49,_)
----
        idx
xxx>     50    (id=1)
?         0    (id=2)
xx>      49    (id=3)
?         0    (id=4)
0

committed cfg=(1,2) cfgj=(3,4) idx=(50,48,49,_)
----
        idx
xxx>     50    (id=1)
x>       48    (id=2)
xx>      49    (id=3)
?         0    (id=4)
0

committed cfg=(1,2) cfgj=(3,4) idx=(50,48,49,47)
----
        idx
xxx>     50    (id=1)
x>       48    (id=2)
xx>      49    (id=3)
>        47    (id=4)
47

# Joint overlapping two-node configs.
committed cfg=(1,2) cfgj=(2,3) idx=(_,_,_)
----
       idx
?        0    (id=1)
?        0    (id=2)
?        0    (id=3)
0

committed cfg=(1,2) cfgj=(2,3) idx=(100,_,_)
----
       idx
xx>    100    (id=1)
?        0    (id=2)
?        0    (id=3)
0

committed cfg=(1,2) cfgj=(2,3) idx=(_,100,_)
----
       idx
?        0    (id=1)
xx>    100    (id=2)
?        0    (id=3)
0

committed cfg=(1,2) cfgj=(2,3) idx=(_,100,99)
----
       idx
?        0    (id=1)
xx>    100    (id=2)
x>      99    (id=3)
0

committed cfg=(1,2) cfgj=(2,3) idx=(101,100,99)
----
       idx
xx>    101    (id=1)
x>     100    (id=2)
>       99    (id=3)
99

# Joint identical two-node configs.
committed cfg=(1,2) cfgj=(1,2) idx=(_,_)
----
      idx
?       0    (id=1)
?       0    (id=2)
0

committed cfg=(1,2) cfgj=(1,2) idx=(_,40)
----
      idx
?       0    (id=1)
x>     40    (id=2)
0

committed cfg=(1,2) cfgj=(1,2) idx=(41,40)
----
      idx
x>     41    (id=1)
>      40    (id=2)
40



# Joint disjoint three-node configs.

committed cfg=(1,2,3) cfgj=(4,5,6) idx=(_,_,_,_,_,_)
----
          idx
?           0    (id=1)
?           0    (id=2)
?           0    (id=3)
?           0    (id=4)
?           0    (id=5)
?           0    (id=6)
0

committed cfg=(1,2,3) cfgj=(4,5,6) idx=(100,_,_,_,_,_)
----
          idx
xxxxx>    100    (id=1)
?           0    (id=2)
?           0    (id=3)
?           0    (id=4)
?           0    (id=5)
?           0    (id=6)
0

committed cfg=(1,2,3) cfgj=(4,5,6) idx=(100,_,_,90,_,_)
----
          idx
xxxxx>    100    (id=1)
?           0    (id=2)
?           0    (id=3)
xxxx>      90    (id=4)
?           0    (id=5)
?           0    (id=6)
0

committed cfg=(1,2,3) cfgj=(4,5,6) idx=(100,99,_,_,_,_)
----
          idx
xxxxx>    100    (id=1)
xxxx>      99    (id=2)
?           0    (id=3)
?           0    (id=4)
?           0    (id=5)
?           0    (id=6)
0

# First quorum <= 99, second one <= 97. Both quorums guarantee that 90 is
# committed.
committed cfg=(1,2,3) cfgj=(4,5,6) idx=(_,99,90,97,95,_)
----
          idx
?           0    (id=1)
xxxxx>     99    (id=2)
xx>        90    (id=3)
xxxx>      97    (id=4)
xxx>       95    (id=5)
?           0    (id=6)
90

# First quorum collapsed to 92. Second one already had at least 95 committed,
# so the result also collapses.
committed cfg=(1,2,3) cfgj=(4,5,6) idx=(92,99,90,97,95,_)
----
          idx
xx>        92    (id=1)
xxxxx>     99    (id=2)
x>         90    (id=3)
xxxx>      97    (id=4)
xxx>       95    (id=5)
?           0    (id=6)
92

# Second quorum collapses, but nothing changes in the output.
committed cfg=(1,2,3) cfgj=(4,5,6) idx=(92,99,90,97,95,77)
----
          idx
xx>        92    (id=1)
xxxxx>     99    (id=2)
x>         90    (id=3)
xxxx>      97    (id=4)
xxx>       95    (id=5)
>          77    (id=6)
92


# Joint overlapping three-node configs.

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(_,_,_,_,_)
----
         idx
?          0    (id=1)
?          0    (id=2)
?          0    (id=3)
?          0    (id=4)
?          0    (id=5)
0

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(100,_,_,_,_)
----
         idx
xxxx>    100    (id=1)
?          0    (id=2)
?          0    (id=3)
?          0    (id=4)
?          0    (id=5)
0

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(100,101,_,_,_)
----
         idx
xxx>     100    (id=1)
xxxx>    101    (id=2)
?          0    (id=3)
?          0    (id=4)
?          0    (id=5)
0

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(100,101,100,_,_)
----
         idx
xx>      100    (id=1)
xxxx>    101    (id=2)
>        100    (id=3)
?          0    (id=4)
?          0    (id=5)
0

# Second quorum could commit either 98 or 99, but first quorum is open.
committed cfg=(1,2,3) cfgj=(1,4,5) idx=(_,100,_,99,98)
----
         idx
?          0    (id=1)
xxxx>    100    (id=2)
?          0    (id=3)
xxx>      99    (id=4)
xx>       98    (id=5)
0

# Additionally, first quorum can commit either 100 or 99
committed cfg=(1,2,3) cfgj=(1,4,5) idx=(_,100,99,99,98)
----
         idx
?          0    (id=1)
xxxx>    100    (id=2)
xx>       99    (id=3)
>         99    (id=4)
x>        98    (id=5)
98

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(1,100,99,99,98)
----
         idx
>          1    (id=1)
xxxx>    100    (id=2)
xx>       99    (id=3)
>         99    (id=4)
x>        98    (id=5)
98

committed cfg=(1,2,3) cfgj=(1,4,5) idx=(100,100,99,99,98)
----
         idx
xxx>     100    (id=1)
>        100    (id=2)
x>        99    (id=3)
>         99    (id=4)
>         98    (id=5)
99


# More overlap.

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(_,_,_,_)
----
        idx
?         0    (id=1)
?         0    (id=2)
?         0    (id=3)
?         0    (id=4)
0

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(_,100,99,_)
----
        idx
?         0    (id=1)
xxx>    100    (id=2)
xx>      99    (id=3)
?         0    (id=4)
99

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(98,100,99,_)
----
        idx
x>       98    (id=1)
xxx>    100    (id=2)
xx>      99    (id=3)
?         0    (id=4)
99

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(100,100,99,_)
----
        idx
xx>     100    (id=1)
>       100    (id=2)
x>       99    (id=3)
?         0    (id=4)
99

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(100,100,99,98)
----
        idx
xx>     100    (id=1)
>       100    (id=2)
x>       99    (id=3)
>        98    (id=4)
99

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(100,_,_,101)
----
        idx
xx>     100    (id=1)
?         0    (id=2)
?         0    (id=3)
xxx>    101    (id=4)
0

committed cfg=(1,2,3) cfgj=(2,3,4) idx=(100,99,_,101)
----
        idx
xx>     100    (id=1)
x>       99    (id=2)
?         0    (id=3)
xxx>    101    (id=4)
99

# Identical. This is also exercised in the test harness, so it's listed here
# only briefly.
committed cfg=(1,2,3) cfgj=(1,2,3) idx=(50,45,_)
----
       idx
xx>     50    (id=1)
x>      45    (id=2)
?        0    (id=3)
45