Skip to content

make configuration change effective on received#202

Closed
hicqu wants to merge 30 commits intotikv:masterfrom
hicqu:cc-effective-on-received
Closed

make configuration change effective on received#202
hicqu wants to merge 30 commits intotikv:masterfrom
hicqu:cc-effective-on-received

Conversation

@hicqu
Copy link
Copy Markdown
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
Copy Markdown
Contributor

@hicqu Can you make the CI pass?

@hicqu
Copy link
Copy Markdown
Contributor Author

hicqu commented Apr 3, 2019

PTAL @BusyJay @Hoverbear @nolouch thank you!

@Hoverbear Hoverbear added this to the 0.6.0 milestone Apr 5, 2019
@hicqu
Copy link
Copy Markdown
Contributor Author

hicqu commented Apr 9, 2019

PTAL again, thank you. @Hoverbear @BusyJay

@Hoverbear
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Hoverbear
Hoverbear previously approved these changes Apr 12, 2019
hicqu added 3 commits October 9, 2019 21:12
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
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
Copy Markdown
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?

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
Copy Markdown
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
Copy Markdown
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.

hicqu added 5 commits October 11, 2019 15:05
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>
next_configuration: Option<Configuration>,

/// Uncommitted removed progresses with indices, which must be monotonically increasing.
pub(crate) uncommitted_removes: Vec<(u64, Vec<u64>)>,
Copy link
Copy Markdown
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>
@hicqu hicqu force-pushed the cc-effective-on-received branch from 1517451 to 335e64a Compare October 14, 2019 10:40
hicqu added 3 commits October 16, 2019 15:19
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
hicqu added 2 commits October 16, 2019 20:04
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
if snap.get_metadata().index < request_index {
// NOTE: the logic is only for tests.
snap.mut_metadata().index = request_index;
snap.mut_metadata().conf_state_index = request_index;
Copy link
Copy Markdown
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
..Default::default()
};
if let Some(e) = rd.entries.first() {
for i in (0..raft.conf_states().len()).rev() {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

hicqu added 2 commits October 21, 2019 12:04
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
Signed-off-by: qupeng <qupeng@pingcap.com>
@hicqu
Copy link
Copy Markdown
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants