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

implement CommittedEntries pagination #161

Closed
wants to merge 0 commits into from

Conversation

Fullstop000
Copy link
Member

@Fullstop000 Fullstop000 commented Dec 26, 2018

Fixes #105

@Fullstop000
Copy link
Member Author

I got several warnings and errors complaining about some deprecated lint names when executing cargo clippy --all -- -D clippy in rustc 1.33.0-nightly (14b96659e 2018-12-25).
warnings like :

warning: lint name `clippy` is deprecated and does not have an effect anymore. Use: clippy::all
  |
  = note: requested on the command line with `-D clippy`

warning: lint name `clippy` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore
 --> src/eraftpb.rs:6:45
  |
6 | #![cfg_attr(feature = "cargo-clippy", allow(clippy))]
  |                                             ^^^^^^ help: change it to: `clippy::all`
  |
  = note: #[warn(renamed_and_removed_lints)] on by default

erros like below :

error: methods called `new` usually return `Self`
   --> src/raft.rs:208:5
    |
208 | /     pub fn new(c: &Config, store: T) -> Result<Raft<T>> {
209 | |         c.validate()?;
210 | |         let rs = store.initial_state()?;
211 | |         let conf_state = &rs.conf_state;
...   |
292 | |         Ok(r)
293 | |     }
    | |_____^
    |
    = note: `-D clippy::new-ret-no-self` implied by `-D clippy`
    = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/master/index.html#new_ret_no_self

Probably I need some guidance about this since I'm a rust cookie ( just wrote this PR as my first shot in rust )

@Hoverbear
Copy link
Contributor

Hi @Fullstop000 I'll deal with those errors. :) Sorry about that!

src/raft_log.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

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

Hi! Thanks so much for tacking this! We really appreciate it! 🎉

In general it LGTM, but I notice in the etcd PR (here there is a second test added. Can you explain the choice to not add this one?

@Hoverbear Hoverbear mentioned this pull request Dec 31, 2018
@Hoverbear Hoverbear added this to the 0.5.0 milestone Dec 31, 2018
@Hoverbear Hoverbear added the Feature Related to a major feature. label Dec 31, 2018
@Hoverbear Hoverbear mentioned this pull request Dec 31, 2018
@Fullstop000
Copy link
Member Author

Fullstop000 commented Jan 2, 2019

@Hoverbear the second test TestAppendPagination is to test whether MaxSizePerMsg is able to cap the total byte size of entries in each message.
Do I need to add this as I don't clearly know whether we've tested this or not ( seems not ) ?

And I find that etcd-raft has added a new config parameter MaxCommittedSizePerReady to control this instead of MsgSizePerMsg.
etcd-io/etcd@e4af2be

@Hoverbear Hoverbear self-assigned this Jan 4, 2019
@Hoverbear
Copy link
Contributor

@Fullstop000 Great catch. I think this is a more clear functionality. @hicqu can you take a look?

@Fullstop000
Copy link
Member Author

I'll use the new parameter max_committed_size_per_ready instead. And the test for max_size_per_msg will be added.

Hoverbear
Hoverbear previously approved these changes Jan 7, 2019
Copy link
Contributor

@Hoverbear Hoverbear 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.

@Hoverbear Hoverbear requested a review from hicqu January 7, 2019 20:16
@siddontang
Copy link
Contributor

Ping @BusyJay @hicqu

src/config.rs Outdated Show resolved Hide resolved
Hoverbear
Hoverbear previously approved these changes Feb 7, 2019
Copy link
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

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

Generally LGTM, only a small lint related comment.

src/raw_node.rs Outdated Show resolved Hide resolved
src/raft_log.rs Outdated
new_entry_with_data(5, 1, data.clone()),
new_entry_with_data(6, 1, data.clone()),
];
let unit_msg_size = u64::from(protobuf::Message::compute_size(&new_entry_with_data(
Copy link
Member

Choose a reason for hiding this comment

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

What about &ents[0]?

src/raw_node.rs Outdated
// If we hit a size limit when loading CommittedEntries, clamp
// our HardState.Commit to what we're actually returning. This is
// also used as our cursor to resume for the next Ready.
if let Some(committed_entries) = rd.committed_entries.as_ref() {
Copy link
Member

Choose a reason for hiding this comment

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

What about rd.committed_entries.as_ref().and_then(|c| c.last())?

Copy link
Member Author

@Fullstop000 Fullstop000 Feb 21, 2019

Choose a reason for hiding this comment

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

OMG, it's really beautiful here to use functional pattern.

cfg.max_committed_size_per_ready = 1024;
let storage = new_storage();
let mut raw_node = RawNode::new(&cfg, storage.clone(), vec![new_peer(1)]).unwrap();
let rd = raw_node.ready();
Copy link
Member

Choose a reason for hiding this comment

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

This three lines seem unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean the 3rd line or all the lines from 121 to 123? I couldn't figure it out why the raw_node should be removed.

@@ -2620,6 +2620,46 @@ fn test_leader_increase_next() {
}
}

#[test]
fn test_send_append_pagination_with_max_size_per_msg() {
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this case? Maybe you can add a hook to Network to implement a similar case with the original PR.

Copy link
Member Author

@Fullstop000 Fullstop000 Feb 21, 2019

Choose a reason for hiding this comment

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

It ensures the hard_state.commit matches with last committed entry index in Ready if committed_entries overflow the max_committed_size_per_ready.

@Hoverbear
Copy link
Contributor

Hi @Fullstop000 have you had a chance to see this feedback? Can I help you at all with it?

@Fullstop000
Copy link
Member Author

Fullstop000 commented Feb 21, 2019

@BusyJay @Hoverbear Sorry for the delay. Kind of busy here :(

@Hoverbear Hoverbear requested a review from BusyJay March 6, 2019 20:58
@CLAassistant
Copy link

CLAassistant commented Aug 19, 2019

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ Hoverbear
✅ Fullstop000
❌ Hetian Zhu


Hetian Zhu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

raft: Introduce CommittedEntries pagination
5 participants