-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #585 from drmingdrmer/50-fix-584
Fix: Error After change_membership: `assertion failed: value > prev`: #584
- Loading branch information
Showing
9 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(clippy::uninlined_format_args)] | ||
|
||
use std::sync::Arc; | ||
|
||
use actix_web::middleware; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
#![allow(clippy::uninlined_format_args)] | ||
|
||
mod test_cluster; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#![allow(clippy::uninlined_format_args)] | ||
|
||
use std::fmt::Display; | ||
use std::path::Path; | ||
use std::sync::Arc; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
#![allow(clippy::uninlined_format_args)] | ||
|
||
mod test_cluster; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
use std::option::Option::None; | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
|
||
|
53 changes: 53 additions & 0 deletions
53
openraft/tests/membership/t99_issue_584_replication_state_reverted.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
|
||
use anyhow::Result; | ||
use maplit::btreeset; | ||
use openraft::Config; | ||
|
||
use crate::fixtures::init_default_ut_tracing; | ||
use crate::fixtures::RaftRouter; | ||
|
||
#[async_entry::test(worker_threads = 8, init = "init_default_ut_tracing()", tracing_span = "debug")] | ||
async fn t99_issue_584_replication_state_reverted() -> Result<()> { | ||
// - Add a learner and replicate all logs to it. | ||
// - Add the learner as a voter. When membership changes, openraft internally restarts all replication. | ||
// | ||
// This case asserts it does not break the internal monotonic-replication-progress guarantee. | ||
|
||
let config = Arc::new( | ||
Config { | ||
max_in_snapshot_log_to_keep: 2000, // prevent snapshot | ||
enable_tick: false, | ||
..Default::default() | ||
} | ||
.validate()?, | ||
); | ||
let mut router = RaftRouter::new(config.clone()); | ||
|
||
let mut log_index = router.new_nodes_from_single(btreeset! {0}, btreeset! {1}).await?; | ||
|
||
let n = 500u64; | ||
tracing::info!("--- write up to {} logs", n); | ||
{ | ||
router.client_request_many(0, "foo", (n - log_index) as usize).await?; | ||
log_index = n; | ||
|
||
router.wait(&1, timeout()).log(Some(log_index), "replicate all logs to learner").await?; | ||
} | ||
|
||
tracing::info!("--- change-membership: make learner node-1 a voter. This should not panic"); | ||
{ | ||
let leader = router.get_raft_handle(&0)?; | ||
leader.change_membership(btreeset![0, 1], true, false).await?; | ||
log_index += 2; // 2 change_membership log | ||
|
||
let _ = log_index; | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
fn timeout() -> Option<Duration> { | ||
Some(Duration::from_millis(1_000)) | ||
} |