Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch MsgAppend entries #179

Merged
merged 13 commits into from
Feb 27, 2019
Merged

batch MsgAppend entries #179

merged 13 commits into from
Feb 27, 2019

Conversation

poonai
Copy link
Contributor

@poonai poonai commented Feb 3, 2019

#18
entries will be appended if there is an existing receiver MsgAppend message.
let me know if anything needs to be added.
Signed-off-by: balaji [email protected]

@poonai poonai changed the title batch MsgAppend entries wip: batch MsgAppend entries Feb 4, 2019
@poonai poonai changed the title wip: batch MsgAppend entries batch MsgAppend entries Feb 4, 2019
@poonai poonai changed the title batch MsgAppend entries wip:batch MsgAppend entries Feb 4, 2019
@siddontang
Copy link
Contributor

Thanks @Sch00lb0y

I am looking forward to your benchmark results :-)

@poonai poonai changed the title wip:batch MsgAppend entries batch MsgAppend entries Feb 4, 2019
@poonai
Copy link
Contributor Author

poonai commented Feb 4, 2019

@siddontang
i've ran cargo bench first on master then in my branch.
here the results are :)


     Running target/release/deps/benches-e34ad2fed821ca2a
Raft::new (0, 0)        time:   [731.49 ns 743.10 ns 756.68 ns]                              
                        change: [-8.3193% -6.8205% -5.4825%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  3 (3.00%) high mild
  8 (8.00%) high severe

Raft::new (3, 1)        time:   [1.4503 us 1.4658 us 1.4843 us]                              
                        change: [-8.9753% -6.7582% -4.5908%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 18 outliers among 100 measurements (18.00%)
  5 (5.00%) high mild
  13 (13.00%) high severe

Raft::new (5, 2)        time:   [1.9350 us 1.9584 us 1.9865 us]                              
                        change: [-10.508% -8.3376% -6.2217%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  7 (7.00%) high mild
  6 (6.00%) high severe

Raft::new (7, 3)        time:   [2.2570 us 2.2744 us 2.2940 us]                              
                        change: [-10.405% -8.3169% -6.2810%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe

Raft::campaign (3, 1, CampaignPreElection)                                                                             
                        time:   [2.0903 us 2.1140 us 2.1425 us]
                        change: [-16.260% -12.981% -9.7622%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  7 (7.00%) high mild
  5 (5.00%) high severe

Raft::campaign (3, 1, CampaignElection)                                                                             
                        time:   [2.2346 us 2.2644 us 2.3009 us]
                        change: [-17.014% -15.160% -13.365%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  3 (3.00%) high mild
  6 (6.00%) high severe

Raft::campaign (3, 1, CampaignTransfer)                                                                             
                        time:   [2.2733 us 2.3058 us 2.3438 us]
                        change: [-22.538% -19.933% -17.248%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  3 (3.00%) high mild
  9 (9.00%) high severe

Raft::campaign (5, 2, CampaignPreElection)                                                                             
                        time:   [3.2261 us 3.2696 us 3.3229 us]
                        change: [-14.794% -12.915% -11.022%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 16 outliers among 100 measurements (16.00%)
  5 (5.00%) high mild
  11 (11.00%) high severe

Raft::campaign (5, 2, CampaignElection)                                                                             
                        time:   [3.4008 us 3.4372 us 3.4843 us]
                        change: [-8.6416% -7.1726% -5.7362%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  4 (4.00%) high mild
  2 (2.00%) high severe

Raft::campaign (5, 2, CampaignTransfer)                                                                             
                        time:   [3.4621 us 3.5239 us 3.5961 us]
                        change: [-21.563% -19.115% -16.534%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  2 (2.00%) low severe
  2 (2.00%) low mild
  2 (2.00%) high mild
  7 (7.00%) high severe

Raft::campaign (7, 3, CampaignPreElection)                                                                             
                        time:   [4.1477 us 4.2540 us 4.3778 us]
                        change: [-12.611% -11.106% -9.4771%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  1 (1.00%) low severe
  1 (1.00%) low mild
  3 (3.00%) high mild
  7 (7.00%) high severe

Raft::campaign (7, 3, CampaignElection)                                                                             
                        time:   [4.3318 us 4.4031 us 4.4982 us]
                        change: [-14.321% -12.782% -11.188%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  6 (6.00%) high mild
  5 (5.00%) high severe

Raft::campaign (7, 3, CampaignTransfer)                                                                             
                        time:   [4.7296 us 4.7658 us 4.8054 us]
                        change: [-16.778% -15.117% -13.548%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 20 outliers among 100 measurements (20.00%)
  3 (3.00%) low mild
  5 (5.00%) high mild
  12 (12.00%) high severe

RawNode::new            time:   [1.0428 us 1.0615 us 1.0827 us]                          
                        change: [-13.120% -11.057% -8.9629%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
  3 (3.00%) high mild
  9 (9.00%) high severe

Progress::default       time:   [18.561 ns 18.930 ns 19.437 ns]                              
                        change: [-12.345% -10.227% -8.2306%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  5 (5.00%) high mild
  5 (5.00%) high severe

ProgressSet::new        time:   [22.223 ns 22.580 ns 23.003 ns]                             
                        change: [-6.9651% -5.2815% -3.5809%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  4 (4.00%) high mild
  6 (6.00%) high severe

ProgressSet::with_capacity (0, 0)                                                                            
                        time:   [49.451 ns 50.084 ns 50.780 ns]
                        change: [-9.1844% -8.0334% -6.8367%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 9 outliers among 100 measurements (9.00%)
  6 (6.00%) high mild
  3 (3.00%) high severe

ProgressSet::with_capacity (3, 1)                                                                             
                        time:   [103.80 ns 105.67 ns 107.90 ns]
                        change: [-19.221% -16.504% -13.752%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) high mild
  7 (7.00%) high severe

ProgressSet::with_capacity (5, 2)                                                                             
                        time:   [103.70 ns 105.17 ns 106.95 ns]
                        change: [-13.648% -11.687% -9.7855%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  3 (3.00%) high mild
  4 (4.00%) high severe

ProgressSet::with_capacity (7, 3)                                                                             
                        time:   [167.94 ns 170.28 ns 173.30 ns]
                        change: [-29.965% -25.396% -20.680%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  4 (4.00%) high mild
  10 (10.00%) high severe

ProgressSet::insert_voter (0, 0)                                                                             
                        time:   [189.54 ns 192.49 ns 196.24 ns]
                        change: [-23.446% -20.937% -18.570%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 16 outliers among 100 measurements (16.00%)
  3 (3.00%) low mild
  3 (3.00%) high mild
  10 (10.00%) high severe

ProgressSet::insert_voter (3, 1)                                                                             
                        time:   [315.76 ns 320.03 ns 325.49 ns]
                        change: [-20.502% -18.351% -16.255%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  6 (6.00%) high mild
  4 (4.00%) high severe

ProgressSet::insert_voter (5, 2)                                                                             
                        time:   [475.56 ns 482.83 ns 491.60 ns]
                        change: [-14.509% -12.193% -9.8767%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  5 (5.00%) high mild
  8 (8.00%) high severe

ProgressSet::insert_voter (7, 3)                                                                             
                        time:   [536.23 ns 544.23 ns 554.10 ns]
                        change: [-10.716% -8.5009% -5.7993%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  1 (1.00%) high mild
  7 (7.00%) high severe

ProgressSet::insert_learner (0, 0)                                                                             
                        time:   [192.81 ns 195.63 ns 198.97 ns]
                        change: [-13.240% -11.525% -9.5887%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 10 outliers among 100 measurements (10.00%)
  6 (6.00%) high mild
  4 (4.00%) high severe

ProgressSet::insert_learner (3, 1)                                                                             
                        time:   [285.18 ns 289.11 ns 293.18 ns]
                        change: [-15.744% -13.233% -10.821%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 23 outliers among 100 measurements (23.00%)
  4 (4.00%) low severe
  4 (4.00%) low mild
  7 (7.00%) high mild
  8 (8.00%) high severe

ProgressSet::insert_learner (5, 2)                                                                             
                        time:   [495.69 ns 503.89 ns 513.31 ns]
                        change: [-11.663% -9.6787% -7.6610%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  1 (1.00%) high mild
  4 (4.00%) high severe

ProgressSet::insert_learner (7, 3)                                                                             
                        time:   [512.73 ns 522.32 ns 533.90 ns]
                        change: [-6.9803% -5.2665% -3.3886%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  3 (3.00%) high mild
  2 (2.00%) high severe

ProgressSet::promote (0, 0)                                                                            
                        time:   [46.860 ns 47.273 ns 47.781 ns]
                        change: [-8.5775% -7.2841% -6.0761%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
  4 (4.00%) high mild
  7 (7.00%) high severe

ProgressSet::promote (3, 1)                                                                             
                        time:   [290.99 ns 295.69 ns 301.00 ns]
                        change: [-5.9020% -2.9352% -0.1376%] (p = 0.05 < 0.05)
                        Change within noise threshold.
Found 9 outliers among 100 measurements (9.00%)
  4 (4.00%) high mild
  5 (5.00%) high severe

ProgressSet::promote (5, 2)                                                                             
                        time:   [243.56 ns 247.51 ns 252.41 ns]
                        change: [-6.6327% -4.0816% -1.6351%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 17 outliers among 100 measurements (17.00%)
  9 (9.00%) high mild
  8 (8.00%) high severe

ProgressSet::promote (7, 3)                                                                             
                        time:   [385.11 ns 388.34 ns 392.01 ns]
                        change: [+0.7613% +4.2684% +8.2887%] (p = 0.02 < 0.05)
                        Change within noise threshold.
Found 17 outliers among 100 measurements (17.00%)
  1 (1.00%) low mild
  6 (6.00%) high mild
  10 (10.00%) high severe

ProgressSet::remove (0, 0)                                                                            
                        time:   [99.595 ns 100.40 ns 101.37 ns]
                        change: [-4.2012% -3.2849% -2.2523%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) high mild
  5 (5.00%) high severe

ProgressSet::remove (3, 1)                                                                             
                        time:   [255.63 ns 260.69 ns 266.88 ns]
                        change: [-5.2706% -2.3233% +0.6107%] (p = 0.16 > 0.05)
                        No change in performance detected.
Found 16 outliers among 100 measurements (16.00%)
  3 (3.00%) high mild
  13 (13.00%) high severe

ProgressSet::remove (5, 2)                                                                             
                        time:   [305.31 ns 311.17 ns 318.02 ns]
                        change: [-5.4494% -3.5546% -1.4418%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 21 outliers among 100 measurements (21.00%)
  1 (1.00%) low mild
  4 (4.00%) high mild
  16 (16.00%) high severe

ProgressSet::remove (7, 3)                                                                             
                        time:   [419.19 ns 423.03 ns 427.27 ns]
                        change: [-7.3719% -3.6897% +0.0770%] (p = 0.06 > 0.05)
                        No change in performance detected.
Found 12 outliers among 100 measurements (12.00%)
  3 (3.00%) high mild
  9 (9.00%) high severe

ProgressSet::iter (0, 0)                                                                            
                        time:   [37.068 ns 37.443 ns 37.882 ns]
                        change: [-4.3858% -3.0103% -1.5889%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  1 (1.00%) high mild
  6 (6.00%) high severe

ProgressSet::iter (3, 1)                                                                             
                        time:   [182.55 ns 185.41 ns 188.75 ns]
                        change: [-4.0651% -1.6787% +0.7790%] (p = 0.19 > 0.05)
                        No change in performance detected.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

ProgressSet::iter (5, 2)                                                                             
                        time:   [244.36 ns 246.91 ns 249.50 ns]
                        change: [-6.5752% -4.7651% -2.9078%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe

ProgressSet::iter (7, 3)                                                                             
                        time:   [380.72 ns 386.86 ns 394.41 ns]
                        change: [-4.5560% -1.6883% +1.0961%] (p = 0.26 > 0.05)
                        No change in performance detected.
Found 6 outliers among 100 measurements (6.00%)
  2 (2.00%) high mild
  4 (4.00%) high severe

ProgressSet::get (0, 0) time:   [37.289 ns 37.629 ns 38.045 ns]                                    
                        change: [-8.0562% -6.9443% -5.8061%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 16 outliers among 100 measurements (16.00%)
  3 (3.00%) low mild
  6 (6.00%) high mild
  7 (7.00%) high severe

ProgressSet::get (3, 1) time:   [165.37 ns 167.61 ns 170.37 ns]                                     
                        change: [-10.868% -9.2362% -7.3906%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 24 outliers among 100 measurements (24.00%)
  7 (7.00%) low mild
  7 (7.00%) high mild
  10 (10.00%) high severe

ProgressSet::get (5, 2) time:   [217.74 ns 220.98 ns 225.01 ns]                                     
                        change: [-9.8832% -7.4678% -5.2426%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) high mild
  5 (5.00%) high severe

ProgressSet::get (7, 3) time:   [359.79 ns 364.37 ns 370.08 ns]                                     
                        change: [-3.1134% -0.2760% +2.3337%] (p = 0.85 > 0.05)
                        No change in performance detected.
Found 8 outliers among 100 measurements (8.00%)
  4 (4.00%) high mild
  4 (4.00%) high severe

ProgressSet::nodes (0, 0)                                                                            
                        time:   [36.520 ns 36.941 ns 37.471 ns]
                        change: [-3.3023% -1.8421% -0.3524%] (p = 0.01 < 0.05)
                        Change within noise threshold.
Found 11 outliers among 100 measurements (11.00%)
  2 (2.00%) high mild
  9 (9.00%) high severe

ProgressSet::nodes (3, 1)                                                                             
                        time:   [180.95 ns 184.34 ns 188.34 ns]
                        change: [-3.1321% -1.5617% +0.1568%] (p = 0.06 > 0.05)
                        No change in performance detected.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) high mild
  3 (3.00%) high severe

ProgressSet::nodes (5, 2)                                                                             
                        time:   [241.69 ns 244.66 ns 248.28 ns]
                        change: [-14.130% -11.285% -8.4664%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe

ProgressSet::nodes (7, 3)                                                                             
                        time:   [373.90 ns 377.88 ns 383.07 ns]
                        change: [-18.879% -16.015% -13.049%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  2 (2.00%) high mild
  5 (5.00%) high severe

@brson
Copy link

brson commented Feb 6, 2019

Awesome improvements @Sch00lb0y !

src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
@Hoverbear Hoverbear added this to the 0.6.0 milestone Feb 11, 2019
src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
src/progress.rs Outdated Show resolved Hide resolved
@Hoverbear
Copy link
Contributor

The rest LGTM! :) Thanks so much for this contribution.

@siddontang
Copy link
Contributor

PTAL @BusyJay

@BusyJay
Copy link
Member

BusyJay commented Feb 13, 2019

I don't think batch policy implemented here is involved in the posted benchmark result. Can you add a flag to make this feature be able to be opted out when necessary?

@poonai
Copy link
Contributor Author

poonai commented Feb 13, 2019

Hi @BusyJay ,

Thanks for pointing it out. Even, I felt the same. cuz it showing different number for every run. That's why I ran cargo clean and made those results.

Can you add a flag to make this feature be able to be opted out when necessary?

flag as in option like skip_bcast_commit ?

@BusyJay
Copy link
Member

BusyJay commented Feb 13, 2019

Yes. So that if the optimization doesn't perform as expected, user can still have a choice.

@poonai
Copy link
Contributor Author

poonai commented Feb 13, 2019

@BusyJay @Hoverbear

I have addressed your suggestions.

Hoverbear
Hoverbear previously approved these changes Feb 13, 2019
@zhangjinpeng87
Copy link
Member

Please fix the conflict.

@@ -4110,3 +4111,22 @@ fn test_new_raft_with_bad_config_errors() {
let raft = Raft::new(&invalid_config, new_storage());
assert!(raft.is_err())
}
// tests whether MsgAppend are batched
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a blank line above.

src/raft.rs Outdated
batched_entries.append(ents);
msg.set_entries(RepeatedField::from_vec(batched_entries));
is_empty = msg.get_entries().is_empty();
if !is_empty {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should break when target message is found.

- add test for msg append batching

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
@poonai
Copy link
Contributor Author

poonai commented Feb 15, 2019

@BusyJay conflict resolved and added those changes

@Hoverbear Hoverbear added Feature Related to a major feature. Do Not Merge A blocked PR. Please do not merge it. labels Feb 15, 2019
@Hoverbear
Copy link
Contributor

Labelling this DNM since it's close to merge and we're about to release #182. This will be part of 0.6.0

@Hoverbear Hoverbear removed the Do Not Merge A blocked PR. Please do not merge it. label Feb 20, 2019
@brson
Copy link

brson commented Feb 21, 2019

LGTM

@brson brson self-requested a review February 21, 2019 01:44
brson
brson previously approved these changes Feb 21, 2019
src/raft.rs Outdated
let mut last_idx = 0;
let mut is_empty = true;
for msg in &mut self.msgs {
if msg.get_log_term() == term
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different log term can be sent in the same message.

src/raft.rs Outdated
// will append the entries to the existing MsgAppend
let mut is_batched = false;
let mut last_idx = 0;
let mut is_empty = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last_idx != 0 indicates it's not empty.

src/raft.rs Outdated
let mut batched_entries = msg.take_entries().into_vec();
batched_entries.append(ents);
msg.set_entries(RepeatedField::from_vec(batched_entries));
is_empty = msg.get_entries().is_empty();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check if ents is empty instead.

src/raft.rs Outdated
msg.set_index(pr.next_idx - 1);
msg.set_commit(self.raft_log.committed);
let mut batched_entries = msg.take_entries().into_vec();
batched_entries.append(ents);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if logs in origin msg and in ents are not continuous?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will that case come? (sorry if I've asked stupid question :( )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, follower can reject the leader's MsgAppend to make it reset next_index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it that case should I discard the previous ents?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For simplicity, you can also just give up batching in that case.

- add test to assert non continuous entries

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
@poonai
Copy link
Contributor Author

poonai commented Feb 25, 2019

@BusyJay I've made those changes and added a necessary assertion for non-continuous entries in the test case. Please have a look

Thanks :)

Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest LGTM

src/raft.rs Outdated
"{} is sending append in unhandled state {:?}",
self.tag, pr.state
),
msg.set_index(pr.next_idx - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not update index anymore. Seems missing a case to cover it.

src/util.rs Outdated
pub fn is_continuous_ents(msg: &Message, ents: &[Entry]) -> bool {
if !msg.get_entries().is_empty() && !ents.is_empty() {
let expected_next_idx = msg.get_entries().last().unwrap().get_index() + 1;
if expected_next_idx != ents.first().unwrap().get_index() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean return expected_next_idx == ents.first().unwrap().get_index()?

- add assertion to check index
- refactor is_continuous util

Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
Signed-off-by: பாலாஜி ஜின்னா <[email protected]>
@poonai
Copy link
Contributor Author

poonai commented Feb 27, 2019

@BusyJay done :)

Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@Hoverbear
Copy link
Contributor

Thanks so much @Sch00lb0y :) Really appreciate your continued improvements!

@Hoverbear Hoverbear merged commit 408120b into tikv:master Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Related to a major feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants