@@ -142,7 +142,7 @@ impl RawNode<Follower> {
142
142
// The leader will send periodic heartbeats. If we don't have a
143
143
// leader in this term yet, follow it. If the commit_index advances,
144
144
// apply state transitions.
145
- Event :: Heartbeat { commit_index, commit_term } => {
145
+ Event :: Heartbeat { commit_index, commit_term, read_seq } => {
146
146
// Check that the heartbeat is from our leader.
147
147
let from = msg. from . unwrap ( ) ;
148
148
match self . role . leader {
@@ -160,7 +160,10 @@ impl RawNode<Follower> {
160
160
self . state_tx . send ( Instruction :: Apply { entry } ) ?;
161
161
}
162
162
}
163
- self . send ( msg. from , Event :: ConfirmLeader { commit_index, has_committed } ) ?;
163
+ self . send (
164
+ msg. from ,
165
+ Event :: ConfirmLeader { commit_index, has_committed, read_seq } ,
166
+ ) ?;
164
167
}
165
168
166
169
// Replicate entries from the leader. If we don't have a leader in
@@ -329,7 +332,7 @@ pub mod tests {
329
332
from : Address :: Node ( 2 ) ,
330
333
to : Address :: Node ( 1 ) ,
331
334
term : 3 ,
332
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 } ,
335
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 , read_seq : 7 } ,
333
336
} ) ?;
334
337
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 2 ) ) . voted_for ( None ) . committed ( 3 ) ;
335
338
assert_messages (
@@ -338,7 +341,7 @@ pub mod tests {
338
341
from: Address :: Node ( 1 ) ,
339
342
to: Address :: Node ( 2 ) ,
340
343
term: 3 ,
341
- event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true } ,
344
+ event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true , read_seq : 7 } ,
342
345
} ] ,
343
346
) ;
344
347
assert_messages (
@@ -358,7 +361,7 @@ pub mod tests {
358
361
from : Address :: Node ( 2 ) ,
359
362
to : Address :: Node ( 1 ) ,
360
363
term : 3 ,
361
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 3 } ,
364
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 3 , read_seq : 7 } ,
362
365
} ) ?;
363
366
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 2 ) ) . voted_for ( None ) . committed ( 2 ) ;
364
367
assert_messages (
@@ -367,7 +370,7 @@ pub mod tests {
367
370
from: Address :: Node ( 1 ) ,
368
371
to: Address :: Node ( 2 ) ,
369
372
term: 3 ,
370
- event: Event :: ConfirmLeader { commit_index: 3 , has_committed: false } ,
373
+ event: Event :: ConfirmLeader { commit_index: 3 , has_committed: false , read_seq : 7 } ,
371
374
} ] ,
372
375
) ;
373
376
assert_messages ( & mut state_rx, vec ! [ ] ) ;
@@ -382,7 +385,7 @@ pub mod tests {
382
385
from : Address :: Node ( 2 ) ,
383
386
to : Address :: Node ( 1 ) ,
384
387
term : 3 ,
385
- event : Event :: Heartbeat { commit_index : 5 , commit_term : 3 } ,
388
+ event : Event :: Heartbeat { commit_index : 5 , commit_term : 3 , read_seq : 7 } ,
386
389
} ) ?;
387
390
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 2 ) ) . voted_for ( None ) . committed ( 2 ) ;
388
391
assert_messages (
@@ -391,7 +394,7 @@ pub mod tests {
391
394
from: Address :: Node ( 1 ) ,
392
395
to: Address :: Node ( 2 ) ,
393
396
term: 3 ,
394
- event: Event :: ConfirmLeader { commit_index: 5 , has_committed: false } ,
397
+ event: Event :: ConfirmLeader { commit_index: 5 , has_committed: false , read_seq : 7 } ,
395
398
} ] ,
396
399
) ;
397
400
assert_messages ( & mut state_rx, vec ! [ ] ) ;
@@ -408,7 +411,7 @@ pub mod tests {
408
411
from : Address :: Node ( 3 ) ,
409
412
to : Address :: Node ( 1 ) ,
410
413
term : 3 ,
411
- event : Event :: Heartbeat { commit_index : 5 , commit_term : 3 } ,
414
+ event : Event :: Heartbeat { commit_index : 5 , commit_term : 3 , read_seq : 7 } ,
412
415
} )
413
416
. unwrap ( ) ;
414
417
}
@@ -422,7 +425,7 @@ pub mod tests {
422
425
from : Address :: Node ( 3 ) ,
423
426
to : Address :: Node ( 1 ) ,
424
427
term : 3 ,
425
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 } ,
428
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 , read_seq : 7 } ,
426
429
} ) ?;
427
430
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 3 ) ) . voted_for ( None ) . committed ( 3 ) ;
428
431
assert_messages (
@@ -431,7 +434,7 @@ pub mod tests {
431
434
from: Address :: Node ( 1 ) ,
432
435
to: Address :: Node ( 3 ) ,
433
436
term: 3 ,
434
- event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true } ,
437
+ event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true , read_seq : 7 } ,
435
438
} ] ,
436
439
) ;
437
440
assert_messages (
@@ -451,7 +454,7 @@ pub mod tests {
451
454
from : Address :: Node ( 2 ) ,
452
455
to : Address :: Node ( 1 ) ,
453
456
term : 3 ,
454
- event : Event :: Heartbeat { commit_index : 1 , commit_term : 1 } ,
457
+ event : Event :: Heartbeat { commit_index : 1 , commit_term : 1 , read_seq : 7 } ,
455
458
} ) ?;
456
459
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 2 ) ) . voted_for ( None ) . committed ( 2 ) ;
457
460
assert_messages (
@@ -460,7 +463,7 @@ pub mod tests {
460
463
from: Address :: Node ( 1 ) ,
461
464
to: Address :: Node ( 2 ) ,
462
465
term: 3 ,
463
- event: Event :: ConfirmLeader { commit_index: 1 , has_committed: true } ,
466
+ event: Event :: ConfirmLeader { commit_index: 1 , has_committed: true , read_seq : 7 } ,
464
467
} ] ,
465
468
) ;
466
469
assert_messages ( & mut state_rx, vec ! [ ] ) ;
@@ -475,7 +478,7 @@ pub mod tests {
475
478
from : Address :: Node ( 3 ) ,
476
479
to : Address :: Node ( 1 ) ,
477
480
term : 4 ,
478
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 } ,
481
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 , read_seq : 7 } ,
479
482
} ) ?;
480
483
assert_node ( & mut node) . is_follower ( ) . term ( 4 ) . leader ( Some ( 3 ) ) . voted_for ( None ) ;
481
484
assert_messages (
@@ -484,7 +487,7 @@ pub mod tests {
484
487
from: Address :: Node ( 1 ) ,
485
488
to: Address :: Node ( 3 ) ,
486
489
term: 4 ,
487
- event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true } ,
490
+ event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true , read_seq : 7 } ,
488
491
} ] ,
489
492
) ;
490
493
assert_messages (
@@ -504,7 +507,7 @@ pub mod tests {
504
507
from : Address :: Node ( 2 ) ,
505
508
to : Address :: Node ( 1 ) ,
506
509
term : 2 ,
507
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 } ,
510
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 , read_seq : 7 } ,
508
511
} ) ?;
509
512
assert_node ( & mut node) . is_follower ( ) . term ( 3 ) . leader ( Some ( 2 ) ) . voted_for ( None ) . committed ( 2 ) ;
510
513
assert_messages ( & mut node_rx, vec ! [ ] ) ;
@@ -989,7 +992,7 @@ pub mod tests {
989
992
from : Address :: Node ( 3 ) ,
990
993
to : Address :: Node ( 1 ) ,
991
994
term : 4 ,
992
- event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 } ,
995
+ event : Event :: Heartbeat { commit_index : 3 , commit_term : 2 , read_seq : 7 } ,
993
996
} ) ?;
994
997
assert_node ( & mut node) . is_follower ( ) . term ( 4 ) . leader ( Some ( 3 ) ) . forwarded ( vec ! [ ] ) ;
995
998
assert_messages (
@@ -1005,7 +1008,11 @@ pub mod tests {
1005
1008
from: Address :: Node ( 1 ) ,
1006
1009
to: Address :: Node ( 3 ) ,
1007
1010
term: 4 ,
1008
- event: Event :: ConfirmLeader { commit_index: 3 , has_committed: true } ,
1011
+ event: Event :: ConfirmLeader {
1012
+ commit_index: 3 ,
1013
+ has_committed: true ,
1014
+ read_seq: 7 ,
1015
+ } ,
1009
1016
} ,
1010
1017
] ,
1011
1018
) ;
@@ -1033,15 +1040,19 @@ pub mod tests {
1033
1040
from : Address :: Node ( 2 ) ,
1034
1041
to : Address :: Node ( 1 ) ,
1035
1042
term : 3 ,
1036
- event : Event :: Heartbeat { commit_index : 2 , commit_term : 1 } ,
1043
+ event : Event :: Heartbeat { commit_index : 2 , commit_term : 1 , read_seq : 7 } ,
1037
1044
} ) ?;
1038
1045
assert_messages (
1039
1046
& mut node_rx,
1040
1047
vec ! [ Message {
1041
1048
from: Address :: Node ( 1 ) ,
1042
1049
to: Address :: Node ( 2 ) ,
1043
1050
term: 3 ,
1044
- event: Event :: ConfirmLeader { commit_index: 2 , has_committed: true } ,
1051
+ event: Event :: ConfirmLeader {
1052
+ commit_index: 2 ,
1053
+ has_committed: true ,
1054
+ read_seq: 7 ,
1055
+ } ,
1045
1056
} ] ,
1046
1057
)
1047
1058
}
0 commit comments