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

make configuration change effective on received #202

Closed
wants to merge 30 commits into from

Conversation

hicqu
Copy link
Contributor

@hicqu hicqu commented Apr 2, 2019

Make configuration changes effective on received.

Some test cases about membership change are removed:

  • tests in test_membership_change::api.
    Because now these API are removed.
  • pending_delete_fails_after_begin, pending_create_with_quorum_fails_after_begin, pending_create_and_destroy_both_fail.
    They are covered by minority_followers_halt.

@hicqu hicqu requested review from BusyJay and Hoverbear April 2, 2019 08:19
@Hoverbear
Copy link
Contributor

@hicqu Can you make the CI pass?

@hicqu
Copy link
Contributor Author

hicqu commented Apr 3, 2019

PTAL @BusyJay @Hoverbear @nolouch thank you!

src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
src/raft.rs Show resolved Hide resolved
src/raft.rs Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
@Hoverbear Hoverbear added this to In progress in Joint Consensus via automation Apr 5, 2019
@Hoverbear Hoverbear added this to the 0.6.0 milestone Apr 5, 2019
src/raft_log.rs Outdated Show resolved Hide resolved
src/storage.rs Outdated Show resolved Hide resolved
src/progress/progress_set.rs Outdated Show resolved Hide resolved
harness/src/network.rs Outdated Show resolved Hide resolved
@hicqu
Copy link
Contributor Author

hicqu commented Apr 9, 2019

PTAL again, thank you. @Hoverbear @BusyJay

src/raft.rs Outdated Show resolved Hide resolved
@Hoverbear
Copy link
Contributor

@hicqu I'm sorry about the merge conflicts, we merged #201. :(

Could you fix the merge conflicts? I think in most cases it should be straightforward. You can ask @nrc or @ice1000 if you encounter any strange problems.

@ice1000
Copy link
Contributor

ice1000 commented Apr 11, 2019

  • Replace ::new() with ::new_()
  • Replace use protobuf::Message with use prost::Message as Msg
  • Replace x.compute_size() with Msg::encoded_len(&x) (where this Msg is prost::Message)
  • Replace RepeatedField::from_vec(x) with x
  • Replace let data = protobuf::Message::write_to_bytes(&cc)?; with let mut data = Vec::with_capacity(ProstMsg::encoded_len(&cc)); cc.encode(&mut data)?;

@hicqu
Copy link
Contributor Author

hicqu commented Apr 12, 2019

@Hoverbear it doesn't matter. I was waiting for #214 exactly. Could you take a look again? Thanks!

@Hoverbear
Copy link
Contributor

@hicqu You have a clippy lint fail :(

The command "if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo fmt -- --check; fi" exited with 0.
9.10s$ if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo clippy -- -D clippy::all; fi
    Updating crates.io index
   Compiling raft v0.5.0 (/home/travis/build/pingcap/raft-rs)
error: redundant closure found
   --> src/progress/progress_set.rs:673:49
    |
673 |         self.next_configuration = next_conf.map(|c| c.into());
    |                                                 ^^^^^^^^^^^^ help: remove closure as shown: `std::convert::Into::into`
    |
note: lint level defined here
   --> src/lib.rs:360:9
    |
360 | #![deny(clippy::all)]
    |         ^^^^^^^^^^^
    = note: #[deny(clippy::redundant_closure)] implied by #[deny(clippy::all)]
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
error: aborting due to previous error
error: Could not compile `raft`.
To learn more, run the command again with --verbose.
The command "if [[ $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_OS_NAME == "linux" ]]; then cargo clippy -- -D clippy::all; fi" exited with 101.

harness/src/network.rs Outdated Show resolved Hide resolved
src/raft.rs Outdated Show resolved Hide resolved
Hoverbear
Hoverbear previously approved these changes Apr 12, 2019
let mut conf_change = ConfChange::default();
conf_change.merge_from_bytes(&e.data).unwrap();
raw_node.apply_conf_change(&conf_change).ok();
if raw_node.propose_conf_change(vec![], cc).is_ok() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not unwrap directly?

@@ -491,5 +481,5 @@ fn test_skip_bcast_commit() {

assert_eq!(nt.peers[&1].raft_log.committed, 7);
assert_eq!(nt.peers[&2].raft_log.committed, 7);
assert_eq!(nt.peers[&3].raft_log.committed, 7);
assert_eq!(nt.peers[&3].raft_log.committed, 5);
Copy link
Member

Choose a reason for hiding this comment

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

This shows a problem that a node will not get notified that it's removed.

Signed-off-by: qupeng <qupeng@pingcap.com>
@BusyJay
Copy link
Member

BusyJay commented Oct 11, 2019

Bugs described in https://groups.google.com/forum/#!msg/raft-dev/t4xj6dJTP6E/d2D9LrWRza8J is not addressed in this PR.

fix a bug about single node membership change

Signed-off-by: qupeng <qupeng@pingcap.com>
fix all test cases

Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
@@ -159,6 +165,9 @@ pub struct ProgressSet {
#[get = "pub"]
next_configuration: Option<Configuration>,

/// Uncommitted removed progresses with indices, which must be monotonically increasing.
pub(crate) uncommitted_removes: Vec<(u64, Vec<u64>)>,
Copy link
Member

Choose a reason for hiding this comment

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

GC after committed is simpler.

Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
harness/tests/integration_cases/test_raft.rs Outdated Show resolved Hide resolved
src/progress/progress_set.rs Show resolved Hide resolved
src/progress/progress_set.rs Show resolved Hide resolved
src/progress/progress_set.rs Outdated Show resolved Hide resolved
src/progress/progress_set.rs Show resolved Hide resolved
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
assert!(
check_membership_change_configuration((vec![1], vec![]), (vec![], vec![]),).is_err()
)
assert!(check_membership_change_configuration((vec![1], vec![]), (vec![], vec![]),).is_ok())
Copy link
Member

Choose a reason for hiding this comment

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

/cc @Hoverbear PTAL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because currently an empty configuration is allowed as target. Do you think we need to ban it? @Hoverbear

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really sure it's a valid state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it's valid means there is a machanism to remove all peers from a Raft group, although TiKV doesn't need it.

Signed-off-by: qupeng <qupeng@pingcap.com>
src/storage.rs Outdated
snap.mut_metadata().index = request_index;
snap.mut_metadata().conf_state_index = request_index;
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing. What if there are conf change between conf_state_index and request_index?

src/raw_node.rs Outdated
@@ -130,6 +132,18 @@ impl Ready {
entries: raft.raft_log.unstable_entries().unwrap_or(&[]).to_vec(),
..Default::default()
};
if let Some(e) = rd.entries.first() {
for i in (0..raft.conf_states().len()).rev() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not use Iterator::find? It seems more understandable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems it's better to find it from tail to head because there could be many unapplied entries in conf_states.

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 entries.iter().rev().position()?

src/raw_node.rs Outdated
if raft.conf_states()[i].index >= e.index {
continue;
}
if i < raft.conf_states().len() {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's always true.

Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
@hicqu
Copy link
Contributor Author

hicqu commented Oct 29, 2019

Close. Need to find other solutions for etcd-io/etcd#11284.

@hicqu hicqu closed this Oct 29, 2019
Joint Consensus automation moved this from Needs review to Done Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants