-
Notifications
You must be signed in to change notification settings - Fork 406
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
fix a bug about snapshot and adjust some test cases #213
Conversation
PTAL @Hoverbear @BusyJay thank you! |
@@ -207,6 +211,15 @@ fn on_ready( | |||
return; | |||
} | |||
|
|||
// Apply the snashot. It's also necessary with same reason as above. |
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.
// Apply the snashot. It's also necessary with same reason as above. | |
// Apply the snapshot. It's also necessary with same reason as above. |
Also, which reason? That the program will be blocked forever?
@@ -61,21 +61,39 @@ pub struct Network { | |||
} | |||
|
|||
impl Network { | |||
/// Initializes a network from peers. | |||
/// Get a base config. Calling `Network::new` will initialize peers with this config. | |||
pub fn base_config() -> Config { |
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.
pub fn base_config() -> Config { | |
pub fn default_config() -> Config { |
@hicqu Seems maybe |
Thanks for your review @Hoverbear ! I will address them in #214 . Now I will close this PR because I prefer the another solution. :) |
I think cause the root cause of the panic of five_mem_node is MemStorage::initialize_with_conf_state() :
|
self.term(idx).map(|t| t == term).unwrap_or(false) | ||
match self.term(idx) { | ||
// For uninitialized storage, should return false. | ||
Ok(0) => term == 0 && self.last_index() > 0, |
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 don't think it need to add some logics that exceeds etcd-raft.
The bug causes an exmaple panics in #205 .
In our implemetation,
RaftLog::term(un_received_index)
returns0
. So if a peer receives a snapshot or normal entry with log-term0
,RaftLog::match_term(log_term, un_received_index)
will returntrue
but it should befalse
exactly.This PR fixes it by making
RaftLog::match_term
cover this case.And, add a case
test_snapshot_with_term_0
to cover it, and do some adjusts for some other test cases. At last, removeInterface::initial
because we don't need it any more.