-
Notifications
You must be signed in to change notification settings - Fork 403
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
Conversation
@hicqu Can you make the CI pass? |
PTAL @BusyJay @Hoverbear @nolouch thank you! |
PTAL again, thank you. @Hoverbear @BusyJay |
|
@Hoverbear it doesn't matter. I was waiting for #214 exactly. Could you take a look again? Thanks! |
@hicqu You have a clippy lint fail :(
|
Signed-off-by: qupeng <[email protected]>
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() { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 <[email protected]>
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 <[email protected]>
fix all test cases Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
src/progress/progress_set.rs
Outdated
@@ -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>)>, |
There was a problem hiding this comment.
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 <[email protected]>
1517451
to
335e64a
Compare
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
assert!( | ||
check_membership_change_configuration((vec![1], vec![]), (vec![], vec![]),).is_err() | ||
) | ||
assert!(check_membership_change_configuration((vec![1], vec![]), (vec![], vec![]),).is_ok()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @Hoverbear PTAL
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 <[email protected]>
src/storage.rs
Outdated
snap.mut_metadata().index = request_index; | ||
snap.mut_metadata().conf_state_index = request_index; |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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 <[email protected]>
Signed-off-by: qupeng <[email protected]>
Signed-off-by: qupeng <[email protected]>
Close. Need to find other solutions for etcd-io/etcd#11284. |
Make configuration changes effective on received.
Some test cases about membership change are removed:
Because now these API are removed.
They are covered by minority_followers_halt.